From d28545a7b2819f5d15a9c95c32b21858fa19aa8d Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Bellet Date: Tue, 17 May 2022 12:10:41 +0200 Subject: [PATCH 1/2] Display both phone number and email to the alternative invoice --- app/views/spree/admin/orders/invoice2.html.haml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/views/spree/admin/orders/invoice2.html.haml b/app/views/spree/admin/orders/invoice2.html.haml index 2f1b152cdf..689909d856 100644 --- a/app/views/spree/admin/orders/invoice2.html.haml +++ b/app/views/spree/admin/orders/invoice2.html.haml @@ -66,6 +66,12 @@ %br - if @order.bill_address = @order.bill_address.address_part2 + - if @order.bill_address.phone.present? + %br + = @order.bill_address.phone + - if @order&.customer&.email.present? + %br + = @order.customer.email = render 'spree/admin/orders/invoice_table2' From cf687864ccd1eed4e2d0d3f9c29ea92f2537f102 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Bellet Date: Tue, 17 May 2022 13:58:05 +0200 Subject: [PATCH 2/2] Update specs to check on both invoice models presence of phone and email --- spec/features/admin/invoice_print_spec.rb | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/spec/features/admin/invoice_print_spec.rb b/spec/features/admin/invoice_print_spec.rb index 0d603e9c49..ede39ff449 100644 --- a/spec/features/admin/invoice_print_spec.rb +++ b/spec/features/admin/invoice_print_spec.rb @@ -98,6 +98,28 @@ describe ' end end end + + shared_examples "Check display on each invoice: legacy and alternative" do |alternative_invoice| + let!(:completed_order) do + create(:completed_order_with_fees, distributor: distributor, order_cycle: order_cycle, + user: create(:user, email: "xxxxxx@example.com"), + bill_address: create(:address, phone: '1234567890')) + end + + before do + allow(Spree::Config).to receive(:invoice_style2?).and_return(alternative_invoice) + login_as_admin_and_visit spree.print_admin_order_path(completed_order) + convert_pdf_to_page + end + + it "display phone number and email of the customer" do + expect(page).to have_content "1234567890" + expect(page).to have_content "xxxxxx@example.com" + end + end + + it_behaves_like "Check display on each invoice: legacy and alternative", false + it_behaves_like "Check display on each invoice: legacy and alternative", true end def convert_pdf_to_page