songtianlun
8bb7615cb1
- Change `user.send(:activate)` to `user.activate` for clarity. - Fix typo in email parameter from `emial` to `email` in password reset. - Update render calls to include status codes for better error handling. - Modify password reset email method to accept a user parameter. - Update tests to reflect changes in password reset functionality. These changes improve the clarity of the user activation process and ensure that the password reset functionality works correctly with proper error handling and user feedback.
27 lines
1.0 KiB
Ruby
27 lines
1.0 KiB
Ruby
require "test_helper"
|
|
|
|
class UserMailerTest < ActionMailer::TestCase
|
|
test "account_activation" do
|
|
user = users(:michael)
|
|
user.activation_token = User.new_token
|
|
mail = UserMailer.account_activation(user)
|
|
assert_equal "Account activation", mail.subject
|
|
assert_equal [ user.email ], mail.to
|
|
assert_equal [ "noreply@mail.frytea.com" ], mail.from
|
|
assert_match user.name, mail.body.encoded
|
|
assert_match user.activation_token, mail.body.encoded
|
|
assert_match CGI.escape(user.email), mail.body.encoded
|
|
end
|
|
|
|
test "password_reset" do
|
|
user = users(:michael)
|
|
user.reset_token = User.new_token
|
|
mail = UserMailer.password_reset(user)
|
|
assert_equal "Password reset", mail.subject
|
|
assert_equal [ user.email ], mail.to
|
|
assert_equal [ "noreply@mail.frytea.com" ], mail.from
|
|
assert_match user.reset_token, mail.body.encoded
|
|
assert_match CGI.escape(user.email), mail.body.encoded
|
|
end
|
|
end
|