diff options
author | Harald Eilertsen <haraldei@anduin.net> | 2015-10-04 12:42:56 +0200 |
---|---|---|
committer | Harald Eilertsen <haraldei@anduin.net> | 2015-10-04 12:59:11 +0200 |
commit | 448380ae81e3dfe182b9092880d4a314b39d034a (patch) | |
tree | ee5f34a250f2710d7decb732de8e832f69259146 | |
parent | 1f63803e7bdac1abe4219e98a1a7bd84529ec144 (diff) | |
download | norsk-urskog-registrations-448380ae81e3dfe182b9092880d4a314b39d034a.tar.gz norsk-urskog-registrations-448380ae81e3dfe182b9092880d4a314b39d034a.tar.bz2 norsk-urskog-registrations-448380ae81e3dfe182b9092880d4a314b39d034a.zip |
Add dummy method to generate PDF from registration data.
-rw-r--r-- | Gemfile | 1 | ||||
-rw-r--r-- | Gemfile.lock | 6 | ||||
-rw-r--r-- | lib/registration.rb | 5 | ||||
-rw-r--r-- | registration.rb | 1 | ||||
-rw-r--r-- | spec/registration_spec.rb | 12 |
5 files changed, 24 insertions, 1 deletions
@@ -2,6 +2,7 @@ source "https://rubygems.org" gem "sinatra" gem "mail" +gem "prawn" group :development, :test do gem 'byebug' diff --git a/Gemfile.lock b/Gemfile.lock index 4a18b9f..a057e87 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -6,6 +6,10 @@ GEM mail (2.6.3) mime-types (>= 1.16, < 3) mime-types (2.6.2) + pdf-core (0.6.0) + prawn (2.0.2) + pdf-core (~> 0.6.0) + ttfunk (~> 1.4.0) rack (1.6.4) rack-protection (1.5.3) rack @@ -29,6 +33,7 @@ GEM rack-protection (~> 1.4) tilt (>= 1.3, < 3) tilt (2.0.1) + ttfunk (1.4.0) PLATFORMS ruby @@ -36,6 +41,7 @@ PLATFORMS DEPENDENCIES byebug mail + prawn rack-test rspec sinatra diff --git a/lib/registration.rb b/lib/registration.rb index 5a31ca0..51c7663 100644 --- a/lib/registration.rb +++ b/lib/registration.rb @@ -11,3 +11,8 @@ def send_registration_emails_for(band) mail.deliver! end + +def generate_pdf_for(band) + Prawn::Document.generate("#{band.name}.pdf") do + end +end diff --git a/registration.rb b/registration.rb index f599bfd..e5be8f0 100644 --- a/registration.rb +++ b/registration.rb @@ -11,6 +11,7 @@ class RegistrationApp < Sinatra::Base if request.form_data? #p request['band'] @band = Band.new(request['band']) + generate_pdf_for @band send_registration_emails_for @band erb :submitted end diff --git a/spec/registration_spec.rb b/spec/registration_spec.rb index ed95fae..c8858cc 100644 --- a/spec/registration_spec.rb +++ b/spec/registration_spec.rb @@ -1,3 +1,5 @@ +require "prawn" + describe RegistrationApp do include Rack::Test::Methods @@ -76,6 +78,10 @@ describe RegistrationApp do } } } + + class_spy("Prawn::Document") + allow(Prawn::Document).to receive('generate') + post '/submit', 'band' => params end @@ -106,7 +112,11 @@ describe RegistrationApp do expect(last_response).to match /Merknad: Rævrukkje rum kjurr!/ end - it 'sends and email to Norsk Urskog' do + it "generates a PDF file" do + expect(Prawn::Document).to have_received('generate').with("Imbalance.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') |