docbrown/spec/services/profile_fields/field_definition_spec.rb
Michael Kohl c2d23cfc4d
[deploy] Seed profile fields (#9605)
* Fix schema.rb

* Add service objects for base and link fields

* Add link fields to seeds

* Make placeholder a keyword argument

* Add work fields

* Add explanation column to profile fields

* Add coding fields

* Switch from inheritance to mixin

* Add email checkbox to base fields

* Add branding fields

* Add spec for ProfileFields::FieldDefinition

* Move migration back into correct location

* Rename column from explanation to description

* Rename attribute in mixin

* chore: rename from explanation to description

* Add ProfileFields::ImportFromCsv

* Simplify ProfileFields::ImportFromCsv

* Add comment about disabled cop to spec

* Add TODO comment to Rake task

* Document mixin

* Add groups to profile fields

Co-authored-by: Ridhwana <ridhwana.khan16@gmail.com>
2020-08-05 10:11:30 -04:00

24 lines
703 B
Ruby

require "rails_helper"
RSpec.describe ProfileFields::FieldDefinition, type: :service do
let(:test_class) do
Class.new do
include ProfileFields::FieldDefinition
group "Test" do
field "Test 1", :text_area, placeholder: "Test", description: "For testing"
field "Test 2", :check_box
end
end
end
context "when adding fields" do
it "creates all the profile fields in the DB", :aggregate_failures do
expect do
test_class.call
end.to change(ProfileField, :count).by(2)
expect(ProfileField.pluck(:label)).to match_array(["Test 1", "Test 2"])
expect(ProfileField.pluck(:group)).to match_array(%w[Test Test])
end
end
end