Fix brand color validation (#14303)
This commit is contained in:
parent
dc27f597fb
commit
de043b3d6d
2 changed files with 7 additions and 1 deletions
|
|
@ -17,7 +17,8 @@ module Users
|
|||
|
||||
validates :brand_color1,
|
||||
:brand_color2,
|
||||
format: { with: HEX_COLOR_REGEXP, message: "is not a valid hex color" }
|
||||
format: { with: HEX_COLOR_REGEXP, message: "is not a valid hex color" },
|
||||
allow_nil: true
|
||||
validates :user_id, presence: true
|
||||
validates :experience_level, numericality: { less_than_or_equal_to: 10 }, allow_blank: true
|
||||
validates :feed_referential_link, inclusion: { in: [true, false] }
|
||||
|
|
|
|||
|
|
@ -29,6 +29,11 @@ RSpec.describe Users::Setting, type: :model do
|
|||
expect(setting).to be_valid
|
||||
end
|
||||
|
||||
it "is valid if the brand color is nil" do
|
||||
setting.brand_color1 = nil
|
||||
expect(setting).to be_valid
|
||||
end
|
||||
|
||||
it "is invalid if the field is too long" do
|
||||
setting.brand_color1 = "#deadbeef"
|
||||
expect(setting).not_to be_valid
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue