Skip to content

Commit b6ede7c

Browse files
committed
Merge branch 'following-users'
2 parents a1f0045 + 3d33134 commit b6ede7c

File tree

1 file changed

+23
-23
lines changed

1 file changed

+23
-23
lines changed

test/integration/password_resets_test.rb

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@ class PasswordResets < ActionDispatch::IntegrationTest
44

55
def setup
66
ActionMailer::Base.deliveries.clear
7-
@user = users(:michael)
87
end
98
end
109

11-
class PasswordResetsTest < PasswordResets
10+
class ForgotPasswordFormTest < PasswordResets
1211

1312
test "password reset path" do
1413
get new_password_reset_path
@@ -18,81 +17,82 @@ class PasswordResetsTest < PasswordResets
1817

1918
test "reset path with invalid email" do
2019
post password_resets_path, params: { password_reset: { email: "" } }
21-
assert_not flash.empty?
2220
assert_response :unprocessable_entity
21+
assert_not flash.empty?
2322
assert_template 'password_resets/new'
2423
end
2524
end
2625

27-
class PasswordForm < PasswordResets
26+
class PasswordResetForm < PasswordResets
2827

2928
def setup
3029
super
30+
@user = users(:michael)
3131
post password_resets_path,
3232
params: { password_reset: { email: @user.email } }
33-
@actual_user = assigns(:user)
33+
@reset_user = assigns(:user)
3434
end
3535
end
3636

37-
class PasswordFormTest < PasswordForm
37+
class PasswordFormTest < PasswordResetForm
3838

3939
test "reset with valid email" do
40-
assert_not_equal @user.reset_digest, @user.reload.reset_digest
40+
assert_not_equal @user.reset_digest, @reset_user.reset_digest
4141
assert_equal 1, ActionMailer::Base.deliveries.size
4242
assert_not flash.empty?
4343
assert_redirected_to root_url
4444
end
4545

4646
test "reset with wrong email" do
47-
get edit_password_reset_path(@actual_user.reset_token, email: "")
47+
get edit_password_reset_path(@reset_user.reset_token, email: "")
4848
assert_redirected_to root_url
4949
end
5050

5151
test "reset with inactive user" do
52-
@actual_user.toggle!(:activated)
53-
get edit_password_reset_path(@actual_user.reset_token,
54-
email: @actual_user.email)
52+
@reset_user.toggle!(:activated)
53+
get edit_password_reset_path(@reset_user.reset_token,
54+
email: @reset_user.email)
5555
assert_redirected_to root_url
5656
end
5757

5858
test "reset with right email but wrong token" do
59-
get edit_password_reset_path('wrong token', email: @actual_user.email)
59+
get edit_password_reset_path('wrong token', email: @reset_user.email)
6060
assert_redirected_to root_url
6161
end
6262

6363
test "reset with right email and right token" do
64-
get edit_password_reset_path(@actual_user.reset_token,
65-
email: @actual_user.email)
64+
get edit_password_reset_path(@reset_user.reset_token,
65+
email: @reset_user.email)
6666
assert_template 'password_resets/edit'
67-
assert_select "input[name=email][type=hidden][value=?]", @actual_user.email
67+
assert_select "input[name=email][type=hidden][value=?]", @reset_user.email
6868
end
6969
end
7070

71-
class PasswordUpdateTest < PasswordForm
71+
class PasswordUpdateTest < PasswordResetForm
7272

7373
test "update with invalid password and confirmation" do
74-
patch password_reset_path(@actual_user.reset_token),
75-
params: { email: @actual_user.email,
74+
patch password_reset_path(@reset_user.reset_token),
75+
params: { email: @reset_user.email,
7676
user: { password: "foobaz",
7777
password_confirmation: "barquux" } }
7878
assert_select 'div#error_explanation'
7979
end
8080

8181
test "update with empty password" do
82-
patch password_reset_path(@actual_user.reset_token),
83-
params: { email: @actual_user.email,
82+
patch password_reset_path(@reset_user.reset_token),
83+
params: { email: @reset_user.email,
8484
user: { password: "",
8585
password_confirmation: "" } }
8686
assert_select 'div#error_explanation'
8787
end
8888

8989
test "update with valid password and confirmation" do
90-
patch password_reset_path(@actual_user.reset_token),
91-
params: { email: @actual_user.email,
90+
patch password_reset_path(@reset_user.reset_token),
91+
params: { email: @reset_user.email,
9292
user: { password: "foobaz",
9393
password_confirmation: "foobaz" } }
9494
assert is_logged_in?
9595
assert_not flash.empty?
96-
assert_redirected_to @actual_user
96+
assert_redirected_to @reset_user
9797
end
9898
end

0 commit comments

Comments
 (0)