okkez-multi_auth 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README +36 -0
- data/app/controllers/application_controller.rb +11 -0
- data/app/controllers/auth/email_controller.rb +34 -0
- data/app/controllers/auth/open_id_controller.rb +43 -0
- data/app/controllers/auth_controller.rb +24 -0
- data/app/controllers/credentials/email_controller.rb +156 -0
- data/app/controllers/credentials/open_id_controller.rb +85 -0
- data/app/controllers/credentials_controller.rb +14 -0
- data/app/controllers/signup/email_controller.rb +132 -0
- data/app/controllers/signup/open_id_controller.rb +62 -0
- data/app/controllers/signup_controller.rb +8 -0
- data/app/helpers/application_helper.rb +5 -0
- data/app/models/activation_mailer.rb +114 -0
- data/app/models/email_credential.rb +89 -0
- data/app/models/email_credential_edit_form.rb +52 -0
- data/app/models/email_login_form.rb +24 -0
- data/app/models/email_password_edit_form.rb +36 -0
- data/app/models/open_id_credential.rb +33 -0
- data/app/models/open_id_login_form.rb +17 -0
- data/app/models/session.rb +19 -0
- data/app/models/user.rb +37 -0
- data/app/views/activation_mailer/complete_for_credential.erb +4 -0
- data/app/views/activation_mailer/complete_for_notice.erb +4 -0
- data/app/views/activation_mailer/complete_for_signup.erb +4 -0
- data/app/views/activation_mailer/request_for_credential.erb +11 -0
- data/app/views/activation_mailer/request_for_notice.erb +11 -0
- data/app/views/activation_mailer/request_for_signup.erb +11 -0
- data/app/views/auth/email/index.html.erb +90 -0
- data/app/views/auth/logged_in.html.erb +21 -0
- data/app/views/auth/logged_out.html.erb +21 -0
- data/app/views/auth/open_id/index.html.erb +16 -0
- data/app/views/credentials/email/activated.html.erb +4 -0
- data/app/views/credentials/email/activation.html.erb +15 -0
- data/app/views/credentials/email/created.html.erb +15 -0
- data/app/views/credentials/email/delete.html.erb +20 -0
- data/app/views/credentials/email/edit_password.html.erb +31 -0
- data/app/views/credentials/email/new.html.erb +36 -0
- data/app/views/credentials/index.html.erb +88 -0
- data/app/views/credentials/open_id/delete.html.erb +20 -0
- data/app/views/credentials/open_id/new.html.erb +26 -0
- data/app/views/signup/email/_progress.html.erb +14 -0
- data/app/views/signup/email/activated.html.erb +9 -0
- data/app/views/signup/email/activation.html.erb +27 -0
- data/app/views/signup/email/created.html.erb +14 -0
- data/app/views/signup/email/index.html.erb +34 -0
- data/app/views/signup/email/validated.html.erb +21 -0
- data/app/views/signup/index.html.erb +51 -0
- data/app/views/signup/open_id/authenticated.html.erb +15 -0
- data/app/views/signup/open_id/created.html.erb +6 -0
- data/app/views/signup/open_id/index.html.erb +16 -0
- data/config/boot.rb +110 -0
- data/config/database.yml +22 -0
- data/config/database.yml.sqlite3 +22 -0
- data/config/environment.rb +62 -0
- data/config/routes.rb +51 -0
- data/config/smtp.yml.example +8 -0
- data/db/development.sqlite3 +0 -0
- data/db/schema.rb +88 -0
- data/db/test.sqlite3 +0 -0
- data/lib/action_mailer_util.rb +15 -0
- data/lib/multi_auth.rb +64 -0
- data/lib/multi_auth_helper.rb +98 -0
- data/lib/notice_formatter.rb +106 -0
- data/lib/open_id_authentication/result.rb +12 -0
- data/lib/token_util.rb +18 -0
- data/public/404.html +92 -0
- data/public/422.html +91 -0
- data/public/500.html +92 -0
- data/public/503.html +92 -0
- data/public/favicon.ico +0 -0
- data/public/images/battery/cell.png +0 -0
- data/public/images/battery/level-green.png +0 -0
- data/public/images/battery/level-orange.png +0 -0
- data/public/images/battery/level-red.png +0 -0
- data/public/images/battery/level-yellow.png +0 -0
- data/public/images/battery/style.html +82 -0
- data/public/images/favicons/livedoor.png +0 -0
- data/public/images/favicons/mixi.png +0 -0
- data/public/images/favicons/yahoo.png +0 -0
- data/public/images/h1-back.png +0 -0
- data/public/images/icons/fam/add.png +0 -0
- data/public/images/icons/fam/bin.png +0 -0
- data/public/images/icons/fam/bomb.png +0 -0
- data/public/images/icons/fam/cog.png +0 -0
- data/public/images/icons/fam/delete.png +0 -0
- data/public/images/icons/fam/email-with-desc.png +0 -0
- data/public/images/icons/fam/email.png +0 -0
- data/public/images/icons/fam/feed.png +0 -0
- data/public/images/icons/fam/help.png +0 -0
- data/public/images/icons/fam/key-with-desc.png +0 -0
- data/public/images/icons/fam/key.png +0 -0
- data/public/images/icons/fam/lightning.png +0 -0
- data/public/images/icons/fam/plugin.png +0 -0
- data/public/images/icons/fam/stop.png +0 -0
- data/public/images/icons/fam/table_save.png +0 -0
- data/public/images/icons/fam/tick.png +0 -0
- data/public/images/icons/fam/user.png +0 -0
- data/public/images/icons/fam/vcard.png +0 -0
- data/public/images/icons/openid-with-desc.png +0 -0
- data/public/images/icons/openid.png +0 -0
- data/public/images/logo-back.png +0 -0
- data/public/images/logo.png +0 -0
- data/public/images/side-column-back.png +0 -0
- data/public/javascripts/application.js +2 -0
- data/public/javascripts/controls.js +963 -0
- data/public/javascripts/dragdrop.js +973 -0
- data/public/javascripts/effects.js +1128 -0
- data/public/javascripts/prototype.js +4320 -0
- data/public/robots.txt +5 -0
- data/public/stylesheets/application.css +365 -0
- data/public/stylesheets/auth.css +22 -0
- data/public/stylesheets/home.css +114 -0
- data/rails/init.rb +24 -0
- data/test/functional/auth/email_controller_test.rb +102 -0
- data/test/functional/auth/open_id_controller_test.rb +76 -0
- data/test/functional/auth_controller_test.rb +74 -0
- data/test/functional/credentials/email_controller_test.rb +488 -0
- data/test/functional/credentials/open_id_controller_test.rb +308 -0
- data/test/functional/credentials_controller_test.rb +49 -0
- data/test/functional/signup/email_controller_test.rb +369 -0
- data/test/functional/signup/open_id_controller_test.rb +44 -0
- data/test/functional/signup_controller_test.rb +17 -0
- data/test/performance/browsing_test.rb +9 -0
- data/test/test_helper.rb +82 -0
- data/test/unit/action_mailer_util_test.rb +63 -0
- data/test/unit/activation_mailer_test.rb +181 -0
- data/test/unit/email_credential_edit_form_test.rb +173 -0
- data/test/unit/email_credential_test.rb +324 -0
- data/test/unit/email_login_form_test.rb +76 -0
- data/test/unit/email_password_edit_form_test.rb +117 -0
- data/test/unit/helpers/auth_helper_test.rb +4 -0
- data/test/unit/helpers/credentials/email_helper_test.rb +4 -0
- data/test/unit/helpers/credentials/open_id_helper_test.rb +4 -0
- data/test/unit/helpers/credentials_helper_test.rb +4 -0
- data/test/unit/helpers/email_auth_helper_test.rb +4 -0
- data/test/unit/helpers/email_signup_helper_test.rb +4 -0
- data/test/unit/helpers/open_id_auth_helper_test.rb +4 -0
- data/test/unit/helpers/open_id_signup_helper_test.rb +4 -0
- data/test/unit/helpers/password_auth_helper_test.rb +4 -0
- data/test/unit/helpers/password_signup_helper_test.rb +4 -0
- data/test/unit/helpers/signup_helper_test.rb +4 -0
- data/test/unit/notice_formatter_test.rb +153 -0
- data/test/unit/open_id_credential_test.rb +108 -0
- data/test/unit/open_id_login_form_test.rb +57 -0
- data/test/unit/session_test.rb +53 -0
- data/test/unit/token_util_test.rb +51 -0
- data/test/unit/user_test.rb +177 -0
- metadata +220 -0
@@ -0,0 +1,74 @@
|
|
1
|
+
|
2
|
+
require 'test_helper'
|
3
|
+
|
4
|
+
class AuthControllerTest < ActionController::TestCase
|
5
|
+
test "routes" do
|
6
|
+
base = {:controller => "auth"}
|
7
|
+
|
8
|
+
assert_routing("/auth/logged_in", base.merge(:action => "logged_in"))
|
9
|
+
assert_routing("/auth/logout", base.merge(:action => "logout"))
|
10
|
+
assert_routing("/auth/logged_out", base.merge(:action => "logged_out"))
|
11
|
+
end
|
12
|
+
|
13
|
+
test "GET logged_in" do
|
14
|
+
return_path = "/return"
|
15
|
+
|
16
|
+
get :logged_in, :return_path => return_path
|
17
|
+
|
18
|
+
assert_response(:success)
|
19
|
+
assert_template("logged_in")
|
20
|
+
|
21
|
+
assert_equal(return_path, assigns(:return_path))
|
22
|
+
end
|
23
|
+
|
24
|
+
test "GET logged_in, without return path" do
|
25
|
+
get :logged_in
|
26
|
+
|
27
|
+
assert_response(:success)
|
28
|
+
assert_template("logged_in")
|
29
|
+
|
30
|
+
assert_equal(root_path, assigns(:return_path))
|
31
|
+
end
|
32
|
+
|
33
|
+
test "POST logout" do
|
34
|
+
@request.session[:user_id] = 0
|
35
|
+
|
36
|
+
post :logout
|
37
|
+
|
38
|
+
assert_response(:redirect)
|
39
|
+
assert_redirected_to(:controller => "auth", :action => "logged_out")
|
40
|
+
|
41
|
+
assert_equal(nil, @request.session[:user_id])
|
42
|
+
end
|
43
|
+
|
44
|
+
test "GET logout, abnormal, method not allowed" do
|
45
|
+
@request.session[:user_id] = 0
|
46
|
+
|
47
|
+
get :logout
|
48
|
+
|
49
|
+
assert_response(405)
|
50
|
+
assert_template(nil)
|
51
|
+
|
52
|
+
assert_equal(0, @request.session[:user_id])
|
53
|
+
end
|
54
|
+
|
55
|
+
test "GET logged_out" do
|
56
|
+
return_path = "/return"
|
57
|
+
|
58
|
+
get :logged_out, :return_path => return_path
|
59
|
+
|
60
|
+
assert_response(:success)
|
61
|
+
assert_template("logged_out")
|
62
|
+
|
63
|
+
assert_equal(return_path, assigns(:return_path))
|
64
|
+
end
|
65
|
+
|
66
|
+
test "GET logged_out, without return path" do
|
67
|
+
get :logged_out
|
68
|
+
|
69
|
+
assert_response(:success)
|
70
|
+
assert_template("logged_out")
|
71
|
+
|
72
|
+
assert_equal(root_path, assigns(:return_path))
|
73
|
+
end
|
74
|
+
end
|
@@ -0,0 +1,488 @@
|
|
1
|
+
|
2
|
+
require 'test_helper'
|
3
|
+
|
4
|
+
class Credentials::EmailControllerTest < ActionController::TestCase
|
5
|
+
def setup
|
6
|
+
@yuya = users(:yuya)
|
7
|
+
@yuya_gmail = email_credentials(:yuya_gmail)
|
8
|
+
@yuya_nayutaya = email_credentials(:yuya_nayutaya)
|
9
|
+
@risa_example = email_credentials(:risa_example)
|
10
|
+
|
11
|
+
@edit_form = EmailCredentialEditForm.new(
|
12
|
+
:email => "email@example.jp",
|
13
|
+
:password => "password",
|
14
|
+
:password_confirmation => "password")
|
15
|
+
|
16
|
+
@password_edit_form = EmailPasswordEditForm.new(
|
17
|
+
:password => "password",
|
18
|
+
:password_confirmation => "password")
|
19
|
+
|
20
|
+
session_login(@yuya)
|
21
|
+
end
|
22
|
+
|
23
|
+
test "routes" do
|
24
|
+
base = {:controller => "credentials/email"}
|
25
|
+
|
26
|
+
assert_routing("/credentials/email/new", base.merge(:action => "new"))
|
27
|
+
assert_routing("/credentials/email/create", base.merge(:action => "create"))
|
28
|
+
|
29
|
+
assert_routing("/credential/email/1234567890/created", base.merge(:action => "created", :email_credential_id => "1234567890"))
|
30
|
+
assert_routing("/credential/email/1234567890/edit_password", base.merge(:action => "edit_password", :email_credential_id => "1234567890"))
|
31
|
+
assert_routing("/credential/email/1234567890/update_password", base.merge(:action => "update_password", :email_credential_id => "1234567890"))
|
32
|
+
assert_routing("/credential/email/1234567890/delete", base.merge(:action => "delete", :email_credential_id => "1234567890"))
|
33
|
+
assert_routing("/credential/email/1234567890/destroy", base.merge(:action => "destroy", :email_credential_id => "1234567890"))
|
34
|
+
|
35
|
+
assert_routing("/credential/email/token/0123456789/activation", base.merge(:action => "activation", :activation_token => "0123456789"))
|
36
|
+
assert_routing("/credential/email/token/0123456789/activate", base.merge(:action => "activate", :activation_token => "0123456789"))
|
37
|
+
assert_routing("/credential/email/token/0123456789/activated", base.merge(:action => "activated", :activation_token => "0123456789"))
|
38
|
+
end
|
39
|
+
|
40
|
+
test "GET new" do
|
41
|
+
get :new
|
42
|
+
|
43
|
+
assert_response(:success)
|
44
|
+
assert_template("new")
|
45
|
+
assert_flash_empty
|
46
|
+
assert_logged_in(@yuya)
|
47
|
+
|
48
|
+
assert_equal(
|
49
|
+
EmailCredentialEditForm.new.attributes,
|
50
|
+
assigns(:edit_form).attributes)
|
51
|
+
end
|
52
|
+
|
53
|
+
test "GET new, abnormal, no login" do
|
54
|
+
session_logout
|
55
|
+
|
56
|
+
get :new
|
57
|
+
|
58
|
+
assert_response(:redirect)
|
59
|
+
assert_redirected_to(root_path)
|
60
|
+
assert_flash_error
|
61
|
+
end
|
62
|
+
|
63
|
+
test "POST create" do
|
64
|
+
assert_equal(true, @edit_form.valid?)
|
65
|
+
|
66
|
+
assert_difference("EmailCredential.count", +1) {
|
67
|
+
post :create, :edit_form => @edit_form.attributes
|
68
|
+
}
|
69
|
+
|
70
|
+
assert_response(:redirect)
|
71
|
+
assert_redirected_to(:controller => "credentials/email", :action => "created", :email_credential_id => assigns(:email_credential).id)
|
72
|
+
assert_flash_notice
|
73
|
+
assert_logged_in(@yuya)
|
74
|
+
|
75
|
+
assert_equal(
|
76
|
+
@edit_form.attributes,
|
77
|
+
assigns(:edit_form).attributes)
|
78
|
+
|
79
|
+
assigns(:email_credential).reload
|
80
|
+
assert_equal(@yuya.id, assigns(:email_credential).user_id)
|
81
|
+
assert_equal(@edit_form.email, assigns(:email_credential).email)
|
82
|
+
assert_equal(true, EmailCredential.compare_hashed_password(@edit_form.password, assigns(:email_credential).hashed_password))
|
83
|
+
assert_equal(nil, assigns(:email_credential).activated_at)
|
84
|
+
|
85
|
+
# TODO: アクティベーションメールを送信
|
86
|
+
end
|
87
|
+
|
88
|
+
test "POST create, invalid form" do
|
89
|
+
@edit_form.email = nil
|
90
|
+
assert_equal(false, @edit_form.valid?)
|
91
|
+
|
92
|
+
assert_difference("EmailCredential.count", 0) {
|
93
|
+
post :create, :edit_form => @edit_form.attributes
|
94
|
+
}
|
95
|
+
|
96
|
+
assert_response(:success)
|
97
|
+
assert_template("new")
|
98
|
+
assert_flash_error
|
99
|
+
|
100
|
+
assert_equal(nil, assigns(:edit_form).password)
|
101
|
+
assert_equal(nil, assigns(:edit_form).password_confirmation)
|
102
|
+
end
|
103
|
+
|
104
|
+
test "GET create, abnormal, method not allowed" do
|
105
|
+
get :create
|
106
|
+
|
107
|
+
assert_response(405)
|
108
|
+
assert_template(nil)
|
109
|
+
end
|
110
|
+
|
111
|
+
test "POST create, abnormal, no login" do
|
112
|
+
session_logout
|
113
|
+
|
114
|
+
post :create
|
115
|
+
|
116
|
+
assert_response(:redirect)
|
117
|
+
assert_redirected_to(root_path)
|
118
|
+
assert_flash_error
|
119
|
+
end
|
120
|
+
|
121
|
+
test "GET created" do
|
122
|
+
get :created, :email_credential_id => @yuya_gmail.id
|
123
|
+
|
124
|
+
assert_response(:success)
|
125
|
+
assert_template("created")
|
126
|
+
assert_flash_empty
|
127
|
+
assert_logged_in(@yuya)
|
128
|
+
|
129
|
+
assert_equal(@yuya_gmail, assigns(:email_credential))
|
130
|
+
end
|
131
|
+
|
132
|
+
test "GET created, abnormal, no login" do
|
133
|
+
session_logout
|
134
|
+
|
135
|
+
get :created, :email_credential_id => @yuya_gmail.id
|
136
|
+
|
137
|
+
assert_response(:redirect)
|
138
|
+
assert_redirected_to(root_path)
|
139
|
+
assert_flash_error
|
140
|
+
end
|
141
|
+
|
142
|
+
test "GET created, abnormal, invalid email credential id" do
|
143
|
+
get :created, :email_credential_id => "0"
|
144
|
+
|
145
|
+
assert_response(:redirect)
|
146
|
+
assert_redirected_to(root_path)
|
147
|
+
assert_flash_error
|
148
|
+
end
|
149
|
+
|
150
|
+
test "GET created, abnormal, other's email credential" do
|
151
|
+
get :created, :email_credential_id => @risa_example.id
|
152
|
+
|
153
|
+
assert_response(:redirect)
|
154
|
+
assert_redirected_to(root_path)
|
155
|
+
assert_flash_error
|
156
|
+
end
|
157
|
+
|
158
|
+
test "GET edit_password" do
|
159
|
+
get :edit_password, :email_credential_id => @yuya_gmail.id
|
160
|
+
|
161
|
+
assert_response(:success)
|
162
|
+
assert_template("edit_password")
|
163
|
+
assert_flash_empty
|
164
|
+
assert_logged_in(@yuya)
|
165
|
+
|
166
|
+
assert_equal(@yuya_gmail, assigns(:email_credential))
|
167
|
+
|
168
|
+
assert_equal(
|
169
|
+
EmailPasswordEditForm.new.attributes,
|
170
|
+
assigns(:edit_form).attributes)
|
171
|
+
end
|
172
|
+
|
173
|
+
test "GET edit_password, abnormal, no login" do
|
174
|
+
session_logout
|
175
|
+
|
176
|
+
get :edit_password, :email_credential_id => @yuya_gmail.id
|
177
|
+
|
178
|
+
assert_response(:redirect)
|
179
|
+
assert_redirected_to(root_path)
|
180
|
+
assert_flash_error
|
181
|
+
end
|
182
|
+
|
183
|
+
test "GET edit_password, abnormal, invalid email credential id" do
|
184
|
+
get :edit_password, :email_credential_id => "0"
|
185
|
+
|
186
|
+
assert_response(:redirect)
|
187
|
+
assert_redirected_to(root_path)
|
188
|
+
assert_flash_error
|
189
|
+
end
|
190
|
+
|
191
|
+
test "GET edit_password, abnormal, other's email credential" do
|
192
|
+
get :edit_password, :email_credential_id => @risa_example.id
|
193
|
+
|
194
|
+
assert_response(:redirect)
|
195
|
+
assert_redirected_to(root_path)
|
196
|
+
assert_flash_error
|
197
|
+
end
|
198
|
+
|
199
|
+
test "POST update_password" do
|
200
|
+
assert_equal(true, @password_edit_form.valid?)
|
201
|
+
|
202
|
+
post :update_password, :email_credential_id => @yuya_gmail.id, :edit_form => @password_edit_form.attributes
|
203
|
+
|
204
|
+
assert_response(:redirect)
|
205
|
+
assert_redirected_to(:controller => "/credentials", :action => "index")
|
206
|
+
assert_flash_notice
|
207
|
+
assert_logged_in(@yuya)
|
208
|
+
|
209
|
+
assert_equal(@yuya_gmail, assigns(:email_credential))
|
210
|
+
|
211
|
+
assert_equal(
|
212
|
+
@password_edit_form.attributes,
|
213
|
+
assigns(:edit_form).attributes)
|
214
|
+
|
215
|
+
assigns(:email_credential).reload
|
216
|
+
assert_equal(
|
217
|
+
true,
|
218
|
+
EmailCredential.compare_hashed_password(@password_edit_form.password, assigns(:email_credential).hashed_password))
|
219
|
+
end
|
220
|
+
|
221
|
+
test "POST update_password, invalid form" do
|
222
|
+
@password_edit_form.password = "x"
|
223
|
+
assert_equal(false, @password_edit_form.valid?)
|
224
|
+
|
225
|
+
post :update_password, :email_credential_id => @yuya_gmail.id, :edit_form => @password_edit_form.attributes
|
226
|
+
|
227
|
+
assert_response(:success)
|
228
|
+
assert_template("edit_password")
|
229
|
+
assert_flash_error
|
230
|
+
|
231
|
+
assert_equal(nil, assigns(:edit_form).password)
|
232
|
+
assert_equal(nil, assigns(:edit_form).password_confirmation)
|
233
|
+
end
|
234
|
+
|
235
|
+
test "GET update_password, abnormal, method not allowed" do
|
236
|
+
get :update_password, :email_credential_id => @yuya_gmail.id
|
237
|
+
|
238
|
+
assert_response(405)
|
239
|
+
assert_template(nil)
|
240
|
+
end
|
241
|
+
|
242
|
+
test "POST update_password, abnormal, no login" do
|
243
|
+
session_logout
|
244
|
+
|
245
|
+
post :update_password, :email_credential_id => @yuya_gmail.id
|
246
|
+
|
247
|
+
assert_response(:redirect)
|
248
|
+
assert_redirected_to(root_path)
|
249
|
+
assert_flash_error
|
250
|
+
end
|
251
|
+
|
252
|
+
test "POST update_password, abnormal, invalid email credential id" do
|
253
|
+
post :update_password, :email_credential_id => "0"
|
254
|
+
|
255
|
+
assert_response(:redirect)
|
256
|
+
assert_redirected_to(root_path)
|
257
|
+
assert_flash_error
|
258
|
+
end
|
259
|
+
|
260
|
+
test "POST update_password, abnormal, other's email credential" do
|
261
|
+
post :update_password, :email_credential_id => @risa_example.id
|
262
|
+
|
263
|
+
assert_response(:redirect)
|
264
|
+
assert_redirected_to(root_path)
|
265
|
+
assert_flash_error
|
266
|
+
end
|
267
|
+
|
268
|
+
test "GET delete" do
|
269
|
+
get :delete, :email_credential_id => @yuya_gmail.id
|
270
|
+
|
271
|
+
assert_response(:success)
|
272
|
+
assert_template("delete")
|
273
|
+
assert_flash_empty
|
274
|
+
assert_logged_in(@yuya)
|
275
|
+
|
276
|
+
assert_equal(@yuya_gmail, assigns(:email_credential))
|
277
|
+
end
|
278
|
+
|
279
|
+
test "GET delete, abnormal, no login" do
|
280
|
+
session_logout
|
281
|
+
|
282
|
+
get :delete, :email_credential_id => @yuya_gmail.id
|
283
|
+
|
284
|
+
assert_response(:redirect)
|
285
|
+
assert_redirected_to(root_path)
|
286
|
+
assert_flash_error
|
287
|
+
end
|
288
|
+
|
289
|
+
test "GET delete, abnormal, invalid email credential id" do
|
290
|
+
get :delete, :email_credential_id => "0"
|
291
|
+
|
292
|
+
assert_response(:redirect)
|
293
|
+
assert_redirected_to(root_path)
|
294
|
+
assert_flash_error
|
295
|
+
end
|
296
|
+
|
297
|
+
test "GET delete, abnormal, other's email credential" do
|
298
|
+
get :delete, :email_credential_id => @risa_example.id
|
299
|
+
|
300
|
+
assert_response(:redirect)
|
301
|
+
assert_redirected_to(root_path)
|
302
|
+
assert_flash_error
|
303
|
+
end
|
304
|
+
|
305
|
+
test "POST destroy" do
|
306
|
+
assert_difference("EmailCredential.count", -1) {
|
307
|
+
post :destroy, :email_credential_id => @yuya_gmail.id
|
308
|
+
}
|
309
|
+
|
310
|
+
assert_response(:redirect)
|
311
|
+
assert_redirected_to(:controller => "/credentials", :action => "index")
|
312
|
+
assert_flash_notice
|
313
|
+
assert_logged_in(@yuya)
|
314
|
+
|
315
|
+
assert_equal(@yuya_gmail, assigns(:email_credential))
|
316
|
+
|
317
|
+
assert_equal(nil, EmailCredential.find_by_id(@yuya_gmail.id))
|
318
|
+
end
|
319
|
+
|
320
|
+
test "GET destroy, abnormal, method not allowed" do
|
321
|
+
get :destroy, :email_credential_id => @yuya_gmail.id
|
322
|
+
|
323
|
+
assert_response(405)
|
324
|
+
assert_template(nil)
|
325
|
+
end
|
326
|
+
|
327
|
+
test "POST destroy, abnormal, no login" do
|
328
|
+
session_logout
|
329
|
+
|
330
|
+
post :destroy, :email_credential_id => @yuya_gmail.id
|
331
|
+
|
332
|
+
assert_response(:redirect)
|
333
|
+
assert_redirected_to(root_path)
|
334
|
+
assert_flash_error
|
335
|
+
end
|
336
|
+
|
337
|
+
test "POST destroy, abnormal, invalid email credential id" do
|
338
|
+
post :destroy, :email_credential_id => "0"
|
339
|
+
|
340
|
+
assert_response(:redirect)
|
341
|
+
assert_redirected_to(root_path)
|
342
|
+
assert_flash_error
|
343
|
+
end
|
344
|
+
|
345
|
+
test "POST destroy, abnormal, other's email credential" do
|
346
|
+
post :destroy, :email_credential_id => @risa_example.id
|
347
|
+
|
348
|
+
assert_response(:redirect)
|
349
|
+
assert_redirected_to(root_path)
|
350
|
+
assert_flash_error
|
351
|
+
end
|
352
|
+
|
353
|
+
test "GET activation" do
|
354
|
+
assert_equal(false, @yuya_nayutaya.activated?)
|
355
|
+
|
356
|
+
get :activation, :activation_token => @yuya_nayutaya.activation_token
|
357
|
+
|
358
|
+
assert_response(:success)
|
359
|
+
assert_template("activation")
|
360
|
+
assert_flash_empty
|
361
|
+
assert_logged_in(@yuya)
|
362
|
+
|
363
|
+
assert_equal(@yuya_nayutaya, assigns(:email_credential))
|
364
|
+
end
|
365
|
+
|
366
|
+
test "GET activation, no login" do
|
367
|
+
session_logout
|
368
|
+
assert_equal(false, @yuya_nayutaya.activated?)
|
369
|
+
|
370
|
+
get :activation, :activation_token => @yuya_nayutaya.activation_token
|
371
|
+
|
372
|
+
assert_response(:success)
|
373
|
+
assert_template("activation")
|
374
|
+
assert_flash_empty
|
375
|
+
assert_not_logged_in
|
376
|
+
|
377
|
+
assert_equal(@yuya_nayutaya, assigns(:email_credential))
|
378
|
+
end
|
379
|
+
|
380
|
+
test "GET activation, abnormal, invalid activation token" do
|
381
|
+
get :activation, :activation_token => "0"
|
382
|
+
|
383
|
+
assert_response(:redirect)
|
384
|
+
assert_redirected_to(root_path)
|
385
|
+
assert_flash_error
|
386
|
+
end
|
387
|
+
|
388
|
+
test "GET activation, abnormal, already activated" do
|
389
|
+
assert_equal(true, @yuya_gmail.activated?)
|
390
|
+
|
391
|
+
get :activation, :activation_token => @yuya_gmail.activation_token
|
392
|
+
|
393
|
+
assert_response(:redirect)
|
394
|
+
assert_redirected_to(root_path)
|
395
|
+
assert_flash_error
|
396
|
+
end
|
397
|
+
|
398
|
+
test "POST activate" do
|
399
|
+
time = Time.local(2009, 1, 1)
|
400
|
+
assert_equal(false, @yuya_nayutaya.activated?)
|
401
|
+
|
402
|
+
Kagemusha::DateTime.at(time) {
|
403
|
+
post :activate, :activation_token => @yuya_nayutaya.activation_token
|
404
|
+
}
|
405
|
+
|
406
|
+
assert_response(:redirect)
|
407
|
+
assert_redirected_to(:controller => "credentials/email", :action => "activated")
|
408
|
+
assert_flash_empty
|
409
|
+
assert_logged_in(@yuya)
|
410
|
+
|
411
|
+
assert_equal(@yuya_nayutaya, assigns(:email_credential))
|
412
|
+
|
413
|
+
assigns(:email_credential).reload
|
414
|
+
assert_equal(true, assigns(:email_credential).activated?)
|
415
|
+
assert_equal(time, assigns(:email_credential).activated_at)
|
416
|
+
end
|
417
|
+
|
418
|
+
test "POST activate, no login" do
|
419
|
+
session_logout
|
420
|
+
assert_equal(false, @yuya_nayutaya.activated?)
|
421
|
+
|
422
|
+
post :activate, :activation_token => @yuya_nayutaya.activation_token
|
423
|
+
|
424
|
+
assert_response(:redirect)
|
425
|
+
assert_redirected_to(:controller => "credentials/email", :action => "activated")
|
426
|
+
assert_flash_empty
|
427
|
+
assert_not_logged_in
|
428
|
+
|
429
|
+
assert_equal(@yuya_nayutaya, assigns(:email_credential))
|
430
|
+
end
|
431
|
+
|
432
|
+
test "GET activate, abnormal, method not allowed" do
|
433
|
+
get :activate, :activation_token => @yuya_nayutaya.activation_token
|
434
|
+
|
435
|
+
assert_response(405)
|
436
|
+
assert_template(nil)
|
437
|
+
end
|
438
|
+
|
439
|
+
test "POST activate, abnormal, invalid activation token" do
|
440
|
+
post :activate, :activation_token => "0"
|
441
|
+
|
442
|
+
assert_response(:redirect)
|
443
|
+
assert_redirected_to(root_path)
|
444
|
+
assert_flash_error
|
445
|
+
end
|
446
|
+
|
447
|
+
test "POST activate, abnormal, already activated" do
|
448
|
+
assert_equal(true, @yuya_gmail.activated?)
|
449
|
+
|
450
|
+
post :activate, :activation_token => @yuya_gmail.activation_token
|
451
|
+
|
452
|
+
assert_response(:redirect)
|
453
|
+
assert_redirected_to(root_path)
|
454
|
+
assert_flash_error
|
455
|
+
end
|
456
|
+
|
457
|
+
test "GET activated" do
|
458
|
+
get :activated, :activation_token => @yuya_nayutaya.activation_token
|
459
|
+
|
460
|
+
assert_response(:success)
|
461
|
+
assert_template("activated")
|
462
|
+
assert_flash_empty
|
463
|
+
assert_logged_in(@yuya)
|
464
|
+
|
465
|
+
assert_equal(@yuya_nayutaya, assigns(:email_credential))
|
466
|
+
end
|
467
|
+
|
468
|
+
test "GET activated, no login" do
|
469
|
+
session_logout
|
470
|
+
|
471
|
+
get :activated, :activation_token => @yuya_nayutaya.activation_token
|
472
|
+
|
473
|
+
assert_response(:success)
|
474
|
+
assert_template("activated")
|
475
|
+
assert_flash_empty
|
476
|
+
assert_not_logged_in
|
477
|
+
|
478
|
+
assert_equal(@yuya_nayutaya, assigns(:email_credential))
|
479
|
+
end
|
480
|
+
|
481
|
+
test "GET activated, abnormal, invalid activation token" do
|
482
|
+
get :activated, :activation_token => "0"
|
483
|
+
|
484
|
+
assert_response(:redirect)
|
485
|
+
assert_redirected_to(root_path)
|
486
|
+
assert_flash_error
|
487
|
+
end
|
488
|
+
end
|