From e5cc892ce66968d4e15ea3fbf62a9fdd43b410d9 Mon Sep 17 00:00:00 2001 From: Kuldeep Aggarwal Date: Tue, 10 Jun 2014 12:27:17 +0530 Subject: remove depricated Validatior#setup --- activemodel/lib/active_model/validator.rb | 16 ---------------- activemodel/test/cases/validations_test.rb | 21 --------------------- 2 files changed, 37 deletions(-) diff --git a/activemodel/lib/active_model/validator.rb b/activemodel/lib/active_model/validator.rb index bddacc8c45..65cb1e5a88 100644 --- a/activemodel/lib/active_model/validator.rb +++ b/activemodel/lib/active_model/validator.rb @@ -106,7 +106,6 @@ module ActiveModel # Accepts options that will be made available through the +options+ reader. def initialize(options = {}) @options = options.except(:class).freeze - deprecated_setup(options) end # Returns the kind for this validator. @@ -122,21 +121,6 @@ module ActiveModel def validate(record) raise NotImplementedError, "Subclasses must implement a validate(record) method." end - - private - def deprecated_setup(options) # TODO: remove me in 4.2. - return unless respond_to?(:setup) - ActiveSupport::Deprecation.warn "The `Validator#setup` instance method is deprecated and will be removed on Rails 4.2. Do your setup in the constructor instead: - -class MyValidator < ActiveModel::Validator - def initialize(options={}) - super - options[:class].send :attr_accessor, :custom_attribute - end -end -" - setup(options[:class]) - end end # +EachValidator+ is a validator which iterates through the attributes given diff --git a/activemodel/test/cases/validations_test.rb b/activemodel/test/cases/validations_test.rb index 6a74ee353d..4fee704ef5 100644 --- a/activemodel/test/cases/validations_test.rb +++ b/activemodel/test/cases/validations_test.rb @@ -378,25 +378,4 @@ class ValidationsTest < ActiveModel::TestCase assert topic.invalid? assert duped.valid? end - - # validator test: - def test_setup_is_deprecated_but_still_receives_klass # TODO: remove me in 4.2. - validator_class = Class.new(ActiveModel::Validator) do - def setup(klass) - @old_klass = klass - end - - def validate(*) - @old_klass == Topic or raise "#setup didn't work" - end - end - - assert_deprecated do - Topic.validates_with validator_class - end - - t = Topic.new - t.valid? - end - end -- cgit v1.2.3