質問編集履歴
3
エラー個所を追記しました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -72,18 +72,18 @@
|
|
72
72
|
|
73
73
|
get edit_user_path(@user)
|
74
74
|
|
75
|
+
**assert_template 'users/edit'** #ここでエラー
|
76
|
+
|
77
|
+
patch user_path(@user),params:{user:{name:"",
|
78
|
+
|
79
|
+
email:"foo@invalid",
|
80
|
+
|
81
|
+
password: "foo",
|
82
|
+
|
83
|
+
password_confirmation: "bar"}}
|
84
|
+
|
75
85
|
assert_template 'users/edit'
|
76
86
|
|
77
|
-
patch user_path(@user),params:{user:{name:"",
|
78
|
-
|
79
|
-
email:"foo@invalid",
|
80
|
-
|
81
|
-
password: "foo",
|
82
|
-
|
83
|
-
password_confirmation: "bar"}}
|
84
|
-
|
85
|
-
assert_template 'users/edit'
|
86
|
-
|
87
87
|
assert_select "div.alert",count:1
|
88
88
|
|
89
89
|
end
|
@@ -112,7 +112,7 @@
|
|
112
112
|
|
113
113
|
assert_not flash.empty?
|
114
114
|
|
115
|
-
assert_redirected_to @user
|
115
|
+
**assert_redirected_to @user** #ここでエラー
|
116
116
|
|
117
117
|
@user.reload
|
118
118
|
|
2
log/test.logを追加いたしました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -276,7 +276,119 @@
|
|
276
276
|
|
277
277
|
|
278
278
|
|
279
|
-
以下が、log
|
279
|
+
以下が、log/test.logとなります。
|
280
|
+
|
281
|
+
```
|
282
|
+
|
283
|
+
UsersEditTest: test_successful_edit_with_friendly_forwarding
|
284
|
+
|
285
|
+
------------------------------------------------------------
|
286
|
+
|
287
|
+
[1m[36mUser Load (0.1ms)[0m [1m[34mSELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT ?[0m [["id", 762146111], ["LIMIT", 1]]
|
288
|
+
|
289
|
+
Started GET "/users/762146111/edit" for 127.0.0.1 at 2019-10-14 07:11:42 +0000
|
290
|
+
|
291
|
+
Processing by UsersController#edit as HTML
|
292
|
+
|
293
|
+
Parameters: {"id"=>"762146111"}
|
294
|
+
|
295
|
+
Redirected to http://www.example.com/login
|
296
|
+
|
297
|
+
Filter chain halted as :logged_in_user rendered or redirected
|
298
|
+
|
299
|
+
Completed 302 Found in 0ms (ActiveRecord: 0.0ms)
|
300
|
+
|
301
|
+
Started POST "/login" for 127.0.0.1 at 2019-10-14 07:11:42 +0000
|
302
|
+
|
303
|
+
Processing by SessionsController#create as HTML
|
304
|
+
|
305
|
+
Parameters: {"session"=>{"email"=>"michael@example.com", "password"=>"[FILTERED]", "remember_me"=>"1"}}
|
306
|
+
|
307
|
+
[1m[36mUser Load (0.1ms)[0m [1m[34mSELECT "users".* FROM "users" WHERE "users"."email" = ? LIMIT ?[0m [["email", "michael@example.com"], ["LIMIT", 1]]
|
308
|
+
|
309
|
+
[1m[35m (0.1ms)[0m [1m[35mSAVEPOINT active_record_1[0m
|
310
|
+
|
311
|
+
[1m[35mSQL (0.7ms)[0m [1m[33mUPDATE "users" SET "remember_digest" = ?, "updated_at" = ? WHERE "users"."id" = ?[0m [["remember_digest", "$2a$04$juX6Kq62d8GXIB/UwY6sWuY/h8/S7PPNhuIYM7VhMyc1P/58cVrfq"], ["updated_at", "2019-10-14 07:11:42.396379"], ["id", 762146111]]
|
312
|
+
|
313
|
+
[1m[35m (0.1ms)[0m [1m[35mRELEASE SAVEPOINT active_record_1[0m
|
314
|
+
|
315
|
+
Redirected to http://www.example.com/users/762146111/edit
|
316
|
+
|
317
|
+
Completed 302 Found in 6ms (ActiveRecord: 0.9ms)
|
318
|
+
|
319
|
+
Started PATCH "/users/762146111" for 127.0.0.1 at 2019-10-14 07:11:42 +0000
|
320
|
+
|
321
|
+
Processing by UsersController#update as HTML
|
322
|
+
|
323
|
+
Parameters: {"user"=>{"name"=>"Foo Bar", "email"=>"foo@bar.com", "password"=>"[FILTERED]", "password_confirmation"=>"[FILTERED]"}, "id"=>"762146111"}
|
324
|
+
|
325
|
+
[1m[36mUser Load (0.1ms)[0m [1m[34mSELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT ?[0m [["id", 762146111], ["LIMIT", 1]]
|
326
|
+
|
327
|
+
[1m[36mUser Load (0.1ms)[0m [1m[34mSELECT "users".* FROM "users" WHERE (762146111) LIMIT ?[0m [["LIMIT", 1]]
|
328
|
+
|
329
|
+
Redirected to http://www.example.com/
|
330
|
+
|
331
|
+
Filter chain halted as :correct_user rendered or redirected
|
332
|
+
|
333
|
+
Completed 302 Found in 2ms (ActiveRecord: 0.2ms)
|
334
|
+
|
335
|
+
[1m[35m (1.1ms)[0m [1m[31mrollback transaction[0m
|
336
|
+
|
337
|
+
[1m[35m (0.0ms)[0m [1m[36mbegin transaction[0m
|
338
|
+
|
339
|
+
```
|
340
|
+
|
341
|
+
|
342
|
+
|
343
|
+
```
|
344
|
+
|
345
|
+
-------------------------------------
|
346
|
+
|
347
|
+
UsersEditTest: test_unsuccessful_edit
|
348
|
+
|
349
|
+
-------------------------------------
|
350
|
+
|
351
|
+
[1m[36mUser Load (0.1ms)[0m [1m[34mSELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT ?[0m [["id", 762146111], ["LIMIT", 1]]
|
352
|
+
|
353
|
+
Started POST "/login" for 127.0.0.1 at 2019-10-14 07:11:42 +0000
|
354
|
+
|
355
|
+
Processing by SessionsController#create as HTML
|
356
|
+
|
357
|
+
Parameters: {"session"=>{"email"=>"michael@example.com", "password"=>"[FILTERED]", "remember_me"=>"1"}}
|
358
|
+
|
359
|
+
[1m[36mUser Load (0.1ms)[0m [1m[34mSELECT "users".* FROM "users" WHERE "users"."email" = ? LIMIT ?[0m [["email", "michael@example.com"], ["LIMIT", 1]]
|
360
|
+
|
361
|
+
[1m[35m (0.1ms)[0m [1m[35mSAVEPOINT active_record_1[0m
|
362
|
+
|
363
|
+
[1m[35mSQL (0.7ms)[0m [1m[33mUPDATE "users" SET "remember_digest" = ?, "updated_at" = ? WHERE "users"."id" = ?[0m [["remember_digest", "$2a$04$r1N4U0sSl5psnpSZYHEK/Oou4UtteAodY.tYAsJGVLl07e8qaEqKa"], ["updated_at", "2019-10-14 07:11:42.420147"], ["id", 762146111]]
|
364
|
+
|
365
|
+
[1m[35m (0.1ms)[0m [1m[35mRELEASE SAVEPOINT active_record_1[0m
|
366
|
+
|
367
|
+
Redirected to http://www.example.com/users/762146111
|
368
|
+
|
369
|
+
Completed 302 Found in 8ms (ActiveRecord: 0.9ms)
|
370
|
+
|
371
|
+
Started GET "/users/762146111/edit" for 127.0.0.1 at 2019-10-14 07:11:42 +0000
|
372
|
+
|
373
|
+
Processing by UsersController#edit as HTML
|
374
|
+
|
375
|
+
Parameters: {"id"=>"762146111"}
|
376
|
+
|
377
|
+
[1m[36mUser Load (0.1ms)[0m [1m[34mSELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT ?[0m [["id", 762146111], ["LIMIT", 1]]
|
378
|
+
|
379
|
+
[1m[36mUser Load (0.9ms)[0m [1m[34mSELECT "users".* FROM "users" WHERE (762146111) LIMIT ?[0m [["LIMIT", 1]]
|
380
|
+
|
381
|
+
Redirected to http://www.example.com/
|
382
|
+
|
383
|
+
Filter chain halted as :correct_user rendered or redirected
|
384
|
+
|
385
|
+
Completed 302 Found in 3ms (ActiveRecord: 1.0ms)
|
386
|
+
|
387
|
+
[1m[35m (1.1ms)[0m [1m[31mrollback transaction[0m
|
388
|
+
|
389
|
+
[1m[35m (0.0ms)[0m [1m[36mbegin transaction[0m
|
390
|
+
|
391
|
+
```
|
280
392
|
|
281
393
|
|
282
394
|
|
1
コードの形がわかるようにインテンドも実際の形に修正して、上げ直しました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -46,15 +46,7 @@
|
|
46
46
|
|
47
47
|
### 該当のソースコード
|
48
48
|
|
49
|
-
|
50
|
-
|
51
|
-
ソースコード
|
52
|
-
|
53
|
-
```
|
49
|
+
```ここに言語を入力
|
54
|
-
|
55
|
-
**user_edit_test.rb**
|
56
|
-
|
57
|
-
|
58
50
|
|
59
51
|
require 'test_helper'
|
60
52
|
|
@@ -72,6 +64,8 @@
|
|
72
64
|
|
73
65
|
|
74
66
|
|
67
|
+
|
68
|
+
|
75
69
|
test "unsuccessful edit" do
|
76
70
|
|
77
71
|
log_in_as(@user)
|
@@ -126,13 +120,19 @@
|
|
126
120
|
|
127
121
|
assert_equal email,@user.email
|
128
122
|
|
129
|
-
end
|
123
|
+
end
|
124
|
+
|
125
|
+
|
130
126
|
|
131
127
|
end
|
132
128
|
|
133
|
-
|
129
|
+
```
|
130
|
+
|
134
|
-
|
131
|
+
```
|
132
|
+
|
135
|
-
|
133
|
+
users.yml
|
134
|
+
|
135
|
+
|
136
136
|
|
137
137
|
michael:
|
138
138
|
|
@@ -142,7 +142,13 @@
|
|
142
142
|
|
143
143
|
password_digest: <%= User.digest('password') %>
|
144
144
|
|
145
|
-
|
145
|
+
admin: true
|
146
|
+
|
147
|
+
activated: true
|
148
|
+
|
149
|
+
activated_at: <%= Time.zone.now %>
|
150
|
+
|
151
|
+
|
146
152
|
|
147
153
|
archer:
|
148
154
|
|
@@ -152,6 +158,10 @@
|
|
152
158
|
|
153
159
|
password_digest: <%= User.digest('password') %>
|
154
160
|
|
161
|
+
activated: true
|
162
|
+
|
163
|
+
activated_at: <%= Time.zone.now %>
|
164
|
+
|
155
165
|
|
156
166
|
|
157
167
|
lana:
|
@@ -162,6 +172,10 @@
|
|
162
172
|
|
163
173
|
password_digest: <%= User.digest('password') %>
|
164
174
|
|
175
|
+
activated: true
|
176
|
+
|
177
|
+
activated_at: <%= Time.zone.now %>
|
178
|
+
|
165
179
|
|
166
180
|
|
167
181
|
malory:
|
@@ -172,6 +186,10 @@
|
|
172
186
|
|
173
187
|
password_digest: <%= User.digest('password') %>
|
174
188
|
|
189
|
+
activated: true
|
190
|
+
|
191
|
+
activated_at: <%= Time.zone.now %>
|
192
|
+
|
175
193
|
|
176
194
|
|
177
195
|
<% 30.times do |n| %>
|
@@ -184,8 +202,14 @@
|
|
184
202
|
|
185
203
|
password_digest: <%= User.digest('password') %>
|
186
204
|
|
205
|
+
activated: true
|
206
|
+
|
207
|
+
activated_at: <%= Time.zone.now %>
|
208
|
+
|
187
209
|
<% end %>
|
188
210
|
|
211
|
+
```
|
212
|
+
|
189
213
|
|
190
214
|
|
191
215
|
### 試したこと
|
@@ -198,6 +222,8 @@
|
|
198
222
|
|
199
223
|
|
200
224
|
|
225
|
+
```
|
226
|
+
|
201
227
|
<% 30.times do |n| %>
|
202
228
|
|
203
229
|
user_<%= n %>:
|
@@ -210,12 +236,16 @@
|
|
210
236
|
|
211
237
|
<% end %>
|
212
238
|
|
239
|
+
```
|
240
|
+
|
213
241
|
|
214
242
|
|
215
243
|
のコードを加えると今回のエラーメッセージが表示されるようになりました。
|
216
244
|
|
217
245
|
|
218
246
|
|
247
|
+
```
|
248
|
+
|
219
249
|
lana:
|
220
250
|
|
221
251
|
name: Lana Kane
|
@@ -234,6 +264,8 @@
|
|
234
264
|
|
235
265
|
password_digest: <%= User.digest('password') %>
|
236
266
|
|
267
|
+
```
|
268
|
+
|
237
269
|
|
238
270
|
|
239
271
|
だけをmichaelとarcherの後に追加しても同様のエラーが発生致します。
|
@@ -244,6 +276,10 @@
|
|
244
276
|
|
245
277
|
|
246
278
|
|
279
|
+
以下が、log
|
280
|
+
|
281
|
+
|
282
|
+
|
247
283
|
|
248
284
|
|
249
285
|
|