Able to submit Checkout form via Ajax

This commit is contained in:
Will Marshall
2014-04-09 15:31:15 +10:00
parent 36a4e34dff
commit 873de1d118
3 changed files with 4 additions and 3 deletions

View File

@@ -10,7 +10,7 @@ Darkswarm.factory 'Order', ($resource, Product, order, $http)->
submit: ->
$http.put('/shop/checkout', {order: @preprocess()}).success (data, status)=>
console.log data
# Navigate to order confirmation
window.location.pathname = data.path
.error (errors, status)=>
console.log "error"
@errors = errors
@@ -23,6 +23,8 @@ Darkswarm.factory 'Order', ($resource, Product, order, $http)->
munged_order["bill_address_attributes"] = value
else if name == "ship_address"
munged_order["ship_address_attributes"] = value
else if name == "payment_method_id"
munged_order["payments_attributes"] = [{payment_method_id: value}]
else
munged_order[name] = value
munged_order

View File

@@ -23,7 +23,7 @@
"ng-model" => "order.bill_address.city"
.large-6.columns
= ba.select :state_id, @order.billing_address.country.states.map{|c|[c.name, c.id]},
= ba.select :state_id, @order.billing_address.country.states.map{|c|[c.name, c.id]}, {include_blank: false},
"ng-model" => "order.bill_address.state_id"
.row
.large-6.columns

View File

@@ -94,7 +94,6 @@ describe Shop::CheckoutController do
it "returns order confirmation url on success" do
order.stub(:update_attributes).and_return true
order.stub(:state).and_return "complete"
#order.stub(:completed?).and_return true
xhr :post, :update, order: {}, use_route: :spree
response.status.should == 200