-
-
Notifications
You must be signed in to change notification settings - Fork 503
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Resolves #4818 Fix print feature for product drive with no participant #4831
base: main
Are you sure you want to change the base?
Changes from 3 commits
0551b16
2895c03
4b1f019
0257ea9
572f94b
a159eca
dd98442
0023558
e3b10d0
8f63509
eef0854
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,17 @@ | |
create(:donation, organization: organization, donation_site: donation_site, source: Donation::SOURCES[:donation_site], | ||
comment: "A donation comment") | ||
end | ||
let(:product_drive) { create(:product_drive, name: "Second Best Product Drive") } | ||
let(:product_drive_participant) { | ||
create(:product_drive_participant, business_name: "A Good Place to Collect Diapers", email: "[email protected]") | ||
} | ||
let(:product_drive_donation) do | ||
create(:donation, organization: organization, product_drive: product_drive, source: Donation::SOURCES[:product_drive], | ||
product_drive_participant: product_drive_participant, comment: "A product drive donation") | ||
end | ||
let(:product_drive_donation_without_participant) do | ||
create(:donation, organization: organization, product_drive: product_drive, source: Donation::SOURCES[:product_drive], comment: "A product drive donation without participant") | ||
end | ||
let(:item1) { FactoryBot.create(:item, name: "Item 1", package_size: 50, value_in_cents: 100) } | ||
let(:item2) { FactoryBot.create(:item, name: "Item 2", value_in_cents: 200) } | ||
let(:item3) { FactoryBot.create(:item, name: "Item 3", value_in_cents: 300) } | ||
|
@@ -65,4 +76,21 @@ | |
expect(pdf_test.page(1).text).to include("Total Items Received") | ||
end | ||
end | ||
|
||
context "product drive donation" do | ||
it "renders correctly" do | ||
pdf = described_class.new(organization, product_drive_donation) | ||
pdf_test = PDF::Reader.new(StringIO.new(pdf.compute_and_render)) | ||
expect(pdf_test.page(1).text).to include(product_drive_donation.product_drive_participant.business_name) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I much prefer explicit checks - since you've given the participant a specific business name, you should be checking against that string rather than going back to the model you created. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
expect(pdf_test.page(1).text).to include(product_drive_donation.product_drive_participant.email) | ||
expect(pdf_test.page(1).text).to include(product_drive_donation.comment) | ||
end | ||
|
||
it "renders correctly without a product drive participant" do | ||
pdf = described_class.new(organization, product_drive_donation_without_participant) | ||
pdf_test = PDF::Reader.new(StringIO.new(pdf.compute_and_render)) | ||
expect(pdf_test.page(1).text).to include(product_drive_donation_without_participant.product_drive.name) | ||
expect(pdf_test.page(1).text).to include(product_drive_donation_without_participant.comment) | ||
end | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you are missing this requirement in your fix:
If you just call
name
on the product drive, that prefix "Product Drive" will be missing.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated! Added label for product drive
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added Product Drive Label.pdf