Skip to content

Commit

Permalink
use OmniAuth::Utils.camelize
Browse files Browse the repository at this point in the history
This will display the provider name with the original camelization:
facebook => Facebook
github => GitHub
linkedin => LinkedIn
  • Loading branch information
timoschilling committed Aug 28, 2015
1 parent 6ed6e09 commit f5e984c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion app/views/devise/shared/_links.html.erb
Expand Up @@ -20,6 +20,6 @@
<%- if devise_mapping.omniauthable? %>
<%- resource_class.omniauth_providers.each do |provider| %>
<%= link_to "Sign in with #{provider.to_s.titleize}", omniauth_authorize_path(resource_name, provider) %><br />
<%= link_to "Sign in with #{OmniAuth::Utils.camelize(provider)}", omniauth_authorize_path(resource_name, provider) %><br />
<% end -%>
<% end -%>
19 changes: 10 additions & 9 deletions test/integration/omniauthable_test.rb
Expand Up @@ -20,6 +20,7 @@ class OmniauthableIntegrationTest < ActionDispatch::IntegrationTest
"credentials" => {"token" => 'plataformatec'},
"extra" => {"user_hash" => FACEBOOK_INFO}
}
OmniAuth.config.add_camelization 'facebook', 'FaceBook'
end

teardown do
Expand All @@ -40,7 +41,7 @@ def stub_action!(name)

test "can access omniauth.auth in the env hash" do
visit "/users/sign_in"
click_link "Sign in with Facebook"
click_link "Sign in with FaceBook"

json = ActiveSupport::JSON.decode(response.body)

Expand All @@ -54,7 +55,7 @@ def stub_action!(name)
test "cleans up session on sign up" do
assert_no_difference "User.count" do
visit "/users/sign_in"
click_link "Sign in with Facebook"
click_link "Sign in with FaceBook"
end

assert session["devise.facebook_data"]
Expand All @@ -75,7 +76,7 @@ def stub_action!(name)
test "cleans up session on cancel" do
assert_no_difference "User.count" do
visit "/users/sign_in"
click_link "Sign in with Facebook"
click_link "Sign in with FaceBook"
end

assert session["devise.facebook_data"]
Expand All @@ -86,7 +87,7 @@ def stub_action!(name)
test "cleans up session on sign in" do
assert_no_difference "User.count" do
visit "/users/sign_in"
click_link "Sign in with Facebook"
click_link "Sign in with FaceBook"
end

assert session["devise.facebook_data"]
Expand All @@ -96,13 +97,13 @@ def stub_action!(name)

test "sign in and send remember token if configured" do
visit "/users/sign_in"
click_link "Sign in with Facebook"
click_link "Sign in with FaceBook"
assert_nil warden.cookies["remember_user_token"]

stub_action!(:sign_in_facebook) do
create_user
visit "/users/sign_in"
click_link "Sign in with Facebook"
click_link "Sign in with FaceBook"
assert warden.authenticated?(:user)
assert warden.cookies["remember_user_token"]
end
Expand All @@ -118,16 +119,16 @@ def stub_action!(name)
OmniAuth.config.mock_auth[:facebook] = :access_denied
visit "/users/auth/facebook/callback?error=access_denied"
assert_current_url "/users/sign_in"
assert_contain 'Could not authenticate you from Facebook because "Access denied".'
assert_contain 'Could not authenticate you from FaceBook because "Access denied".'
end

test "handles other exceptions from OmniAuth" do
OmniAuth.config.mock_auth[:facebook] = :invalid_credentials

visit "/users/sign_in"
click_link "Sign in with Facebook"
click_link "Sign in with FaceBook"

assert_current_url "/users/sign_in"
assert_contain 'Could not authenticate you from Facebook because "Invalid credentials".'
assert_contain 'Could not authenticate you from FaceBook because "Invalid credentials".'
end
end

0 comments on commit f5e984c

Please sign in to comment.