songtianlun
a54ebdbf23
- Implement AccountActivationsController for activation logic - Create UserMailer for sending activation emails - Update SessionsController to handle unactivated users - Modify UsersController to restrict access to activated users - Add activation fields to User model and database migration - Create views for account activation emails - Add tests for account activation functionality
24 lines
853 B
Ruby
24 lines
853 B
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
|
|
mail = UserMailer.password_reset
|
|
assert_equal "Password reset", mail.subject
|
|
assert_equal [ "to@example.org" ], mail.to
|
|
assert_equal [ "noreply@mail.frytea.com" ], mail.from
|
|
assert_match "Hi", mail.body.encoded
|
|
end
|
|
end
|