Skip to content

Commit

Permalink
Remove deprecated usage of string keys in URL helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelfranca committed Jan 4, 2015
1 parent e4e1fd7 commit 34e3807
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 37 deletions.
4 changes: 4 additions & 0 deletions actionpack/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
* Remove deprecated usage of string keys in URL helpers.

*Rafael Mendonça França*

* Remove deprecated `only_path` option on `*_path` helpers.

*Rafael Mendonça França*
Expand Down
18 changes: 1 addition & 17 deletions actionpack/lib/action_dispatch/routing/route_set.rb
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ def call(t, args, inner_options)
controller_options = t.url_options
options = controller_options.merge @options
hash = handle_positional_args(controller_options,
deprecate_string_options(inner_options) || {},
inner_options || {},
args,
options,
@segment_keys)
Expand Down Expand Up @@ -272,22 +272,6 @@ def handle_positional_args(controller_options, inner_options, args, result, path

result.merge!(inner_options)
end

DEPRECATED_STRING_OPTIONS = %w[controller action]

def deprecate_string_options(options)
options ||= {}
deprecated_string_options = options.keys & DEPRECATED_STRING_OPTIONS
if deprecated_string_options.any?
msg = "Calling URL helpers with string keys #{deprecated_string_options.join(", ")} is deprecated. Use symbols instead."
ActiveSupport::Deprecation.warn(msg)
deprecated_string_options.each do |option|
value = options.delete(option)
options[option.to_sym] = value
end
end
options
end
end

private
Expand Down
20 changes: 0 additions & 20 deletions actionpack/test/dispatch/routing/route_set_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -128,26 +128,6 @@ def call(env)
assert_equal '/a/users/1', url_helpers.user_path(1, foo: 'a')
end

test "stringified controller and action keys are properly symbolized" do
draw do
root 'foo#bar'
end

assert_deprecated do
assert_equal '/', url_helpers.root_path('controller' => 'foo', 'action' => 'bar')
end
end

test "mix of string and symbol keys are properly symbolized" do
draw do
root 'foo#bar'
end

assert_deprecated do
assert_equal '/', url_helpers.root_path('controller' => 'foo', :action => 'bar')
end
end

private
def draw(&block)
@set.draw(&block)
Expand Down

0 comments on commit 34e3807

Please sign in to comment.