* Fix typo * Add SMTP configs to Settings::General * Expand Settings's show page * Expand Settings::General's constants * Move smtp_enabled? logic to ApplicationMailer * Apply suggestions from code review Co-authored-by: Ridhwana <Ridhwana.Khan16@gmail.com> * Add missing descriptions and placeholders * Remove production guard clause * Change delivery_method to a callback * Create Settings::SMTP * Run migration * Move constants * Remove SMTP from Settings::General * Create SMTPSettingsController * Add back guard clause * Change which perform_deliveries configuration to use from * Update config/environments/production.rb * Rename migration to singular * Run migration again * Fix name * Alphabetize and add validation for authentication * Move settings and enabled? logic to Settings::SMTP * Change after_action to before_action * Fix broken spec * Fix broken spec * Create SMTP specs * Provide default for port * Create spec for ApplicationMailer * Fix broken spec * Move smtp_enabled? * Search and replace Co-authored-by: Ridhwana <Ridhwana.Khan16@gmail.com>
27 lines
1,001 B
Ruby
27 lines
1,001 B
Ruby
require "rails_helper"
|
|
|
|
RSpec.describe ApplicationMailer, type: :mailer do
|
|
let(:user) { create(:user) }
|
|
let(:email) { VerificationMailer.with(user_id: user.id).account_ownership_verification_email }
|
|
|
|
describe "#set_perform_deliveries" do
|
|
it "changes perform_deliveries from true to false if smtp is not enabled" do
|
|
expect { email.deliver_now }.to change(described_class, :perform_deliveries).from(true).to(false)
|
|
end
|
|
|
|
it "changes perform_deliveries from false to true if smtp is enabled" do
|
|
described_class.perform_deliveries = false
|
|
allow(ForemInstance).to receive(:smtp_enabled?).and_return(true)
|
|
|
|
expect { email.deliver_now }.to change(described_class, :perform_deliveries).from(false).to(true)
|
|
end
|
|
end
|
|
|
|
describe "#set_delivery_options" do
|
|
it "evoked Settings::SMTP.settings during callback" do
|
|
allow(Settings::SMTP).to receive(:settings)
|
|
email.deliver_now
|
|
expect(Settings::SMTP).to have_received(:settings)
|
|
end
|
|
end
|
|
end
|