mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-07-19 05:09:38 +02:00
Allow a self-hosted user to configure their SMTP settings directly from within the UI (#682)
* Add setting fields to model * Allow to configure SMTP settings * Normalize locales * Cleanup locales * Remove 'coming soon' * fix test * Reset credentials * Reset development config * Check smtp spelling * Use post instead of get method * TLS ENV variable is more descriptive * Rework application mailer * Follow rails convention for mailer action params * Reset schema.rb to main * Test WIP * Add test for controller and mailer * Move tests from controller to model * Custom error message if settings are not all present * Comment smtp config in development env * Add default tls enabled value * Rubocop * Fix controller test * Reset credentials * Normalize locales * Test * fix test * Fix application mailer test that fails randomly * Error flash message instead of notice * Rework application mailer tests
This commit is contained in:
parent
f0480e7ab7
commit
6fdb8e8d69
15 changed files with 200 additions and 15 deletions
|
@ -44,4 +44,38 @@ class Settings::HostingsControllerTest < ActionDispatch::IntegrationTest
|
|||
assert_equal "release", Setting.upgrades_target
|
||||
assert_equal NEW_RENDER_DEPLOY_HOOK, Setting.render_deploy_hook
|
||||
end
|
||||
|
||||
test " #send_test_email if smtp settings are populated try to send an email and redirect with notice" do
|
||||
Setting.stubs(:smtp_settings_populated?).returns(true)
|
||||
|
||||
test_email_mock = mock
|
||||
test_email_mock.expects(:deliver_now)
|
||||
|
||||
mailer_mock = mock
|
||||
mailer_mock.expects(:test_email).returns(test_email_mock)
|
||||
|
||||
NotificationMailer.expects(:with).with(user: users(:family_admin)).returns(mailer_mock)
|
||||
|
||||
post send_test_email_settings_hosting_path
|
||||
assert_response :found
|
||||
assert controller.flash[:notice].present?
|
||||
end
|
||||
|
||||
test "#send_test_email with one blank smtp setting" do
|
||||
Setting.stubs(:smtp_settings_populated?).returns(false)
|
||||
NotificationMailer.expects(:with).never
|
||||
|
||||
post send_test_email_settings_hosting_path
|
||||
assert_response :unprocessable_entity
|
||||
assert controller.flash[:error].present?
|
||||
end
|
||||
|
||||
test "#send_test_email when sending the email raise an error" do
|
||||
Setting.stubs(:smtp_settings_populated?).returns(true)
|
||||
NotificationMailer.stubs(:with).raises(StandardError)
|
||||
|
||||
post send_test_email_settings_hosting_path
|
||||
assert_response :unprocessable_entity
|
||||
assert controller.flash[:error].present?
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue