* add optional fields to user - this provides the back-end implementation for #2365 * fix mistakes in schema.rb * renamed OptionalField to userOptionalField * rename field column in user_optional_fields to label * add uniqueness validation on user_optional_field labels * scope flag uniqueness to user_id * add indexing on label in user_optional_fields * add optional fields to user - this provides the back-end implementation for #2365 * fix mistakes in schema.rb * add index on user_id for user_optional_fields * Remove duplicate model * Fix schema * Re-add past indexes * Remove old index * Remove another old index * add `null:false` to columns in optional fields * add `null: false` to the migration - Updated test to account for the null constraint * add null:false to user_id on user_optional_tables Co-authored-by: rhymes <rhymesete@gmail.com> Co-authored-by: Ben Halpern <bendhalpern@gmail.com>
14 lines
530 B
Ruby
14 lines
530 B
Ruby
require "rails_helper"
|
|
|
|
RSpec.describe UserOptionalField, type: :model do
|
|
subject { user_optional_field }
|
|
|
|
let(:user_optional_field) { create(:user_optional_field) }
|
|
|
|
it { is_expected.to belong_to(:user) }
|
|
it { is_expected.to validate_presence_of(:label) }
|
|
it { is_expected.to validate_uniqueness_of(:label).scoped_to(:user_id) }
|
|
it { is_expected.to validate_length_of(:label).is_at_most(30) }
|
|
it { is_expected.to validate_presence_of(:value) }
|
|
it { is_expected.to validate_length_of(:value).is_at_most(128) }
|
|
end
|