Sha256: eefccb4ca43e1319106e07200b7891ff8097c1f965d8013a788784ba377c4dd5

Contents?: true

Size: 1.18 KB

Versions: 6

Compression:

Stored size: 1.18 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')

describe OrdersController do
  before(:each) do
    Variant.stub!(:find).with(any_args).and_return(@variant = mock_model(Variant, :price => 10, :on_hand => 50))
    @order = Order.create
    @token = "TOKEN123"
    @order.token = @token
    @order.save
  end

  describe "create" do
    it "should add the variant to the order" do
      controller.stub!(:object).and_return(@order)
      @order.should_receive(:add_variant).with(@variant, 2)
      post :create, :variants => {"345" => 2}
    end

    it "should not set the state" do
      @order.should_not_receive(:state=)
      post :create, :id => @order.number, :quantities => {456 => "123=1"}, :order => {:state => "paid"}
    end   
  end
  
  describe "update" do
    %w{ship_amount tax_amount item_total total user number ip_address checkout_complete state}.each do |attribute|
      it "should not set #{attribute} with mass assignment" do
        #@order.send(attribute).should_not == "naughty"
        @order.should_not_receive("#{attribute}=".to_sym).with("naughty")
        put :update, "id" => @order.number, "order" => {attribute => "naughty"}
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
spree-0.8.4 spec/controllers/orders_controller_spec.rb
spree-0.8.5 spec/controllers/orders_controller_spec.rb
spree-0.8.0 spec/controllers/orders_controller_spec.rb
spree-0.8.1 spec/controllers/orders_controller_spec.rb
spree-0.8.2 spec/controllers/orders_controller_spec.rb
spree-0.8.3 spec/controllers/orders_controller_spec.rb