docbrown/spec/models/shared_examples/a_profile_field.rb
Michael Kohl 4ae59b56e3
Add custom profile fields (#10202)
* Add custom_profile_fields table

* Add CustomProfileField model and refactor

* Remove trailing whitespace

* Stop ignoring removed column

* Add explanatory comment

* Update service object

* Fix bug in service object

* Refactor and fix specs

* Increase limit from 3 to 5

* Update comment to reflect code changes
2020-09-09 14:37:15 +00:00

20 lines
665 B
Ruby

RSpec.shared_examples "a profile field" do
let(:profile_field_class) { described_class.name.underscore }
describe "validations" do
describe "builtin validations" do
subject { create(profile_field_class) }
it { is_expected.to validate_presence_of(:label) }
it { is_expected.to validate_uniqueness_of(:label).case_insensitive }
it { is_expected.to validate_presence_of(:attribute_name).on(:update) }
end
end
describe "callbacks" do
it "automatically generates an attribute name" do
field = create(profile_field_class, label: "Test? Test! 1")
expect(field.attribute_name).to eq "test_test1"
end
end
end