mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-13 19:54:02 +00:00
Provide primitive test coverage of the ticket pdf
This commit is contained in:
parent
4d4ef597dc
commit
b4c7c8d5a4
3 changed files with 52 additions and 0 deletions
2
Gemfile
2
Gemfile
|
|
@ -276,6 +276,8 @@ group :test do
|
||||||
gem 'rails-controller-testing'
|
gem 'rails-controller-testing'
|
||||||
# For managing the environment
|
# For managing the environment
|
||||||
gem 'climate_control'
|
gem 'climate_control'
|
||||||
|
# For PDFs
|
||||||
|
gem 'pdf-inspector', require: "pdf/inspector"
|
||||||
end
|
end
|
||||||
|
|
||||||
group :development, :test do
|
group :development, :test do
|
||||||
|
|
|
||||||
13
Gemfile.lock
13
Gemfile.lock
|
|
@ -12,6 +12,7 @@ GEM
|
||||||
remote: https://rubygems.org/
|
remote: https://rubygems.org/
|
||||||
remote: https://rails-assets.org/
|
remote: https://rails-assets.org/
|
||||||
specs:
|
specs:
|
||||||
|
Ascii85 (1.0.3)
|
||||||
actioncable (5.0.7.1)
|
actioncable (5.0.7.1)
|
||||||
actionpack (= 5.0.7.1)
|
actionpack (= 5.0.7.1)
|
||||||
nio4r (>= 1.2, < 3.0)
|
nio4r (>= 1.2, < 3.0)
|
||||||
|
|
@ -62,6 +63,7 @@ GEM
|
||||||
activerecord (>= 3.0)
|
activerecord (>= 3.0)
|
||||||
addressable (2.5.2)
|
addressable (2.5.2)
|
||||||
public_suffix (>= 2.0.2, < 4.0)
|
public_suffix (>= 2.0.2, < 4.0)
|
||||||
|
afm (0.2.2)
|
||||||
airbrake (7.4.0)
|
airbrake (7.4.0)
|
||||||
airbrake-ruby (~> 2.12)
|
airbrake-ruby (~> 2.12)
|
||||||
airbrake-ruby (2.12.0)
|
airbrake-ruby (2.12.0)
|
||||||
|
|
@ -226,6 +228,7 @@ GEM
|
||||||
rubocop (>= 0.50.0)
|
rubocop (>= 0.50.0)
|
||||||
sysexits (~> 1.1)
|
sysexits (~> 1.1)
|
||||||
hashdiff (0.3.7)
|
hashdiff (0.3.7)
|
||||||
|
hashery (2.1.2)
|
||||||
hashie (3.5.7)
|
hashie (3.5.7)
|
||||||
html2haml (2.2.0)
|
html2haml (2.2.0)
|
||||||
erubis (~> 2.7.0)
|
erubis (~> 2.7.0)
|
||||||
|
|
@ -350,6 +353,14 @@ GEM
|
||||||
parser (2.5.3.0)
|
parser (2.5.3.0)
|
||||||
ast (~> 2.4.0)
|
ast (~> 2.4.0)
|
||||||
pdf-core (0.2.5)
|
pdf-core (0.2.5)
|
||||||
|
pdf-inspector (1.3.0)
|
||||||
|
pdf-reader (>= 1.0, < 3.0.a)
|
||||||
|
pdf-reader (2.2.0)
|
||||||
|
Ascii85 (~> 1.0.0)
|
||||||
|
afm (~> 0.2.1)
|
||||||
|
hashery (~> 2.0)
|
||||||
|
ruby-rc4
|
||||||
|
ttfunk
|
||||||
pg (1.1.3)
|
pg (1.1.3)
|
||||||
piwik_analytics (1.0.2)
|
piwik_analytics (1.0.2)
|
||||||
actionpack
|
actionpack
|
||||||
|
|
@ -497,6 +508,7 @@ GEM
|
||||||
ruby-oembed (0.12.0)
|
ruby-oembed (0.12.0)
|
||||||
ruby-openid (2.5.0)
|
ruby-openid (2.5.0)
|
||||||
ruby-progressbar (1.10.0)
|
ruby-progressbar (1.10.0)
|
||||||
|
ruby-rc4 (0.1.5)
|
||||||
ruby_dep (1.5.0)
|
ruby_dep (1.5.0)
|
||||||
ruby_parser (3.11.0)
|
ruby_parser (3.11.0)
|
||||||
sexp_processor (~> 4.9)
|
sexp_processor (~> 4.9)
|
||||||
|
|
@ -664,6 +676,7 @@ DEPENDENCIES
|
||||||
omniauth-google-oauth2
|
omniauth-google-oauth2
|
||||||
omniauth-openid
|
omniauth-openid
|
||||||
paper_trail
|
paper_trail
|
||||||
|
pdf-inspector
|
||||||
pg
|
pg
|
||||||
piwik_analytics (~> 1.0.1)
|
piwik_analytics (~> 1.0.1)
|
||||||
prawn-qrcode (~> 0.2.2.1)
|
prawn-qrcode (~> 0.2.2.1)
|
||||||
|
|
|
||||||
37
spec/pdfs/ticket_pdf_spec.rb
Normal file
37
spec/pdfs/ticket_pdf_spec.rb
Normal file
|
|
@ -0,0 +1,37 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
describe TicketPdf do
|
||||||
|
let(:registration_ticket) { create(:registration_ticket, price_cents: 0) }
|
||||||
|
let(:conference) do
|
||||||
|
create(
|
||||||
|
:conference,
|
||||||
|
title: 'ExampleCon',
|
||||||
|
tickets: [registration_ticket],
|
||||||
|
registration_period: create(:registration_period, start_date: 3.days.ago)
|
||||||
|
)
|
||||||
|
end
|
||||||
|
let(:participant) { create(:user) }
|
||||||
|
let(:ticket_purchase) do
|
||||||
|
create(
|
||||||
|
:ticket_purchase,
|
||||||
|
user: participant,
|
||||||
|
conference: conference,
|
||||||
|
ticket: registration_ticket,
|
||||||
|
quantity: 1
|
||||||
|
)
|
||||||
|
end
|
||||||
|
let(:physical_ticket) do
|
||||||
|
create(:physical_ticket, ticket_purchase: ticket_purchase)
|
||||||
|
end
|
||||||
|
let(:layout) { conference.ticket_layout.to_sym }
|
||||||
|
let(:file_name) { "ticket_for_#{conference.short_title}.pdf" }
|
||||||
|
|
||||||
|
it 'generates a PDF for a physical ticket' do
|
||||||
|
pdf = described_class.new(conference, participant, physical_ticket, layout, file_name)
|
||||||
|
page_analysis = PDF::Inspector::Page.analyze(pdf.render)
|
||||||
|
expect(page_analysis.pages.length).to eq(1)
|
||||||
|
expect(page_analysis.pages.first[:strings]).to include(conference.title)
|
||||||
|
end
|
||||||
|
end
|
||||||
Loading…
Add table
Add a link
Reference in a new issue