mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Remove deprecate *_path
helpers in email views
This commit is contained in:
parent
2cc91c37bc
commit
d282125a18
6 changed files with 10 additions and 94 deletions
|
@ -1,3 +1,7 @@
|
|||
* Remove deprecate `*_path` helpers in email views.
|
||||
|
||||
*Rafael Mendonça França*
|
||||
|
||||
* Remove deprecated `deliver` and `deliver!` methods.
|
||||
|
||||
*claudiob*
|
||||
|
|
|
@ -87,7 +87,7 @@ module ActionDispatch
|
|||
# named routes.
|
||||
class NamedRouteCollection #:nodoc:
|
||||
include Enumerable
|
||||
attr_reader :routes, :url_helpers_module
|
||||
attr_reader :routes, :url_helpers_module, :path_helpers_module
|
||||
|
||||
def initialize
|
||||
@routes = {}
|
||||
|
@ -162,25 +162,6 @@ module ActionDispatch
|
|||
routes.length
|
||||
end
|
||||
|
||||
def path_helpers_module(warn = false)
|
||||
if warn
|
||||
mod = @path_helpers_module
|
||||
helpers = @path_helpers
|
||||
Module.new do
|
||||
include mod
|
||||
|
||||
helpers.each do |meth|
|
||||
define_method(meth) do |*args, &block|
|
||||
ActiveSupport::Deprecation.warn("The method `#{meth}` cannot be used here as a full URL is required. Use `#{meth.to_s.sub(/_path$/, '_url')}` instead")
|
||||
super(*args, &block)
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
@path_helpers_module
|
||||
end
|
||||
end
|
||||
|
||||
class UrlHelper # :nodoc:
|
||||
def self.create(route, options, route_name, url_strategy)
|
||||
if optimize_helper?(route)
|
||||
|
@ -500,12 +481,10 @@ module ActionDispatch
|
|||
|
||||
if supports_path
|
||||
path_helpers = routes.named_routes.path_helpers_module
|
||||
else
|
||||
path_helpers = routes.named_routes.path_helpers_module(true)
|
||||
end
|
||||
|
||||
include path_helpers
|
||||
extend path_helpers
|
||||
include path_helpers
|
||||
extend path_helpers
|
||||
end
|
||||
|
||||
# plus a singleton class method called _routes ...
|
||||
included do
|
||||
|
|
|
@ -26,20 +26,6 @@ module ActionDispatch
|
|||
x.new.pond_duck_path Duck.new
|
||||
end
|
||||
end
|
||||
|
||||
def test_path_deprecation
|
||||
rs = ::ActionDispatch::Routing::RouteSet.new
|
||||
rs.draw do
|
||||
resources :ducks
|
||||
end
|
||||
|
||||
x = Class.new {
|
||||
include rs.url_helpers(false)
|
||||
}
|
||||
assert_deprecated do
|
||||
assert_equal '/ducks', x.new.ducks_path
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -65,7 +65,6 @@ module ApplicationTests
|
|||
RUBY
|
||||
|
||||
require "#{app_path}/config/environment"
|
||||
assert Foo.method_defined?(:foo_path)
|
||||
assert Foo.method_defined?(:foo_url)
|
||||
assert Foo.method_defined?(:main_app)
|
||||
end
|
||||
|
|
|
@ -428,58 +428,6 @@ module ApplicationTests
|
|||
assert_match '<option selected value="?part=text%2Fplain">View as plain-text email</option>', last_response.body
|
||||
end
|
||||
|
||||
test "*_path helpers emit a deprecation" do
|
||||
|
||||
app_file "config/routes.rb", <<-RUBY
|
||||
Rails.application.routes.draw do
|
||||
get 'foo', to: 'foo#index'
|
||||
end
|
||||
RUBY
|
||||
|
||||
mailer 'notifier', <<-RUBY
|
||||
class Notifier < ActionMailer::Base
|
||||
default from: "from@example.com"
|
||||
|
||||
def path_in_view
|
||||
mail to: "to@example.org"
|
||||
end
|
||||
|
||||
def path_in_mailer
|
||||
@url = foo_path
|
||||
mail to: "to@example.org"
|
||||
end
|
||||
end
|
||||
RUBY
|
||||
|
||||
html_template 'notifier/path_in_view', "<%= link_to 'foo', foo_path %>"
|
||||
|
||||
mailer_preview 'notifier', <<-RUBY
|
||||
class NotifierPreview < ActionMailer::Preview
|
||||
def path_in_view
|
||||
Notifier.path_in_view
|
||||
end
|
||||
|
||||
def path_in_mailer
|
||||
Notifier.path_in_mailer
|
||||
end
|
||||
end
|
||||
RUBY
|
||||
|
||||
app('development')
|
||||
|
||||
assert_deprecated do
|
||||
get "/rails/mailers/notifier/path_in_view.html"
|
||||
assert_equal 200, last_response.status
|
||||
end
|
||||
|
||||
html_template 'notifier/path_in_mailer', "No ERB in here"
|
||||
|
||||
assert_deprecated do
|
||||
get "/rails/mailers/notifier/path_in_mailer.html"
|
||||
assert_equal 200, last_response.status
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
def build_app
|
||||
super
|
||||
|
|
|
@ -741,8 +741,8 @@ YAML
|
|||
assert_equal "bukkits_", Bukkits.table_name_prefix
|
||||
assert_equal "bukkits", Bukkits::Engine.engine_name
|
||||
assert_equal Bukkits.railtie_namespace, Bukkits::Engine
|
||||
assert ::Bukkits::MyMailer.method_defined?(:foo_path)
|
||||
assert !::Bukkits::MyMailer.method_defined?(:bar_path)
|
||||
assert ::Bukkits::MyMailer.method_defined?(:foo_url)
|
||||
assert !::Bukkits::MyMailer.method_defined?(:bar_url)
|
||||
|
||||
get("/bukkits/from_app")
|
||||
assert_equal "false", last_response.body
|
||||
|
|
Loading…
Reference in a new issue