diff options
| author | Xinhui | 2017-07-07 12:23:12 +0200 |
|---|---|---|
| committer | Xinhui | 2017-07-07 12:43:24 +0200 |
| commit | 72c90c1b3da9b09319a435bd549ba3b5070df31a (patch) | |
| tree | 8fc64e34a34c535439abfe04437e5510a3cd8336 /spec/mailers/calendar_mailer_spec.rb | |
| parent | 8d8c76aca3ab4a4cda2de7d9d2d80dc98949ed0e (diff) | |
| download | chouette-core-72c90c1b3da9b09319a435bd549ba3b5070df31a.tar.bz2 | |
Add CalendarMailer
Diffstat (limited to 'spec/mailers/calendar_mailer_spec.rb')
| -rw-r--r-- | spec/mailers/calendar_mailer_spec.rb | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/spec/mailers/calendar_mailer_spec.rb b/spec/mailers/calendar_mailer_spec.rb new file mode 100644 index 000000000..75241b063 --- /dev/null +++ b/spec/mailers/calendar_mailer_spec.rb @@ -0,0 +1,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) } + + 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") + 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 |
