Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion storefront/templates/app/controllers/carts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,20 @@ def accurate_title

def order_params
if params[:order]
params[:order].permit(*permitted_order_attributes)
params[:order].permit(*permitted_cart_attributes)
else
{}
end
end

def permitted_cart_attributes
permitted_attributes.customer_metadata_attributes +
[
:email,
line_items_attributes: permitted_line_item_attributes,
]
end

def assign_order
@order = current_order
unless @order
Expand Down
10 changes: 10 additions & 0 deletions storefront/templates/spec/requests/carts_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,16 @@

expect(response).to redirect_to checkout_state_path("address")
end

context "when sending payment attributes" do
let(:check) { create(:check_payment_method) }

it "does not allow creating a payment" do
expect {
patch cart_path, params: {order: {payments_attributes: [{amount: 10.0, payment_method_id: check.id}]}}
}.not_to change { order.reload.payments.count }
end
end
end
end

Expand Down
Loading