From 7e96bac6a48abbf6ac761aab9c01e7efc838b5c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Mon, 5 Aug 2013 11:24:04 +0200 Subject: [PATCH] Get rid of deprecated code --- app/views/devise/_links.erb | 3 --- lib/devise.rb | 12 ------------ lib/devise/mailers/helpers.rb | 6 ------ lib/devise/models.rb | 10 ++-------- lib/devise/rails/routes.rb | 8 -------- lib/devise/strategies/authenticatable.rb | 12 ------------ test/models_test.rb | 19 ------------------- test/support/helpers.rb | 21 --------------------- 8 files changed, 2 insertions(+), 89 deletions(-) delete mode 100644 app/views/devise/_links.erb diff --git a/app/views/devise/_links.erb b/app/views/devise/_links.erb deleted file mode 100644 index 44416761..00000000 --- a/app/views/devise/_links.erb +++ /dev/null @@ -1,3 +0,0 @@ -<% ActiveSupport::Deprecation.warn "Rendering partials devise/_links.erb is deprecated" \ - "please use devise/shared/_links.erb instead."%> -<%= render "shared/links" %> diff --git a/lib/devise.rb b/lib/devise.rb index b9a21564..f6d89bde 100644 --- a/lib/devise.rb +++ b/lib/devise.rb @@ -227,18 +227,6 @@ module Devise mattr_accessor :clean_up_csrf_token_on_authentication @@clean_up_csrf_token_on_authentication = true - def self.encryptor=(value) - warn "\n[DEVISE] To select a encryption which isn't bcrypt, you should use devise-encryptable gem.\n" - end - - def self.use_salt_as_remember_token=(value) - warn "\n[DEVISE] Devise.use_salt_as_remember_token is deprecated and has no effect. Please remove it.\n" - end - - def self.apply_schema=(value) - warn "\n[DEVISE] Devise.apply_schema is deprecated and has no effect. Please remove it.\n" - end - # PRIVATE CONFIGURATION # Store scopes mappings. diff --git a/lib/devise/mailers/helpers.rb b/lib/devise/mailers/helpers.rb index 4f70747a..06cd4b42 100644 --- a/lib/devise/mailers/helpers.rb +++ b/lib/devise/mailers/helpers.rb @@ -35,12 +35,6 @@ module Devise :template_name => action }.merge(opts) - if resource.respond_to?(:headers_for) - ActiveSupport::Deprecation.warn "Calling headers_for in the model is no longer supported. " << - "Please customize your mailer instead." - headers.merge!(resource.headers_for(action)) - end - @email = headers[:to] headers end diff --git a/lib/devise/models.rb b/lib/devise/models.rb index f88aee16..2f973d25 100644 --- a/lib/devise/models.rb +++ b/lib/devise/models.rb @@ -56,14 +56,8 @@ module Devise klass.devise_modules.each do |mod| constant = const_get(mod.to_s.classify) - if constant.respond_to?(:required_fields) - constant.required_fields(klass).each do |field| - failed_attributes << field unless instance.respond_to?(field) - end - else - ActiveSupport::Deprecation.warn "The module #{mod} doesn't implement self.required_fields(klass). " \ - "Devise uses required_fields to warn developers of any missing fields in their models. " \ - "Please implement #{mod}.required_fields(klass) that returns an array of symbols with the required fields." + constant.required_fields(klass).each do |field| + failed_attributes << field unless instance.respond_to?(field) end end diff --git a/lib/devise/rails/routes.rb b/lib/devise/rails/routes.rb index 28285745..6e28dc8e 100644 --- a/lib/devise/rails/routes.rb +++ b/lib/devise/rails/routes.rb @@ -222,14 +222,6 @@ module ActionDispatch::Routing routes = mapping.used_routes devise_scope mapping.name do - if block_given? - ActiveSupport::Deprecation.warn "Passing a block to devise_for is deprecated. " \ - "Please remove the block from devise_for (only the block, the call to " \ - "devise_for must still exist) and call devise_scope :#{mapping.name} do ... end " \ - "with the block instead", caller - yield - end - with_devise_exclusive_scope mapping.fullpath, mapping.name, options do routes.each { |mod| send("devise_#{mod}", mapping, mapping.controllers) } end diff --git a/lib/devise/strategies/authenticatable.rb b/lib/devise/strategies/authenticatable.rb index 28f12cda..0ded0256 100644 --- a/lib/devise/strategies/authenticatable.rb +++ b/lib/devise/strategies/authenticatable.rb @@ -26,20 +26,8 @@ module Devise # In case the resource can't be validated, it will fail with the given # unauthenticated_message. def validate(resource, &block) - unless resource - ActiveSupport::Deprecation.warn "an empty resource was given to #{self.class.name}#validate. " \ - "Please ensure the resource is not nil", caller - end - result = resource && resource.valid_for_authentication?(&block) - case result - when Symbol, String - ActiveSupport::Deprecation.warn "valid_for_authentication? should return a boolean value" - fail!(result) - return false - end - if result decorate(resource) true diff --git a/test/models_test.rb b/test/models_test.rb index 6a002598..a5f13b4f 100644 --- a/test/models_test.rb +++ b/test/models_test.rb @@ -141,23 +141,4 @@ class CheckFieldsTest < ActiveSupport::TestCase Devise::Models.check_fields!(Magician) end end - - test "doesn't raise a NoMethodError exception when the module doesn't have a required_field(klass) class method" do - driver = Class.new do - extend Devise::Models - - def self.before_validation(instance) - end - - attr_accessor :encrypted_password, :email - - devise :database_authenticatable - end - - swap_module_method_existence Devise::Models::DatabaseAuthenticatable, :required_fields do - assert_deprecated do - Devise::Models.check_fields!(driver) - end - end - end end diff --git a/test/support/helpers.rb b/test/support/helpers.rb index d3e1521c..375d3c3f 100644 --- a/test/support/helpers.rb +++ b/test/support/helpers.rb @@ -67,25 +67,4 @@ class ActiveSupport::TestCase end end end - - def swap_module_method_existence(klass, method) - klass.module_eval %Q[ - class << self - alias #{method}_referenced #{method} - undef #{method} - end - ] - - begin - yield if block_given? - ensure - - klass.module_eval %Q[ - class << self - alias #{method} #{method}_referenced - undef #{method}_referenced - end - ] - end - end end