From 056733a4266101a91f072fd95b3b9b1e43bf2297 Mon Sep 17 00:00:00 2001 From: Rohan Mitchell Date: Sun, 24 Jun 2012 13:48:55 +1000 Subject: [PATCH] Add controller spec for deselecting distributors --- .../distributors_controller_spec.rb | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/spec/controllers/distributors_controller_spec.rb b/spec/controllers/distributors_controller_spec.rb index 68ecef24d0..17a2abab83 100644 --- a/spec/controllers/distributors_controller_spec.rb +++ b/spec/controllers/distributors_controller_spec.rb @@ -4,13 +4,32 @@ require 'spree/core/current_order' describe Spree::DistributorsController do include Spree::Core::CurrentOrder + before do + stub!(:before_save_new_order) + stub!(:after_save_new_order) + end + + it "selects distributors" do d = create(:distributor) spree_get :select, :id => d.id + response.should be_redirect order = current_order(false) order.distributor.should == d + end + + it "deselects distributors" do + d = create(:distributor) + order = current_order(true) + order.distributor = d + order.save! + + spree_get :deselect response.should be_redirect + + order.reload + order.distributor.should be_nil end end