mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-11 23:17:48 +00:00
The way we set up email sending completely changes with Spree 2. This change encapsulates that code in a single method so that it can be changed easily and doesn't create further merge conflicts while we are still working on the master branch and the Spree upgrade.
33 lines
937 B
Ruby
33 lines
937 B
Ruby
require 'spec_helper'
|
|
|
|
describe EnterpriseMailer do
|
|
include OpenFoodNetwork::EmailHelper
|
|
|
|
let!(:enterprise) { create(:enterprise) }
|
|
let!(:user) { create(:user) }
|
|
|
|
before do
|
|
ActionMailer::Base.deliveries = []
|
|
setup_email
|
|
end
|
|
|
|
describe "#welcome" do
|
|
it "sends a welcome email when given an enterprise" do
|
|
EnterpriseMailer.welcome(enterprise).deliver
|
|
|
|
mail = ActionMailer::Base.deliveries.first
|
|
expect(mail.subject)
|
|
.to eq "#{enterprise.name} is now on #{Spree::Config[:site_name]}"
|
|
end
|
|
end
|
|
|
|
describe "#manager_invitation" do
|
|
it "should send a manager invitation email when given an enterprise and user" do
|
|
EnterpriseMailer.manager_invitation(enterprise, user).deliver
|
|
expect(ActionMailer::Base.deliveries.count).to eq 1
|
|
mail = ActionMailer::Base.deliveries.first
|
|
expect(mail.subject).to eq "#{enterprise.name} has invited you to be a manager"
|
|
end
|
|
end
|
|
end
|