remove :equal_to deprecation message

This commit is contained in:
Adam Meehan 2011-02-26 13:08:11 +11:00
parent 3533ce0702
commit 014bb76622
2 changed files with 0 additions and 22 deletions

View File

@ -1,4 +1,3 @@
#TODO remove deprecated option :equal_to
module ValidatesTimeliness
class Validator
@ -8,7 +7,6 @@ module ValidatesTimeliness
RESTRICTION_METHODS = {
:is_at => :==,
:equal_to => :==,
:before => :<,
:after => :>,
:on_or_before => :<=,
@ -143,12 +141,6 @@ module ValidatesTimeliness
end
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 << :with_date unless type == :time
invalid_for_type << :with_time unless type == :date

View File

@ -25,10 +25,6 @@ describe ValidatesTimeliness::Validator do
end
describe "option keys validation" do
before(:all) do
ActiveSupport::Deprecation.silenced = true
end
before do
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 }
@ -42,15 +38,6 @@ describe ValidatesTimeliness::Validator do
it "should not raise error if option keys are valid" do
lambda { Person.validates_datetime(@valid_options) }.should_not raise_error(ArgumentError)
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
describe "evaluate_option_value" do
@ -429,7 +416,6 @@ describe ValidatesTimeliness::Validator do
end
describe "instance with :with_time option" 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))
validate_with(:birth_date, "2000-01-01")