-
-
Notifications
You must be signed in to change notification settings - Fork 503
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FIX replace with space if partner primary contact name/email/phone is…
… blank * Add rspec * Other comparison pdfs change because previously blank phone # skipped line, now blank phone # adds a blank line * Move instance_method call inside function
- Loading branch information
Showing
8 changed files
with
27 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
module PDFComparisonTestFactory | ||
StorageCreation = Data.define(:organization, :storage_location, :items) | ||
FilePaths = Data.define(:expected_pickup_file_path, :expected_same_address_file_path, :expected_different_address_file_path, :expected_incomplete_address_file_path) | ||
FilePaths = Data.define(:expected_pickup_file_path, :expected_same_address_file_path, :expected_different_address_file_path, :expected_incomplete_address_file_path, :expected_no_contact_file_path) | ||
|
||
def create_organization_storage_items | ||
org = Organization.create!( | ||
|
@@ -39,17 +39,18 @@ def get_file_paths | |
expected_same_address_file_path = Rails.root.join("spec", "fixtures", "files", "distribution_same_address.pdf") | ||
expected_different_address_file_path = Rails.root.join("spec", "fixtures", "files", "distribution_program_address.pdf") | ||
expected_incomplete_address_file_path = Rails.root.join("spec", "fixtures", "files", "distribution_incomplete_address.pdf") | ||
FilePaths.new(expected_pickup_file_path, expected_same_address_file_path, expected_different_address_file_path, expected_incomplete_address_file_path) | ||
expected_no_contact_file_path = Rails.root.join("spec", "fixtures", "files", "distribution_no_contact.pdf") | ||
FilePaths.new(expected_pickup_file_path, expected_same_address_file_path, expected_different_address_file_path, expected_incomplete_address_file_path, expected_no_contact_file_path) | ||
end | ||
|
||
private def create_profile(partner:, program_address1:, program_address2:, program_city:, program_state:, program_zip:, | ||
address1: "Example Address 1", city: "Example City", state: "Example State", zip: "12345") | ||
address1: "Example Address 1", city: "Example City", state: "Example State", zip: "12345", primary_contact_name: "Jaqueline Kihn DDS", primary_contact_email: "[email protected]") | ||
|
||
Partners::Profile.create!( | ||
partner_id: partner.id, | ||
essentials_bank_id: partner.organization.id, | ||
primary_contact_name: "Jaqueline Kihn DDS", | ||
primary_contact_email: "[email protected]", | ||
primary_contact_name: primary_contact_name, | ||
primary_contact_email: primary_contact_email, | ||
address1: address1, | ||
address2: "", | ||
city: city, | ||
|
@@ -79,6 +80,10 @@ def create_profile_with_incomplete_address(partner) | |
create_profile(partner: partner, program_address1: "Example Program Address 1", program_address2: "", program_city: "", program_state: "", program_zip: "") | ||
end | ||
|
||
def create_profile_no_contact_with_program_address(partner) | ||
create_profile(partner: partner, program_address1: "Example Program Address 1", program_address2: "", program_city: "Example Program City", program_state: "Example Program State", program_zip: 54321, primary_contact_name: "", primary_contact_email: "") | ||
end | ||
|
||
def create_line_items_request(distribution, partner, storage_creation) | ||
LineItem.create!(itemizable: distribution, item: storage_creation.items[0], quantity: 50) | ||
LineItem.create!(itemizable: distribution, item: storage_creation.items[1], quantity: 100) | ||
|
@@ -109,7 +114,7 @@ def create_dist(partner, storage_creation, delivery_method) | |
|
||
private def create_comparison_pdf(storage_creation, profile_create_method, expected_file_path, delivery_method) | ||
partner = create_partner(storage_creation.organization) | ||
profile = profile_create_method.bind_call(Class.new.extend(PDFComparisonTestFactory), partner) | ||
profile = PDFComparisonTestFactory.instance_method(profile_create_method).bind_call(Class.new.extend(PDFComparisonTestFactory), partner) | ||
dist = create_dist(partner, storage_creation, delivery_method) | ||
pdf_file = DistributionPdf.new(storage_creation.organization, dist).compute_and_render | ||
File.binwrite(expected_file_path, pdf_file) | ||
|
@@ -124,10 +129,11 @@ def create_comparison_pdfs | |
storage_creation = create_organization_storage_items | ||
file_paths = get_file_paths | ||
|
||
create_comparison_pdf(storage_creation, PDFComparisonTestFactory.instance_method(:create_profile_no_address), file_paths.expected_pickup_file_path, :pick_up) | ||
create_comparison_pdf(storage_creation, PDFComparisonTestFactory.instance_method(:create_profile_without_program_address), file_paths.expected_same_address_file_path, :shipped) | ||
create_comparison_pdf(storage_creation, PDFComparisonTestFactory.instance_method(:create_profile_with_program_address), file_paths.expected_different_address_file_path, :delivery) | ||
create_comparison_pdf(storage_creation, PDFComparisonTestFactory.instance_method(:create_profile_with_incomplete_address), file_paths.expected_incomplete_address_file_path, :delivery) | ||
create_comparison_pdf(storage_creation, :create_profile_no_address, file_paths.expected_pickup_file_path, :pick_up) | ||
create_comparison_pdf(storage_creation, :create_profile_without_program_address, file_paths.expected_same_address_file_path, :shipped) | ||
create_comparison_pdf(storage_creation, :create_profile_with_program_address, file_paths.expected_different_address_file_path, :delivery) | ||
create_comparison_pdf(storage_creation, :create_profile_with_incomplete_address, file_paths.expected_incomplete_address_file_path, :delivery) | ||
create_comparison_pdf(storage_creation, :create_profile_no_contact_with_program_address, file_paths.expected_no_contact_file_path, :delivery) | ||
|
||
storage_creation.storage_location.destroy! | ||
storage_creation.items[0].destroy! | ||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters