forked from fixin.me/fixin.me
Test registration e-mail
This commit is contained in:
parent
4a1fe657c0
commit
2d95b11a34
@ -34,7 +34,7 @@ module FixinMe
|
|||||||
# SETUP: Below settings need to be updated on a per-installation basis.
|
# SETUP: Below settings need to be updated on a per-installation basis.
|
||||||
#
|
#
|
||||||
# URL to use in sent e-mails.
|
# URL to use in sent e-mails.
|
||||||
config.action_mailer.default_url_options = {host: 'localhost'}
|
config.action_mailer.default_url_options = {host: 'localhost', :protocol => 'https'}
|
||||||
# https://guides.rubyonrails.org/configuring.html#config-action-mailer-delivery-method
|
# https://guides.rubyonrails.org/configuring.html#config-action-mailer-delivery-method
|
||||||
config.action_mailer.delivery_method = :sendmail
|
config.action_mailer.delivery_method = :sendmail
|
||||||
|
|
||||||
|
@ -39,6 +39,7 @@ Rails.application.configure do
|
|||||||
# The :test delivery method accumulates sent emails in the
|
# The :test delivery method accumulates sent emails in the
|
||||||
# ActionMailer::Base.deliveries array.
|
# ActionMailer::Base.deliveries array.
|
||||||
config.action_mailer.delivery_method = :test
|
config.action_mailer.delivery_method = :test
|
||||||
|
config.action_mailer.default_url_options = {host: '127.0.0.1', :protocol => 'http'}
|
||||||
|
|
||||||
# Print deprecation notices to the stderr.
|
# Print deprecation notices to the stderr.
|
||||||
config.active_support.deprecation = :stderr
|
config.active_support.deprecation = :stderr
|
||||||
|
@ -28,15 +28,26 @@ class UsersTest < ApplicationSystemTestCase
|
|||||||
test "register" do
|
test "register" do
|
||||||
visit new_user_session_url
|
visit new_user_session_url
|
||||||
click_link t(:register)
|
click_link t(:register)
|
||||||
|
|
||||||
fill_in User.human_attribute_name(:email).capitalize, with: random_email
|
fill_in User.human_attribute_name(:email).capitalize, with: random_email
|
||||||
password = random_password
|
password = random_password
|
||||||
fill_in User.human_attribute_name(:password).capitalize, with: password
|
fill_in User.human_attribute_name(:password).capitalize, with: password
|
||||||
fill_in t('users.registrations.new.password_confirmation'), with: password
|
fill_in t('users.registrations.new.password_confirmation'), with: password
|
||||||
assert_difference ->{User.count}, 1 do
|
assert_difference ->{User.count}, 1 do
|
||||||
click_on t(:register)
|
assert_emails 1 do
|
||||||
|
click_on t(:register)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
assert_no_current_path new_user_registration_path
|
assert_no_current_path new_user_registration_path
|
||||||
assert_text t('devise.registrations.signed_up_but_unconfirmed')
|
assert_text t('devise.registrations.signed_up_but_unconfirmed')
|
||||||
|
|
||||||
|
with_last_email do |mail|
|
||||||
|
visit Capybara.string(mail.body.to_s).find_link("Confirm my account")[:href]
|
||||||
|
end
|
||||||
|
assert_current_path new_user_session_path
|
||||||
|
assert_text t('devise.confirmations.confirmed')
|
||||||
|
assert User.last.confirmed?
|
||||||
end
|
end
|
||||||
|
|
||||||
#test "visiting the index" do
|
#test "visiting the index" do
|
||||||
|
@ -10,6 +10,7 @@ class ActiveSupport::TestCase
|
|||||||
fixtures :all
|
fixtures :all
|
||||||
|
|
||||||
include AbstractController::Translation
|
include AbstractController::Translation
|
||||||
|
include ActionMailer::TestHelper
|
||||||
|
|
||||||
def randomize_user_password!(user)
|
def randomize_user_password!(user)
|
||||||
random_password.tap { |p| user.update!(password: p) }
|
random_password.tap { |p| user.update!(password: p) }
|
||||||
@ -22,4 +23,8 @@ class ActiveSupport::TestCase
|
|||||||
def random_email
|
def random_email
|
||||||
"%s@%s.%s" % (1..3).map { SecureRandom.alphanumeric(rand(1..20)) }
|
"%s@%s.%s" % (1..3).map { SecureRandom.alphanumeric(rand(1..20)) }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def with_last_email
|
||||||
|
yield(ActionMailer::Base.deliveries.last)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user