From c852c616d5f0fdbf446fb8fda6a0e387793bdb23 Mon Sep 17 00:00:00 2001 From: luisramos0 Date: Fri, 22 Mar 2019 10:59:50 +0000 Subject: [PATCH 1/3] Update spree revision to include last package_factory fix and update spree dependencies --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 0d86913a2c..5728364ed3 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -31,7 +31,7 @@ GIT GIT remote: https://github.com/openfoodfoundation/spree.git - revision: f55722b38db7e706a8521c9091a0e00119bb4d20 + revision: 060d0a5d8b31f68990fa792e0e88910c742d9a96 branch: 2-0-4-stable specs: spree (2.0.4) From 5791eba9bdf1e410b1c225e3ad3ba2c71a5acfa4 Mon Sep 17 00:00:00 2001 From: luisramos0 Date: Wed, 3 Apr 2019 12:55:30 +0100 Subject: [PATCH 2/3] Enhance orders edit page spec to verify that shipping method can be edited and that shipping methods of other distributors are not listed --- spec/features/admin/orders_spec.rb | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/spec/features/admin/orders_spec.rb b/spec/features/admin/orders_spec.rb index aecdd4e7c7..f6748903e6 100644 --- a/spec/features/admin/orders_spec.rb +++ b/spec/features/admin/orders_spec.rb @@ -219,7 +219,9 @@ feature %q{ end feature "viewing the edit page" do - let!(:different_shipping_method) { create(:shipping_method, name: "Different Shipping Method") } + let!(:shipping_method_for_distributor1) { create(:shipping_method, name: "Normal", distributors: [distributor1]) } + let!(:different_shipping_method_for_distributor1) { create(:shipping_method, name: "Different", distributors: [distributor1]) } + let!(:shipping_method_for_distributor2) { create(:shipping_method, name: "Other", distributors: [distributor2]) } background do Spree::Config[:enable_receipt_printing?] = true @@ -227,10 +229,12 @@ feature %q{ distributor1.update_attribute(:abn, '12345678') @order = create(:order_with_taxes, distributor: distributor1, + ship_address: create(:address), product_price: 110, tax_rate_amount: 0.1, tax_rate_name: "Tax 1") Spree::TaxRate.adjust(@order) + @order.update_shipping_fees! visit spree.edit_admin_order_path(@order) end @@ -288,14 +292,14 @@ feature %q{ end scenario "can edit shipping method" do - expect(page).to_not have_content different_shipping_method.name + expect(page).to_not have_content different_shipping_method_for_distributor1.name find('.edit-method').click - expect(page).to have_select2 'selected_shipping_rate_id', with_options: [different_shipping_method.name] - select2_select different_shipping_method.name, from: 'selected_shipping_rate_id' + expect(page).to have_select2 'selected_shipping_rate_id', with_options: [shipping_method_for_distributor1.name, different_shipping_method_for_distributor1.name], without_options: [shipping_method_for_distributor2.name] + select2_select different_shipping_method_for_distributor1.name, from: 'selected_shipping_rate_id' find('.save-method').click - expect(page).to have_content different_shipping_method.name + expect(page).to have_content different_shipping_method_for_distributor1.name end scenario "can edit tracking number" do From 46278e3edda19363d32093d91c492cc3d73da869 Mon Sep 17 00:00:00 2001 From: luisramos0 Date: Wed, 3 Apr 2019 13:48:09 +0100 Subject: [PATCH 3/3] Set distributor in order and shipping methods so that refreshing shipment rates suceeds --- spec/controllers/spree/api/shipments_controller_spec.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/spec/controllers/spree/api/shipments_controller_spec.rb b/spec/controllers/spree/api/shipments_controller_spec.rb index 88ff8f6ad6..3c71618c50 100644 --- a/spec/controllers/spree/api/shipments_controller_spec.rb +++ b/spec/controllers/spree/api/shipments_controller_spec.rb @@ -25,7 +25,9 @@ describe Spree::Api::ShipmentsController, type: :controller do let(:error_message) { "broken shipments creation" } before do - order.update_attribute(:ship_address_id, order_ship_address.id) + order.update_attribute :ship_address_id, order_ship_address.id + order.update_attribute :distributor, variant.product.supplier + shipment.shipping_method.distributors << variant.product.supplier end sign_in_as_admin! @@ -56,6 +58,7 @@ describe Spree::Api::ShipmentsController, type: :controller do it 'updates existing shipment with variant override if an VO is sent' do hub = create(:distributor_enterprise) order.update_attribute(:distributor, hub) + shipment.shipping_method.distributors << hub variant_override = create(:variant_override, hub: hub, variant: variant) spree_post :create, params