Find only outgoing exchanges for Enterprise scopes using with_order_cycles_outer

This commit is contained in:
Rohan Mitchell
2014-03-26 12:07:06 +11:00
parent ac8990f7e7
commit abf83b0e58
2 changed files with 1 additions and 2 deletions

View File

@@ -47,7 +47,7 @@ class Enterprise < ActiveRecord::Base
joins('LEFT OUTER JOIN product_distributions ON product_distributions.distributor_id = enterprises.id').
joins('LEFT OUTER JOIN spree_products ON spree_products.id = product_distributions.product_id')
scope :with_order_cycles_outer,
joins('LEFT OUTER JOIN exchanges ON (exchanges.receiver_id = enterprises.id)').
joins("LEFT OUTER JOIN exchanges ON (exchanges.receiver_id = enterprises.id AND exchanges.incoming = 'f')").
joins('LEFT OUTER JOIN order_cycles ON (order_cycles.id = exchanges.order_cycle_id)')
scope :with_order_cycles_and_exchange_variants_outer,

View File

@@ -106,7 +106,6 @@ describe Enterprise do
create(:simple_order_cycle, suppliers: [s], distributors: [d], variants: [p.master], orders_open_at: 1.week.from_now, orders_close_at: 2.weeks.from_now)
Enterprise.active_distributors.should be_empty
end
end
describe "with_distributed_active_products_on_hand" do