diff --git a/spec/archive/controllers/home_controller_spec.rb b/spec/archive/controllers/home_controller_spec.rb deleted file mode 100644 index 18be4a0700..0000000000 --- a/spec/archive/controllers/home_controller_spec.rb +++ /dev/null @@ -1,80 +0,0 @@ -require 'spec_helper' - -describe Spree::HomeController do - it "loads products" do - product = create(:product) - spree_get :index - assigns(:products).should == [product] - assigns(:products_local).should be_nil - assigns(:products_remote).should be_nil - end - - it "splits products by local/remote distributor when distributor is selected" do - # Given two distributors with a product under each - d1 = create(:distributor_enterprise) - d2 = create(:distributor_enterprise) - p1 = create(:product, :distributors => [d1]) - p2 = create(:product, :distributors => [d2]) - - # And the first distributor is selected - controller.stub(:current_distributor).and_return(d1) - - # When I fetch the home page, the products should be split by local/remote distributor - spree_get :index - assigns(:products).should be_nil - assigns(:products_local).should == [p1] - assigns(:products_remote).should == [p2] - end - - context "BaseController: merging incomplete orders" do - it "loads the incomplete order when there is no current order" do - incomplete_order = double(:order, id: 1, distributor: 2, order_cycle: 3) - current_order = nil - - user = double(:user, last_incomplete_spree_order: incomplete_order) - controller.stub(:try_spree_current_user).and_return(user) - controller.stub(:current_order).and_return(current_order) - - incomplete_order.should_receive(:destroy).never - incomplete_order.should_receive(:merge!).never - - session[:order_id] = nil - spree_get :index - session[:order_id].should == incomplete_order.id - end - - it "destroys the incomplete order when there is a current order" do - oc = double(:order_cycle, closed?: false) - incomplete_order = double(:order, distributor: 1, order_cycle: oc) - current_order = double(:order, distributor: 1, order_cycle: oc) - - user = double(:user, last_incomplete_spree_order: incomplete_order) - controller.stub(:try_spree_current_user).and_return(user) - controller.stub(:current_order).and_return(current_order) - - incomplete_order.should_receive(:destroy) - incomplete_order.should_receive(:merge!).never - current_order.should_receive(:merge!).never - - session[:order_id] = 123 - - spree_get :index - end - end - - context "StoreController: handling order cycles expiring mid-order" do - it "clears the order and displays an expiry message" do - oc = double(:order_cycle, id: 123, closed?: true) - controller.stub(:current_order_cycle) { oc } - - order = double(:order) - order.should_receive(:empty!) - order.should_receive(:set_order_cycle!).with(nil) - controller.stub(:current_order) { order } - - spree_get :index - session[:expired_order_cycle_id].should == 123 - response.should redirect_to spree.order_cycle_expired_orders_path - end - end -end diff --git a/spec/features/consumer/shopping/checkout_spec.rb b/spec/features/consumer/shopping/checkout_spec.rb index f7cdf78fa9..82db9069b6 100644 --- a/spec/features/consumer/shopping/checkout_spec.rb +++ b/spec/features/consumer/shopping/checkout_spec.rb @@ -18,122 +18,115 @@ feature "As a consumer I want to check out my cart", js: true do create_enterprise_group_for distributor end - # Disabled :in for performance reasons - [:out].each do |auth_state| - describe "logged #{auth_state.to_s}, distributor selected, order cycle selected, product in cart" do - let(:user) { create_enterprise_user } + describe "logged #{auth_state.to_s}, distributor selected, order cycle selected, product in cart" do + let(:user) { create_enterprise_user } + before do + select_distributor + select_order_cycle + add_product_to_cart + end + + describe "with shipping methods" do + let(:sm1) { create(:shipping_method, require_ship_address: true, name: "Frogs", description: "yellow") } + let(:sm2) { create(:shipping_method, require_ship_address: false, name: "Donkeys", description: "blue") } before do - if auth_state == :in - login_to_consumer_section - end - select_distributor - select_order_cycle - add_product_to_cart + distributor.shipping_methods << sm1 + distributor.shipping_methods << sm2 end - describe "with shipping methods" do - let(:sm1) { create(:shipping_method, require_ship_address: true, name: "Frogs", description: "yellow") } - let(:sm2) { create(:shipping_method, require_ship_address: false, name: "Donkeys", description: "blue") } + context "on the checkout page" do before do - distributor.shipping_methods << sm1 - distributor.shipping_methods << sm2 + visit "/shop/checkout" + end + it "shows all shipping methods, but doesn't show ship address when not needed" do + toggle_accordion "Shipping" + page.should have_content "Frogs" + page.should have_content "Donkeys" end - context "on the checkout page" do + context "When shipping method requires an address" do before do - visit "/shop/checkout" - end - it "shows all shipping methods, but doesn't show ship address when not needed" do toggle_accordion "Shipping" - page.should have_content "Frogs" - page.should have_content "Donkeys" + choose(sm1.name) end - - context "When shipping method requires an address" do - before do - toggle_accordion "Shipping" - choose(sm1.name) - end - it "shows ship address forms when 'same as billing address' is unchecked" do - uncheck "Shipping address same as billing address?" - find("#ship_address > div.visible").visible?.should be_true - end + it "shows ship address forms when 'same as billing address' is unchecked" do + uncheck "Shipping address same as billing address?" + find("#ship_address > div.visible").visible?.should be_true end end + end - describe "with payment methods" do - let(:pm1) { create(:payment_method, distributors: [distributor], name: "Roger rabbit", type: "Spree::PaymentMethod::Check") } - let(:pm2) { create(:payment_method, distributors: [distributor]) } - let(:pm3) { create(:payment_method, distributors: [distributor], name: "Paypal", type: "Spree::BillingIntegration::PaypalExpress") } + describe "with payment methods" do + let(:pm1) { create(:payment_method, distributors: [distributor], name: "Roger rabbit", type: "Spree::PaymentMethod::Check") } + let(:pm2) { create(:payment_method, distributors: [distributor]) } + let(:pm3) { create(:payment_method, distributors: [distributor], name: "Paypal", type: "Spree::BillingIntegration::PaypalExpress") } - before do - pm1 # Lazy evaluation of ze create()s - pm2 - visit "/shop/checkout" + before do + pm1 # Lazy evaluation of ze create()s + pm2 + visit "/shop/checkout" + toggle_accordion "Payment Details" + end + + it "shows all available payment methods" do + page.should have_content pm1.name + page.should have_content pm2.name + end + + describe "Purchasing" do + it "takes us to the order confirmation page when we submit a complete form" do + toggle_accordion "Shipping" + choose sm2.name toggle_accordion "Payment Details" + choose pm1.name + toggle_accordion "Customer Details" + within "#details" do + fill_in "First Name", with: "Will" + fill_in "Last Name", with: "Marshall" + fill_in "Email", with: "test@test.com" + fill_in "Phone", with: "0468363090" + end + toggle_accordion "Billing" + within "#billing" do + fill_in "Address", with: "123 Your Face" + select "Australia", from: "Country" + select "Victoria", from: "State" + fill_in "City", with: "Melbourne" + fill_in "Postcode", with: "3066" + end + click_button "Purchase" + sleep 10 + page.should have_content "Your order has been processed successfully" end - it "shows all available payment methods" do - page.should have_content pm1.name - page.should have_content pm2.name - end - - describe "Purchasing" do - it "takes us to the order confirmation page when we submit a complete form" do - toggle_accordion "Shipping" - choose sm2.name - toggle_accordion "Payment Details" - choose pm1.name - toggle_accordion "Customer Details" - within "#details" do - fill_in "First Name", with: "Will" - fill_in "Last Name", with: "Marshall" - fill_in "Email", with: "test@test.com" - fill_in "Phone", with: "0468363090" - end - toggle_accordion "Billing" - within "#billing" do - fill_in "Address", with: "123 Your Face" - select "Australia", from: "Country" - select "Victoria", from: "State" - fill_in "City", with: "Melbourne" - fill_in "Postcode", with: "3066" - end - click_button "Purchase" - sleep 10 - page.should have_content "Your order has been processed successfully" + it "takes us to the order confirmation page when submitted with 'same as billing address' checked" do + toggle_accordion "Shipping" + choose sm1.name + toggle_accordion "Payment Details" + choose pm1.name + toggle_accordion "Customer Details" + within "#details" do + fill_in "First Name", with: "Will" + fill_in "Last Name", with: "Marshall" + fill_in "Email", with: "test@test.com" + fill_in "Phone", with: "0468363090" end - - it "takes us to the order confirmation page when submitted with 'same as billing address' checked" do - toggle_accordion "Shipping" - choose sm1.name - toggle_accordion "Payment Details" - choose pm1.name - toggle_accordion "Customer Details" - within "#details" do - fill_in "First Name", with: "Will" - fill_in "Last Name", with: "Marshall" - fill_in "Email", with: "test@test.com" - fill_in "Phone", with: "0468363090" - end - toggle_accordion "Billing" - within "#billing" do - fill_in "City", with: "Melbourne" - fill_in "Postcode", with: "3066" - fill_in "Address", with: "123 Your Face" - select "Australia", from: "Country" - select "Victoria", from: "State" - end - toggle_accordion "Shipping" - check "Shipping address same as billing address?" - click_button "Purchase" - sleep 10 - page.should have_content "Your order has been processed successfully" + toggle_accordion "Billing" + within "#billing" do + fill_in "City", with: "Melbourne" + fill_in "Postcode", with: "3066" + fill_in "Address", with: "123 Your Face" + select "Australia", from: "Country" + select "Victoria", from: "State" end + toggle_accordion "Shipping" + check "Shipping address same as billing address?" + click_button "Purchase" + sleep 10 + page.should have_content "Your order has been processed successfully" end end end end - end end