Make enterprises controller spec assert the corrrect state of current_distributor

This validates bug #5496 is fixed
This commit is contained in:
Luis Ramos
2020-05-26 11:26:20 +01:00
parent 4026e072d5
commit 52810b0f4a

View File

@@ -2,6 +2,7 @@ require 'spec_helper'
describe EnterprisesController, type: :controller do
describe "shopping for a distributor" do
let(:user) { create(:user) }
let(:order) { controller.current_order(true) }
let(:line_item) { create(:line_item) }
let!(:current_distributor) { create(:distributor_enterprise, with_payment_and_shipping: true) }
@@ -17,10 +18,23 @@ describe EnterprisesController, type: :controller do
it "sets the shop as the distributor on the order when shopping for the distributor" do
spree_get :shop, id: distributor
expect(controller.current_distributor).to eq(distributor)
expect(controller.current_order.distributor).to eq(distributor)
expect(controller.current_order.order_cycle).to be_nil
end
context "when user is logged in" do
before { allow(controller).to receive(:spree_current_user) { user } }
it "sets the shop as the distributor on the order when shopping for the distributor" do
spree_get :shop, id: distributor
expect(controller.current_distributor).to eq(distributor)
expect(controller.current_order.distributor).to eq(distributor)
expect(controller.current_order.order_cycle).to be_nil
end
end
it "sorts order cycles by the distributor's preferred ordering attr" do
distributor.update_attribute(:preferred_shopfront_order_cycle_order, 'orders_close_at')
spree_get :shop, id: distributor
@@ -32,7 +46,6 @@ describe EnterprisesController, type: :controller do
end
context "using FilterOrderCycles tag rules" do
let(:user) { create(:user) }
let!(:order_cycle3) { create(:simple_order_cycle, distributors: [distributor], orders_open_at: 3.days.ago, orders_close_at: 4.days.from_now) }
let!(:oc3_exchange) { order_cycle3.exchanges.outgoing.to_enterprise(distributor).first }
let(:customer) { create(:customer, user: user, enterprise: distributor) }