FIX: do not impose default min/max validation on hidden site setting

This commit is contained in:
Arpit Jalan 2017-04-22 12:06:02 +05:30
parent 5fab2042f5
commit dad2024094
2 changed files with 11 additions and 2 deletions

View File

@ -1,8 +1,8 @@
class IntegerSettingValidator
def initialize(opts={})
@opts = opts
@opts[:min] = 0 unless @opts[:min].present?
@opts[:max] = 20000 unless @opts[:max].present?
@opts[:min] = 0 unless @opts[:min].present? || @opts[:hidden]
@opts[:max] = 20000 unless @opts[:max].present? || @opts[:hidden]
end
def valid_value?(val)

View File

@ -97,5 +97,14 @@ describe IntegerSettingValidator do
expect(validator.valid_value?(-2)).to eq(false)
end
end
context "when setting is hidden" do
subject(:validator) { described_class.new(hidden: true) }
it "does not impose default validations" do
expect(validator.valid_value?(-1)).to eq(true)
expect(validator.valid_value?(20001)).to eq(true)
end
end
end
end