Skip to content

Commit

Permalink
Fix arguments to find_by_token_for (#299)
Browse files Browse the repository at this point in the history
  • Loading branch information
dwightwatson authored Feb 5, 2024
1 parent 77ff9fd commit 97789bc
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/controllers/password_resets_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def update
private

def set_user_by_token
@user = User.find_by_token_for(password_reset: params[:token])
@user = User.find_by_token_for(:password_reset, params[:token])
redirect_to new_password_reset_path, alert: t("password_resets.update.invalid_token") unless @user.present?
end

Expand Down
30 changes: 30 additions & 0 deletions test/controllers/password_resets_controller_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
require "test_helper"

class PasswordResetsControllerTest < ActionDispatch::IntegrationTest
setup do
@user = users(:bob)
end

test "new" do
get new_password_reset_path
assert_response :ok
end

test "create" do
assert_enqueued_emails 1 do
post password_reset_path, params: { email: @user.email }
assert_redirected_to root_url
end
end

test "edit" do
get edit_password_reset_path(token: @user.generate_token_for(:password_reset))
assert_response :ok
end

test "update" do
patch password_reset_path(token: @user.generate_token_for(:password_reset)),
params: { user: { password: "password", password_confirmation: "password" } }
assert_redirected_to new_session_url
end
end

0 comments on commit 97789bc

Please sign in to comment.