Skip to content
Open
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
6 changes: 3 additions & 3 deletions admin/app/controllers/solidus_admin/orders_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def new
end

def show
load_order
load_order(Spree::Order.includes(line_items: {variant: [:images, {product: :variant_images, option_values: :option_type}]}))
Comment thread
ikraamg marked this conversation as resolved.

respond_to do |format|
format.html { render component("orders/show").new(order: @order) }
Expand Down Expand Up @@ -111,8 +111,8 @@ def customers_for

private

def load_order
@order = Spree::Order.find_by!(number: params[:id])
def load_order(scope = Spree::Order)
@order = scope.find_by!(number: params[:id])
authorize! action_name, @order
end

Expand Down
26 changes: 26 additions & 0 deletions admin/spec/requests/solidus_admin/orders_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# frozen_string_literal: true

require "spec_helper"
Comment thread
ikraamg marked this conversation as resolved.

RSpec.describe "SolidusAdmin::OrdersController", type: :request do
Comment thread
ikraamg marked this conversation as resolved.
let(:admin_user) { create(:admin_user) }

before do
allow(SolidusAdmin::Config).to receive(:enable_alpha_features?).and_return(true)
Comment thread
ikraamg marked this conversation as resolved.
allow_any_instance_of(SolidusAdmin::BaseController).to receive(:spree_current_user).and_return(admin_user)
Comment thread
ikraamg marked this conversation as resolved.
end

describe "GET #show" do
Comment thread
ikraamg marked this conversation as resolved.
let(:order) { create(:completed_order_with_totals, line_items_count: 3) }

it "renders successfully" do
Comment thread
ikraamg marked this conversation as resolved.
get solidus_admin.order_path(order)
expect(response).to have_http_status(:ok)
end

it "loads line item variants in a single query" do
Comment thread
ikraamg marked this conversation as resolved.
expect { get solidus_admin.order_path(order) }
.to make_database_queries(matching: /from .spree_variants..*\bid. IN \(/im, count: 1)
Comment thread
ikraamg marked this conversation as resolved.
end
end
end
Loading