|
5 | 5 | create(:donation, organization: organization, donation_site: donation_site, source: Donation::SOURCES[:donation_site], |
6 | 6 | comment: "A donation comment") |
7 | 7 | end |
| 8 | + let(:product_drive) { create(:product_drive, name: "Second Best Product Drive") } |
| 9 | + let(:product_drive_participant) { |
| 10 | + create(:product_drive_participant, business_name: "A Good Place to Collect Diapers", address: "1500 Remount Road, Front Royal, VA 22630", email: "[email protected]") |
| 11 | + } |
| 12 | + let(:product_drive_donation) do |
| 13 | + create(:donation, organization: organization, product_drive: product_drive, source: Donation::SOURCES[:product_drive], |
| 14 | + product_drive_participant: product_drive_participant, comment: "A product drive donation") |
| 15 | + end |
| 16 | + let(:product_drive_donation_without_participant) do |
| 17 | + create(:donation, organization: organization, product_drive: product_drive, source: Donation::SOURCES[:product_drive], comment: "A product drive donation without participant") |
| 18 | + end |
8 | 19 | let(:item1) { FactoryBot.create(:item, name: "Item 1", package_size: 50, value_in_cents: 100) } |
9 | 20 | let(:item2) { FactoryBot.create(:item, name: "Item 2", value_in_cents: 200) } |
10 | 21 | let(:item3) { FactoryBot.create(:item, name: "Item 3", value_in_cents: 300) } |
|
65 | 76 | expect(pdf_test.page(1).text).to include("Total Items Received") |
66 | 77 | end |
67 | 78 | end |
| 79 | + |
| 80 | + context "product drive donation" do |
| 81 | + it "renders correctly" do |
| 82 | + pdf = described_class.new(organization, product_drive_donation) |
| 83 | + pdf_test = PDF::Reader.new(StringIO.new(pdf.compute_and_render)) |
| 84 | + expect(pdf_test.page(1).text).to include("A Good Place to Collect Diapers") |
| 85 | + expect(pdf_test.page(1).text).to include("[email protected]") |
| 86 | + expect(pdf_test.page(1).text).to include("1500 Remount Road, Front Royal, VA 22630") |
| 87 | + expect(pdf_test.page(1).text).to include("A product drive donation") |
| 88 | + end |
| 89 | + |
| 90 | + it "renders correctly without a product drive participant" do |
| 91 | + pdf = described_class.new(organization, product_drive_donation_without_participant) |
| 92 | + pdf_test = PDF::Reader.new(StringIO.new(pdf.compute_and_render)) |
| 93 | + expect(pdf_test.page(1).text).to include("Product Drive -- Second Best Product Drive") |
| 94 | + expect(pdf_test.page(1).text).to include("A product drive donation") |
| 95 | + end |
| 96 | + end |
68 | 97 | end |
0 commit comments