docbrown/spec/lib/data_update_scripts/create_profile_fields_spec.rb
Michael Kohl 83dc9408b6
Drop profile fields for static attributes (#14109)
* Drop profile fields for static attributes

* Update profile page with static field form

* Fix specs

* Update Cypress test
2021-07-01 14:30:40 -04:00

35 lines
1 KiB
Ruby

require "rails_helper"
require Rails.root.join("lib/data_update_scripts/20200901040521_create_profile_fields.rb")
describe DataUpdateScripts::CreateProfileFields do
def profile_field_and_group_count
[ProfileField.count, ProfileFieldGroup.count]
end
before do
ProfileFieldGroup.destroy_all
ProfileField.destroy_all
end
context "when no profile fields or groups exist" do
it "creates all profile fields and groups" do
expect do
described_class.new.run
end.to change { profile_field_and_group_count }.from([0, 0]).to([11, 4])
end
end
context "when profile fields and/or groups already exist" do
before do
csv = Rails.root.join("lib/data/dev_profile_fields.csv")
ProfileFields::ImportFromCsv.call(csv)
end
it "works when profile fields or groups already exist", :aggregate_failures do
expect do
described_class.new.run
end.not_to change { profile_field_and_group_count }
expect(profile_field_and_group_count).to eq [11, 4]
end
end
end