blob: 00d73a58ba69a9c04922c388c1cafaa71d4a18cc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
require "rails_helper"
RSpec.describe CalendarMailer, type: :mailer do
shared_examples 'notify all user' do |type|
let!(:user) { create(:user) }
let(:calendar) { create(:calendar, shared: true) }
let(:email) { CalendarMailer.send(type, calendar.id, user.id) }
it 'should deliver email to user' do
expect(email).to deliver_to user.email
end
it 'should have correct from' do
expect(email.from).to eq(['stif-boiv@af83.com'])
end
it 'should have subject' do
expect(email).to have_subject I18n.t("mailers.calendar_mailer.#{type}.subject")
end
it 'should have correct body' do
key = I18n.t("mailers.calendar_mailer.#{type}.body", cal_name: calendar.name, cal_index_url: workgroup_calendars_url(calendar.workgroup))
expect(email).to have_body_text /#{key}/
end
end
describe 'updated' do
it_behaves_like 'notify all user', 'updated'
end
describe 'created' do
it_behaves_like 'notify all user', 'created'
end
end
|