mirror of
https://github.com/ditkrg/validates_timeliness.git
synced 2026-01-25 07:16:41 +00:00
deprecation warning example for :equal_to with messages silenced
This commit is contained in:
parent
4df1974524
commit
d255bbfccf
@ -12,11 +12,15 @@ describe ValidatesTimeliness::Validator do
|
|||||||
Time.now = nil
|
Time.now = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
before :each do
|
def person
|
||||||
@person = Person.new
|
@person ||= Person.new
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "option keys validation" do
|
describe "option keys validation" do
|
||||||
|
before(:all) do
|
||||||
|
ActiveSupport::Deprecation.silenced = true
|
||||||
|
end
|
||||||
|
|
||||||
before do
|
before do
|
||||||
keys = ValidatesTimeliness::Validator::VALID_OPTION_KEYS - [:invalid_date_message, :invalid_time_message, :with_date, :with_time]
|
keys = ValidatesTimeliness::Validator::VALID_OPTION_KEYS - [:invalid_date_message, :invalid_time_message, :with_date, :with_time]
|
||||||
@valid_options = keys.inject({}) {|hash, opt| hash[opt] = nil; hash }
|
@valid_options = keys.inject({}) {|hash, opt| hash[opt] = nil; hash }
|
||||||
@ -30,6 +34,15 @@ describe ValidatesTimeliness::Validator do
|
|||||||
it "should not raise error if option keys are valid" do
|
it "should not raise error if option keys are valid" do
|
||||||
lambda { Person.validates_datetime(@valid_options) }.should_not raise_error(ArgumentError)
|
lambda { Person.validates_datetime(@valid_options) }.should_not raise_error(ArgumentError)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "should display deprecation notice for :equal_to" do
|
||||||
|
::ActiveSupport::Deprecation.should_receive(:warn)
|
||||||
|
Person.validates_datetime :equal_to => Time.now
|
||||||
|
end
|
||||||
|
|
||||||
|
after(:all) do
|
||||||
|
ActiveSupport::Deprecation.silenced = false
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "evaluate_option_value" do
|
describe "evaluate_option_value" do
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user