Skip to content

Commit

Permalink
Make enterprises controller spec assert the corrrect state of current…
Browse files Browse the repository at this point in the history
…_distributor

This validates bug #5496 is fixed
  • Loading branch information
luisramos0 committed May 26, 2020
1 parent 4026e07 commit 52810b0
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion spec/controllers/enterprises_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

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) }
Expand All @@ -17,10 +18,23 @@
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
Expand All @@ -32,7 +46,6 @@
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) }
Expand Down

0 comments on commit 52810b0

Please sign in to comment.