From cdf71b419fdbda1b72da11e603c7720c27d0c531 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Bellet Date: Mon, 19 Sep 2022 17:36:07 +0200 Subject: [PATCH] Search within all enterprises if user is the super admin --- app/controllers/spree/admin/search_controller.rb | 7 ++++++- spec/system/admin/order_spec.rb | 1 - 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/controllers/spree/admin/search_controller.rb b/app/controllers/spree/admin/search_controller.rb index 1ddb023b3a..df96618fc0 100644 --- a/app/controllers/spree/admin/search_controller.rb +++ b/app/controllers/spree/admin/search_controller.rb @@ -19,7 +19,12 @@ module Spree def customers @customers = [] - if spree_current_user.enterprises.pluck(:id).include? search_params[:distributor_id].to_i + enterprise_ids = if spree_current_user.admin? + Enterprise.pluck(:id) + else + spree_current_user.enterprises.pluck(:id) + end + if enterprise_ids.include? search_params[:distributor_id].to_i @customers = Customer. ransack(m: 'or', email_start: search_params[:q], first_name_start: search_params[:q], last_name_start: search_params[:q]). diff --git a/spec/system/admin/order_spec.rb b/spec/system/admin/order_spec.rb index c25d5c13c1..ef43bd5b2d 100644 --- a/spec/system/admin/order_spec.rb +++ b/spec/system/admin/order_spec.rb @@ -755,7 +755,6 @@ describe ' end it "finds a customer by name" do - pending("issue #9684") serching_for_customers end end