mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-30 21:27:17 +00:00
Merge pull request #11488 from macanudo527/fix_helperinstancevariable_2
Fix Rails/HelperInstanceVariable 2
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
# This configuration was generated by
|
||||
# `rubocop --auto-gen-config --auto-gen-only-exclude --exclude-limit 1400 --no-auto-gen-timestamp`
|
||||
# using RuboCop version 1.56.1.
|
||||
# using RuboCop version 1.56.2.
|
||||
# The point is for the user to remove these configuration records
|
||||
# one by one as the offenses are removed from the code base.
|
||||
# Note that changes in the inspected code, or installation of new
|
||||
@@ -186,7 +186,7 @@ Metrics/BlockNesting:
|
||||
Exclude:
|
||||
- 'app/models/spree/payment/processing.rb'
|
||||
|
||||
# Offense count: 43
|
||||
# Offense count: 44
|
||||
# Configuration parameters: CountComments, Max, CountAsOne.
|
||||
Metrics/ClassLength:
|
||||
Exclude:
|
||||
@@ -226,7 +226,6 @@ Metrics/ClassLength:
|
||||
- 'app/services/cart_service.rb'
|
||||
- 'app/services/order_cycle_form.rb'
|
||||
- 'app/services/order_syncer.rb'
|
||||
- 'app/services/sets/product_set.rb'
|
||||
- 'engines/order_management/app/services/order_management/order/updater.rb'
|
||||
- 'lib/open_food_network/enterprise_fee_calculator.rb'
|
||||
- 'lib/open_food_network/order_cycle_form_applicator.rb'
|
||||
@@ -290,7 +289,7 @@ Metrics/MethodLength:
|
||||
- 'lib/spree/localized_number.rb'
|
||||
- 'lib/tasks/sample_data/product_factory.rb'
|
||||
|
||||
# Offense count: 49
|
||||
# Offense count: 48
|
||||
# Configuration parameters: CountComments, Max, CountAsOne.
|
||||
Metrics/ModuleLength:
|
||||
Exclude:
|
||||
@@ -341,7 +340,6 @@ Metrics/ModuleLength:
|
||||
- 'spec/models/spree/tax_rate_spec.rb'
|
||||
- 'spec/services/permissions/order_spec.rb'
|
||||
- 'spec/services/variant_units/option_value_namer_spec.rb'
|
||||
- 'spec/support/request/shop_workflow.rb'
|
||||
- 'spec/support/request/stripe_stubs.rb'
|
||||
|
||||
# Offense count: 7
|
||||
@@ -440,14 +438,12 @@ Rails/HasManyOrHasOneDependent:
|
||||
- 'app/models/spree/user.rb'
|
||||
- 'app/models/spree/variant.rb'
|
||||
|
||||
# Offense count: 59
|
||||
# Offense count: 26
|
||||
# Configuration parameters: Include.
|
||||
# Include: app/helpers/**/*.rb
|
||||
Rails/HelperInstanceVariable:
|
||||
Exclude:
|
||||
- 'app/helpers/application_helper.rb'
|
||||
- 'app/helpers/injection_helper.rb'
|
||||
- 'app/helpers/order_cycles_helper.rb'
|
||||
- 'app/helpers/shared_helper.rb'
|
||||
- 'app/helpers/shop_helper.rb'
|
||||
- 'app/helpers/spree/admin/orders_helper.rb'
|
||||
@@ -523,7 +519,7 @@ Rails/NegateInclude:
|
||||
- 'lib/spree/localized_number.rb'
|
||||
- 'spec/support/matchers/table_matchers.rb'
|
||||
|
||||
# Offense count: 17
|
||||
# Offense count: 16
|
||||
Rails/OutputSafety:
|
||||
Exclude:
|
||||
- 'app/helpers/angular_form_helper.rb'
|
||||
@@ -533,19 +529,16 @@ Rails/OutputSafety:
|
||||
- 'app/helpers/spree/admin/navigation_helper.rb'
|
||||
- 'app/helpers/spree/admin/orders_helper.rb'
|
||||
- 'app/helpers/spree/admin/zones_helper.rb'
|
||||
- 'app/serializers/api/product_serializer.rb'
|
||||
- 'lib/reporting/queries/query_builder.rb'
|
||||
- 'lib/reporting/queries/query_interface.rb'
|
||||
- 'lib/spree/money.rb'
|
||||
|
||||
# Offense count: 29
|
||||
# Offense count: 31
|
||||
# This cop supports unsafe autocorrection (--autocorrect-all).
|
||||
Rails/Pluck:
|
||||
Exclude:
|
||||
- 'app/controllers/admin/variant_overrides_controller.rb'
|
||||
- 'app/helpers/shop_helper.rb'
|
||||
- 'app/services/cart_service.rb'
|
||||
- 'app/services/sets/product_set.rb'
|
||||
- 'lib/reporting/report_headers_builder.rb'
|
||||
- 'spec/controllers/admin/bulk_line_items_controller_spec.rb'
|
||||
- 'spec/controllers/admin/subscriptions_controller_spec.rb'
|
||||
@@ -830,7 +823,7 @@ Style/HashLikeCase:
|
||||
Exclude:
|
||||
- 'app/models/enterprise.rb'
|
||||
|
||||
# Offense count: 1767
|
||||
# Offense count: 1769
|
||||
# This cop supports safe autocorrection (--autocorrect).
|
||||
# Configuration parameters: EnforcedStyle, EnforcedShorthandSyntax, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols.
|
||||
# SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys
|
||||
|
||||
@@ -55,10 +55,10 @@ module ApplicationHelper
|
||||
end
|
||||
end
|
||||
|
||||
def body_classes
|
||||
def body_classes(hide_menu, shopfront_layout)
|
||||
classes = []
|
||||
classes << "off-canvas" unless @hide_menu
|
||||
classes << @shopfront_layout
|
||||
classes << "off-canvas" unless hide_menu
|
||||
classes << shopfront_layout
|
||||
end
|
||||
|
||||
def pdf_stylesheet_pack_tag(source)
|
||||
|
||||
@@ -12,7 +12,7 @@ module InjectionHelper
|
||||
"enterprises",
|
||||
enterprises || default_enterprise_query,
|
||||
Api::EnterpriseSerializer,
|
||||
enterprise_injection_data
|
||||
enterprise_injection_data,
|
||||
)
|
||||
end
|
||||
|
||||
@@ -56,15 +56,16 @@ module InjectionHelper
|
||||
|
||||
inject_json_array "enterprises",
|
||||
enterprises_and_relatives,
|
||||
Api::EnterpriseSerializer, enterprise_injection_data
|
||||
Api::EnterpriseSerializer,
|
||||
enterprise_injection_data
|
||||
end
|
||||
|
||||
def inject_group_enterprises
|
||||
def inject_group_enterprises(group)
|
||||
inject_json_array(
|
||||
"enterprises",
|
||||
@group.enterprises.activated.visible.all,
|
||||
group.enterprises.activated.visible.all,
|
||||
Api::EnterpriseSerializer,
|
||||
enterprise_injection_data
|
||||
enterprise_injection_data,
|
||||
)
|
||||
end
|
||||
|
||||
@@ -105,29 +106,18 @@ module InjectionHelper
|
||||
inject_json "openStreetMapConfig", {}, Api::OpenStreetMapConfigSerializer
|
||||
end
|
||||
|
||||
def inject_spree_api_key
|
||||
def inject_spree_api_key(spree_api_key)
|
||||
render partial: "json/injection_ams",
|
||||
locals: { name: 'spreeApiKey', json: "'#{@spree_api_key}'" }
|
||||
locals: { name: 'spreeApiKey', json: "'#{spree_api_key}'" }
|
||||
end
|
||||
|
||||
def inject_available_countries
|
||||
inject_json_array "availableCountries", available_countries, Api::CountrySerializer
|
||||
end
|
||||
|
||||
def inject_enterprise_attributes
|
||||
def inject_enterprise_attributes(enterprise_attributes)
|
||||
render partial: "json/injection_ams",
|
||||
locals: { name: 'enterpriseAttributes', json: @enterprise_attributes.to_json.to_s }
|
||||
end
|
||||
|
||||
def inject_orders
|
||||
inject_json_array "orders", @orders.all, Api::OrderSerializer
|
||||
end
|
||||
|
||||
def inject_shops
|
||||
customers = spree_current_user.customers
|
||||
shops = Enterprise.where(id: @orders.pluck(:distributor_id).uniq |
|
||||
customers.pluck(:enterprise_id))
|
||||
inject_json_array "shops", shops.all, Api::ShopForOrdersSerializer
|
||||
locals: { name: 'enterpriseAttributes', json: enterprise_attributes.to_json.to_s }
|
||||
end
|
||||
|
||||
def inject_saved_credit_cards
|
||||
|
||||
@@ -55,8 +55,8 @@ module OrderCyclesHelper
|
||||
end
|
||||
end
|
||||
|
||||
def active_order_cycle_for_distributor?(_distributor)
|
||||
OrderCycle.active.with_distributor(@distributor).present?
|
||||
def active_order_cycle_for_distributor?(distributor)
|
||||
OrderCycle.active.with_distributor(distributor).present?
|
||||
end
|
||||
|
||||
def simple_index
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module ShopHelper
|
||||
def oc_select_options
|
||||
@order_cycles.map { |oc| { time: pickup_time(oc), id: oc.id } }
|
||||
def oc_select_options(order_cycles)
|
||||
order_cycles.map { |oc| { time: pickup_time(oc), id: oc.id } }
|
||||
end
|
||||
|
||||
def require_customer?
|
||||
@@ -40,20 +40,17 @@ module ShopHelper
|
||||
}
|
||||
end
|
||||
|
||||
def shop_tab_names
|
||||
shop_tabs.map { |tab| tab[:name] }
|
||||
end
|
||||
|
||||
def show_home_tab?
|
||||
require_customer? || current_distributor.preferred_shopfront_message.present?
|
||||
end
|
||||
|
||||
def shopfront_closed_message?
|
||||
no_open_order_cycles? && current_distributor.preferred_shopfront_closed_message.present?
|
||||
def shopfront_closed_message?(order_cycles)
|
||||
no_open_order_cycles?(order_cycles) && \
|
||||
current_distributor.preferred_shopfront_closed_message.present?
|
||||
end
|
||||
|
||||
def no_open_order_cycles?
|
||||
@no_open_order_cycles ||= @order_cycles&.empty?
|
||||
def no_open_order_cycles?(order_cycles)
|
||||
@no_open_order_cycles ||= order_cycles&.empty?
|
||||
end
|
||||
|
||||
def show_shopping_cta?
|
||||
|
||||
@@ -14,15 +14,15 @@
|
||||
.select-label
|
||||
%span= t :enterprises_ready_for
|
||||
|
||||
- if oc_select_options.count == 1
|
||||
- if oc_select_options(@order_cycles).count == 1
|
||||
%p
|
||||
= oc_select_options.first[:time]
|
||||
= oc_select_options(@order_cycles).first[:time]
|
||||
|
||||
- else
|
||||
%select.select2.avenir#order_cycle_id{"ng-model" => "order_cycle.order_cycle_id",
|
||||
"ofn-change-order-cycle" => true,
|
||||
"disabled" => require_customer?,
|
||||
"ng-options" => "oc.id as oc.time for oc in #{oc_select_options.to_json}"}
|
||||
"ng-options" => "oc.id as oc.time for oc in #{oc_select_options(@order_cycles).to_json}"}
|
||||
|
||||
- if oc_select_options.count > 1
|
||||
- if oc_select_options(@order_cycles).count > 1
|
||||
%option{value: "", disabled: "", selected: ""}= t :shopping_oc_select
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
- content_for :injection_data do
|
||||
= inject_available_countries
|
||||
= inject_group_enterprises
|
||||
= inject_group_enterprises(@group)
|
||||
= inject_open_street_map_config
|
||||
- cache(*CacheService::FragmentCaching.ams_all_taxons) do
|
||||
= inject_taxons
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
|
||||
= action_cable_meta_tag
|
||||
|
||||
%body{ class: body_classes, "body-scroll": "true", "data-turbo": "false" }
|
||||
%body{ class: body_classes(@hide_menu, @shopfront_layout), "body-scroll": "true", "data-turbo": "false" }
|
||||
.off-canvas-wrap{ offcanvas: true }
|
||||
.fixed.off-canvas-fixed
|
||||
= render "shared/menu/menu" unless @hide_menu
|
||||
|
||||
@@ -5,9 +5,9 @@
|
||||
= render partial: "shared/google_maps_js"
|
||||
|
||||
- content_for :injection_data do
|
||||
= inject_spree_api_key
|
||||
= inject_spree_api_key(@spree_api_key)
|
||||
= inject_available_countries
|
||||
= inject_enterprise_attributes
|
||||
= inject_enterprise_attributes(@enterprise_attributes)
|
||||
|
||||
- steps = %w{about contact details finished images introduction}
|
||||
- steps += %w{logo promo social steps type}
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
.small-12.columns
|
||||
.content
|
||||
.shopfront_closed_message
|
||||
- if shopfront_closed_message?
|
||||
- if shopfront_closed_message?(@order_cycles)
|
||||
= current_distributor.preferred_shopfront_closed_message.html_safe
|
||||
- else
|
||||
= t :shopping_oc_closed_description
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
- content_for :injection_data do
|
||||
= inject_current_order_cycle
|
||||
|
||||
- unless no_open_order_cycles? || require_customer?
|
||||
- unless no_open_order_cycles?(@order_cycles) || require_customer?
|
||||
%ordercycle{"ng-controller" => "OrderCycleCtrl", "ng-cloak" => true,
|
||||
"ng-class" => "{'requires-selection': !OrderCycle.selected()}"}
|
||||
%form.custom
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
= render partial: "shop/messages/customer_required"
|
||||
|
||||
- else
|
||||
- if no_open_order_cycles?
|
||||
- if no_open_order_cycles?(@order_cycles)
|
||||
= render partial: "shop/messages/closed_shop"
|
||||
|
||||
- else
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
= render partial: "shopping_shared/order_cycles"
|
||||
|
||||
%div{"ng-controller" => "ProductsCtrl"}
|
||||
- if no_open_order_cycles?
|
||||
- if no_open_order_cycles?(@order_cycles)
|
||||
= render partial: "shop/messages/closed_shop"
|
||||
- else
|
||||
= render partial: "shop/messages/select_oc"
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
= t :orders_oc_expired_headline
|
||||
|
||||
%p
|
||||
- if active_order_cycle_for_distributor? current_distributor
|
||||
- if active_order_cycle_for_distributor? @distributor
|
||||
= t :orders_oc_expired_text_others_html, time: distance_of_time_in_words_to_now(@order_cycle.orders_close_at), link: link_to t(:orders_oc_expired_text_link), spree.clear_orders_path
|
||||
- else
|
||||
= t :orders_oc_expired_text, time: distance_of_time_in_words_to_now(@order_cycle.orders_close_at)
|
||||
|
||||
Reference in New Issue
Block a user