* 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
19 lines
632 B
Ruby
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
|