Files
openproject/spec/mailers/shared_examples.rb
Oliver Günther d0801dd060 Use ApplicationMailer.mail_from in more places
It is defined by SaaS to use the reply_token, which fails otherwise
2025-10-29 15:53:06 +01:00

32 lines
879 B
Ruby

# frozen_string_literal: true
RSpec.shared_examples_for "mail is sent" do
let(:letters_sent_count) { 1 }
let(:mail) { deliveries.first }
let(:html_body) { mail.body.parts.detect { |p| p.content_type.include? "text/html" }.body.encoded }
it "actually sends a mail" do
expect(deliveries.size).to eql(letters_sent_count)
end
it "is sent to the recipient" do
expect(deliveries.first.to).to include(recipient.mail)
end
it "is sent from the configured address" do
expect(deliveries.first.from).to contain_exactly(ApplicationMailer.mail_from)
end
end
RSpec.shared_examples_for "multiple mails are sent" do |set_letters_sent_count|
it_behaves_like "mail is sent" do
let(:letters_sent_count) { set_letters_sent_count }
end
end
RSpec.shared_examples_for "mail is not sent" do
it "sends no mail" do
expect(deliveries).to be_empty
end
end