FIX: do not impose default min/max validation on hidden site setting
This commit is contained in:
parent
5fab2042f5
commit
dad2024094
|
@ -1,8 +1,8 @@
|
||||||
class IntegerSettingValidator
|
class IntegerSettingValidator
|
||||||
def initialize(opts={})
|
def initialize(opts={})
|
||||||
@opts = opts
|
@opts = opts
|
||||||
@opts[:min] = 0 unless @opts[:min].present?
|
@opts[:min] = 0 unless @opts[:min].present? || @opts[:hidden]
|
||||||
@opts[:max] = 20000 unless @opts[:max].present?
|
@opts[:max] = 20000 unless @opts[:max].present? || @opts[:hidden]
|
||||||
end
|
end
|
||||||
|
|
||||||
def valid_value?(val)
|
def valid_value?(val)
|
||||||
|
|
|
@ -97,5 +97,14 @@ describe IntegerSettingValidator do
|
||||||
expect(validator.valid_value?(-2)).to eq(false)
|
expect(validator.valid_value?(-2)).to eq(false)
|
||||||
end
|
end
|
||||||
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
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue