mirror of
https://github.com/heartcombo/devise.git
synced 2022-11-09 12:18:31 -05:00
Add a test to ensure user.remember_me = true followed by a sign in sends the cookie, closes #776
This commit is contained in:
parent
930d5874ca
commit
43a3431c3e
2 changed files with 33 additions and 0 deletions
|
@ -29,6 +29,18 @@ class OmniauthableIntegrationTest < ActionController::IntegrationTest
|
|||
}
|
||||
end
|
||||
|
||||
def stub_action!(name)
|
||||
Users::OmniauthCallbacksController.class_eval do
|
||||
alias_method :__old_facebook, :facebook
|
||||
alias_method :facebook, name
|
||||
end
|
||||
yield
|
||||
ensure
|
||||
Users::OmniauthCallbacksController.class_eval do
|
||||
alias_method :facebook, :__old_facebook
|
||||
end
|
||||
end
|
||||
|
||||
test "can access omniauth.auth in the env hash" do
|
||||
visit "/users/sign_in"
|
||||
click_link "Sign in with Facebook"
|
||||
|
@ -85,6 +97,20 @@ class OmniauthableIntegrationTest < ActionController::IntegrationTest
|
|||
assert !session["devise.facebook_data"]
|
||||
end
|
||||
|
||||
test "sign in and send remember token if configured" do
|
||||
visit "/users/sign_in"
|
||||
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"
|
||||
assert warden.authenticated?(:user)
|
||||
assert warden.cookies["remember_user_token"]
|
||||
end
|
||||
end
|
||||
|
||||
# The following two tests are commented because OmniAuth's test
|
||||
# support is not yet able to support failure scenarios.
|
||||
#
|
||||
|
|
|
@ -4,4 +4,11 @@ class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
|
|||
session["devise.facebook_data"] = data["extra"]["user_hash"]
|
||||
render :json => data
|
||||
end
|
||||
|
||||
def sign_in_facebook
|
||||
user = User.find_by_email('user@test.com')
|
||||
user.remember_me = true
|
||||
sign_in user
|
||||
render :text => ""
|
||||
end
|
||||
end
|
Loading…
Add table
Reference in a new issue