質問編集履歴

2

文章の書き直し

2021/04/30 12:11

投稿

hazuma
hazuma

スコア20

test CHANGED
File without changes
test CHANGED
@@ -1,221 +1 @@
1
- Ruby on railsの参考書で学習をしています。
2
-
3
- パスワードリセットの実装をし、その後ローカルでテストをした際にエラーが出て詰まっております。
4
-
5
-
6
-
7
- 流れとしてはパスワードリセット申請画面(new.html.erb)からユーザーのメールアドレスを送るとlocalhost:3000/letter_openerにリセット申請のメールが送られてきてリンクを踏むとパスワードリセット(edit.html.erb)画面に行くといった感じです。
8
-
9
-
10
-
11
- リセットなどは問題なくできました。
12
-
13
- # エラー文
14
-
15
- ```
16
-
17
- 1) パスワードリセット パスワードが変更できる
18
-
19
- Failure/Error: fill_in 'メールアドレス', with: user.email
20
-
21
-
22
-
23
- Capybara::ElementNotFound:
24
-
25
- Unable to find field "メールアドレス" that is not disabled
26
-
27
-
28
-
29
- [Screenshot]: tmp/screenshots/failures_r_spec_example_groups_nested_6_パスワードが変更できる_708.png
30
-
31
-
32
-
33
-
34
-
35
- # ./spec/system/password_reset/password_resets_spec.rb:8:in `block (2 levels) in <main>'
36
-
37
- ```
38
-
39
- #該当しそうなコード
40
-
41
- edit.html.erb
42
-
43
- ```
44
-
45
- <%= content_for(:title, 'パスワードリセット') %>
46
-
47
- <div class="container">
48
-
49
- <div class="row">
50
-
51
- <div class=" col-md-10 offset-md-1 col-lg-8 offset-lg-2">
52
-
53
- <h1><%='パスワードリセット'%></h1>
54
-
55
- <%= form_with model: @user, url: password_reset_path(@token), local: true do |f| %>
56
-
57
- <% render 'shared/error_messages', object:f .object %>
58
-
59
- <div class="form-group">
60
-
61
- <p><%=f.label :email%></p>
62
-
63
- <%=@user.email %>
64
-
65
- </div>
66
-
67
- <div class = 'form-group'>
68
-
69
- <%= f.label :password %>
70
-
71
- <%= f.password_field :password, class: 'form-control' %>
72
-
73
- </div>
74
-
75
- <div class = 'form-group'>
76
-
77
- <%= f.label :password_confirmation %>
1
+ klsふぁんklfdskfkjだhファかdbfhkじゃdhフィdfジャhjkfでゃsふぁ
78
-
79
- <%= f.password_field :password_confirmation, class: 'form-control' %>
80
-
81
- </div>
82
-
83
- <%= f.submit '更新', class: 'btn btn-primary' %>
84
-
85
- <% end %>
86
-
87
- </div>
88
-
89
- </div>
90
-
91
- </div>
92
-
93
-
94
-
95
- ```
96
-
97
- new.html.erb
98
-
99
- ```
100
-
101
- <%= content_for(:title, 'ユーザー登録') %>
102
-
103
- <div class="container">
104
-
105
- <div class="row">
106
-
107
- <div class="col-md-10 offset-md-1 col-lg-8 offset-lg-2">
108
-
109
- <h1><%= t '.title' %></h1>
110
-
111
- <%= form_with model: @user, local: true do |f| %>
112
-
113
- <%= render 'shared/error_messages', object: f.object %>
114
-
115
- <div class="form-group">
116
-
117
- <%= f.label :last_name, User.human_attribute_name(:last_name) %>
118
-
119
- <%= f.text_field :last_name, class: 'form-control' %>
120
-
121
- </div>
122
-
123
- <div class="form-group">
124
-
125
- <%= f.label :first_name, User.human_attribute_name(:first_name) %>
126
-
127
- <%= f.text_field :first_name, class: 'form-control' %>
128
-
129
- </div>
130
-
131
- <div class="form-group">
132
-
133
- <%= f.label :email, User.human_attribute_name(:email) %>
134
-
135
- <%= f.email_field :email, class: 'form-control' %>
136
-
137
- </div>
138
-
139
- <div class="form-group">
140
-
141
- <%= f.label :password, User.human_attribute_name(:password) %>
142
-
143
- <%= f.password_field :password, class: 'form-control' %>
144
-
145
- </div>
146
-
147
- <div class="form-group">
148
-
149
- <%= f.label :password_confirmation, User.human_attribute_name(:password_confirmation) %>
150
-
151
- <%= f.password_field :password_confirmation, class: 'form-control' %>
152
-
153
- </div>
154
-
155
- <%= f.submit (t 'defaults.register'), class: 'btn btn-primary' %>
156
-
157
- <% end %>
158
-
159
- <div class='text-center'>
160
-
161
- <%= link_to (t '.to_login'), login_path %>
162
-
163
- </div>
164
-
165
- </div>
166
-
167
- </div>
168
-
169
- </div>
170
-
171
- ```
172
-
173
- password_resets_spec.rb
174
-
175
- ```
176
-
177
- require 'rails_helper'
178
-
179
-
180
-
181
- RSpec.describe 'パスワードリセット', type: :system do
182
-
183
- let(:user) { create(:user) }
184
-
185
-
186
-
187
- it 'パスワードが変更できる' do
188
-
189
- visit new_password_reset_path
190
-
191
- fill_in 'メールアドレス', with: user.email
192
-
193
- click_button '送信'
194
-
195
- expect(page).to have_content('パスワードリセット手順を送信しました'), 'フラッシュメッセージ「パスワードリセット手順を送信しました」が表示されていません'
196
-
197
- visit edit_password_reset_path(user.reload.reset_password_token)
198
-
199
- fill_in 'パスワード', with: '123456789'
200
-
201
- fill_in 'パスワード確認', with: '123456789'
202
-
203
- click_button '更新する'
204
-
205
- expect(current_path).to eq(login_path), 'パスワードリセット後にログイン画面に遷移していません'
206
-
207
- expect(page).to have_content('パスワードを変更しました'), 'フラッシュメッセージ「パスワードを変更しました」が表示されていません'
208
-
209
- end
210
-
211
- end
212
-
213
- ```
214
-
215
- # 実装画面
216
-
217
- [new.hmtl.erb](https://i.gyazo.com/13345b148d8a094877efd655553041e1.png)
218
-
219
- [edit.html.erb](https://i.gyazo.com/0e1dfc7c850af413724e3b92c4abc16d.png)
220
-
221
- [edit.html.erb検証ツール](https://i.gyazo.com/5b19a30fde662c64aadcf6267444f049.png)

1

文章の書き直し

2021/04/30 12:11

投稿

hazuma
hazuma

スコア20

test CHANGED
File without changes
test CHANGED
@@ -218,4 +218,4 @@
218
218
 
219
219
  [edit.html.erb](https://i.gyazo.com/0e1dfc7c850af413724e3b92c4abc16d.png)
220
220
 
221
- [検証ツール](https://i.gyazo.com/5b19a30fde662c64aadcf6267444f049.png)
221
+ [edit.html.erb検証ツール](https://i.gyazo.com/5b19a30fde662c64aadcf6267444f049.png)