secret
Created

  • Download Gist
custom_auth_failure.rb
Ruby
1 2 3 4 5 6 7
class CustomAuthenticationFailure < Devise::FailureApp
protected
 
def redirect_url
"/"
end
end
devise.rb
Ruby
1 2 3 4 5 6 7 8 9
# ...
config.warden do |manager|
manager[:default_strategies][:user].unshift :token_cookie_strategy
end
 
config.warden do |manager|
manager.failure_app = CustomAuthenticationFailure
end
# ...
users_controller_spec.rb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
require 'spec_helper'
 
describe UsersController do
before :each do
@user = FactoryGirl.create(:user)
end
 
describe "User can log in using a token in a signed cookie" do
it "logs in with token in cookie" do
@user.ensure_authentication_token!
cookies[:authentication_token] = @user.authentication_token
get :personal
response.should render_template("personal")
# THE RESPONSE IS REDIRECT
end
end
end

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.