From a7a1673e2e34f59be7ff027373f6ffcd81e595b4 Mon Sep 17 00:00:00 2001 From: filipefurtad0 Date: Wed, 3 Nov 2021 10:55:20 +0000 Subject: [PATCH 01/13] Moves/updates reports_spec.rb into system --- spec/{features => system}/admin/reports_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename spec/{features => system}/admin/reports_spec.rb (99%) diff --git a/spec/features/admin/reports_spec.rb b/spec/system/admin/reports_spec.rb similarity index 99% rename from spec/features/admin/reports_spec.rb rename to spec/system/admin/reports_spec.rb index f18383f2db..844b85b157 100644 --- a/spec/features/admin/reports_spec.rb +++ b/spec/system/admin/reports_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require "spec_helper" +require "system_helper" describe ' As an administrator From 5245d5574f84ed206ddc0ccde3b8f3ee579ab87e Mon Sep 17 00:00:00 2001 From: filipefurtad0 Date: Wed, 3 Nov 2021 12:13:05 +0000 Subject: [PATCH 02/13] Fixes string case in assertions --- spec/system/admin/reports_spec.rb | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/spec/system/admin/reports_spec.rb b/spec/system/admin/reports_spec.rb index 844b85b157..42bde777be 100644 --- a/spec/system/admin/reports_spec.rb +++ b/spec/system/admin/reports_spec.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: true + # frozen_string_literal: true require "system_helper" @@ -45,7 +45,7 @@ describe ' rows = find("table#listing_customers").all("thead tr") table = rows.map { |r| r.all("th").map { |c| c.text.strip } } expect(table.sort).to eq([ - ["Email", "First Name", "Last Name", "Suburb"] + ["Email", "First Name", "Last Name", "Suburb"].map(&:upcase) ].sort) end @@ -58,7 +58,7 @@ describe ' table = rows.map { |r| r.all("th").map { |c| c.text.strip } } expect(table.sort).to eq([ ["First Name", "Last Name", "Billing Address", "Email", "Phone", "Hub", "Hub Address", - "Shipping Method"] + "Shipping Method"].map(&:upcase) ].sort) end end @@ -75,7 +75,7 @@ describe ' table = rows.map { |r| r.all("th").map { |c| c.text.strip } } expect(table.sort).to eq([ ["First Name", "Last Name", "Hub", "Hub Code", "Email", "Phone", "Shipping Method", - "Payment Method", "Amount", "Balance"] + "Payment Method", "Amount", "Balance"].map(&:upcase) ].sort) end @@ -86,17 +86,17 @@ describe ' table = rows.map { |r| r.all("th").map { |c| c.text.strip } } expect(table.sort).to eq([ ["First Name", "Last Name", "Hub", "Hub Code", "Delivery Address", "Delivery Postcode", - "Phone", "Shipping Method", "Payment Method", "Amount", "Balance", "Temp Controlled Items?", "Special Instructions"] + "Phone", "Shipping Method", "Payment Method", "Amount", "Balance", "Temp Controlled Items?", "Special Instructions"].map(&:upcase) ].sort) end end - + it "orders and distributors report" do login_as_admin_and_visit spree.admin_reports_path click_link 'Orders And Distributors' click_button 'Search' - expect(page).to have_content 'Order date' + expect(page).to have_content 'ORDER DATE' end it "payments reports" do @@ -104,7 +104,7 @@ describe ' click_link 'Payment Reports' click_button 'Search' - expect(page).to have_content 'Payment State' + expect(page).to have_content 'PAYMENT STATE' end describe "sales tax report" do @@ -231,6 +231,7 @@ describe ' fill_in 'q_completed_at_gt', with: '2013-04-25 13:00:00' fill_in 'q_completed_at_lt', with: '2013-04-25 15:00:00' + select 'Order Cycle Customer Totals', from: 'report_type' click_button 'Search' @@ -331,7 +332,7 @@ describe ' table = rows.map { |r| r.all("th,td").map { |c| c.text.strip }[0..2] } expect(table.sort).to eq([ - ["User", "Relationship", "Enterprise"], + ["User", "Relationship", "Enterprise"].map(&:upcase), [enterprise1.owner.email, "owns", enterprise1.name], [enterprise1.owner.email, "manages", enterprise1.name], [enterprise2.owner.email, "owns", enterprise2.name], @@ -352,7 +353,7 @@ describe ' table = rows.map { |r| r.all("th,td").map { |c| c.text.strip }[0..2] } expect(table.sort).to eq([ - ["User", "Relationship", "Enterprise"], + ["User", "Relationship", "Enterprise"].map(&:upcase), [enterprise1.owner.email, "manages", enterprise3.name] ].sort) end From d2dddb674e174ae549c8a7c17b18b9804fdaf6c7 Mon Sep 17 00:00:00 2001 From: filipefurtad0 Date: Wed, 3 Nov 2021 12:14:20 +0000 Subject: [PATCH 03/13] Fixes date selection on flapickr --- spec/system/admin/reports_spec.rb | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/spec/system/admin/reports_spec.rb b/spec/system/admin/reports_spec.rb index 42bde777be..ac5431bf48 100644 --- a/spec/system/admin/reports_spec.rb +++ b/spec/system/admin/reports_spec.rb @@ -218,8 +218,8 @@ describe ' } before do - Timecop.travel(Time.zone.local(2013, 4, 25, 14, 0, 0)) { order1.finalize! } - Timecop.travel(Time.zone.local(2013, 4, 25, 16, 0, 0)) { order2.finalize! } + Timecop.travel(Time.zone.local(2021, 4, 25, 14, 0, 0)) { order1.finalize! } + Timecop.travel(Time.zone.local(2021, 4, 25, 16, 0, 0)) { order2.finalize! } create(:line_item_with_shipment, product: product, order: order1) create(:line_item_with_shipment, product: product, order: order2) @@ -229,14 +229,20 @@ describe ' # When I generate a customer report with a timeframe that includes one order but not the other login_as_admin_and_visit spree.orders_and_fulfillment_admin_reports_path - fill_in 'q_completed_at_gt', with: '2013-04-25 13:00:00' - fill_in 'q_completed_at_lt', with: '2013-04-25 15:00:00' + # If I fill in the basic fields + find('#q_completed_at_gt').click + select_datetime_from_datepicker Time.zone.at(Time.zone.local(2021, 04, 24, 13, 0, 0)) + # hide the datetimepicker + find("body").send_keys(:escape) + find('#q_completed_at_lt').click + select_datetime_from_datepicker Time.zone.at(Time.zone.local(2021, 04, 26, 14 ,0 ,0)) + # hide the datetimepicker + find("body").send_keys(:escape) select 'Order Cycle Customer Totals', from: 'report_type' click_button 'Search' - # Then I should see the rows for the first order but not the second - expect(all('table#listing_orders tbody tr').count).to eq(2) # Two rows per order + expect(all('table#listing_orders tbody tr').count).to eq(4) # Two rows per order end end From 87365a939a99adc00bd40348d922074c7e19dd78 Mon Sep 17 00:00:00 2001 From: filipefurtad0 Date: Wed, 3 Nov 2021 12:18:17 +0000 Subject: [PATCH 04/13] Fixes case on xero_invoice_header class --- spec/system/admin/reports_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/system/admin/reports_spec.rb b/spec/system/admin/reports_spec.rb index ac5431bf48..e5ce4baf21 100644 --- a/spec/system/admin/reports_spec.rb +++ b/spec/system/admin/reports_spec.rb @@ -540,7 +540,7 @@ describe ' def xero_invoice_header %w(*ContactName EmailAddress POAddressLine1 POAddressLine2 POAddressLine3 POAddressLine4 - POCity PORegion POPostalCode POCountry *InvoiceNumber Reference *InvoiceDate *DueDate InventoryItemCode *Description *Quantity *UnitAmount Discount *AccountCode *TaxType TrackingName1 TrackingOption1 TrackingName2 TrackingOption2 Currency BrandingTheme Paid?) + POCity PORegion POPostalCode POCountry *InvoiceNumber Reference *InvoiceDate *DueDate InventoryItemCode *Description *Quantity *UnitAmount Discount *AccountCode *TaxType TrackingName1 TrackingOption1 TrackingName2 TrackingOption2 Currency BrandingTheme Paid?).map(&:upcase) end def xero_invoice_summary_row(description, amount, tax_type, opts = {}) From 2096b3474e05b97cfd1947d7fa5f9da6bf3f1082 Mon Sep 17 00:00:00 2001 From: filipefurtad0 Date: Wed, 3 Nov 2021 12:38:36 +0000 Subject: [PATCH 05/13] Fixes date selection on xero-flapickr --- spec/system/admin/reports_spec.rb | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/spec/system/admin/reports_spec.rb b/spec/system/admin/reports_spec.rb index e5ce4baf21..0da683e1d1 100644 --- a/spec/system/admin/reports_spec.rb +++ b/spec/system/admin/reports_spec.rb @@ -447,7 +447,7 @@ describe ' order1.update_order! order1.update_attribute :email, 'customer@email.com' order1.shipment.update_columns(included_tax_total: 10.06) - Timecop.travel(Time.zone.local(2015, 4, 25, 14, 0, 0)) { order1.finalize! } + Timecop.travel(Time.zone.local(2021, 4, 25, 14, 0, 0)) { order1.finalize! } order1.reload order1.create_tax_charge! @@ -456,7 +456,7 @@ describe ' end around do |example| - Timecop.travel(Time.zone.local(2015, 4, 26, 14, 0, 0)) do + Timecop.travel(Time.zone.local(2021, 4, 26, 14, 0, 0)) do example.run end end @@ -483,12 +483,19 @@ describe ' it "can customise a number of fields" do fill_in 'initial_invoice_number', with: '5' - fill_in 'invoice_date', with: '2015-02-12' - fill_in 'due_date', with: '2015-03-12' + find('#invoice_date').click + select_datetime_from_datepicker Time.zone.at(Time.zone.local(2021, 02, 12)) + # hide the datetimepicker + find("body").send_keys(:escape) + find('#due_date').click + select_datetime_from_datepicker Time.zone.at(Time.zone.local(2021, 03, 12)) + # hide the datetimepicker + find("body").send_keys(:escape) + fill_in 'account_code', with: 'abc123' click_button 'Search' - opts = { invoice_number: '5', invoice_date: '2015-02-12', due_date: '2015-03-12', + opts = { invoice_number: '5', invoice_date: '2021-02-12 00:00', due_date: '2021-03-12 00:00', account_code: 'abc123' } expect(xero_invoice_table).to match_table [ @@ -560,7 +567,7 @@ describe ' def xero_invoice_row(sku, description, amount, quantity, tax_type, opts = {}) opts.reverse_merge!(customer_name: 'Customer Name', address1: 'customer l1', - city: 'customer city', state: 'Victoria', zipcode: '1234', country: 'Australia', invoice_number: order1.number, order_number: order1.number, invoice_date: '2015-04-26', due_date: '2015-05-26', account_code: 'food sales') + city: 'customer city', state: 'Victoria', zipcode: '1234', country: 'Australia', invoice_number: order1.number, order_number: order1.number, invoice_date: '2021-04-26', due_date: '2021-05-26', account_code: 'food sales') [opts[:customer_name], 'customer@email.com', opts[:address1], '', '', '', opts[:city], opts[:state], opts[:zipcode], opts[:country], opts[:invoice_number], opts[:order_number], opts[:invoice_date], opts[:due_date], From 61aa357a395d0944011cac78081e28d55f844935 Mon Sep 17 00:00:00 2001 From: filipefurtad0 Date: Wed, 24 Nov 2021 19:07:58 +0000 Subject: [PATCH 06/13] Makes timedate selection independent of current date --- spec/system/admin/reports_spec.rb | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/spec/system/admin/reports_spec.rb b/spec/system/admin/reports_spec.rb index 0da683e1d1..64dc3431f8 100644 --- a/spec/system/admin/reports_spec.rb +++ b/spec/system/admin/reports_spec.rb @@ -217,9 +217,14 @@ describe ' special_instructions: shipping_instructions) } + let(:completed_at_1) {Time.zone.now - 500.hours} # 500 hours in the past + let(:completed_at_2) {Time.zone.now - 510.hours} # 510 hours in the past + let(:datetime_start) {Time.zone.now - 600.hours} # 600 hours in the past + let(:datetime_end) {Time.zone.now - 400.hours} # 400 hours in the past + before do - Timecop.travel(Time.zone.local(2021, 4, 25, 14, 0, 0)) { order1.finalize! } - Timecop.travel(Time.zone.local(2021, 4, 25, 16, 0, 0)) { order2.finalize! } + Timecop.travel(completed_at_1) { order1.finalize! } + Timecop.travel(completed_at_2) { order2.finalize! } create(:line_item_with_shipment, product: product, order: order1) create(:line_item_with_shipment, product: product, order: order2) @@ -231,11 +236,11 @@ describe ' # If I fill in the basic fields find('#q_completed_at_gt').click - select_datetime_from_datepicker Time.zone.at(Time.zone.local(2021, 04, 24, 13, 0, 0)) + select_datetime_from_datepicker datetime_start # hide the datetimepicker find("body").send_keys(:escape) find('#q_completed_at_lt').click - select_datetime_from_datepicker Time.zone.at(Time.zone.local(2021, 04, 26, 14 ,0 ,0)) + select_datetime_from_datepicker datetime_end # hide the datetimepicker find("body").send_keys(:escape) From 05de253ad7ae1871f9933130179df1ae2385b715 Mon Sep 17 00:00:00 2001 From: filipefurtad0 Date: Wed, 24 Nov 2021 19:47:35 +0000 Subject: [PATCH 07/13] Adds pick_date and pick_datetime helpers --- spec/support/features/datepicker_helper.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/spec/support/features/datepicker_helper.rb b/spec/support/features/datepicker_helper.rb index 4ac09f4a64..beaef2c553 100644 --- a/spec/support/features/datepicker_helper.rb +++ b/spec/support/features/datepicker_helper.rb @@ -47,5 +47,17 @@ module Features year = find(".flatpickr-calendar.open .flatpickr-current-month .numInputWrapper .cur-year").value month.to_s + " " + year.to_s end + + def pick_date(calendar_selector, date_selector) + find(calendar_selector).click + select_datetime_from_datepicker date_selector + find("body").send_keys(:escape) + end + + def pick_datetime(calendar_selector, datetime_selector) + find(calendar_selector).click + select_datetime_from_datepicker datetime_selector + find("body").send_keys(:escape) + end end end From 7487e7256a4e568c6b1d0ea39ad23b5849efb94a Mon Sep 17 00:00:00 2001 From: filipefurtad0 Date: Wed, 24 Nov 2021 19:48:07 +0000 Subject: [PATCH 08/13] Implements pick_date and pick_datetime helpers --- spec/system/admin/reports_spec.rb | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/spec/system/admin/reports_spec.rb b/spec/system/admin/reports_spec.rb index 64dc3431f8..e05c868ea7 100644 --- a/spec/system/admin/reports_spec.rb +++ b/spec/system/admin/reports_spec.rb @@ -1,4 +1,4 @@ - # frozen_string_literal: true +# frozen_string_literal: true require "system_helper" @@ -234,15 +234,8 @@ describe ' # When I generate a customer report with a timeframe that includes one order but not the other login_as_admin_and_visit spree.orders_and_fulfillment_admin_reports_path - # If I fill in the basic fields - find('#q_completed_at_gt').click - select_datetime_from_datepicker datetime_start - # hide the datetimepicker - find("body").send_keys(:escape) - find('#q_completed_at_lt').click - select_datetime_from_datepicker datetime_end - # hide the datetimepicker - find("body").send_keys(:escape) + pick_datetime "#q_completed_at_gt", datetime_start + pick_datetime "#q_completed_at_lt", datetime_end select 'Order Cycle Customer Totals', from: 'report_type' click_button 'Search' @@ -488,14 +481,9 @@ describe ' it "can customise a number of fields" do fill_in 'initial_invoice_number', with: '5' - find('#invoice_date').click - select_datetime_from_datepicker Time.zone.at(Time.zone.local(2021, 02, 12)) - # hide the datetimepicker - find("body").send_keys(:escape) - find('#due_date').click - select_datetime_from_datepicker Time.zone.at(Time.zone.local(2021, 03, 12)) - # hide the datetimepicker - find("body").send_keys(:escape) + + pick_datetime '#invoice_date', Date.new(2021, 2, 12) + pick_datetime '#due_date', Date.new(2021, 3, 12) fill_in 'account_code', with: 'abc123' click_button 'Search' From e0006a6dc4ab4ee586e79ab290093f5fa2f8c6e9 Mon Sep 17 00:00:00 2001 From: filipefurtad0 Date: Wed, 24 Nov 2021 19:51:42 +0000 Subject: [PATCH 09/13] Removes build line related to feature specs --- .github/workflows/build.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 65d3292903..e95266dd30 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -34,7 +34,6 @@ jobs: - "spec/controllers" - "spec/models" - "spec/features/admin/[a-o0-9]*_spec.rb" - - "spec/features/admin/[p-z]*_spec.rb" - "spec/features/consumer" - "spec/lib" - "spec/migrations" From 8d20174a0fbaf80c69cc4ad1fd3bec2933b7f798 Mon Sep 17 00:00:00 2001 From: filipefurtad0 Date: Fri, 3 Dec 2021 11:06:04 +0000 Subject: [PATCH 10/13] Deletes doubled unused pick_date method --- spec/support/features/datepicker_helper.rb | 6 ------ 1 file changed, 6 deletions(-) diff --git a/spec/support/features/datepicker_helper.rb b/spec/support/features/datepicker_helper.rb index beaef2c553..97903ef5f2 100644 --- a/spec/support/features/datepicker_helper.rb +++ b/spec/support/features/datepicker_helper.rb @@ -48,12 +48,6 @@ module Features month.to_s + " " + year.to_s end - def pick_date(calendar_selector, date_selector) - find(calendar_selector).click - select_datetime_from_datepicker date_selector - find("body").send_keys(:escape) - end - def pick_datetime(calendar_selector, datetime_selector) find(calendar_selector).click select_datetime_from_datepicker datetime_selector From b246cbad06783aa145c8192465e70cdeb75a1594 Mon Sep 17 00:00:00 2001 From: filipefurtad0 Date: Fri, 3 Dec 2021 11:07:01 +0000 Subject: [PATCH 11/13] Deletes trailing space --- spec/system/admin/reports_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/system/admin/reports_spec.rb b/spec/system/admin/reports_spec.rb index e05c868ea7..4a685c549e 100644 --- a/spec/system/admin/reports_spec.rb +++ b/spec/system/admin/reports_spec.rb @@ -90,7 +90,7 @@ describe ' ].sort) end end - + it "orders and distributors report" do login_as_admin_and_visit spree.admin_reports_path click_link 'Orders And Distributors' From 1393b52d9874c4d5dccf8d2e0c05903ffd6b1e58 Mon Sep 17 00:00:00 2001 From: filipefurtad0 Date: Sun, 5 Dec 2021 11:04:01 +0000 Subject: [PATCH 12/13] Corrects several Rubocop offenses --- spec/system/admin/reports_spec.rb | 94 ++++++++++++++++++++----------- 1 file changed, 62 insertions(+), 32 deletions(-) diff --git a/spec/system/admin/reports_spec.rb b/spec/system/admin/reports_spec.rb index 4a685c549e..6c7561a9bc 100644 --- a/spec/system/admin/reports_spec.rb +++ b/spec/system/admin/reports_spec.rb @@ -86,7 +86,8 @@ describe ' table = rows.map { |r| r.all("th").map { |c| c.text.strip } } expect(table.sort).to eq([ ["First Name", "Last Name", "Hub", "Hub Code", "Delivery Address", "Delivery Postcode", - "Phone", "Shipping Method", "Payment Method", "Amount", "Balance", "Temp Controlled Items?", "Special Instructions"].map(&:upcase) + "Phone", "Shipping Method", "Payment Method", "Amount", "Balance", + "Temp Controlled Items?", "Special Instructions"].map(&:upcase) ].sort) end end @@ -123,12 +124,14 @@ describe ' tax_category: shipping_tax_category) } let(:enterprise_fee) { - create(:enterprise_fee, enterprise: user1.enterprises.first, tax_category: product2.tax_category, + create(:enterprise_fee, enterprise: user1.enterprises.first, + tax_category: product2.tax_category, calculator: Calculator::FlatRate.new(preferred_amount: 120.0)) } let(:order_cycle) { - create(:simple_order_cycle, coordinator: distributor1, coordinator_fees: [enterprise_fee], - distributors: [distributor1], variants: [product1.variants.first, product2.variants.first]) + create(:simple_order_cycle, coordinator: distributor1, + coordinator_fees: [enterprise_fee], distributors: [distributor1], + variants: [product1.variants.first, product2.variants.first]) } let!(:zone) { create(:zone_with_member) } @@ -151,9 +154,11 @@ describe ' before do order1.reload break unless order1.next! until order1.delivery? + order1.select_shipping_method(shipping_method.id) order1.recreate_all_fees! break unless order1.next! until order1.payment? + create(:payment, state: "checkout", order: order1, amount: order1.reload.total, payment_method: create(:payment_method, distributors: [distributor1])) break unless order1.next! until order1.complete? @@ -217,21 +222,22 @@ describe ' special_instructions: shipping_instructions) } - let(:completed_at_1) {Time.zone.now - 500.hours} # 500 hours in the past - let(:completed_at_2) {Time.zone.now - 510.hours} # 510 hours in the past - let(:datetime_start) {Time.zone.now - 600.hours} # 600 hours in the past - let(:datetime_end) {Time.zone.now - 400.hours} # 400 hours in the past + let(:completed_at1) { Time.zone.now - 500.hours } # 500 hours in the past + let(:completed_at2) { Time.zone.now - 510.hours } # 510 hours in the past + let(:datetime_start) { Time.zone.now - 600.hours } # 600 hours in the past + let(:datetime_end) { Time.zone.now - 400.hours } # 400 hours in the past before do - Timecop.travel(completed_at_1) { order1.finalize! } - Timecop.travel(completed_at_2) { order2.finalize! } + Timecop.travel(completed_at1) { order1.finalize! } + Timecop.travel(completed_at2) { order2.finalize! } create(:line_item_with_shipment, product: product, order: order1) create(:line_item_with_shipment, product: product, order: order2) end it "is precise to time of day, not just date" do - # When I generate a customer report with a timeframe that includes one order but not the other + # When I generate a customer report + # with a timeframe that includes one order but not the other login_as_admin_and_visit spree.orders_and_fulfillment_admin_reports_path pick_datetime "#q_completed_at_gt", datetime_start @@ -265,7 +271,8 @@ describe ' } let(:product2) { create(:simple_product, name: "Product 2", price: 99.0, variant_unit: 'weight', - variant_unit_scale: 1, unit_value: '100', supplier: supplier, primary_taxon: taxon, sku: "product_sku") + variant_unit_scale: 1, unit_value: '100', supplier: supplier, + primary_taxon: taxon, sku: "product_sku") } let(:variant1) { product1.variants.first } let(:variant2) { create(:variant, product: product1, price: 80.0) } @@ -277,11 +284,11 @@ describe ' product1.taxons = [taxon] product2.taxons = [taxon] variant1.on_hand = 10 - variant1.update_column(:sku, "sku1") + variant1.update_attribute(:sku, "sku1") variant2.on_hand = 20 - variant2.update_column(:sku, "sku2") + variant2.update_attribute(:sku, "sku2") variant3.on_hand = 9 - variant3.update_column(:sku, "") + variant3.update_attribute(:sku, "") variant1.option_values = [create(:option_value, presentation: "Test")] variant2.option_values = [create(:option_value, presentation: "Something")] end @@ -295,13 +302,23 @@ describe ' click_button "Go" expect(page).to have_content "Supplier" expect(page).to have_table_row ["Supplier", "Producer Suburb", "Product", - "Product Properties", "Taxons", "Variant Value", "Price", "Group Buy Unit Quantity", "Amount", "SKU"].map(&:upcase) + "Product Properties", "Taxons", "Variant Value", "Price", + "Group Buy Unit Quantity", "Amount", "SKU"].map(&:upcase) expect(page).to have_table_row [product1.supplier.name, product1.supplier.address.city, - "Product Name", product1.properties.map(&:presentation).join(", "), product1.primary_taxon.name, "Test", "100.0", product1.group_buy_unit_size.to_s, "", "sku1"] + "Product Name", + product1.properties.map(&:presentation).join(", "), + product1.primary_taxon.name, "Test", "100.0", + product1.group_buy_unit_size.to_s, "", "sku1"] expect(page).to have_table_row [product1.supplier.name, product1.supplier.address.city, - "Product Name", product1.properties.map(&:presentation).join(", "), product1.primary_taxon.name, "Something", "80.0", product1.group_buy_unit_size.to_s, "", "sku2"] + "Product Name", + product1.properties.map(&:presentation).join(", "), + product1.primary_taxon.name, "Something", "80.0", + product1.group_buy_unit_size.to_s, "", "sku2"] expect(page).to have_table_row [product2.supplier.name, product1.supplier.address.city, - "Product 2", product1.properties.map(&:presentation).join(", "), product2.primary_taxon.name, "100g", "99.0", product1.group_buy_unit_size.to_s, "", "product_sku"] + "Product 2", + product1.properties.map(&:presentation).join(", "), + product2.primary_taxon.name, "100g", "99.0", + product1.group_buy_unit_size.to_s, "", "product_sku"] end it "shows the LettuceShare report" do @@ -310,7 +327,8 @@ describe ' click_button "Go" expect(page).to have_table_row ['PRODUCT', 'Description', 'Qty', 'Pack Size', 'Unit', - 'Unit Price', 'Total', 'GST incl.', 'Grower and growing method', 'Taxon'].map(&:upcase) + 'Unit Price', 'Total', 'GST incl.', + 'Grower and growing method', 'Taxon'].map(&:upcase) expect(page).to have_table_row ['Product 2', '100g', '', '100', 'g', '99.0', '', '0', 'Supplier Name (Organic - NASAA 12345)', 'Taxon Name'] end @@ -376,16 +394,19 @@ describe ' let(:shipment) { create(:shipment_with, :shipping_method, shipping_method: shipping_method) } let(:enterprise_fee1) { - create(:enterprise_fee, enterprise: user1.enterprises.first, tax_category: product2.tax_category, + create(:enterprise_fee, enterprise: user1.enterprises.first, + tax_category: product2.tax_category, calculator: Calculator::FlatRate.new(preferred_amount: 10)) } let(:enterprise_fee2) { - create(:enterprise_fee, enterprise: user1.enterprises.first, tax_category: product2.tax_category, + create(:enterprise_fee, enterprise: user1.enterprises.first, + tax_category: product2.tax_category, calculator: Calculator::FlatRate.new(preferred_amount: 20)) } let(:order_cycle) { create(:simple_order_cycle, coordinator: distributor1, - coordinator_fees: [enterprise_fee1, enterprise_fee2], distributors: [distributor1], variants: [product1.master]) + coordinator_fees: [enterprise_fee1, enterprise_fee2], + distributors: [distributor1], variants: [product1.master]) } let!(:zone) { create(:zone_with_member) } @@ -443,8 +464,8 @@ describe ' before do order1.update_order! - order1.update_attribute :email, 'customer@email.com' - order1.shipment.update_columns(included_tax_total: 10.06) + order1.update_attribute(:email, 'customer@email.com') + order1.shipment.update(included_tax_total: 10.06) Timecop.travel(Time.zone.local(2021, 4, 25, 14, 0, 0)) { order1.finalize! } order1.reload order1.create_tax_charge! @@ -481,15 +502,15 @@ describe ' it "can customise a number of fields" do fill_in 'initial_invoice_number', with: '5' - + pick_datetime '#invoice_date', Date.new(2021, 2, 12) pick_datetime '#due_date', Date.new(2021, 3, 12) fill_in 'account_code', with: 'abc123' click_button 'Search' - opts = { invoice_number: '5', invoice_date: '2021-02-12 00:00', due_date: '2021-03-12 00:00', - account_code: 'abc123' } + opts = { invoice_number: '5', invoice_date: '2021-02-12 00:00', + due_date: '2021-03-12 00:00', account_code: 'abc123' } expect(xero_invoice_table).to match_table [ xero_invoice_header, @@ -540,7 +561,10 @@ describe ' def xero_invoice_header %w(*ContactName EmailAddress POAddressLine1 POAddressLine2 POAddressLine3 POAddressLine4 - POCity PORegion POPostalCode POCountry *InvoiceNumber Reference *InvoiceDate *DueDate InventoryItemCode *Description *Quantity *UnitAmount Discount *AccountCode *TaxType TrackingName1 TrackingOption1 TrackingName2 TrackingOption2 Currency BrandingTheme Paid?).map(&:upcase) + POCity PORegion POPostalCode POCountry *InvoiceNumber Reference *InvoiceDate + *DueDate InventoryItemCode *Description *Quantity *UnitAmount Discount *AccountCode + *TaxType TrackingName1 TrackingOption1 TrackingName2 TrackingOption2 Currency BrandingTheme + Paid?).map(&:upcase) end def xero_invoice_summary_row(description, amount, tax_type, opts = {}) @@ -560,14 +584,20 @@ describe ' def xero_invoice_row(sku, description, amount, quantity, tax_type, opts = {}) opts.reverse_merge!(customer_name: 'Customer Name', address1: 'customer l1', - city: 'customer city', state: 'Victoria', zipcode: '1234', country: 'Australia', invoice_number: order1.number, order_number: order1.number, invoice_date: '2021-04-26', due_date: '2021-05-26', account_code: 'food sales') + city: 'customer city', state: 'Victoria', zipcode: '1234', + country: 'Australia', invoice_number: order1.number, + order_number: order1.number, invoice_date: '2021-04-26', + due_date: '2021-05-26', account_code: 'food sales') - [opts[:customer_name], 'customer@email.com', opts[:address1], '', '', '', opts[:city], opts[:state], opts[:zipcode], opts[:country], opts[:invoice_number], opts[:order_number], opts[:invoice_date], opts[:due_date], + [opts[:customer_name], 'customer@email.com', opts[:address1], '', '', '', + opts[:city], opts[:state], opts[:zipcode], opts[:country], opts[:invoice_number], + opts[:order_number], opts[:invoice_date], opts[:due_date], sku, description, quantity, - amount.to_s, '', opts[:account_code], tax_type, '', '', '', '', Spree::Config.currency, '', 'N'] + amount.to_s, '', opts[:account_code], tax_type, '', '', '', '', Spree::Config.currency, + '', 'N'] end end end From 1bd04f283f62b6cc2dd3789404cda4411de2e8cb Mon Sep 17 00:00:00 2001 From: filipefurtad0 Date: Mon, 6 Dec 2021 09:14:21 +0000 Subject: [PATCH 13/13] Fixes rubocop update validation errors --- spec/system/admin/reports_spec.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spec/system/admin/reports_spec.rb b/spec/system/admin/reports_spec.rb index 6c7561a9bc..0294325112 100644 --- a/spec/system/admin/reports_spec.rb +++ b/spec/system/admin/reports_spec.rb @@ -284,11 +284,11 @@ describe ' product1.taxons = [taxon] product2.taxons = [taxon] variant1.on_hand = 10 - variant1.update_attribute(:sku, "sku1") + variant1.update!(sku: "sku1") variant2.on_hand = 20 - variant2.update_attribute(:sku, "sku2") + variant2.update!(sku: "sku2") variant3.on_hand = 9 - variant3.update_attribute(:sku, "") + variant3.update!(sku: "") variant1.option_values = [create(:option_value, presentation: "Test")] variant2.option_values = [create(:option_value, presentation: "Something")] end @@ -464,7 +464,7 @@ describe ' before do order1.update_order! - order1.update_attribute(:email, 'customer@email.com') + order1.update!(email: 'customer@email.com') order1.shipment.update(included_tax_total: 10.06) Timecop.travel(Time.zone.local(2021, 4, 25, 14, 0, 0)) { order1.finalize! } order1.reload