docbrown/spec/mailers/digest_mailer_spec.rb
Mac Siri 842e6880b8
Routine rubocop fix on /spec (#19217)
* Softrun rubocop

* Hardrun rubocop (-A)

* Change a rubocop rule

* Add missing cops

* Undo & redo rubocop -A
2023-03-21 09:55:26 -04:00

25 lines
918 B
Ruby

require "rails_helper"
RSpec.describe DigestMailer do
let(:user) { create(:user) }
let(:article) { build_stubbed(:article) }
let(:from_email_address) { "custom_noreply@forem.com" }
describe "#digest_email" do
before do
allow(article).to receive(:title).and_return("test title")
allow(Settings::SMTP).to receive(:provided_minimum_settings?).and_return(true)
allow(Settings::SMTP).to receive(:from_email_address).and_return(from_email_address)
end
it "works correctly", :aggregate_failures do
email = described_class.with(user: user, articles: [article]).digest_email
expect(email.subject).not_to be_nil
expect(email.to).to eq([user.email])
expect(email.from).to eq([from_email_address])
expected_from = "#{Settings::Community.community_name} Digest <#{from_email_address}>"
expect(email["from"].value).to eq(expected_from)
end
end
end