forked from binarylogic/authlogic
/
activation_test.rb
43 lines (37 loc) · 1.32 KB
/
activation_test.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
require File.dirname(__FILE__) + '/../test_helper.rb'
module SessionTest
module ActivationTest
class ClassMethodsTest < ActiveSupport::TestCase
def test_activated
assert UserSession.activated?
Authlogic::Session::Base.controller = nil
assert !UserSession.activated?
end
def test_controller
Authlogic::Session::Base.controller = nil
assert_nil Authlogic::Session::Base.controller
thread1 = Thread.new do
controller = MockController.new
Authlogic::Session::Base.controller = controller
assert_equal controller, Authlogic::Session::Base.controller
end
thread1.join
assert_nil Authlogic::Session::Base.controller
thread2 = Thread.new do
controller = MockController.new
Authlogic::Session::Base.controller = controller
assert_equal controller, Authlogic::Session::Base.controller
end
thread2.join
assert_nil Authlogic::Session::Base.controller
end
end
class InstanceMethodsTest < ActiveSupport::TestCase
def test_init
UserSession.controller = nil
assert_raise(Authlogic::Session::Activation::NotActivatedError) { UserSession.new }
UserSession.controller = controller
end
end
end
end