docbrown/spec/models/custom_profile_field_spec.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

19 lines
632 B
Ruby

require "rails_helper"
RSpec.describe CustomProfileField, type: :model do
it_behaves_like "a profile field"
describe "#validate_maximum_count" do
it "validates that user's can't have more than 3 custom profile fields" do
profile = create(:profile)
create_list(:custom_profile_field, 5, profile: profile)
custom_profile_field = build(:custom_profile_field, profile: profile)
custom_profile_field.save
expect(custom_profile_field).not_to be_valid
expect(custom_profile_field.errors[:profile_id])
.to include("maximum number of custom profile fields exceeded")
end
end
end