sample_rails_tailwind/test/mailers/user_mailer_test.rb
songtianlun 494e12bb9e chore: update production mailer configuration
- Change default URL options to use environment variable
- Update SMTP settings to fetch credentials from environment variables
- Comment out hardcoded email sender in tests

These changes improve the flexibility of the mailer configuration by
allowing it to adapt to different environments through environment
variables. This reduces the risk of exposing sensitive information
in the codebase and makes it easier to configure for different
production setups.
2025-01-08 13:27:28 +08:00

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