[deploy] Start ignoring group column for profile fields (#10045)
* Start ignoring group column for profile fields * Fix specs Co-authored-by: mstruve <mollylbs@gmail.com>
This commit is contained in:
parent
fbfde2b29e
commit
cfe288d8cc
4 changed files with 9 additions and 6 deletions
|
|
@ -1,4 +1,6 @@
|
|||
class ProfileField < ApplicationRecord
|
||||
self.ignored_columns = ["group"]
|
||||
|
||||
before_create :generate_attribute_name
|
||||
|
||||
WORD_REGEX = /\w+/.freeze
|
||||
|
|
|
|||
|
|
@ -5,7 +5,8 @@ module ProfileFields
|
|||
def self.call(file)
|
||||
CSV.foreach(file, headers: HEADERS, skip_blanks: true) do |row|
|
||||
row = row.to_h
|
||||
row[:profile_field_group] = ProfileFieldGroup.find_or_create_by(name: row[:group])
|
||||
group = row.delete(:group)
|
||||
row[:profile_field_group] = ProfileFieldGroup.find_or_create_by(name: group)
|
||||
ProfileField.create(row)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -7,13 +7,13 @@ RSpec.describe ProfileFields::Add, type: :service do
|
|||
it "creates a new profile field and adds a store accessor", :aggregate_failures do
|
||||
expect(profile.respond_to?(:new_field)).to be false
|
||||
expect do
|
||||
described_class.call(label: "New Field", group: "Basic")
|
||||
described_class.call(label: "New Field", input_type: :check_box)
|
||||
end.to change(ProfileField, :count).by(1)
|
||||
expect(profile.respond_to?(:new_field)).to be true
|
||||
end
|
||||
|
||||
it "returns the correct response object", :aggregate_failures do
|
||||
add_response = described_class.call(label: "Another New Field", group: "Basic")
|
||||
add_response = described_class.call(label: "Another New Field", input_type: :check_box)
|
||||
expect(add_response.success?).to be true
|
||||
expect(add_response.profile_field).to be_an_instance_of(ProfileField)
|
||||
expect(add_response.error_message).to be_blank
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ RSpec.describe ProfileFields::ImportFromCsv do
|
|||
expect(field.input_type).to eq "text_field"
|
||||
expect(field.placeholder_text).to eq "John Doe"
|
||||
expect(field.description).to be_nil
|
||||
expect(field.group).to eq "Basic"
|
||||
expect(field.profile_field_group.name).to eq "Basic"
|
||||
end
|
||||
|
||||
it "handles missing placeholder_texts", :aggregate_failures do
|
||||
|
|
@ -25,7 +25,7 @@ RSpec.describe ProfileFields::ImportFromCsv do
|
|||
expect(field.input_type).to eq "text_area"
|
||||
expect(field.placeholder_text).to be_nil
|
||||
expect(field.description).to eq "Programming languages"
|
||||
expect(field.group).to eq "Coding"
|
||||
expect(field.profile_field_group.name).to eq "Coding"
|
||||
end
|
||||
|
||||
it "handles commas in correctly quoted fields", :aggregate_failures do
|
||||
|
|
@ -33,6 +33,6 @@ RSpec.describe ProfileFields::ImportFromCsv do
|
|||
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.group).to eq "Branding"
|
||||
expect(field.profile_field_group.name).to eq "Branding"
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue