mirror of
https://github.com/ditkrg/validates_timeliness.git
synced 2026-01-22 22:06:45 +00:00
remove :equal_to deprecation message
This commit is contained in:
parent
3533ce0702
commit
014bb76622
@ -1,4 +1,3 @@
|
|||||||
#TODO remove deprecated option :equal_to
|
|
||||||
module ValidatesTimeliness
|
module ValidatesTimeliness
|
||||||
|
|
||||||
class Validator
|
class Validator
|
||||||
@ -8,7 +7,6 @@ module ValidatesTimeliness
|
|||||||
|
|
||||||
RESTRICTION_METHODS = {
|
RESTRICTION_METHODS = {
|
||||||
:is_at => :==,
|
:is_at => :==,
|
||||||
:equal_to => :==,
|
|
||||||
:before => :<,
|
:before => :<,
|
||||||
:after => :>,
|
:after => :>,
|
||||||
:on_or_before => :<=,
|
:on_or_before => :<=,
|
||||||
@ -143,12 +141,6 @@ module ValidatesTimeliness
|
|||||||
end
|
end
|
||||||
|
|
||||||
def validate_options(options)
|
def validate_options(options)
|
||||||
if options.key?(:equal_to)
|
|
||||||
::ActiveSupport::Deprecation.warn("ValidatesTimeliness :equal_to option is deprecated due to clash with a default Rails option. Use :is_at instead. You will need to fix any I18n error message references to this option date/time attributes now.")
|
|
||||||
options[:is_at] = options.delete(:equal_to)
|
|
||||||
options[:is_at_message] = options.delete(:equal_to_message)
|
|
||||||
end
|
|
||||||
|
|
||||||
invalid_for_type = ([:time, :date, :datetime] - [type]).map {|k| "invalid_#{k}_message".to_sym }
|
invalid_for_type = ([:time, :date, :datetime] - [type]).map {|k| "invalid_#{k}_message".to_sym }
|
||||||
invalid_for_type << :with_date unless type == :time
|
invalid_for_type << :with_date unless type == :time
|
||||||
invalid_for_type << :with_time unless type == :date
|
invalid_for_type << :with_time unless type == :date
|
||||||
|
|||||||
@ -25,10 +25,6 @@ describe ValidatesTimeliness::Validator do
|
|||||||
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 }
|
||||||
@ -42,15 +38,6 @@ 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
|
||||||
@ -429,7 +416,6 @@ describe ValidatesTimeliness::Validator do
|
|||||||
end
|
end
|
||||||
|
|
||||||
describe "instance with :with_time option" do
|
describe "instance with :with_time option" do
|
||||||
|
|
||||||
it "should validate date attribute as datetime combining value of :with_time against restrictions " do
|
it "should validate date attribute as datetime combining value of :with_time against restrictions " do
|
||||||
configure_validator(:type => :date, :with_time => '12:31', :on_or_before => Time.mktime(2000,1,1,12,30))
|
configure_validator(:type => :date, :with_time => '12:31', :on_or_before => Time.mktime(2000,1,1,12,30))
|
||||||
validate_with(:birth_date, "2000-01-01")
|
validate_with(:birth_date, "2000-01-01")
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user