From 1f63803e7bdac1abe4219e98a1a7bd84529ec144 Mon Sep 17 00:00:00 2001 From: Harald Eilertsen Date: Sat, 3 Oct 2015 18:46:37 +0200 Subject: Send email to Norsk Urskog when a band is registered. --- spec/registration_spec.rb | 13 +++++++++++++ spec/spec_helper.rb | 5 +++++ 2 files changed, 18 insertions(+) (limited to 'spec') diff --git a/spec/registration_spec.rb b/spec/registration_spec.rb index 5f398c0..ed95fae 100644 --- a/spec/registration_spec.rb +++ b/spec/registration_spec.rb @@ -28,6 +28,12 @@ describe RegistrationApp do end describe 'POST submit' do + include Mail::Matchers + + before :each do + Mail::TestMailer.deliveries.clear + end + context 'with a valid registration' do before :each do params = { @@ -99,6 +105,13 @@ describe RegistrationApp do expect(last_response).to match /Låtskrivere: Harald Eilertsen, Thormod Steinert/ expect(last_response).to match /Merknad: Rævrukkje rum kjurr!/ end + + it 'sends and email to Norsk Urskog' do + message = Mail::TestMailer.deliveries.first + expect(Mail::TestMailer.deliveries).not_to be_empty + expect(message.to).to include('haraldei@anduin.net') + expect(message.subject).to match /Registrering av band Imbalance til Norsk Urskog/ + end end end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index c7171e6..7947e06 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,3 +1,8 @@ require_relative '../registration' require 'rspec' require 'rack/test' +require 'mail' + +Mail.defaults do + delivery_method :test # in practice you'd do this in spec_helper.rb +end -- cgit v1.2.3