From 2e2dc216fa9ed9f7e691431db5ee4801c16f4bd6 Mon Sep 17 00:00:00 2001 From: David Cook Date: Mon, 22 Jul 2013 17:33:50 +1000 Subject: [PATCH] WIP: writing order scope test --- spec/models/order_spec.rb | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/spec/models/order_spec.rb b/spec/models/order_spec.rb index ac6419afb0..ba55a7ef99 100644 --- a/spec/models/order_spec.rb +++ b/spec/models/order_spec.rb @@ -28,15 +28,6 @@ describe Spree::Order do li.max_quantity.should == 3 end - context "canceled order" do - subject.state = 'canceled' #what is the correct way to set this? - - it "doesn't appear in not_state(canceled)" do - subject.should_not be_in_collection(Spree::Order.not_state('canceled')) - end - end - - context "validating distributor changes" do it "checks that a distributor is available when changing" do order_enterprise = FactoryGirl.create(:enterprise, id: 1, :name => "Order Enterprise") @@ -71,4 +62,20 @@ describe Spree::Order do subject.errors.should include :distributor_id end end + + describe "scopes" do + describe "not_state" do + it "finds only orders not in specified state" do + pending "write this test" + s0 = create(:supplier_enterprise) + s1 = create(:supplier_enterprise) + p0 = create(:product, :supplier => s0) + p1 = create(:product, :supplier => s1) + + Spree::Product.in_supplier_or_distributor(s1).should == [p1] + end + + end + end + end