Skip to content

Commit e4e1fd7

Browse files
committed
Remove deprecated only_path option on *_path helpers
1 parent d282125 commit e4e1fd7

3 files changed

Lines changed: 5 additions & 72 deletions

File tree

actionpack/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
* Remove deprecated `only_path` option on `*_path` helpers.
2+
3+
*Rafael Mendonça França*
4+
15
* Remove deprecated `NamedRouteCollection#helpers`.
26

37
*Rafael Mendonça França*

actionpack/lib/action_dispatch/routing/route_set.rb

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ def add(name, route)
130130
@url_helpers_module.send :undef_method, url_name
131131
end
132132
routes[key] = route
133-
define_url_helper @path_helpers_module, route, path_name, route.defaults, name, LEGACY
133+
define_url_helper @path_helpers_module, route, path_name, route.defaults, name, PATH
134134
define_url_helper @url_helpers_module, route, url_name, route.defaults, name, UNKNOWN
135135

136136
@path_helpers << path_name
@@ -319,34 +319,7 @@ def define_url_helper(mod, route, name, opts, route_key, url_strategy)
319319
# :stopdoc:
320320
# strategy for building urls to send to the client
321321
PATH = ->(options) { ActionDispatch::Http::URL.path_for(options) }
322-
FULL = ->(options) { ActionDispatch::Http::URL.full_url_for(options) }
323322
UNKNOWN = ->(options) { ActionDispatch::Http::URL.url_for(options) }
324-
LEGACY = ->(options) {
325-
if options.key?(:only_path)
326-
if options[:only_path]
327-
ActiveSupport::Deprecation.warn(<<-MSG.squish)
328-
You are calling a `*_path` helper with the `only_path` option
329-
explicitly set to `true`. This option will stop working on
330-
path helpers in Rails 5. Simply remove the `only_path: true`
331-
argument from your call as it is redundant when applied to a
332-
path helper.
333-
MSG
334-
335-
PATH.call(options)
336-
else
337-
ActiveSupport::Deprecation.warn(<<-MSG.squish)
338-
You are calling a `*_path` helper with the `only_path` option
339-
explicitly set to `false`. This option will stop working on
340-
path helpers in Rails 5. Use the corresponding `*_url` helper
341-
instead.
342-
MSG
343-
344-
FULL.call(options)
345-
end
346-
else
347-
PATH.call(options)
348-
end
349-
}
350323
# :startdoc:
351324

352325
attr_accessor :formatter, :set, :named_routes, :default_scope, :router

actionpack/test/dispatch/routing/route_set_test.rb

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -105,50 +105,6 @@ def call(env)
105105
assert_equal 'http://example.com/foo', url_helpers.foo_url(only_path: false)
106106
end
107107

108-
test "only_path: true with *_path" do
109-
draw do
110-
get 'foo', to: SimpleApp.new('foo#index')
111-
end
112-
113-
assert_deprecated do
114-
assert_equal '/foo', url_helpers.foo_path(only_path: true)
115-
end
116-
end
117-
118-
test "only_path: false with *_path with global :host option" do
119-
@set.default_url_options = { host: 'example.com' }
120-
121-
draw do
122-
get 'foo', to: SimpleApp.new('foo#index')
123-
end
124-
125-
assert_deprecated do
126-
assert_equal 'http://example.com/foo', url_helpers.foo_path(only_path: false)
127-
end
128-
end
129-
130-
test "only_path: false with *_path with local :host option" do
131-
draw do
132-
get 'foo', to: SimpleApp.new('foo#index')
133-
end
134-
135-
assert_deprecated do
136-
assert_equal 'http://example.com/foo', url_helpers.foo_path(only_path: false, host: 'example.com')
137-
end
138-
end
139-
140-
test "only_path: false with *_path with no :host option" do
141-
draw do
142-
get 'foo', to: SimpleApp.new('foo#index')
143-
end
144-
145-
assert_deprecated do
146-
assert_raises ArgumentError do
147-
assert_equal 'http://example.com/foo', url_helpers.foo_path(only_path: false)
148-
end
149-
end
150-
end
151-
152108
test "explicit keys win over implicit keys" do
153109
draw do
154110
resources :foo do

0 commit comments

Comments
 (0)