mirror of
https://github.com/heartcombo/devise.git
synced 2022-11-09 12:18:31 -05:00
Some warden helpers tests taken from rails_warden
This commit is contained in:
parent
11715cac1f
commit
fff46a53eb
2 changed files with 110 additions and 46 deletions
|
@ -16,8 +16,6 @@ module Devise
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
protected
|
|
||||||
|
|
||||||
# The main accessor for the warden proxy instance
|
# The main accessor for the warden proxy instance
|
||||||
#
|
#
|
||||||
def warden
|
def warden
|
||||||
|
|
66
test/controllers/authenticable_test.rb
Normal file
66
test/controllers/authenticable_test.rb
Normal file
|
@ -0,0 +1,66 @@
|
||||||
|
require 'test/test_helper'
|
||||||
|
require 'ostruct'
|
||||||
|
|
||||||
|
class MockController < ApplicationController
|
||||||
|
attr_accessor :env
|
||||||
|
def request
|
||||||
|
self
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
class AuthenticableTest < ActionController::TestCase
|
||||||
|
|
||||||
|
def setup
|
||||||
|
@controller = MockController.new
|
||||||
|
@mock_warden = OpenStruct.new
|
||||||
|
@controller.env = { 'warden' => @mock_warden }
|
||||||
|
end
|
||||||
|
|
||||||
|
test 'setup warden' do
|
||||||
|
assert_not_nil @controller.warden
|
||||||
|
end
|
||||||
|
|
||||||
|
test 'provide access to warden instance' do
|
||||||
|
assert_equal @controller.warden, @controller.env['warden']
|
||||||
|
end
|
||||||
|
|
||||||
|
test 'run authenticate on warden' do
|
||||||
|
@mock_warden.expects(:authenticate).returns(true)
|
||||||
|
@controller.authenticate
|
||||||
|
end
|
||||||
|
|
||||||
|
test 'run authenticate! on warden' do
|
||||||
|
@mock_warden.expects(:authenticate!).returns(true)
|
||||||
|
@controller.authenticate!
|
||||||
|
end
|
||||||
|
|
||||||
|
test 'run authenticate? on warden' do
|
||||||
|
@mock_warden.expects(:authenticated?).returns(true)
|
||||||
|
@controller.authenticated?
|
||||||
|
end
|
||||||
|
|
||||||
|
test 'proxy logged_in? to authenticated' do
|
||||||
|
@mock_warden.expects(:authenticated?).returns(true)
|
||||||
|
@controller.logged_in?
|
||||||
|
end
|
||||||
|
|
||||||
|
test 'run user on warden' do
|
||||||
|
@mock_warden.expects(:user).returns(true)
|
||||||
|
@controller.user
|
||||||
|
end
|
||||||
|
|
||||||
|
test 'run current_user on warden' do
|
||||||
|
@mock_warden.expects(:user).returns(true)
|
||||||
|
@controller.current_user
|
||||||
|
end
|
||||||
|
|
||||||
|
test 'set the user on warden' do
|
||||||
|
@mock_warden.expects(:set_user).returns(true)
|
||||||
|
@controller.user = User.new
|
||||||
|
end
|
||||||
|
|
||||||
|
test 'proxy logout to warden' do
|
||||||
|
@mock_warden.expects(:logout).returns(true)
|
||||||
|
@controller.logout
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in a new issue