Do not use the dynamic :action segment on Omniauth routes.

This was deprecated on rails/rails#23980.

We now generate scope and provider specific routes, like `user_facebook_omniauth_callback`
or `user_github_omniauth_callback`.

We could deprecate the `omniauth_authorize_path` in favor of the generated routes, but
the `shared/links.html.erb` depends on it to generate all omniauth links at once.

Closes #3983.
This commit is contained in:
Lucas Mazza
2016-03-07 11:19:27 -03:00
parent cecb3ee45b
commit ec07bdb315
4 changed files with 20 additions and 24 deletions

View File

@@ -1,23 +1,21 @@
require 'test_helper'
class OmniAuthRoutesTest < ActionController::TestCase
ExpectedUrlGeneratiorError = ActionController::UrlGenerationError
tests ApplicationController
def assert_path(action, provider, with_param=true)
# Resource param
assert_equal @controller.send(action, :user, provider),
@controller.send("user_#{action}", provider)
@controller.send("user_#{provider}_#{action}")
# With an object
assert_equal @controller.send(action, User.new, provider),
@controller.send("user_#{action}", provider)
@controller.send("user_#{provider}_#{action}")
if with_param
# Default url params
assert_equal @controller.send(action, :user, provider, param: 123),
@controller.send("user_#{action}", provider, param: 123)
@controller.send("user_#{provider}_#{action}", param: 123)
end
end
@@ -32,7 +30,7 @@ class OmniAuthRoutesTest < ActionController::TestCase
test 'should generate authorization path' do
assert_match "/users/auth/facebook", @controller.omniauth_authorize_path(:user, :facebook)
assert_raise ExpectedUrlGeneratiorError do
assert_raise NoMethodError do
@controller.omniauth_authorize_path(:user, :github)
end
end