Skip to content

Commit

Permalink
Fix strong params problem where order object is not sent to controller
Browse files Browse the repository at this point in the history
  • Loading branch information
luisramos0 committed Jun 1, 2020
1 parent 1e3bf7f commit a4a6431
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app/controllers/spree/admin/orders_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ def update_distribution_charge
private

def order_params
return params[:order] if params[:order].blank?

params.require(:order).permit(:distributor_id, :order_cycle_id)
end

Expand Down
8 changes: 8 additions & 0 deletions spec/controllers/spree/admin/orders_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@
context "complete order" do
let(:order) { create :completed_order_with_totals }

it "does not throw an error if no order object is given in params" do
params = { id: order }

spree_put :update, params

expect(response.status).to eq 302
end

it "updates distribution charges and redirects to order details page" do
expect_any_instance_of(Spree::Order).to receive(:update_distribution_charge!)

Expand Down

0 comments on commit a4a6431

Please sign in to comment.