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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
# File 'lib/clearance/test/functional/confirmations_controller_test.rb', line 6
def self.included(base)
base.class_eval do
context 'A GET to #new' do
context "with the User with the given id's salt" do
setup do
@user = Factory :user
get :new, :user_id => @user.to_param, :salt => @user.salt
end
should 'find the User record with the given id and salt' do
assert_equal @user, assigns(:user)
end
should_respond_with :success
should_render_template :new
end
context "without the User with the given id's salt" do
setup do
user = Factory :user
salt = ''
assert_not_equal salt, user.salt
get :new, :user_id => user.to_param, :salt => ''
end
should_respond_with :not_found
should 'render nothing' do
assert @response.body.blank?
end
end
end
context 'A POST to #create' do
context "with the User with the given id's salt" do
setup do
@user = Factory :user
assert ! @user.confirmed?
post :create, :user_id => @user, :salt => @user.salt
@user.reload
end
should 'confirm the User record with the given id' do
assert @user.confirmed?
end
should 'log the User in' do
assert_equal @user.id, session[:user_id]
end
should_redirect_to "@controller.send(:url_after_create)"
end
context "without the User with the given id's salt" do
setup do
user = Factory :user
salt = ''
assert_not_equal salt, user.salt
post :create, :user_id => user.id, :salt => salt
end
should_respond_with :not_found
should 'render nothing' do
assert @response.body.blank?
end
end
end
end
end
|