From 26a8cddd1494969a784c88c93908267132361bf7 Mon Sep 17 00:00:00 2001 From: Devin Howard Date: Thu, 13 Oct 2016 15:39:13 +0800 Subject: [PATCH] mailer spec --- config/environments/test.rb | 1 + spec/mailers/map_mailer_spec.rb | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 spec/mailers/map_mailer_spec.rb diff --git a/config/environments/test.rb b/config/environments/test.rb index 5f0b1ee2..d85899fd 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -30,6 +30,7 @@ Metamaps::Application.configure do # The :test delivery method accumulates sent emails in the # ActionMailer::Base.deliveries array. config.action_mailer.delivery_method = :test + config.action_mailer.default_url_options = { host: 'localhost:3000' } # Print deprecation notices to the stderr config.active_support.deprecation = :stderr diff --git a/spec/mailers/map_mailer_spec.rb b/spec/mailers/map_mailer_spec.rb new file mode 100644 index 00000000..d4da119e --- /dev/null +++ b/spec/mailers/map_mailer_spec.rb @@ -0,0 +1,17 @@ +require 'rails_helper' + +RSpec.describe MapMailer, type: :mailer do + let(:map) { create(:map) } + let(:inviter) { create(:user) } + let(:invitee) { create(:user) } + describe 'invite_to_edit_email' do + let(:mail) { described_class.invite_to_edit_email(map, inviter, invitee) } + + it { expect(mail.from).to eq ['team@metamaps.cc'] } + it { expect(mail.to).to eq [invitee.email] } + it { expect(mail.subject).to match map.name } + it { expect(mail.body.encoded).to match inviter.name } + it { expect(mail.body.encoded).to match map.name } + it { expect(mail.body.encoded).to match map_url(map) } + end +end