diff options
-rw-r--r-- | registration.rb | 4 | ||||
-rw-r--r-- | spec/registration_spec.rb | 17 |
2 files changed, 14 insertions, 7 deletions
diff --git a/registration.rb b/registration.rb index fe0ce40..2801a64 100644 --- a/registration.rb +++ b/registration.rb @@ -21,9 +21,9 @@ class RegistrationApp < Sinatra::Base if request.form_data? @band = Band.new(request['band']) if @band.valid? - pdf_file = File.join("uploads", create_pdf_file_name(@band)) + pdf_file = File.join("/uploads", create_pdf_file_name(@band)) generate_pdf_for(@band, File.join(settings.public_folder, pdf_file)) - send_registration_emails_for(@band, url_for(pdf_file)) + send_registration_emails_for(@band, url_for(pdf_file, :full)) erb :submitted else erb :index diff --git a/spec/registration_spec.rb b/spec/registration_spec.rb index 9bbf477..3111ebc 100644 --- a/spec/registration_spec.rb +++ b/spec/registration_spec.rb @@ -71,11 +71,18 @@ describe RegistrationApp do expect(@doc_spy).to have_received('render_file').with(/uploads\/[0-9]{4}-[0-9]{2}-[0-9]{2}-#{band_params['name']}-#{band_params['city']}\.pdf/) end - it 'sends an 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 #{band_params['name']} til Norsk Urskog/) + describe 'sends an email to Norsk Urskog' do + let(:message) { Mail::TestMailer.deliveries.first } + + it 'sends an email to Norsk Urskog' do + expect(Mail::TestMailer.deliveries).not_to be_empty + expect(message.to).to include('haraldei@anduin.net') + expect(message.subject).to match(/Registrering av band #{band_params['name']} til Norsk Urskog/) + end + + it 'contains the url to the pdf file' do + expect(message.body).to match(/example.org\/uploads\/[0-9]{4}-[0-9]{2}-[0-9]{2}-#{band_params['name']}-#{band_params['city']}\.pdf/) + end end end |