docbrown/spec/services/profile_fields/import_from_csv_spec.rb
Michael Kohl 43ccdb31f1
Remove duplicated work display from header / profile work (#14210)
* Remove duplicated work display from header

* Update work profile field handling

* Update DUS + spec

* Delegate more carefully

* Update delegation guard

* Adapt for removed delegation

* Undo accidental schema changes

* Fix seeds

* Remove accidentaly change

* Fix User#processed_website_url

* Update guard clause

* Update profile card content

* Add Organization#profile

* Be more conservative with profile fields

* Spec fixes round 1

* Fix typo

* Update spec

* Limit number of header fields and update card content

* Decorate correct model

* Update factory

* Update schema.rb

* Fix validation

* How bad could this possibly be?

* Pretty bad, nevermind

* Remove obsolete code

* Reset profile fields during test runs

* Move profile fields back to before(:suite)

* Spec fixes

* Remove accidentally re-added files

* More spec fixes

* Specs

* Change User#tag_keywords_for_search

* More spec fixes

* Add comment

* Undo accidental schema changes

* Attempt spec fix

* Remove fix attempt

* Fix e2e test

* Update spec

* Remove guard clause

* Remove outdated guard clause

* Re-add validation

* Update header field validation

* Fix auto-complete fail
2021-07-30 12:28:40 +02:00

38 lines
1.2 KiB
Ruby

require "rails_helper"
RSpec.describe ProfileFields::ImportFromCsv do
it "ignores empty lines" do
expect do
described_class.call(file_fixture("profile_fields.csv"))
end.to change(ProfileField, :count).by(3)
end
context "when missing attributes" do
before { described_class.call(file_fixture("profile_fields.csv")) }
it "imports fields" do
field = ProfileField.find_by!(label: "Full test")
expect(field.input_type).to eq "text_field"
expect(field.placeholder_text).to eq "Test"
expect(field.description).to eq "Test field"
expect(field.profile_field_group.name).to eq "Basic"
expect(field.display_area).to eq "left_sidebar"
expect(field.show_in_onboarding).to be true
end
it "handles missing descriptions" do
field = ProfileField.find_by!(label: "Test name")
expect(field.description).to be_nil
end
it "handles missing placeholder_texts" do
field = ProfileField.find_by!(label: "Test languages")
expect(field.placeholder_text).to be_nil
end
it "handles commas in correctly quoted fields" do
field = ProfileField.find_by!(label: "Test languages")
expect(field.description).to eq "Programming languages, frameworks, etc."
end
end
end