* Prepare to drop profile columns from user * Update code and factory * Also remove unused constant * Move validation from user to profile * Remove Profiles::ExtractData service object * Add more comments * Simplify sameAs attribute generation * Obey me machine, I am your master * Fix condition order in guard clause * Temporarily disable callback * Fix specs * Reduce usage of Profile#refresh_attributes! * Remove leftover comment * Handle social media links differently * More spec fixes * Fix specs for admin profile fields controller * Fix specs after merge * Fix remaining specs * Update user show request spec * Add comment for follow_hiring_tag * Only save profile when user is valid * Fix seeds.rb for profile fields * Switch from before_save to after_save * Undo unrelated formattin change * Update spec/fixtures/files/profile_fields.csv Co-authored-by: Molly Struve <mollylbs@gmail.com> * Remove data update script and spec * Fix spec * Fix typo in comment * Fix typo in comment * Move article resave logic to service object * Move profile field creation to before(:suite) * Refactor error handling in Profiles::Update * Fix Profiles::Update specs and refactor * Temporarily disable spec * Add ProfileValidator * Clean up * Move DB ready check into app/lib * Refresh attributes after importing from CSV * Fix specs * Remove unused file * A girl has no name. A profile neither. * Fix specs * Add responds_to? check * Spec fix * Add name to user fields in profile settings page Co-authored-by: Molly Struve <mollylbs@gmail.com>
37 lines
1.4 KiB
Ruby
37 lines
1.4 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 "handles missing descriptions", :aggregate_failures do
|
|
field = ProfileField.find_by!(label: "Test name")
|
|
expect(field.input_type).to eq "text_field"
|
|
expect(field.placeholder_text).to eq "John Doe"
|
|
expect(field.description).to be_nil
|
|
expect(field.profile_field_group.name).to eq "Basic"
|
|
end
|
|
|
|
it "handles missing placeholder_texts", :aggregate_failures do
|
|
field = ProfileField.find_by!(label: "Test languages")
|
|
expect(field.input_type).to eq "text_area"
|
|
expect(field.placeholder_text).to be_nil
|
|
expect(field.description).to eq "Programming languages"
|
|
expect(field.profile_field_group.name).to eq "Coding"
|
|
end
|
|
|
|
it "handles commas in correctly quoted fields", :aggregate_failures do
|
|
field = ProfileField.find_by!(label: "Test color")
|
|
expect(field.input_type).to eq "color_field"
|
|
expect(field.placeholder_text).to eq "#000000"
|
|
expect(field.description).to eq "Used for backgrounds, borders etc."
|
|
expect(field.profile_field_group.name).to eq "Branding"
|
|
end
|
|
end
|
|
end
|