1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-07-24 15:49:39 +02:00

Test environment stability improvements (#703)

* Add climate_control gem and test helper

* Replace ENV mods in upgrades test

* Replace ENV mods in registrations test

* Remove ENV references in hostings controller

* Update ENV refs in mailer test

* ActiveStorage cleanup

* Consolidate queue config so appropriate adapter runs in test environment

* Make test environment more explicit

* Centralize self hosting config

* Remove flaky system test
This commit is contained in:
Zach Gollwitzer 2024-05-02 13:18:18 -04:00 committed by GitHub
parent 98df7ccb11
commit 5dfbba403a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 137 additions and 137 deletions

View file

@ -10,33 +10,31 @@ class ApplicationMailerTest < ActionMailer::TestCase
end
test "should use self host settings when self host enabled" do
ENV["SELF_HOSTING_ENABLED"] = "true"
with_self_hosting do
smtp_host = "smtp.example.com"
smtp_port = 466
smtp_username = "user@example.com"
smtp_password = "password"
email_sender = "notification@example.com"
smtp_host = "smtp.example.com"
smtp_port = 466
smtp_username = "user@example.com"
smtp_password = "password"
email_sender = "notification@example.com"
smtp_settings_from_settings = { address: smtp_host,
port: smtp_port,
user_name: smtp_username,
password: smtp_password }
smtp_settings_from_settings = { address: smtp_host,
port: smtp_port,
user_name: smtp_username,
password: smtp_password }
Setting.stubs(:smtp_host).returns(smtp_host)
Setting.stubs(:smtp_port).returns(smtp_port)
Setting.stubs(:smtp_username).returns(smtp_username)
Setting.stubs(:smtp_password).returns(smtp_password)
Setting.stubs(:email_sender).returns(email_sender)
Setting.stubs(:smtp_host).returns(smtp_host)
Setting.stubs(:smtp_port).returns(smtp_port)
Setting.stubs(:smtp_username).returns(smtp_username)
Setting.stubs(:smtp_password).returns(smtp_password)
Setting.stubs(:email_sender).returns(email_sender)
TestMailer.test_email.deliver_now
assert_emails 1
assert_equal smtp_settings_from_settings, ActionMailer::Base.deliveries.first.delivery_method.settings.slice(:address, :port, :user_name, :password)
TestMailer.test_email.deliver_now
assert_emails 1
assert_equal smtp_settings_from_settings, ActionMailer::Base.deliveries.first.delivery_method.settings.slice(:address, :port, :user_name, :password)
end
end
test "should use regular env settings when self host disabled" do
ENV["SELF_HOSTING_ENABLED"] = "false"
TestMailer.test_email.deliver_now
assert_emails 1