From 72403fd0219deb9b3afcf706e4b1d1874294e761 Mon Sep 17 00:00:00 2001 From: Rob Harrington Date: Fri, 10 Apr 2015 13:16:21 +1000 Subject: [PATCH] Fixing broken enterprise controller spec --- app/controllers/admin/enterprises_controller.rb | 1 - spec/controllers/admin/enterprises_controller_spec.rb | 11 ++++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/controllers/admin/enterprises_controller.rb b/app/controllers/admin/enterprises_controller.rb index de60a43edb..bb13bb6739 100644 --- a/app/controllers/admin/enterprises_controller.rb +++ b/app/controllers/admin/enterprises_controller.rb @@ -68,7 +68,6 @@ module Admin def for_order_cycle respond_to do |format| - format.html format.json do render json: ActiveModel::ArraySerializer.new( @collection, each_serializer: Api::Admin::ForOrderCycle::EnterpriseSerializer, spree_current_user: spree_current_user diff --git a/spec/controllers/admin/enterprises_controller_spec.rb b/spec/controllers/admin/enterprises_controller_spec.rb index c383101d25..53edeae6b7 100644 --- a/spec/controllers/admin/enterprises_controller_spec.rb +++ b/spec/controllers/admin/enterprises_controller_spec.rb @@ -419,32 +419,33 @@ module Admin OrderCycle.stub new: "new OrderCycle" OpenFoodNetwork::Permissions.stub(:new) { permission_mock } - allow(permission_mock).to receive :order_cycle_enterprises_for + allow(permission_mock).to receive(:order_cycle_enterprises_for) + allow(ActiveModel::ArraySerializer).to receive(:new) { "" } end context "when no order_cycle or coordinator is provided in params" do - before { spree_get :for_order_cycle } + before { spree_get :for_order_cycle, format: :json } it "returns an empty scope" do expect(permission_mock).to have_received(:order_cycle_enterprises_for).with(nil) end end context "when an order_cycle_id is provided in params" do - before { spree_get :for_order_cycle, order_cycle_id: 1 } + before { spree_get :for_order_cycle, format: :json, order_cycle_id: 1 } it "calls order_cycle_enterprises_for() with the existing OrderCycle" do expect(permission_mock).to have_received(:order_cycle_enterprises_for).with("existing OrderCycle") end end context "when a coordinator is provided in params" do - before { spree_get :for_order_cycle, coordinator_id: 1 } + before { spree_get :for_order_cycle, format: :json, coordinator_id: 1 } it "calls order_cycle_enterprises_for() with a new OrderCycle" do expect(permission_mock).to have_received(:order_cycle_enterprises_for).with("new OrderCycle") end end context "when both an order cycle and a coordinator are provided in params" do - before { spree_get :for_order_cycle, order_cycle_id: 1, coordinator_id: 1 } + before { spree_get :for_order_cycle, format: :json, order_cycle_id: 1, coordinator_id: 1 } it "calls order_cycle_enterprises_for() with the existing OrderCycle" do expect(permission_mock).to have_received(:order_cycle_enterprises_for).with("existing OrderCycle") end