From 01987cc0b88fdb0748d8d71cca4f5e40ea8a2604 Mon Sep 17 00:00:00 2001 From: Harald Eilertsen Date: Mon, 5 Oct 2015 20:13:33 +0200 Subject: Redirect back to form and display error if no songs specified. --- spec/registration_spec.rb | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'spec') diff --git a/spec/registration_spec.rb b/spec/registration_spec.rb index be4e6f7..3d7deed 100644 --- a/spec/registration_spec.rb +++ b/spec/registration_spec.rb @@ -84,5 +84,24 @@ describe RegistrationApp do expect(message.subject).to match /Registrering av band Imbalance til Norsk Urskog/ end end + + context 'with no songs' do + before :each do + @doc_spy = spy("Prawn::Document") + allow(Prawn::Document).to receive('new') { @doc_spy } + allow(@doc_spy).to receive('render_file') + + post '/submit', 'band' => create_band_params(:songs => 0) + end + + it 'should reject request and go back to the registration form' do + expect(last_response.status).to eq(302) + end + + it 'should display an error message' do + follow_redirect! + expect(last_response.body).to include "Du må ha med minst én låt" + end + end end end -- cgit v1.2.3