From ac1595e718fd1bf15eeec1503fa6bdcc4fa83489 Mon Sep 17 00:00:00 2001 From: Ahmed Ejaz Date: Sun, 31 Mar 2024 18:08:22 +0500 Subject: [PATCH] 12314 - remove shared distributor partial - this was only used in the enterprise show view - the above view was deleted here 4f2389e25766a59846e6c13e28064c5bb7242897 - by removing this, we can remove distributor_link_class method - it will also fix the rubocop error --- app/helpers/shared_helper.rb | 10 --------- app/views/shared/_distributor.html.haml | 3 --- spec/helpers/shared_helper_spec.rb | 27 ------------------------- 3 files changed, 40 deletions(-) delete mode 100644 app/views/shared/_distributor.html.haml delete mode 100644 spec/helpers/shared_helper_spec.rb diff --git a/app/helpers/shared_helper.rb b/app/helpers/shared_helper.rb index 17bd12adbe..63e5498409 100644 --- a/app/helpers/shared_helper.rb +++ b/app/helpers/shared_helper.rb @@ -1,16 +1,6 @@ # frozen_string_literal: true module SharedHelper - def distributor_link_class(distributor) - cart = current_order(true) - @active_distributors ||= Enterprise.distributors_with_active_order_cycles - - klass = "shop-distributor" - klass += " empties-cart" unless cart.line_items.empty? || cart.distributor == distributor - klass += @active_distributors.include?(distributor) ? ' active' : ' inactive' - klass - end - def enterprise_user? spree_current_user&.enterprises&.count.to_i > 0 end diff --git a/app/views/shared/_distributor.html.haml b/app/views/shared/_distributor.html.haml deleted file mode 100644 index ea1eeae0a4..0000000000 --- a/app/views/shared/_distributor.html.haml +++ /dev/null @@ -1,3 +0,0 @@ -= succeed ',' do - = link_to "#{distributor.name}".html_safe, enterprise_shop_path(distributor), {class: distributor_link_class(distributor)} -%span.secondary= distributor.city diff --git a/spec/helpers/shared_helper_spec.rb b/spec/helpers/shared_helper_spec.rb deleted file mode 100644 index 7d61898f93..0000000000 --- a/spec/helpers/shared_helper_spec.rb +++ /dev/null @@ -1,27 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -describe SharedHelper, type: :helper do - it "does not require emptying the cart when it is empty" do - d = double(:distributor) - order = double(:order, line_items: []) - allow(helper).to receive(:current_order) { order } - expect(helper.distributor_link_class(d)).not_to match(/empties-cart/) - end - - it "does not require emptying the cart when we are on the same distributor" do - d = double(:distributor) - order = double(:order, line_items: [double(:line_item)], distributor: d) - allow(helper).to receive(:current_order) { order } - expect(helper.distributor_link_class(d)).not_to match(/empties-cart/) - end - - it "requires emptying the cart otherwise" do - d1 = double(:distributor) - d2 = double(:distributor) - order = double(:order, line_items: [double(:line_item)], distributor: d2) - allow(helper).to receive(:current_order) { order } - expect(helper.distributor_link_class(d1)).to match(/empties-cart/) - end -end