Bump RuboCop to 1.86.6

There were a few changes needed:

* Plugins are now specified through `plugin:` config keyword.
* All plugin gems need to be specified explicitly in Gemfile since they
  are no longer dependencies of plugins already specified explicitly.
* All plugin gems need to be updated in other to use the new APIs.
* One cop was renamed.
* New offenses safe to correct were corrected directly with `bundle exec
  rubocop -a`.
* New offenses unsafe to correct were added to the TODO configuration
  with `bundle exec rubocop --auto-gen-config --auto-gen-only-exclude
  --exclude-limit 1400 --no-auto-gen-timestamp`.
This commit is contained in:
David Rodríguez
2025-10-27 11:21:07 +01:00
parent 7415503b63
commit 4c6d894bc0
54 changed files with 298 additions and 105 deletions

View File

@@ -4,7 +4,7 @@
# #
# The configuration is split into three files. Look into those files for more details. # The configuration is split into three files. Look into those files for more details.
# #
require: plugins:
- rubocop-capybara - rubocop-capybara
- rubocop-factory_bot - rubocop-factory_bot
- rubocop-rails - rubocop-rails

View File

@@ -94,7 +94,7 @@ Metrics/PerceivedComplexity:
Enabled: true Enabled: true
Max: 14 # default 8 Max: 14 # default 8
Naming/PredicateName: Naming/PredicatePrefix:
Enabled: false Enabled: false
Naming/VariableNumber: Naming/VariableNumber:

View File

@@ -1,11 +1,44 @@
# This configuration was generated by # This configuration was generated by
# `rubocop --auto-gen-config --auto-gen-only-exclude --exclude-limit 1400 --no-auto-gen-timestamp` # `rubocop --auto-gen-config --auto-gen-only-exclude --exclude-limit 1400 --no-auto-gen-timestamp`
# using RuboCop version 1.64.1. # using RuboCop version 1.81.6.
# The point is for the user to remove these configuration records # The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base. # one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new # Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again. # versions of RuboCop, may require this file to be generated again.
# Offense count: 1
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: RequireParenthesesForMethodChains.
Lint/AmbiguousRange:
Exclude:
- 'app/models/concerns/permalink_generator.rb'
# Offense count: 6
Lint/CopDirectiveSyntax:
Exclude:
- 'app/services/orders/bulk_cancel_service.rb'
- 'lib/tasks/simplecov.rake'
- 'spec/models/database_spec.rb'
- 'spec/system/admin/bulk_order_management_spec.rb'
- 'spec/system/admin/enterprise_relationships_spec.rb'
# Offense count: 2
Lint/DuplicateMethods:
Exclude:
- 'app/models/spree/order.rb'
- 'engines/order_management/app/services/order_management/subscriptions/form.rb'
# Offense count: 3
Lint/UselessConstantScoping:
Exclude:
- 'app/services/weights_and_measures.rb'
- 'lib/reporting/report_metadata_builder.rb'
# Offense count: 1
Lint/UselessOr:
Exclude:
- 'app/models/product_import/entry_validator.rb'
# Offense count: 24 # Offense count: 24
# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes, Max. # Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes, Max.
Metrics/AbcSize: Metrics/AbcSize:
@@ -42,7 +75,7 @@ Metrics/BlockLength:
- 'lib/tasks/data.rake' - 'lib/tasks/data.rake'
# Offense count: 1 # Offense count: 1
# Configuration parameters: CountBlocks, Max. # Configuration parameters: CountBlocks, CountModifierForms, Max.
Metrics/BlockNesting: Metrics/BlockNesting:
Exclude: Exclude:
- 'app/models/spree/payment/processing.rb' - 'app/models/spree/payment/processing.rb'
@@ -182,8 +215,9 @@ Metrics/PerceivedComplexity:
- 'app/models/spree/order/checkout.rb' - 'app/models/spree/order/checkout.rb'
# Offense count: 1 # Offense count: 1
# Configuration parameters: EnforcedStyle, AllowedPatterns. # Configuration parameters: EnforcedStyle, AllowedPatterns, ForbiddenIdentifiers, ForbiddenPatterns.
# SupportedStyles: snake_case, camelCase # SupportedStyles: snake_case, camelCase
# ForbiddenIdentifiers: __id__, __send__
Naming/MethodName: Naming/MethodName:
Exclude: Exclude:
- 'engines/dfc_provider/lib/dfc_provider/catalog_item.rb' - 'engines/dfc_provider/lib/dfc_provider/catalog_item.rb'
@@ -195,23 +229,132 @@ Naming/MethodParameterName:
Exclude: Exclude:
- 'engines/dfc_provider/lib/dfc_provider/catalog_item.rb' - 'engines/dfc_provider/lib/dfc_provider/catalog_item.rb'
# Offense count: 59
# Configuration parameters: Mode, AllowedMethods, AllowedPatterns, AllowBangMethods, WaywardPredicates.
# AllowedMethods: call
# WaywardPredicates: nonzero?
Naming/PredicateMethod:
Exclude:
- 'app/controllers/admin/product_import_controller.rb'
- 'app/controllers/api/v0/order_cycles_controller.rb'
- 'app/controllers/spree/admin/overview_controller.rb'
- 'app/controllers/spree/admin/payments_controller.rb'
- 'app/controllers/voucher_adjustments_controller.rb'
- 'app/forms/enterprise_fees_bulk_update.rb'
- 'app/forms/schedule_form.rb'
- 'app/helpers/spree/orders_helper.rb'
- 'app/models/concerns/variant_stock.rb'
- 'app/models/enterprise.rb'
- 'app/models/enterprise_fee.rb'
- 'app/models/invoice/data_presenter.rb'
- 'app/models/order_cycle.rb'
- 'app/models/product_import/entry_processor.rb'
- 'app/models/product_import/entry_validator.rb'
- 'app/models/spree/order.rb'
- 'app/models/spree/order_contents.rb'
- 'app/models/spree/payment.rb'
- 'app/models/spree/payment/processing.rb'
- 'app/models/spree/state_change.rb'
- 'app/models/spree/user.rb'
- 'app/reflexes/admin/orders_reflex.rb'
- 'app/serializers/api/admin/for_order_cycle/enterprise_serializer.rb'
- 'app/serializers/api/admin/index_enterprise_serializer.rb'
- 'app/serializers/api/admin/index_order_cycle_serializer.rb'
- 'app/serializers/api/admin/order_cycle_serializer.rb'
- 'app/serializers/api/admin/order_serializer.rb'
- 'app/serializers/api/admin/schedule_serializer.rb'
- 'app/serializers/api/admin/subscription_line_item_serializer.rb'
- 'app/serializers/api/admin/user_serializer.rb'
- 'app/serializers/api/admin/variant_serializer.rb'
- 'app/serializers/api/enterprise_shopfront_serializer.rb'
- 'app/serializers/api/enterprise_thin_serializer.rb'
- 'app/serializers/api/order_serializer.rb'
- 'app/serializers/api/uncached_enterprise_serializer.rb'
- 'app/services/cart_service.rb'
- 'app/services/orders/fetch_adjustments_service.rb'
- 'app/services/orders/workflow_service.rb'
- 'app/services/sets/model_set.rb'
- 'app/services/sets/order_cycle_set.rb'
- 'app/services/sets/product_set.rb'
- 'engines/dfc_provider/app/controllers/dfc_provider/addresses_controller.rb'
- 'lib/open_food_network/order_cycle_form_applicator.rb'
- 'lib/open_food_network/order_cycle_permissions.rb'
- 'lib/reporting/reports/enterprise_fee_summary/enterprise_fees_with_tax_report_by_order.rb'
- 'lib/reporting/reports/enterprise_fee_summary/enterprise_fees_with_tax_report_by_producer.rb'
- 'lib/tasks/data/check_invalid_address_used.rake'
# Offense count: 3 # Offense count: 3
# Configuration parameters: EnforcedStyle, AllowedIdentifiers, AllowedPatterns. # Configuration parameters: EnforcedStyle, AllowedIdentifiers, AllowedPatterns, ForbiddenIdentifiers, ForbiddenPatterns.
# SupportedStyles: snake_case, camelCase # SupportedStyles: snake_case, camelCase
Naming/VariableName: Naming/VariableName:
Exclude: Exclude:
- 'engines/dfc_provider/lib/dfc_provider/catalog_item.rb' - 'engines/dfc_provider/lib/dfc_provider/catalog_item.rb'
# Offense count: 6
# This cop supports unsafe autocorrection (--autocorrect-all).
Rails/FindByOrAssignmentMemoization:
Exclude:
- 'app/controllers/admin/customers_controller.rb'
- 'app/controllers/admin/resource_controller.rb'
- 'app/controllers/api/v0/enterprise_fees_controller.rb'
- 'app/controllers/api/v0/order_cycles_controller.rb'
- 'lib/stripe/account_connector.rb'
# Offense count: 32
# This cop supports unsafe autocorrection (--autocorrect-all).
Rails/OrderArguments:
Exclude:
- 'app/controllers/admin/enterprise_fees_controller.rb'
- 'app/controllers/admin/enterprises_controller.rb'
- 'app/controllers/admin/order_cycles_controller.rb'
- 'app/controllers/admin/product_import_controller.rb'
- 'app/controllers/api/v0/states_controller.rb'
- 'app/controllers/spree/admin/overview_controller.rb'
- 'app/controllers/spree/admin/products_controller.rb'
- 'app/helpers/enterprises_helper.rb'
- 'app/models/enterprise.rb'
- 'app/models/enterprise_group.rb'
- 'app/models/enterprise_relationship_permission.rb'
- 'app/models/order_cycle.rb'
- 'app/models/product_import/product_importer.rb'
- 'app/models/schedule.rb'
- 'app/models/spree/country.rb'
- 'app/models/spree/order.rb'
- 'app/models/spree/shipping_rate.rb'
- 'app/models/spree/user.rb'
- 'app/models/spree/zone.rb'
- 'app/models/subscription_line_item.rb'
- 'app/models/tag_rule.rb'
- 'app/models/variant_override.rb'
- 'lib/open_food_network/address_finder.rb'
- 'spec/services/orders/generate_invoice_service_spec.rb'
- 'spec/system/admin/order_cycles/simple_spec.rb'
# Offense count: 1 # Offense count: 1
# Configuration parameters: TransactionMethods. # Configuration parameters: TransactionMethods.
Rails/TransactionExitStatement: Rails/TransactionExitStatement:
Exclude: Exclude:
- 'app/services/place_proxy_order.rb' - 'app/services/place_proxy_order.rb'
# Offense count: 3
# This cop supports unsafe autocorrection (--autocorrect-all).
Style/ArrayIntersect:
Exclude:
- 'app/models/spree/ability.rb'
- 'app/models/spree/variant.rb'
# Offense count: 1
# This cop supports unsafe autocorrection (--autocorrect-all).
Style/BitwisePredicate:
Exclude:
- 'app/helpers/admin/enterprises_helper.rb'
# Offense count: 23 # Offense count: 23
# This cop supports unsafe autocorrection (--autocorrect-all). # This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: EnforcedStyle. # Configuration parameters: EnforcedStyle, EnforcedStyleForClasses, EnforcedStyleForModules.
# SupportedStyles: nested, compact # SupportedStyles: nested, compact
# SupportedStylesForClasses: ~, nested, compact
# SupportedStylesForModules: ~, nested, compact
Style/ClassAndModuleChildren: Style/ClassAndModuleChildren:
Exclude: Exclude:
- 'app/models/calculator/flat_percent_per_item.rb' - 'app/models/calculator/flat_percent_per_item.rb'
@@ -237,6 +380,29 @@ Style/ClassAndModuleChildren:
- 'lib/open_food_network/locking.rb' - 'lib/open_food_network/locking.rb'
- 'spec/models/spree/payment_method_spec.rb' - 'spec/models/spree/payment_method_spec.rb'
# Offense count: 14
# This cop supports unsafe autocorrection (--autocorrect-all).
Style/CollectionQuerying:
Exclude:
- 'app/controllers/spree/credit_cards_controller.rb'
- 'app/models/product_import/product_importer.rb'
- 'app/models/product_import/spreadsheet_entry.rb'
- 'app/models/spree/order.rb'
- 'app/models/spree/order_inventory.rb'
- 'app/models/spree/payment_method.rb'
- 'app/models/spree/user.rb'
- 'app/models/stripe_account.rb'
- 'app/services/order_cycles/warning_service.rb'
- 'lib/reporting/report_renderer.rb'
- 'lib/tasks/sample_data.rake'
# Offense count: 2
# This cop supports unsafe autocorrection (--autocorrect-all).
Style/HashSlice:
Exclude:
- 'app/services/product_filters.rb'
- 'lib/reporting/report_row_builder.rb'
# Offense count: 4 # Offense count: 4
# This cop supports unsafe autocorrection (--autocorrect-all). # This cop supports unsafe autocorrection (--autocorrect-all).
Style/MapToHash: Style/MapToHash:
@@ -274,3 +440,22 @@ Style/OptionalBooleanParameter:
- 'engines/order_management/app/services/order_management/stock/estimator.rb' - 'engines/order_management/app/services/order_management/stock/estimator.rb'
- 'lib/spree/core/controller_helpers/order.rb' - 'lib/spree/core/controller_helpers/order.rb'
- 'spec/support/request/web_helper.rb' - 'spec/support/request/web_helper.rb'
# Offense count: 3
# This cop supports unsafe autocorrection (--autocorrect-all).
Style/RedundantFormat:
Exclude:
- 'spec/models/product_importer_spec.rb'
- 'spec/requests/checkout/stripe_sca_spec.rb'
- 'spec/system/consumer/account/cards_spec.rb'
# Offense count: 8
# Configuration parameters: Max.
Style/SafeNavigationChainLength:
Exclude:
- 'app/controllers/concerns/extra_fields.rb'
- 'app/services/customer_syncer.rb'
- 'app/services/fdc_offer_broker.rb'
- 'engines/dfc_provider/app/services/dfc_catalog.rb'
- 'engines/dfc_provider/app/services/image_builder.rb'
- 'engines/dfc_provider/app/services/quantitative_value_builder.rb'

View File

@@ -194,8 +194,11 @@ group :development do
gem 'query_count' gem 'query_count'
gem 'rails-erd' gem 'rails-erd'
gem 'rubocop' gem 'rubocop'
gem 'rubocop-capybara'
gem 'rubocop-factory_bot'
gem 'rubocop-rails' gem 'rubocop-rails'
gem 'rubocop-rspec' gem 'rubocop-rspec'
gem 'rubocop-rspec_rails'
gem 'spring' gem 'spring'
gem 'spring-commands-rspec' gem 'spring-commands-rspec'
gem 'spring-commands-rubocop' gem 'spring-commands-rubocop'

View File

@@ -192,8 +192,8 @@ GEM
base64 (0.3.0) base64 (0.3.0)
bcp47_spec (0.2.1) bcp47_spec (0.2.1)
bcrypt (3.1.20) bcrypt (3.1.20)
benchmark (0.4.1) benchmark (0.5.0)
bigdecimal (3.2.2) bigdecimal (3.3.1)
bindata (2.5.0) bindata (2.5.0)
bindex (0.8.1) bindex (0.8.1)
bootsnap (1.18.3) bootsnap (1.18.3)
@@ -380,7 +380,7 @@ GEM
highline (2.0.3) highline (2.0.3)
htmlentities (4.3.4) htmlentities (4.3.4)
http_parser.rb (0.8.0) http_parser.rb (0.8.0)
i18n (1.14.5) i18n (1.14.7)
concurrent-ruby (~> 1.0) concurrent-ruby (~> 1.0)
i18n-js (3.9.2) i18n-js (3.9.2)
i18n (>= 0.6.6) i18n (>= 0.6.6)
@@ -416,7 +416,7 @@ GEM
thor (>= 0.14, < 2.0) thor (>= 0.14, < 2.0)
jquery-ui-rails (4.2.1) jquery-ui-rails (4.2.1)
railties (>= 3.2.16) railties (>= 3.2.16)
json (2.7.2) json (2.15.2)
json-canonicalization (1.0.0) json-canonicalization (1.0.0)
json-jwt (1.16.6) json-jwt (1.16.6)
activesupport (>= 4.2) activesupport (>= 4.2)
@@ -444,13 +444,14 @@ GEM
base64 base64
knapsack_pro (8.1.2) knapsack_pro (8.1.2)
rake rake
language_server-protocol (3.17.0.3) language_server-protocol (3.17.0.5)
launchy (3.0.0) launchy (3.0.0)
addressable (~> 2.8) addressable (~> 2.8)
childprocess (~> 5.0) childprocess (~> 5.0)
letter_opener (1.10.0) letter_opener (1.10.0)
launchy (>= 2.2, < 4) launchy (>= 2.2, < 4)
link_header (0.0.8) link_header (0.0.8)
lint_roller (1.1.0)
listen (3.9.0) listen (3.9.0)
rb-fsevent (~> 0.10, >= 0.10.3) rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10) rb-inotify (~> 0.9, >= 0.9.10)
@@ -539,10 +540,10 @@ GEM
paper_trail (15.1.0) paper_trail (15.1.0)
activerecord (>= 6.1) activerecord (>= 6.1)
request_store (~> 1.4) request_store (~> 1.4)
parallel (1.24.0) parallel (1.27.0)
paranoia (2.6.3) paranoia (2.6.3)
activerecord (>= 5.1, < 7.2) activerecord (>= 5.1, < 7.2)
parser (3.3.9.0) parser (3.3.10.0)
ast (~> 2.4.1) ast (~> 2.4.1)
racc racc
paypal-sdk-core (0.3.4) paypal-sdk-core (0.3.4)
@@ -560,6 +561,7 @@ GEM
pp (0.6.2) pp (0.6.2)
prettyprint prettyprint
prettyprint (0.2.0) prettyprint (0.2.0)
prism (1.6.0)
private_address_check (0.5.0) private_address_check (0.5.0)
pry (0.13.1) pry (0.13.1)
coderay (~> 1.1) coderay (~> 1.1)
@@ -671,7 +673,7 @@ GEM
redis-client (>= 0.22.0) redis-client (>= 0.22.0)
redis-client (0.26.1) redis-client (0.26.1)
connection_pool connection_pool
regexp_parser (2.9.2) regexp_parser (2.11.3)
reline (0.6.2) reline (0.6.2)
io-console (~> 0.5) io-console (~> 0.5)
request_store (1.5.1) request_store (1.5.1)
@@ -734,35 +736,39 @@ GEM
rswag-ui (2.16.0) rswag-ui (2.16.0)
actionpack (>= 5.2, < 8.1) actionpack (>= 5.2, < 8.1)
railties (>= 5.2, < 8.1) railties (>= 5.2, < 8.1)
rubocop (1.64.1) rubocop (1.81.6)
json (~> 2.3) json (~> 2.3)
language_server-protocol (>= 3.17.0) language_server-protocol (~> 3.17.0.2)
lint_roller (~> 1.1.0)
parallel (~> 1.10) parallel (~> 1.10)
parser (>= 3.3.0.2) parser (>= 3.3.0.2)
rainbow (>= 2.2.2, < 4.0) rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0) regexp_parser (>= 2.9.3, < 3.0)
rexml (>= 3.2.5, < 4.0) rubocop-ast (>= 1.47.1, < 2.0)
rubocop-ast (>= 1.31.1, < 2.0)
ruby-progressbar (~> 1.7) ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 3.0) unicode-display_width (>= 2.4.0, < 4.0)
rubocop-ast (1.31.3) rubocop-ast (1.47.1)
parser (>= 3.3.1.0) parser (>= 3.3.7.2)
rubocop-capybara (2.20.0) prism (~> 1.4)
rubocop (~> 1.41) rubocop-capybara (2.22.1)
rubocop-factory_bot (2.25.1) lint_roller (~> 1.1)
rubocop (~> 1.41) rubocop (~> 1.72, >= 1.72.1)
rubocop-rails (2.28.0) rubocop-factory_bot (2.27.1)
lint_roller (~> 1.1)
rubocop (~> 1.72, >= 1.72.1)
rubocop-rails (2.33.4)
activesupport (>= 4.2.0) activesupport (>= 4.2.0)
lint_roller (~> 1.1)
rack (>= 1.1) rack (>= 1.1)
rubocop (>= 1.52.0, < 2.0) rubocop (>= 1.75.0, < 2.0)
rubocop-ast (>= 1.31.1, < 2.0) rubocop-ast (>= 1.44.0, < 2.0)
rubocop-rspec (2.29.2) rubocop-rspec (3.7.0)
rubocop (~> 1.40) lint_roller (~> 1.1)
rubocop-capybara (~> 2.17) rubocop (~> 1.72, >= 1.72.1)
rubocop-factory_bot (~> 2.22) rubocop-rspec_rails (2.31.0)
rubocop-rspec_rails (~> 2.28) lint_roller (~> 1.1)
rubocop-rspec_rails (2.28.3) rubocop (~> 1.72, >= 1.72.1)
rubocop (~> 1.40) rubocop-rspec (~> 3.5)
ruby-graphviz (1.2.5) ruby-graphviz (1.2.5)
rexml rexml
ruby-progressbar (1.13.0) ruby-progressbar (1.13.0)
@@ -873,7 +879,9 @@ GEM
rugged (>= 0.27, < 1.10) rugged (>= 0.27, < 1.10)
simplecov simplecov
simplecov_json_formatter simplecov_json_formatter
unicode-display_width (2.5.0) unicode-display_width (3.2.0)
unicode-emoji (~> 4.1)
unicode-emoji (4.1.0)
uniform_notifier (1.17.0) uniform_notifier (1.17.0)
uri (0.13.2) uri (0.13.2)
valid_email2 (5.2.3) valid_email2 (5.2.3)
@@ -1043,8 +1051,11 @@ DEPENDENCIES
rswag-api rswag-api
rswag-ui rswag-ui
rubocop rubocop
rubocop-capybara
rubocop-factory_bot
rubocop-rails rubocop-rails
rubocop-rspec rubocop-rspec
rubocop-rspec_rails
sd_notify sd_notify
select2-rails! select2-rails!
shoulda-matchers shoulda-matchers

View File

@@ -30,7 +30,7 @@ class SearchableDropdownComponent < ViewComponent::Base
:aria_label, :other_attrs :aria_label, :other_attrs
def classes def classes
"fullwidth #{remove_search_plugin? ? 'no-input' : ''}" "fullwidth #{'no-input' if remove_search_plugin?}"
end end
def data def data

View File

@@ -3,6 +3,7 @@
module Admin module Admin
class BulkLineItemsController < Spree::Admin::BaseController class BulkLineItemsController < Spree::Admin::BaseController
include PaginationData include PaginationData
# GET /admin/bulk_line_items.json # GET /admin/bulk_line_items.json
# #
def index def index

View File

@@ -4,6 +4,7 @@ module Admin
class ReportsController < Spree::Admin::BaseController class ReportsController < Spree::Admin::BaseController
include ActiveStorage::SetCurrent include ActiveStorage::SetCurrent
include ReportsActions include ReportsActions
helper ReportsHelper helper ReportsHelper
before_action :authorize_report, only: [:show, :create] before_action :authorize_report, only: [:show, :create]

View File

@@ -7,6 +7,7 @@ module Api
module V0 module V0
class ExchangeProductsController < Api::V0::BaseController class ExchangeProductsController < Api::V0::BaseController
include PaginationData include PaginationData
DEFAULT_PER_PAGE = 100 DEFAULT_PER_PAGE = 100
skip_authorization_check only: [:index] skip_authorization_check only: [:index]

View File

@@ -7,6 +7,7 @@ module Api
module V0 module V0
class ProductsController < Api::V0::BaseController class ProductsController < Api::V0::BaseController
include PaginationData include PaginationData
respond_to :json respond_to :json
DEFAULT_PER_PAGE = 15 DEFAULT_PER_PAGE = 15

View File

@@ -6,6 +6,7 @@ module Spree
module Admin module Admin
class OrdersController < Spree::Admin::BaseController class OrdersController < Spree::Admin::BaseController
include OpenFoodNetwork::SpreeApiKeyLoader include OpenFoodNetwork::SpreeApiKeyLoader
helper CheckoutHelper helper CheckoutHelper
before_action :load_order, only: [:edit, :update, :fire, :resend, :invoice, :print] before_action :load_order, only: [:edit, :update, :fire, :resend, :invoice, :print]

View File

@@ -10,6 +10,7 @@ module Spree
include OpenFoodNetwork::SpreeApiKeyLoader include OpenFoodNetwork::SpreeApiKeyLoader
include OrderCyclesHelper include OrderCyclesHelper
include EnterprisesHelper include EnterprisesHelper
helper ::Admin::ProductsHelper helper ::Admin::ProductsHelper
helper Spree::Admin::TaxCategoriesHelper helper Spree::Admin::TaxCategoriesHelper

View File

@@ -14,6 +14,7 @@ module Spree
include Spree::Core::ControllerHelpers::Order include Spree::Core::ControllerHelpers::Order
include I18nHelper include I18nHelper
before_action :set_locale before_action :set_locale
# Devise::PasswordsController allows for blank passwords. # Devise::PasswordsController allows for blank passwords.

View File

@@ -36,9 +36,7 @@ class ScheduleForm
false unless @schedule.update(permitted_resource_params) false unless @schedule.update(permitted_resource_params)
end end
def order_cycle_ids delegate :order_cycle_ids, to: :@schedule
@schedule.order_cycle_ids
end
private private

View File

@@ -120,7 +120,7 @@ module InjectionHelper
def inject_enterprise_attributes(enterprise_attributes) def inject_enterprise_attributes(enterprise_attributes)
render partial: "json/injection_ams", render partial: "json/injection_ams",
locals: { name: 'enterpriseAttributes', json: enterprise_attributes.to_json.to_s } locals: { name: 'enterpriseAttributes', json: enterprise_attributes.to_json }
end end
def inject_saved_credit_cards def inject_saved_credit_cards

View File

@@ -44,9 +44,7 @@ module ReportsHelper
.pluck(:name, :id) .pluck(:name, :id)
end end
def currency_symbol delegate :currency_symbol, to: :'Spree::Money'
Spree::Money.currency_symbol
end
def enterprise_fee_owner_ids(orders) def enterprise_fee_owner_ids(orders)
EnterpriseFee.where(id: enterprise_fee_ids(orders)) EnterpriseFee.where(id: enterprise_fee_ids(orders))

View File

@@ -10,9 +10,7 @@ module TermsAndConditionsHelper
TermsOfService.required?(distributor) TermsOfService.required?(distributor)
end end
def platform_terms_required? delegate :platform_terms_required?, to: :TermsOfService
TermsOfService.platform_terms_required?
end
def distributor_terms_required? def distributor_terms_required?
TermsOfService.distributor_terms_required?(current_order.distributor) TermsOfService.distributor_terms_required?(current_order.distributor)

View File

@@ -2,6 +2,7 @@
class BulkInvoiceJob < ApplicationJob class BulkInvoiceJob < ApplicationJob
include CableReady::Broadcaster include CableReady::Broadcaster
delegate :render, to: ActionController::Base delegate :render, to: ActionController::Base
attr_reader :options attr_reader :options

View File

@@ -3,6 +3,7 @@
# Renders a report and stores it in a given blob. # Renders a report and stores it in a given blob.
class ReportJob < ApplicationJob class ReportJob < ApplicationJob
include CableReady::Broadcaster include CableReady::Broadcaster
delegate :render, to: ActionController::Base delegate :render, to: ActionController::Base
before_perform :enable_active_storage_urls before_perform :enable_active_storage_urls

View File

@@ -4,6 +4,7 @@ require 'active_support/concern'
module LogDestroyPerformer module LogDestroyPerformer
extend ActiveSupport::Concern extend ActiveSupport::Concern
included do included do
attr_accessor :destroyed_by attr_accessor :destroyed_by

View File

@@ -408,7 +408,7 @@ class Enterprise < ApplicationRecord
def category def category
# Make this crazy logic human readable so we can argue about it sanely. # Make this crazy logic human readable so we can argue about it sanely.
cat = is_primary_producer ? "producer_" : "non_producer_" cat = is_primary_producer ? "producer_" : "non_producer_"
cat << ("sells_#{sells}") cat << "sells_#{sells}"
# Map backend cases to front end cases. # Map backend cases to front end cases.
case cat case cat

View File

@@ -3,6 +3,7 @@
class Invoice class Invoice
class DataPresenter class DataPresenter
include ::ActionView::Helpers::NumberHelper include ::ActionView::Helpers::NumberHelper
attr_reader :invoice attr_reader :invoice
delegate :display_number, :data, :previous_invoice, to: :invoice delegate :display_number, :data, :previous_invoice, to: :invoice
@@ -142,7 +143,7 @@ class Invoice
end end
def paid? def paid?
data[:payment_state] == 'paid' || data[:payment_state] == 'credit_owed' ['paid', 'credit_owed'].include?(data[:payment_state])
end end
def outstanding_balance? def outstanding_balance?

View File

@@ -4,6 +4,7 @@ class Invoice
class DataPresenter class DataPresenter
class Base class Base
include ::ActionView::Helpers::NumberHelper include ::ActionView::Helpers::NumberHelper
attr_reader :data attr_reader :data
def initialize(data) def initialize(data)

View File

@@ -81,17 +81,13 @@ module ProductImport
@reset_counts @reset_counts
end end
def enterprises_index delegate :enterprises_index, to: :@spreadsheet_data
@spreadsheet_data.enterprises_index
end
def enterprise_products def enterprise_products
@processor&.enterprise_products @processor&.enterprise_products
end end
def total_enterprise_products delegate :total_enterprise_products, to: :@processor
@processor.total_enterprise_products
end
def entries_json def entries_json
entries = {} entries = {}
@@ -130,13 +126,9 @@ module ProductImport
@processor.inventory_updated @processor.inventory_updated
end end
def products_reset_count delegate :products_reset_count, to: :@processor
@processor.products_reset_count
end
def total_saved_count delegate :total_saved_count, to: :@processor
@processor.total_saved_count
end
def import_results def import_results
{ entries: entries_json, reset_counts: } { entries: entries_json, reset_counts: }
@@ -183,7 +175,7 @@ module ProductImport
end end
def staged_import? def staged_import?
@import_settings&.key?(:start) && @import_settings&.key?(:end) @import_settings&.key?(:start) && @import_settings.key?(:end)
end end
def init_permissions def init_permissions

View File

@@ -31,9 +31,7 @@ module Spree
self.class.name.titleize.gsub("Calculator/", "") self.class.name.titleize.gsub("Calculator/", "")
end end
def description delegate :description, to: :class
self.class.description
end
def available?(_object) def available?(_object)
true true

View File

@@ -97,7 +97,7 @@ module Spree
} }
validate :disallow_guest_order validate :disallow_guest_order
validates :email, presence: true, validates :email, presence: true,
format: /\A([\w.%+\-']+)@([\w\-]+\.)+(\w{2,})\z/i, format: /\A([\w.%+\-']+)@([\w-]+\.)+(\w{2,})\z/i,
if: :require_email if: :require_email
validates :order_cycle, presence: true, on: :require_distribution validates :order_cycle, presence: true, on: :require_distribution
@@ -417,7 +417,7 @@ module Spree
# Helper methods for checkout steps # Helper methods for checkout steps
def paid? def paid?
payment_state == 'paid' || payment_state == 'credit_owed' ['paid', 'credit_owed'].include?(payment_state)
end end
# "Checkout" is the initial state and, for card payments, "pending" is the state after auth # "Checkout" is the initial state and, for card payments, "pending" is the state after auth

View File

@@ -3,6 +3,7 @@
module Spree module Spree
class ShippingMethod < ApplicationRecord class ShippingMethod < ApplicationRecord
include CalculatedAdjustments include CalculatedAdjustments
DISPLAY_ON_OPTIONS = { DISPLAY_ON_OPTIONS = {
both: "", both: "",
back_end: "back_end" back_end: "back_end"

View File

@@ -8,24 +8,14 @@ module Api
:open_street_map_default_latitude, :open_street_map_default_latitude,
:open_street_map_default_longitude :open_street_map_default_longitude
def open_street_map_enabled delegate :open_street_map_enabled, to: :ContentConfig
ContentConfig.open_street_map_enabled
end
def open_street_map_provider_name delegate :open_street_map_provider_name, to: :ContentConfig
ContentConfig.open_street_map_provider_name
end
def open_street_map_provider_options delegate :open_street_map_provider_options, to: :ContentConfig
ContentConfig.open_street_map_provider_options
end
def open_street_map_default_latitude delegate :open_street_map_default_latitude, to: :ContentConfig
ContentConfig.open_street_map_default_latitude
end
def open_street_map_default_longitude delegate :open_street_map_default_longitude, to: :ContentConfig
ContentConfig.open_street_map_default_longitude
end
end end
end end

View File

@@ -36,7 +36,7 @@ class EmbeddedPageService
def embedding_without_https? def embedding_without_https?
@request.referer && URI(@request.referer).scheme != 'https' && @request.referer && URI(@request.referer).scheme != 'https' &&
!Rails.env.test? && !Rails.env.development? !Rails.env.local?
end end
def process_embedded_request def process_embedded_request

View File

@@ -31,6 +31,11 @@ module DfcProvider
) )
end end
def show
product = SuppliedProductBuilder.supplied_product(variant)
render json: DfcIo.export(product)
end
def create def create
supplied_product = import&.first supplied_product = import&.first
@@ -45,11 +50,6 @@ module DfcProvider
render json: DfcIo.export(supplied_product) render json: DfcIo.export(supplied_product)
end end
def show
product = SuppliedProductBuilder.supplied_product(variant)
render json: DfcIo.export(product)
end
def update def update
supplied_product = import&.first supplied_product = import&.first

View File

@@ -7,6 +7,7 @@ module Web
module V0 module V0
class CookiesConsentController < BaseController class CookiesConsentController < BaseController
include ActionController::Cookies include ActionController::Cookies
respond_to :json respond_to :json
def show def show

View File

@@ -3,6 +3,7 @@
module Reporting module Reporting
class ReportTemplate class ReportTemplate
include ReportsHelper include ReportsHelper
attr_accessor :user, :params, :ransack_params attr_accessor :user, :params, :ransack_params
delegate :render_as, :as_json, :to_html, :to_csv, :to_xlsx, :to_pdf, :to_json, to: :renderer delegate :render_as, :as_json, :to_html, :to_csv, :to_xlsx, :to_pdf, :to_json, to: :renderer

View File

@@ -5,6 +5,7 @@ module Spree
module ControllerHelpers module ControllerHelpers
module Common module Common
extend ActiveSupport::Concern extend ActiveSupport::Concern
included do included do
helper_method :title helper_method :title
helper_method :title= helper_method :title=

View File

@@ -22,9 +22,7 @@ module Spree
alias_method :t, :translate alias_method :t, :translate
def context delegate :context, to: :'Spree::ViewContext'
Spree::ViewContext.context
end
def virtual_path def virtual_path
return unless context return unless context

View File

@@ -5,6 +5,7 @@ require "tasks/sample_data/logging"
module SampleData module SampleData
class OrderCycleFactory class OrderCycleFactory
include Logging include Logging
# rubocop:disable Metrics/MethodLength # rubocop:disable Metrics/MethodLength
def create_samples def create_samples
log "Creating order cycles" log "Creating order cycles"

View File

@@ -22,7 +22,8 @@ namespace :ofn do
ProxyOrder.find_by(order_cycle_id:)&.update!( ProxyOrder.find_by(order_cycle_id:)&.update!(
order_id: nil, order_id: nil,
confirmed_at: nil, confirmed_at: nil,
placed_at: nil) placed_at: nil
)
# Run placement job to create orders # Run placement job to create orders
SubscriptionPlacementJob.perform_now SubscriptionPlacementJob.perform_now

View File

@@ -5,6 +5,7 @@ require 'spec_helper'
module Api module Api
RSpec.describe V0::CustomersController do RSpec.describe V0::CustomersController do
include AuthenticationHelper include AuthenticationHelper
render_views render_views
let(:user) { create(:user) } let(:user) { create(:user) }

View File

@@ -4,6 +4,7 @@ require 'spec_helper'
RSpec.describe Api::V0::OrdersController do RSpec.describe Api::V0::OrdersController do
include AuthenticationHelper include AuthenticationHelper
render_views render_views
let!(:regular_user) { create(:user) } let!(:regular_user) { create(:user) }

View File

@@ -5,6 +5,7 @@ require 'spec_helper'
RSpec.describe Api::V0::ProductImagesController do RSpec.describe Api::V0::ProductImagesController do
include AuthenticationHelper include AuthenticationHelper
include FileHelper include FileHelper
render_views render_views
describe "uploading an image" do describe "uploading an image" do

View File

@@ -4,6 +4,7 @@ require 'spec_helper'
RSpec.describe Api::V0::ShopsController do RSpec.describe Api::V0::ShopsController do
include AuthenticationHelper include AuthenticationHelper
render_views render_views
context "as a non-authenticated user" do context "as a non-authenticated user" do

View File

@@ -4,6 +4,7 @@ require 'spec_helper'
RSpec.describe ShopsController do RSpec.describe ShopsController do
include WebHelper include WebHelper
render_views render_views
let!(:distributor) { create(:distributor_enterprise, with_payment_and_shipping: true) } let!(:distributor) { create(:distributor_enterprise, with_payment_and_shipping: true) }

View File

@@ -1033,8 +1033,6 @@ RSpec.describe ProductImport::ProductImporter do
end end
end end
private
def import_data(csv_data, args = {}) def import_data(csv_data, args = {})
import_user = args[:import_user] || admin import_user = args[:import_user] || admin
import_into = args[:import_into] || 'product_list' import_into = args[:import_into] || 'product_list'

View File

@@ -6,6 +6,7 @@ RSpec.describe Spree::Preferences::Preferable do
a_class = A = a_class = A =
Class.new do Class.new do
include Spree::Preferences::Preferable include Spree::Preferences::Preferable
attr_reader :id attr_reader :id
def initialize def initialize

View File

@@ -63,8 +63,6 @@ RSpec.describe "General Settings" do
end end
end end
private
def update_and_assert_message def update_and_assert_message
click_button 'Update' click_button 'Update'
within("[class='flash success']") do within("[class='flash success']") do

View File

@@ -5,6 +5,7 @@ require 'system_helper'
RSpec.describe "Shipping Categories" do RSpec.describe "Shipping Categories" do
include AuthenticationHelper include AuthenticationHelper
include WebHelper include WebHelper
let(:admin_user) { create(:user) } let(:admin_user) { create(:user) }
context 'user visits shipping categories page' do context 'user visits shipping categories page' do

View File

@@ -5,6 +5,7 @@ require 'system_helper'
RSpec.describe 'Multilingual' do RSpec.describe 'Multilingual' do
include AuthenticationHelper include AuthenticationHelper
include WebHelper include WebHelper
let(:admin_user) { create(:admin_user) } let(:admin_user) { create(:admin_user) }
before do before do

View File

@@ -165,8 +165,8 @@ RSpec.xdescribe '
# And it should have some variants selected # And it should have some variants selected
selected_initial_variants = initial_variants.take initial_variants.size - 1 selected_initial_variants = initial_variants.take initial_variants.size - 1
expect(oc.variants.map(&:id)).to match_array((selected_initial_variants.map(&:id) + [v1.id, expect(oc.variants.map(&:id)).to match_array(selected_initial_variants.map(&:id) + [v1.id,
v2.id])) v2.id])
# And the collection details should have been updated # And the collection details should have been updated
expect(oc.exchanges.where(pickup_time: 'New time 0', expect(oc.exchanges.where(pickup_time: 'New time 0',

View File

@@ -306,7 +306,7 @@ RSpec.describe 'As an enterprise user, I can manage my products' do
within "table.products" do within "table.products" do
# Products does not include the cloned product. # Products does not include the cloned product.
expect(all_input_values).not_to match /COPY OF #{('L' * 254)}/ expect(all_input_values).not_to match /COPY OF #{'L' * 254}/
end end
end end
end end

View File

@@ -183,8 +183,6 @@ RSpec.describe "Packing Reports" do
end end
end end
private
def check_prefilled_dates def check_prefilled_dates
expect(page).to have_input "q[order_completed_at_gt]", value: open_datetime, visible: false expect(page).to have_input "q[order_completed_at_gt]", value: open_datetime, visible: false
expect(page).to have_input "q[order_completed_at_lt]", value: close_datetime, visible: false expect(page).to have_input "q[order_completed_at_lt]", value: close_datetime, visible: false

View File

@@ -13,8 +13,6 @@ RSpec.describe 'sitemap' do
end end
end end
private
def return_page(website) def return_page(website)
# routing does not include the port of the session, this method adds it # routing does not include the port of the session, this method adds it
url = URI(page.driver.browser.url) url = URI(page.driver.browser.url)

View File

@@ -17,6 +17,7 @@ RSpec.describe DateTimeStringValidator do
let(:instance) do let(:instance) do
Class.new do Class.new do
include ActiveModel::Validations include ActiveModel::Validations
attr_accessor :timestamp attr_accessor :timestamp
validates :timestamp, date_time_string: true validates :timestamp, date_time_string: true

View File

@@ -17,6 +17,7 @@ RSpec.describe IntegerArrayValidator do
let(:instance) do let(:instance) do
Class.new do Class.new do
include ActiveModel::Validations include ActiveModel::Validations
attr_accessor :ids attr_accessor :ids
validates :ids, integer_array: true validates :ids, integer_array: true

View File

@@ -4,6 +4,7 @@ require "spec_helper"
RSpec.describe "spree/admin/payment_methods/index.html.haml" do RSpec.describe "spree/admin/payment_methods/index.html.haml" do
include AuthenticationHelper include AuthenticationHelper
helper Spree::Admin::NavigationHelper helper Spree::Admin::NavigationHelper
helper Spree::Admin::BaseHelper helper Spree::Admin::BaseHelper
helper Spree::Core::Engine.routes.url_helpers helper Spree::Core::Engine.routes.url_helpers

View File

@@ -4,6 +4,7 @@ require "spec_helper"
RSpec.describe "spree/shared/_order_details.html.haml" do RSpec.describe "spree/shared/_order_details.html.haml" do
include AuthenticationHelper include AuthenticationHelper
helper Spree::BaseHelper helper Spree::BaseHelper
helper CheckoutHelper helper CheckoutHelper
helper OrderHelper helper OrderHelper