Fix specs: Expect proper query chain

This commit is contained in:
Rohan Mitchell
2014-11-01 10:39:29 +11:00
parent 0d05c7163d
commit 0cf4e01dde
3 changed files with 12 additions and 4 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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