devise_token_auth 0.1.30.beta3 → 0.1.30.beta4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +16 -2
- data/app/controllers/devise_token_auth/concerns/set_user_by_token.rb +9 -9
- data/app/controllers/devise_token_auth/confirmations_controller.rb +5 -5
- data/app/controllers/devise_token_auth/omniauth_callbacks_controller.rb +10 -10
- data/app/controllers/devise_token_auth/passwords_controller.rb +34 -23
- data/app/controllers/devise_token_auth/registrations_controller.rb +10 -11
- data/app/controllers/devise_token_auth/sessions_controller.rb +23 -8
- data/app/controllers/devise_token_auth/token_validations_controller.rb +3 -3
- data/app/models/devise_token_auth/concerns/user.rb +1 -0
- data/app/views/devise_token_auth/omniauth_success.html.erb +1 -1
- data/lib/devise_token_auth/version.rb +1 -1
- data/lib/generators/devise_token_auth/templates/devise_token_auth_create_users.rb.erb +6 -6
- data/test/controllers/demo_group_controller_test.rb +14 -14
- data/test/controllers/demo_mang_controller_test.rb +25 -25
- data/test/controllers/demo_user_controller_test.rb +25 -25
- data/test/controllers/devise_token_auth/confirmations_controller_test.rb +6 -6
- data/test/controllers/devise_token_auth/omniauth_callbacks_controller_test.rb +11 -11
- data/test/controllers/devise_token_auth/passwords_controller_test.rb +110 -84
- data/test/controllers/devise_token_auth/registrations_controller_test.rb +23 -23
- data/test/controllers/devise_token_auth/sessions_controller_test.rb +68 -5
- data/test/controllers/overrides/omniauth_callbacks_controller_test.rb +3 -3
- data/test/controllers/overrides/passwords_controller_test.rb +4 -4
- data/test/controllers/overrides/sessions_controller_test.rb +1 -1
- data/test/controllers/overrides/token_validations_controller_test.rb +5 -5
- data/test/dummy/app/controllers/demo_mang_controller.rb +2 -2
- data/test/dummy/app/controllers/demo_user_controller.rb +2 -2
- data/test/dummy/app/controllers/overrides/confirmations_controller.rb +5 -5
- data/test/dummy/app/controllers/overrides/passwords_controller.rb +6 -6
- data/test/dummy/app/controllers/overrides/registrations_controller.rb +4 -4
- data/test/dummy/app/controllers/overrides/sessions_controller.rb +7 -7
- data/test/dummy/app/controllers/overrides/token_validations_controller.rb +3 -3
- data/test/dummy/config/application.yml +8 -0
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/db/migrate/20140715061447_devise_token_auth_create_users.rb +2 -2
- data/test/dummy/db/migrate/20140715061805_devise_token_auth_create_mangs.rb +2 -2
- data/test/dummy/db/migrate/20140928231203_devise_token_auth_create_evil_users.rb +2 -2
- data/test/dummy/db/schema.rb +12 -9
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/log/development.log +1979 -0
- data/test/dummy/log/test.log +183708 -0
- data/test/dummy/tmp/generators/app/views/devise/mailer/confirmation_instructions.html.erb +5 -0
- data/test/dummy/tmp/generators/app/views/devise/mailer/reset_password_instructions.html.erb +8 -0
- data/test/models/user_test.rb +37 -27
- metadata +10 -10
- data/test/dummy/tmp/generators/app/models/user.rb +0 -7
- data/test/dummy/tmp/generators/config/initializers/devise_token_auth.rb +0 -22
- data/test/dummy/tmp/generators/db/migrate/20141028214843_devise_token_auth_create_users.rb +0 -54
@@ -30,7 +30,7 @@ class OmniauthTest < ActionDispatch::IntegrationTest
|
|
30
30
|
auth_origin_url: @redirect_url
|
31
31
|
}
|
32
32
|
|
33
|
-
@
|
33
|
+
@resource = assigns(:resource)
|
34
34
|
end
|
35
35
|
|
36
36
|
test 'status should be success' do
|
@@ -46,15 +46,15 @@ class OmniauthTest < ActionDispatch::IntegrationTest
|
|
46
46
|
end
|
47
47
|
|
48
48
|
test 'user should have been created' do
|
49
|
-
assert @
|
49
|
+
assert @resource
|
50
50
|
end
|
51
51
|
|
52
52
|
test 'user should be assigned info from provider' do
|
53
|
-
assert_equal 'chongbong@aol.com', @
|
53
|
+
assert_equal 'chongbong@aol.com', @resource.email
|
54
54
|
end
|
55
55
|
|
56
56
|
test 'user should be of the correct class' do
|
57
|
-
assert_equal User, @
|
57
|
+
assert_equal User, @resource.class
|
58
58
|
end
|
59
59
|
|
60
60
|
test 'response contains all serializable attributes for user' do
|
@@ -88,7 +88,7 @@ class OmniauthTest < ActionDispatch::IntegrationTest
|
|
88
88
|
name: @unpermitted_param
|
89
89
|
}
|
90
90
|
|
91
|
-
@
|
91
|
+
@resource = assigns(:resource)
|
92
92
|
end
|
93
93
|
|
94
94
|
test 'status shows success' do
|
@@ -96,11 +96,11 @@ class OmniauthTest < ActionDispatch::IntegrationTest
|
|
96
96
|
end
|
97
97
|
|
98
98
|
test 'additional attribute was passed' do
|
99
|
-
assert_equal @fav_color, @
|
99
|
+
assert_equal @fav_color, @resource.favorite_color
|
100
100
|
end
|
101
101
|
|
102
102
|
test 'non-whitelisted attributes are ignored' do
|
103
|
-
refute_equal @unpermitted_param, @
|
103
|
+
refute_equal @unpermitted_param, @resource.name
|
104
104
|
end
|
105
105
|
end
|
106
106
|
end
|
@@ -113,7 +113,7 @@ class OmniauthTest < ActionDispatch::IntegrationTest
|
|
113
113
|
auth_origin_url: @redirect_url
|
114
114
|
}
|
115
115
|
|
116
|
-
@
|
116
|
+
@resource = assigns(:resource)
|
117
117
|
end
|
118
118
|
|
119
119
|
test 'status should be success' do
|
@@ -129,15 +129,15 @@ class OmniauthTest < ActionDispatch::IntegrationTest
|
|
129
129
|
end
|
130
130
|
|
131
131
|
test 'user should have been created' do
|
132
|
-
assert @
|
132
|
+
assert @resource
|
133
133
|
end
|
134
134
|
|
135
135
|
test 'user should be assigned info from provider' do
|
136
|
-
assert_equal 'chongbong@aol.com', @
|
136
|
+
assert_equal 'chongbong@aol.com', @resource.email
|
137
137
|
end
|
138
138
|
|
139
139
|
test 'user should be of the correct class' do
|
140
|
-
assert_equal Mang, @
|
140
|
+
assert_equal Mang, @resource.class
|
141
141
|
end
|
142
142
|
end
|
143
143
|
end
|
@@ -10,97 +10,123 @@ class DeviseTokenAuth::PasswordsControllerTest < ActionController::TestCase
|
|
10
10
|
describe DeviseTokenAuth::PasswordsController do
|
11
11
|
describe "Password reset" do
|
12
12
|
before do
|
13
|
-
@
|
13
|
+
@resource = users(:confirmed_email_user)
|
14
14
|
@redirect_url = 'http://ng-token-auth.dev'
|
15
15
|
end
|
16
16
|
|
17
17
|
describe 'request password reset' do
|
18
|
-
before do
|
19
|
-
xhr :post, :create, {
|
20
|
-
email: @user.email,
|
21
|
-
redirect_url: @redirect_url
|
22
|
-
}
|
23
|
-
|
24
|
-
@mail = ActionMailer::Base.deliveries.last
|
25
|
-
@user.reload
|
26
|
-
|
27
|
-
@mail_config_name = CGI.unescape(@mail.body.match(/config=([^&]*)&/)[1])
|
28
|
-
@mail_redirect_url = CGI.unescape(@mail.body.match(/redirect_url=([^&]*)&/)[1])
|
29
|
-
@mail_reset_token = @mail.body.match(/reset_password_token=(.*)\"/)[1]
|
30
|
-
end
|
31
18
|
|
32
|
-
|
33
|
-
|
34
|
-
|
19
|
+
describe 'case-sensitive email' do
|
20
|
+
before do
|
21
|
+
xhr :post, :create, {
|
22
|
+
email: @resource.email,
|
23
|
+
redirect_url: @redirect_url
|
24
|
+
}
|
35
25
|
|
36
|
-
|
37
|
-
|
38
|
-
end
|
26
|
+
@mail = ActionMailer::Base.deliveries.last
|
27
|
+
@resource.reload
|
39
28
|
|
40
|
-
|
41
|
-
|
42
|
-
|
29
|
+
@mail_config_name = CGI.unescape(@mail.body.match(/config=([^&]*)&/)[1])
|
30
|
+
@mail_redirect_url = CGI.unescape(@mail.body.match(/redirect_url=([^&]*)&/)[1])
|
31
|
+
@mail_reset_token = @mail.body.match(/reset_password_token=(.*)\"/)[1]
|
32
|
+
end
|
43
33
|
|
44
|
-
|
45
|
-
|
46
|
-
|
34
|
+
test 'response should return success status' do
|
35
|
+
assert_equal 200, response.status
|
36
|
+
end
|
47
37
|
|
48
|
-
|
49
|
-
|
50
|
-
|
38
|
+
test 'action should send an email' do
|
39
|
+
assert @mail
|
40
|
+
end
|
51
41
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
})
|
42
|
+
test 'the email should be addressed to the user' do
|
43
|
+
assert_equal @mail.to.first, @resource.email
|
44
|
+
end
|
56
45
|
|
57
|
-
|
58
|
-
|
46
|
+
test 'the email body should contain a link with redirect url as a query param' do
|
47
|
+
assert_equal @redirect_url, @mail_redirect_url
|
48
|
+
end
|
49
|
+
|
50
|
+
test 'the client config name should fall back to "default"' do
|
51
|
+
assert_equal 'default', @mail_config_name
|
52
|
+
end
|
53
|
+
|
54
|
+
test 'the email body should contain a link with reset token as a query param' do
|
55
|
+
user = User.reset_password_by_token({
|
56
|
+
reset_password_token: @mail_reset_token
|
57
|
+
})
|
58
|
+
|
59
|
+
assert_equal user.id, @resource.id
|
60
|
+
end
|
59
61
|
|
60
|
-
|
61
|
-
|
62
|
-
|
62
|
+
describe 'password reset link failure' do
|
63
|
+
test 'request should not be authorized' do
|
64
|
+
assert_raises(ActionController::RoutingError) {
|
65
|
+
xhr :get, :edit, {
|
66
|
+
reset_password_token: 'bogus',
|
67
|
+
redirect_url: @mail_redirect_url
|
68
|
+
}
|
69
|
+
}
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
describe 'password reset link success' do
|
74
|
+
before do
|
63
75
|
xhr :get, :edit, {
|
64
|
-
reset_password_token:
|
76
|
+
reset_password_token: @mail_reset_token,
|
65
77
|
redirect_url: @mail_redirect_url
|
66
78
|
}
|
67
|
-
|
79
|
+
|
80
|
+
@resource.reload
|
81
|
+
|
82
|
+
raw_qs = response.location.split('?')[1]
|
83
|
+
@qs = Rack::Utils.parse_nested_query(raw_qs)
|
84
|
+
|
85
|
+
@client_id = @qs["client_id"]
|
86
|
+
@expiry = @qs["expiry"]
|
87
|
+
@reset_password = @qs["reset_password"]
|
88
|
+
@token = @qs["token"]
|
89
|
+
@uid = @qs["uid"]
|
90
|
+
end
|
91
|
+
|
92
|
+
test 'respones should have success redirect status' do
|
93
|
+
assert_equal 302, response.status
|
94
|
+
end
|
95
|
+
|
96
|
+
test 'response should contain auth params' do
|
97
|
+
assert @client_id
|
98
|
+
assert @expiry
|
99
|
+
assert @reset_password
|
100
|
+
assert @token
|
101
|
+
assert @uid
|
102
|
+
end
|
103
|
+
|
104
|
+
test 'response auth params should be valid' do
|
105
|
+
assert @resource.valid_token?(@token, @client_id)
|
106
|
+
end
|
68
107
|
end
|
108
|
+
|
69
109
|
end
|
70
110
|
|
71
|
-
describe '
|
111
|
+
describe 'case-insensitive email' do
|
72
112
|
before do
|
73
|
-
|
74
|
-
|
75
|
-
|
113
|
+
@resource_class = User
|
114
|
+
@request_params = {
|
115
|
+
email: @resource.email.upcase,
|
116
|
+
redirect_url: @redirect_url
|
76
117
|
}
|
77
|
-
|
78
|
-
@user.reload
|
79
|
-
|
80
|
-
raw_qs = response.location.split('?')[1]
|
81
|
-
@qs = Rack::Utils.parse_nested_query(raw_qs)
|
82
|
-
|
83
|
-
@client_id = @qs["client_id"]
|
84
|
-
@expiry = @qs["expiry"]
|
85
|
-
@reset_password = @qs["reset_password"]
|
86
|
-
@token = @qs["token"]
|
87
|
-
@uid = @qs["uid"]
|
88
|
-
end
|
89
|
-
|
90
|
-
test 'respones should have success redirect status' do
|
91
|
-
assert_equal 302, response.status
|
92
118
|
end
|
93
119
|
|
94
|
-
test 'response should
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
assert @token
|
99
|
-
assert @uid
|
120
|
+
test 'response should return success status if configured' do
|
121
|
+
@resource_class.case_insensitive_keys = [:email]
|
122
|
+
xhr :post, :create, @request_params
|
123
|
+
assert_equal 200, response.status
|
100
124
|
end
|
101
125
|
|
102
|
-
test 'response
|
103
|
-
|
126
|
+
test 'response should return failure status if not configured' do
|
127
|
+
@resource_class.case_insensitive_keys = []
|
128
|
+
xhr :post, :create, @request_params
|
129
|
+
assert_equal 400, response.status
|
104
130
|
end
|
105
131
|
end
|
106
132
|
end
|
@@ -108,7 +134,7 @@ class DeviseTokenAuth::PasswordsControllerTest < ActionController::TestCase
|
|
108
134
|
describe "change password" do
|
109
135
|
describe 'success' do
|
110
136
|
before do
|
111
|
-
@auth_headers = @
|
137
|
+
@auth_headers = @resource.create_new_auth_token
|
112
138
|
request.headers.merge!(@auth_headers)
|
113
139
|
@new_password = Faker::Internet.password
|
114
140
|
|
@@ -117,7 +143,7 @@ class DeviseTokenAuth::PasswordsControllerTest < ActionController::TestCase
|
|
117
143
|
password_confirmation: @new_password
|
118
144
|
}
|
119
145
|
|
120
|
-
@
|
146
|
+
@resource.reload
|
121
147
|
end
|
122
148
|
|
123
149
|
test "request should be successful" do
|
@@ -125,13 +151,13 @@ class DeviseTokenAuth::PasswordsControllerTest < ActionController::TestCase
|
|
125
151
|
end
|
126
152
|
|
127
153
|
test "new password should authenticate user" do
|
128
|
-
assert @
|
154
|
+
assert @resource.valid_password?(@new_password)
|
129
155
|
end
|
130
156
|
end
|
131
157
|
|
132
158
|
describe 'password mismatch error' do
|
133
159
|
before do
|
134
|
-
@auth_headers = @
|
160
|
+
@auth_headers = @resource.create_new_auth_token
|
135
161
|
request.headers.merge!(@auth_headers)
|
136
162
|
@new_password = Faker::Internet.password
|
137
163
|
|
@@ -148,7 +174,7 @@ class DeviseTokenAuth::PasswordsControllerTest < ActionController::TestCase
|
|
148
174
|
|
149
175
|
describe 'unauthorized user' do
|
150
176
|
before do
|
151
|
-
@auth_headers = @
|
177
|
+
@auth_headers = @resource.create_new_auth_token
|
152
178
|
@new_password = Faker::Internet.password
|
153
179
|
|
154
180
|
xhr :put, :update, {
|
@@ -174,16 +200,16 @@ class DeviseTokenAuth::PasswordsControllerTest < ActionController::TestCase
|
|
174
200
|
end
|
175
201
|
|
176
202
|
before do
|
177
|
-
@
|
203
|
+
@resource = mangs(:confirmed_email_user)
|
178
204
|
@redirect_url = 'http://ng-token-auth.dev'
|
179
205
|
|
180
206
|
xhr :post, :create, {
|
181
|
-
email: @
|
207
|
+
email: @resource.email,
|
182
208
|
redirect_url: @redirect_url
|
183
209
|
}
|
184
210
|
|
185
211
|
@mail = ActionMailer::Base.deliveries.last
|
186
|
-
@
|
212
|
+
@resource.reload
|
187
213
|
|
188
214
|
@mail_config_name = CGI.unescape(@mail.body.match(/config=([^&]*)&/)[1])
|
189
215
|
@mail_redirect_url = CGI.unescape(@mail.body.match(/redirect_url=([^&]*)&/)[1])
|
@@ -199,22 +225,22 @@ class DeviseTokenAuth::PasswordsControllerTest < ActionController::TestCase
|
|
199
225
|
reset_password_token: @mail_reset_token
|
200
226
|
})
|
201
227
|
|
202
|
-
assert_equal user.id, @
|
228
|
+
assert_equal user.id, @resource.id
|
203
229
|
end
|
204
230
|
end
|
205
231
|
|
206
232
|
describe 'unconfirmed user' do
|
207
233
|
before do
|
208
|
-
@
|
234
|
+
@resource = users(:unconfirmed_email_user)
|
209
235
|
@redirect_url = 'http://ng-token-auth.dev'
|
210
236
|
|
211
237
|
xhr :post, :create, {
|
212
|
-
email: @
|
238
|
+
email: @resource.email,
|
213
239
|
redirect_url: @redirect_url
|
214
240
|
}
|
215
241
|
|
216
242
|
@mail = ActionMailer::Base.deliveries.last
|
217
|
-
@
|
243
|
+
@resource.reload
|
218
244
|
|
219
245
|
@mail_config_name = CGI.unescape(@mail.body.match(/config=([^&]*)&/)[1])
|
220
246
|
@mail_redirect_url = CGI.unescape(@mail.body.match(/redirect_url=([^&]*)&/)[1])
|
@@ -225,28 +251,28 @@ class DeviseTokenAuth::PasswordsControllerTest < ActionController::TestCase
|
|
225
251
|
redirect_url: @mail_redirect_url
|
226
252
|
}
|
227
253
|
|
228
|
-
@
|
254
|
+
@resource.reload
|
229
255
|
end
|
230
256
|
|
231
257
|
test 'unconfirmed email user should now be confirmed' do
|
232
|
-
assert @
|
258
|
+
assert @resource.confirmed_at
|
233
259
|
end
|
234
260
|
end
|
235
261
|
|
236
262
|
describe 'alternate user type' do
|
237
263
|
before do
|
238
|
-
@
|
264
|
+
@resource = users(:confirmed_email_user)
|
239
265
|
@redirect_url = 'http://ng-token-auth.dev'
|
240
266
|
@config_name = "altUser"
|
241
267
|
|
242
268
|
xhr :post, :create, {
|
243
|
-
email: @
|
269
|
+
email: @resource.email,
|
244
270
|
redirect_url: @redirect_url,
|
245
271
|
config_name: @config_name
|
246
272
|
}
|
247
273
|
|
248
274
|
@mail = ActionMailer::Base.deliveries.last
|
249
|
-
@
|
275
|
+
@resource.reload
|
250
276
|
|
251
277
|
@mail_config_name = CGI.unescape(@mail.body.match(/config=([^&]*)&/)[1])
|
252
278
|
@mail_redirect_url = CGI.unescape(@mail.body.match(/redirect_url=([^&]*)&/)[1])
|
@@ -21,7 +21,7 @@ class DeviseTokenAuth::RegistrationsControllerTest < ActionDispatch::Integration
|
|
21
21
|
unpermitted_param: '(x_x)'
|
22
22
|
}
|
23
23
|
|
24
|
-
@
|
24
|
+
@resource = assigns(:resource)
|
25
25
|
@data = JSON.parse(response.body)
|
26
26
|
@mail = ActionMailer::Base.deliveries.last
|
27
27
|
end
|
@@ -31,11 +31,11 @@ class DeviseTokenAuth::RegistrationsControllerTest < ActionDispatch::Integration
|
|
31
31
|
end
|
32
32
|
|
33
33
|
test "user should have been created" do
|
34
|
-
assert @
|
34
|
+
assert @resource.id
|
35
35
|
end
|
36
36
|
|
37
37
|
test "user should not be confirmed" do
|
38
|
-
assert_nil @
|
38
|
+
assert_nil @resource.confirmed_at
|
39
39
|
end
|
40
40
|
|
41
41
|
test "new user data should be returned as json" do
|
@@ -43,7 +43,7 @@ class DeviseTokenAuth::RegistrationsControllerTest < ActionDispatch::Integration
|
|
43
43
|
end
|
44
44
|
|
45
45
|
test "new user should receive confirmation email" do
|
46
|
-
assert_equal @
|
46
|
+
assert_equal @resource.email, @mail['to'].to_s
|
47
47
|
end
|
48
48
|
|
49
49
|
test "new user password should not be returned" do
|
@@ -69,7 +69,7 @@ class DeviseTokenAuth::RegistrationsControllerTest < ActionDispatch::Integration
|
|
69
69
|
operating_thetan: @operating_thetan
|
70
70
|
}
|
71
71
|
|
72
|
-
@
|
72
|
+
@resource = assigns(:resource)
|
73
73
|
@data = JSON.parse(response.body)
|
74
74
|
@mail = ActionMailer::Base.deliveries.last
|
75
75
|
|
@@ -83,7 +83,7 @@ class DeviseTokenAuth::RegistrationsControllerTest < ActionDispatch::Integration
|
|
83
83
|
end
|
84
84
|
|
85
85
|
test "additional sign_up params should be considered" do
|
86
|
-
assert_equal @operating_thetan, @
|
86
|
+
assert_equal @operating_thetan, @resource.operating_thetan
|
87
87
|
end
|
88
88
|
|
89
89
|
test 'config_name param is included in the confirmation email link' do
|
@@ -104,7 +104,7 @@ class DeviseTokenAuth::RegistrationsControllerTest < ActionDispatch::Integration
|
|
104
104
|
confirm_success_url: Faker::Internet.url
|
105
105
|
}
|
106
106
|
|
107
|
-
@
|
107
|
+
@resource = assigns(:resource)
|
108
108
|
@data = JSON.parse(response.body)
|
109
109
|
end
|
110
110
|
|
@@ -113,7 +113,7 @@ class DeviseTokenAuth::RegistrationsControllerTest < ActionDispatch::Integration
|
|
113
113
|
end
|
114
114
|
|
115
115
|
test "user should have been created" do
|
116
|
-
assert_nil @
|
116
|
+
assert_nil @resource.id
|
117
117
|
end
|
118
118
|
|
119
119
|
test "error should be returned in the response" do
|
@@ -136,7 +136,7 @@ class DeviseTokenAuth::RegistrationsControllerTest < ActionDispatch::Integration
|
|
136
136
|
confirm_success_url: Faker::Internet.url
|
137
137
|
}
|
138
138
|
|
139
|
-
@
|
139
|
+
@resource = assigns(:resource)
|
140
140
|
@data = JSON.parse(response.body)
|
141
141
|
end
|
142
142
|
|
@@ -145,7 +145,7 @@ class DeviseTokenAuth::RegistrationsControllerTest < ActionDispatch::Integration
|
|
145
145
|
end
|
146
146
|
|
147
147
|
test "user should have been created" do
|
148
|
-
assert_nil @
|
148
|
+
assert_nil @resource.id
|
149
149
|
end
|
150
150
|
|
151
151
|
test "error should be returned in the response" do
|
@@ -287,7 +287,7 @@ class DeviseTokenAuth::RegistrationsControllerTest < ActionDispatch::Integration
|
|
287
287
|
confirm_success_url: Faker::Internet.url
|
288
288
|
}
|
289
289
|
|
290
|
-
@
|
290
|
+
@resource = assigns(:resource)
|
291
291
|
@data = JSON.parse(response.body)
|
292
292
|
end
|
293
293
|
|
@@ -296,7 +296,7 @@ class DeviseTokenAuth::RegistrationsControllerTest < ActionDispatch::Integration
|
|
296
296
|
end
|
297
297
|
|
298
298
|
test "user should have been created" do
|
299
|
-
assert @
|
299
|
+
assert @resource.id
|
300
300
|
end
|
301
301
|
|
302
302
|
test "new user data should be returned as json" do
|
@@ -313,7 +313,7 @@ class DeviseTokenAuth::RegistrationsControllerTest < ActionDispatch::Integration
|
|
313
313
|
confirm_success_url: Faker::Internet.url
|
314
314
|
}
|
315
315
|
|
316
|
-
@
|
316
|
+
@resource = assigns(:resource)
|
317
317
|
@data = JSON.parse(response.body)
|
318
318
|
@mail = ActionMailer::Base.deliveries.last
|
319
319
|
end
|
@@ -323,20 +323,20 @@ class DeviseTokenAuth::RegistrationsControllerTest < ActionDispatch::Integration
|
|
323
323
|
end
|
324
324
|
|
325
325
|
test "use should be a Mang" do
|
326
|
-
assert_equal "Mang", @
|
326
|
+
assert_equal "Mang", @resource.class.name
|
327
327
|
end
|
328
328
|
|
329
329
|
test "Mang should be destroyed" do
|
330
|
-
@auth_headers = @
|
330
|
+
@auth_headers = @resource.create_new_auth_token
|
331
331
|
@client_id = @auth_headers['client']
|
332
332
|
|
333
333
|
# ensure request is not treated as batch request
|
334
|
-
age_token(@
|
334
|
+
age_token(@resource, @client_id)
|
335
335
|
|
336
336
|
delete "/mangs", {}, @auth_headers
|
337
337
|
|
338
338
|
assert_equal 200, response.status
|
339
|
-
refute Mang.where(id: @
|
339
|
+
refute Mang.where(id: @resource.id).first
|
340
340
|
end
|
341
341
|
end
|
342
342
|
|
@@ -352,11 +352,11 @@ class DeviseTokenAuth::RegistrationsControllerTest < ActionDispatch::Integration
|
|
352
352
|
config_name: @config_name
|
353
353
|
}
|
354
354
|
|
355
|
-
@
|
355
|
+
@resource = assigns(:resource)
|
356
356
|
@data = JSON.parse(response.body)
|
357
357
|
@mail = ActionMailer::Base.deliveries.last
|
358
358
|
|
359
|
-
@
|
359
|
+
@resource.reload
|
360
360
|
|
361
361
|
@mail_reset_token = @mail.body.match(/confirmation_token=([^&]*)&/)[1]
|
362
362
|
@mail_redirect_url = CGI.unescape(@mail.body.match(/redirect_url=(.*)\"/)[1])
|
@@ -379,7 +379,7 @@ class DeviseTokenAuth::RegistrationsControllerTest < ActionDispatch::Integration
|
|
379
379
|
confirm_success_url: Faker::Internet.url
|
380
380
|
}
|
381
381
|
|
382
|
-
@
|
382
|
+
@resource = assigns(:resource)
|
383
383
|
@token = response.headers["access-token"]
|
384
384
|
@client_id = response.headers["client"]
|
385
385
|
end
|
@@ -389,11 +389,11 @@ class DeviseTokenAuth::RegistrationsControllerTest < ActionDispatch::Integration
|
|
389
389
|
end
|
390
390
|
|
391
391
|
test "user was created" do
|
392
|
-
assert @
|
392
|
+
assert @resource
|
393
393
|
end
|
394
394
|
|
395
395
|
test "user was confirmed" do
|
396
|
-
assert @
|
396
|
+
assert @resource.confirmed?
|
397
397
|
end
|
398
398
|
|
399
399
|
test "auth headers were returned in response" do
|
@@ -405,7 +405,7 @@ class DeviseTokenAuth::RegistrationsControllerTest < ActionDispatch::Integration
|
|
405
405
|
end
|
406
406
|
|
407
407
|
test "response token is valid" do
|
408
|
-
assert @
|
408
|
+
assert @resource.valid_token?(@token, @client_id)
|
409
409
|
end
|
410
410
|
end
|
411
411
|
end
|