diff options
author | Harald Eilertsen <haraldei@anduin.net> | 2015-11-21 17:44:31 +0100 |
---|---|---|
committer | Harald Eilertsen <haraldei@anduin.net> | 2015-11-21 17:53:53 +0100 |
commit | f37dedaca58ec0a3673ed7f10bf8f5072455680b (patch) | |
tree | 90234af0938773288584f8b3218135f49496520b /spec | |
parent | 732a5b9c15c4b8e96d7cd3d5fb0e8d6463dc8928 (diff) | |
download | norsk-urskog-registrations-f37dedaca58ec0a3673ed7f10bf8f5072455680b.tar.gz norsk-urskog-registrations-f37dedaca58ec0a3673ed7f10bf8f5072455680b.tar.bz2 norsk-urskog-registrations-f37dedaca58ec0a3673ed7f10bf8f5072455680b.zip |
revert back to form if email delivery fails.
Diffstat (limited to 'spec')
-rw-r--r-- | spec/email_spec.rb | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/spec/email_spec.rb b/spec/email_spec.rb new file mode 100644 index 0000000..5c4d310 --- /dev/null +++ b/spec/email_spec.rb @@ -0,0 +1,30 @@ +require 'spec_helper' +require 'net/smtp' + +RSpec.describe "sending email" do + include Rack::Test::Methods + + def app + RegistrationApp + end + + context "with delivery error" do + let(:band_params) { create_band_params } + + before :each do + @mail_spy = spy("Mail") + allow(Mail).to receive('new') { @mail_spy } + allow(@mail_spy).to receive(:deliver!).and_raise(Net::SMTPFatalError.new("Some error message")) + + post '/submit', 'band' => band_params + end + + it "goes back to the registration form" do + expect(last_response.body).to match(/form id="registration-form"/) + end + + it "shows what went wrong" do + expect(last_response.body).to match(/Some error message/) + end + end +end |