Skip to content

Instantly share code, notes, and snippets.

@mribbons
Created July 16, 2013 03:02
Show Gist options
  • Save mribbons/6005434 to your computer and use it in GitHub Desktop.
Save mribbons/6005434 to your computer and use it in GitHub Desktop.
context "create order" do
current_api_user = Spree.user_class.new(:email => "[email protected]")
#current_api_user.email =
current_api_user.generate_spree_api_key!
#current_api_user.save
puts "User: #{current_api_user.inspect}"
it "can create an order" do
variant = create(:variant)
api_post :create, :order => { :line_items => { "0" => { :variant_id => variant.to_param, :quantity => 5 } }, :token => current_api_user.spree_api_key }
response.status.should == 201
order = Order.last
order.line_items.count.should == 1
order.line_items.first.variant.should == variant
order.line_items.first.quantity.should == 5
json_response["state"].should == "cart"
json_response["user_id"].should == current_api_user.id
order.user.should == current_api_user
#order.email == current_api_user.email
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment