Fix shop accidentally becoming order coordinator

The original setup of the order calls:

  create(:simple_order_cycle)

Which picks an arbitrary distributor as coordinator:

  coordinator { Enterprise.is_distributor.first || ... }

There is a chance that any of the existing distributor enterprises
becomes coordinator, causing a test to intermittently fail.

This commit makes the relationship between the reference enterprises and
the order consistent.
This commit is contained in:
Kristina Lim
2019-02-02 03:42:44 +08:00
parent cf744bb663
commit 3104862739

View File

@@ -11,7 +11,9 @@ module Api
let!(:distributor2) { create(:distributor_enterprise) }
let!(:supplier) { create(:supplier_enterprise) }
let!(:coordinator) { create(:distributor_enterprise) }
let!(:coordinator2) { create(:distributor_enterprise) }
let!(:order_cycle) { create(:simple_order_cycle, coordinator: coordinator) }
let!(:order_cycle2) { create(:simple_order_cycle, coordinator: coordinator2) }
let!(:order1) do
create(:order, order_cycle: order_cycle, state: 'complete', completed_at: Time.zone.now,
distributor: distributor, billing_address: create(:address) )
@@ -24,7 +26,9 @@ module Api
create(:order, order_cycle: order_cycle, state: 'complete', completed_at: Time.zone.now,
distributor: distributor, billing_address: create(:address) )
end
let!(:order4) { create(:completed_order_with_fees) }
let!(:order4) do
create(:completed_order_with_fees, order_cycle: order_cycle2, distributor: distributor2)
end
let!(:order5) { create(:order, state: 'cart', completed_at: nil) }
let!(:line_item1) do
create(:line_item, order: order1,
@@ -148,7 +152,7 @@ module Api
get :index, per_page: 15, page: 1
pagination_data = {
'results' => 3,
'results' => 2,
'pages' => 1,
'page' => 1,
'per_page' => 15