From 0cf4e01dde93bb1865dc9112a0667b1127713106 Mon Sep 17 00:00:00 2001 From: Rohan Mitchell Date: Sat, 1 Nov 2014 10:39:29 +1100 Subject: [PATCH] Fix specs: Expect proper query chain --- spec/controllers/home_controller_spec.rb | 3 ++- spec/controllers/map_controller_spec.rb | 8 +++++++- spec/controllers/producers_controller_spec.rb | 5 +++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/spec/controllers/home_controller_spec.rb b/spec/controllers/home_controller_spec.rb index 5cd2b0cda8..16367eb812 100644 --- a/spec/controllers/home_controller_spec.rb +++ b/spec/controllers/home_controller_spec.rb @@ -6,7 +6,8 @@ describe HomeController do let!(:invisible_distributor) { create(:distributor_enterprise, visible: false) } before do - Enterprise.stub(:distributors_with_active_order_cycles).and_return [distributor] + Enterprise.stub_chain(:distributors_with_active_order_cycles, :ready_for_checkout). + and_return [distributor] end it "sets active distributors" do diff --git a/spec/controllers/map_controller_spec.rb b/spec/controllers/map_controller_spec.rb index f3d56853f9..c4e98def8a 100644 --- a/spec/controllers/map_controller_spec.rb +++ b/spec/controllers/map_controller_spec.rb @@ -2,7 +2,13 @@ require 'spec_helper' describe MapController do it "loads active distributors" do - Enterprise.should_receive(:distributors_with_active_order_cycles) + active_distributors = double(:distributors) + + Enterprise.stub_chain(:distributors_with_active_order_cycles, :ready_for_checkout). + and_return(active_distributors) + get :index + + assigns(:active_distributors).should == active_distributors end end diff --git a/spec/controllers/producers_controller_spec.rb b/spec/controllers/producers_controller_spec.rb index 812b08892f..2b7377a471 100644 --- a/spec/controllers/producers_controller_spec.rb +++ b/spec/controllers/producers_controller_spec.rb @@ -4,8 +4,9 @@ describe ProducersController do let!(:distributor) { create(:distributor_enterprise) } before do - Enterprise.stub(:distributors_with_active_order_cycles).and_return [distributor] - Enterprise.stub(:all).and_return [distributor] + Enterprise.stub_chain(:distributors_with_active_order_cycles, :ready_for_checkout). + and_return([distributor]) + Enterprise.stub(:all).and_return([distributor]) end it "sets active distributors" do