Skip to content

Commit

Permalink
Use the main order route to show the order in /admin
Browse files Browse the repository at this point in the history
  • Loading branch information
elia committed Nov 3, 2023
1 parent 52adbbc commit 2359723
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
6 changes: 3 additions & 3 deletions admin/app/controllers/solidus_admin/line_items_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def destroy

@line_item.destroy!

redirect_to cart_order_path(@order), status: :see_other, notice: t('.success')
redirect_to order_path(@order), status: :see_other, notice: t('.success')
end

def create
Expand All @@ -17,7 +17,7 @@ def create
@variant = Spree::Variant.find(variant_id)
@line_item = @order.contents.add(@variant)

redirect_to cart_order_path(@order), status: :see_other, notice: t('.success')
redirect_to order_path(@order), status: :see_other, notice: t('.success')
end

def update
Expand All @@ -28,7 +28,7 @@ def update

@line_item = @order.contents.add(@line_item.variant, desired_quantity - @line_item.quantity)

redirect_to cart_order_path(@order), status: :see_other, notice: t('.success')
redirect_to order_path(@order), status: :see_other, notice: t('.success')
end

private
Expand Down
4 changes: 4 additions & 0 deletions admin/app/controllers/solidus_admin/orders_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ def show
end
end

def edit
redirect_to action: :show
end

def variants_for
load_order

Expand Down
3 changes: 1 addition & 2 deletions admin/config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,10 @@
get 'states', to: 'countries#states'
end

resources :orders, only: [:index] do
resources :orders, only: [:index, :show, :edit] do
resources :line_items, only: [:destroy, :create, :update]

member do
get :cart, to: "orders#show"
get :variants_for
end
end
Expand Down
3 changes: 2 additions & 1 deletion admin/spec/features/order_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
create(:product, name: "Just another product", slug: 'just-another-prod', price: 29.99)
create(:order, number: "R123456789", total: 19.99, state: "cart")

visit "/admin/orders/R123456789/cart"
visit "/admin/orders/R123456789/edit"
expect(page).to have_current_path("/admin/orders/R123456789")

expect(page).to have_content("Order R123456789")

Expand Down

0 comments on commit 2359723

Please sign in to comment.