mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-14 23:47:48 +00:00
resolved rubocop lexically scoped errors
This commit is contained in:
@@ -587,27 +587,27 @@ Rails/InverseOf:
|
||||
# Offense count: 35
|
||||
# Configuration parameters: Include.
|
||||
# Include: app/controllers/**/*.rb, app/mailers/**/*.rb
|
||||
Rails/LexicallyScopedActionFilter:
|
||||
Exclude:
|
||||
- 'app/controllers/admin/enterprise_groups_controller.rb'
|
||||
- 'app/controllers/admin/enterprises_controller.rb'
|
||||
- 'app/controllers/admin/order_cycles_controller.rb'
|
||||
- 'app/controllers/admin/producer_properties_controller.rb'
|
||||
- 'app/controllers/admin/product_import_controller.rb'
|
||||
- 'app/controllers/admin/schedules_controller.rb'
|
||||
- 'app/controllers/admin/subscriptions_controller.rb'
|
||||
- 'app/controllers/concerns/checkout_callbacks.rb'
|
||||
- 'app/controllers/registration_controller.rb'
|
||||
- 'app/controllers/spree/admin/adjustments_controller.rb'
|
||||
- 'app/controllers/spree/admin/payment_methods_controller.rb'
|
||||
- 'app/controllers/spree/admin/payments_controller.rb'
|
||||
- 'app/controllers/spree/admin/products_controller.rb'
|
||||
- 'app/controllers/spree/admin/return_authorizations_controller.rb'
|
||||
- 'app/controllers/spree/admin/search_controller.rb'
|
||||
- 'app/controllers/spree/admin/shipping_methods_controller.rb'
|
||||
- 'app/controllers/spree/admin/users_controller.rb'
|
||||
- 'app/controllers/spree/admin/zones_controller.rb'
|
||||
- 'app/controllers/spree/users_controller.rb'
|
||||
# Rails/LexicallyScopedActionFilter:
|
||||
# Exclude:
|
||||
# - 'app/controllers/admin/enterprise_groups_controller.rb'
|
||||
# - 'app/controllers/admin/enterprises_controller.rb'
|
||||
# - 'app/controllers/admin/order_cycles_controller.rb'
|
||||
# - 'app/controllers/admin/producer_properties_controller.rb'
|
||||
# - 'app/controllers/admin/product_import_controller.rb'
|
||||
# - 'app/controllers/admin/schedules_controller.rb'
|
||||
# - 'app/controllers/admin/subscriptions_controller.rb'
|
||||
# - 'app/controllers/concerns/checkout_callbacks.rb'
|
||||
# - 'app/controllers/registration_controller.rb'
|
||||
# - 'app/controllers/spree/admin/adjustments_controller.rb'
|
||||
# - 'app/controllers/spree/admin/payment_methods_controller.rb'
|
||||
# - 'app/controllers/spree/admin/payments_controller.rb'
|
||||
# - 'app/controllers/spree/admin/products_controller.rb'
|
||||
# - 'app/controllers/spree/admin/return_authorizations_controller.rb'
|
||||
# - 'app/controllers/spree/admin/search_controller.rb'
|
||||
# - 'app/controllers/spree/admin/shipping_methods_controller.rb'
|
||||
# - 'app/controllers/spree/admin/users_controller.rb'
|
||||
# - 'app/controllers/spree/admin/zones_controller.rb'
|
||||
# - 'app/controllers/spree/users_controller.rb'
|
||||
|
||||
# Offense count: 32
|
||||
# This cop supports unsafe autocorrection (--autocorrect-all).
|
||||
|
||||
@@ -363,9 +363,9 @@ GEM
|
||||
thor (>= 0.14, < 2.0)
|
||||
jquery-ui-rails (4.2.1)
|
||||
railties (>= 3.2.16)
|
||||
json (2.7.2)
|
||||
json-canonicalization (1.0.0)
|
||||
json-jwt (1.16.6)
|
||||
json (2.6.3)
|
||||
json-canonicalization (0.4.0)
|
||||
json-jwt (1.16.3)
|
||||
activesupport (>= 4.2)
|
||||
aes_key_wrap
|
||||
base64
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
module Admin
|
||||
class EnterpriseGroupsController < Admin::ResourceController
|
||||
before_action :load_data, except: :index
|
||||
before_action :load_object_data, only: [:new, :edit, :create, :update]
|
||||
before_action :load_object_data
|
||||
|
||||
def index
|
||||
@enterprise_groups = @enterprise_groups.managed_by(spree_current_user)
|
||||
|
||||
@@ -11,23 +11,23 @@ module Admin
|
||||
include Pagy::Backend
|
||||
|
||||
# These need to run before #load_resource so that @object is initialised with sanitised values
|
||||
prepend_before_action :override_owner, only: :create
|
||||
prepend_before_action :override_sells, only: :create
|
||||
prepend_before_action :override_owner
|
||||
prepend_before_action :override_sells
|
||||
|
||||
before_action :load_countries, except: [:index, :register, :check_permalink]
|
||||
before_action :load_countries, except: [:index, :register]
|
||||
before_action :load_methods_and_fees, only: [:edit, :update]
|
||||
before_action :load_groups, only: [:new, :edit, :update, :create]
|
||||
before_action :load_taxons, only: [:new, :edit, :update, :create]
|
||||
before_action :load_groups, only: [:edit, :update]
|
||||
before_action :load_taxons, only: [:edit, :update]
|
||||
before_action :check_can_change_sells, only: :update
|
||||
before_action :check_can_change_bulk_sells, only: :bulk_update
|
||||
before_action :check_can_change_owner, only: :update
|
||||
before_action :check_can_change_bulk_owner, only: :bulk_update
|
||||
before_action :check_can_change_managers, only: :update
|
||||
before_action :strip_new_properties, only: [:create, :update]
|
||||
before_action :strip_new_properties, only: [:update]
|
||||
before_action :load_properties, only: [:edit, :update]
|
||||
before_action :setup_property, only: [:edit]
|
||||
|
||||
after_action :geocode_address_if_use_geocoder, only: [:create, :update]
|
||||
after_action :geocode_address_if_use_geocoder, only: [:update]
|
||||
|
||||
include OrderCyclesHelper
|
||||
|
||||
@@ -252,7 +252,7 @@ module Admin
|
||||
# methods that are specific to each class do not become available until after the
|
||||
# record is persisted. This problem is compounded by the use of calculators.
|
||||
@object.transaction do
|
||||
tag_rules_attributes.select{ |_i, attrs| attrs[:type].present? }.each do |_i, attrs|
|
||||
tag_rules_attributes.select{ |attrs| attrs[:type].present? }.each_value do |attrs|
|
||||
rule = @object.tag_rules.find_by(id: attrs.delete(:id)) ||
|
||||
attrs[:type].constantize.new(enterprise: @object)
|
||||
|
||||
@@ -291,7 +291,7 @@ module Admin
|
||||
def check_can_change_bulk_sells
|
||||
return if spree_current_user.admin?
|
||||
|
||||
params[:sets_enterprise_set][:collection_attributes].each do |_i, enterprise_params|
|
||||
params[:sets_enterprise_set][:collection_attributes].each_value do |enterprise_params|
|
||||
unless spree_current_user == Enterprise.find_by(id: enterprise_params[:id]).owner
|
||||
enterprise_params.delete :sells
|
||||
end
|
||||
@@ -325,7 +325,7 @@ module Admin
|
||||
def check_can_change_bulk_owner
|
||||
return if spree_current_user.admin?
|
||||
|
||||
bulk_params[:collection_attributes].each do |_i, enterprise_params|
|
||||
bulk_params[:collection_attributes].each_value do |enterprise_params|
|
||||
enterprise_params.delete :owner_id
|
||||
end
|
||||
end
|
||||
|
||||
@@ -5,12 +5,12 @@ module Admin
|
||||
include ::OrderCyclesHelper
|
||||
include PaperTrailLogging
|
||||
|
||||
prepend_before_action :set_order_cycle_id, only: [:incoming, :outgoing, :checkout_options]
|
||||
prepend_before_action :set_order_cycle_id
|
||||
before_action :load_data_for_index, only: :index
|
||||
before_action :require_coordinator, only: :new
|
||||
before_action :remove_protected_attrs, only: [:update]
|
||||
before_action :require_order_cycle_set_params, only: [:bulk_update]
|
||||
around_action :protect_invalid_destroy, only: :destroy
|
||||
around_action :protect_invalid_destroy
|
||||
|
||||
def index
|
||||
respond_to do |format|
|
||||
|
||||
@@ -4,7 +4,7 @@ module Admin
|
||||
class ProducerPropertiesController < Admin::ResourceController
|
||||
before_action :load_enterprise
|
||||
before_action :load_properties
|
||||
before_action :setup_property, only: [:index]
|
||||
before_action :setup_property
|
||||
|
||||
private
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ require 'roo'
|
||||
|
||||
module Admin
|
||||
class ProductImportController < Spree::Admin::BaseController
|
||||
before_action :validate_upload_presence, except: %i[index guide validate_data]
|
||||
before_action :validate_upload_presence, except: %i[index validate_data]
|
||||
|
||||
def index
|
||||
@product_categories = Spree::Taxon.order('name ASC').pluck(:name).uniq
|
||||
|
||||
@@ -7,7 +7,7 @@ module Admin
|
||||
include PaperTrailLogging
|
||||
|
||||
before_action :adapt_params, only: [:update]
|
||||
before_action :check_dependent_subscriptions, only: [:destroy]
|
||||
before_action :check_dependent_subscriptions
|
||||
|
||||
after_action :sync_subscriptions_for_update, only: :update
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ require 'open_food_network/permissions'
|
||||
module Admin
|
||||
class SubscriptionsController < Admin::ResourceController
|
||||
before_action :load_shops, only: [:index]
|
||||
before_action :load_form_data, only: [:new, :edit]
|
||||
before_action :load_form_data, only: [:new]
|
||||
before_action :strip_banned_attrs, only: [:update]
|
||||
before_action :wrap_nested_attrs, only: [:create, :update]
|
||||
before_action :check_for_open_orders, only: [:cancel, :pause]
|
||||
|
||||
@@ -7,7 +7,7 @@ module CheckoutCallbacks
|
||||
included do
|
||||
# We need pessimistic locking to avoid race conditions.
|
||||
# Otherwise we fail on duplicate indexes or end up with negative stock.
|
||||
prepend_around_action CurrentOrderLocker, only: [:edit, :update]
|
||||
prepend_around_action CurrentOrderLocker
|
||||
|
||||
prepend_before_action :check_hub_ready_for_checkout
|
||||
prepend_before_action :check_order_cycle_expiry
|
||||
|
||||
@@ -9,7 +9,7 @@ class RegistrationController < BaseController
|
||||
helper 'map'
|
||||
|
||||
before_action :load_spree_api_key, only: [:index]
|
||||
before_action :check_user, except: :authenticate
|
||||
before_action :check_user
|
||||
|
||||
def index
|
||||
@enterprise_attributes = { sells: 'none' }
|
||||
|
||||
@@ -5,10 +5,10 @@ module Spree
|
||||
class AdjustmentsController < ::Admin::ResourceController
|
||||
belongs_to 'spree/order', find_by: :number
|
||||
|
||||
before_action :set_order_id, only: [:create, :update]
|
||||
before_action :skip_changing_canceled_orders, only: [:create, :update]
|
||||
after_action :update_order, only: [:create, :update, :destroy]
|
||||
after_action :apply_tax, only: [:create, :update]
|
||||
before_action :set_order_id
|
||||
before_action :skip_changing_canceled_orders
|
||||
after_action :update_order
|
||||
after_action :apply_tax
|
||||
|
||||
private
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ module Spree
|
||||
skip_before_action :load_resource, only: [:create, :show_provider_preferences]
|
||||
before_action :load_data
|
||||
before_action :validate_payment_method_provider, only: [:create]
|
||||
before_action :load_hubs, only: [:new, :edit, :update]
|
||||
before_action :load_hubs, only: [:update]
|
||||
|
||||
respond_to :html
|
||||
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
module Spree
|
||||
module Admin
|
||||
class PaymentsController < Spree::Admin::BaseController
|
||||
before_action :load_order, except: [:show]
|
||||
before_action :load_payment, only: [:fire, :show]
|
||||
before_action :load_order
|
||||
before_action :load_payment, only: [:fire]
|
||||
before_action :load_data
|
||||
before_action :can_transition_to_payment
|
||||
# We ensure that items are in stock before all screens if the order is in the Payment state.
|
||||
|
||||
@@ -13,7 +13,7 @@ module Spree
|
||||
|
||||
before_action :load_data
|
||||
before_action :load_form_data, only: [:index, :new, :create, :edit, :update]
|
||||
before_action :load_spree_api_key, only: [:index, :variant_overrides]
|
||||
before_action :load_spree_api_key, only: [:index]
|
||||
before_action :strip_new_properties, only: [:create, :update]
|
||||
|
||||
def index
|
||||
|
||||
@@ -5,7 +5,7 @@ module Spree
|
||||
class ReturnAuthorizationsController < ::Admin::ResourceController
|
||||
belongs_to 'spree/order', find_by: :number
|
||||
|
||||
after_action :associate_inventory_units, only: [:create, :update]
|
||||
after_action :associate_inventory_units
|
||||
|
||||
def fire
|
||||
@return_authorization.public_send("#{params[:e]}!")
|
||||
|
||||
@@ -4,7 +4,7 @@ module Spree
|
||||
module Admin
|
||||
class SearchController < Spree::Admin::BaseController
|
||||
# http://spreecommerce.com/blog/2010/11/02/json-hijacking-vulnerability/
|
||||
before_action :check_json_authenticity, only: :index
|
||||
before_action :check_json_authenticity
|
||||
respond_to :json
|
||||
|
||||
def known_users
|
||||
|
||||
@@ -3,11 +3,11 @@
|
||||
module Spree
|
||||
module Admin
|
||||
class ShippingMethodsController < ::Admin::ResourceController
|
||||
before_action :load_data, except: [:index]
|
||||
before_action :set_shipping_category, only: [:create, :update]
|
||||
before_action :set_zones, only: [:create, :update]
|
||||
before_action :load_hubs, only: [:new, :edit, :create, :update]
|
||||
before_action :check_shipping_fee_input, only: [:update]
|
||||
before_action :load_data
|
||||
before_action :set_shipping_category
|
||||
before_action :set_zones
|
||||
before_action :load_hubs, only: [:new]
|
||||
before_action :check_shipping_fee_input
|
||||
|
||||
# Sort shipping methods by distributor name
|
||||
def collection
|
||||
@@ -104,7 +104,7 @@ module Spree
|
||||
|
||||
return unless shipping_fees
|
||||
|
||||
shipping_fees.each do |_, shipping_amount|
|
||||
shipping_fees.each_value do |shipping_amount|
|
||||
unless shipping_amount.nil? || Float(shipping_amount, exception: false)
|
||||
flash[:error] = I18n.t(:calculator_preferred_value_error)
|
||||
return redirect_to location_after_save
|
||||
|
||||
@@ -11,8 +11,7 @@ module Spree
|
||||
|
||||
# http://spreecommerce.com/blog/2010/11/02/json-hijacking-vulnerability/
|
||||
before_action :check_json_authenticity, only: :index
|
||||
before_action :load_roles, only: [:edit, :new, :update, :create,
|
||||
:generate_api_key, :clear_api_key]
|
||||
before_action :load_roles, only: %i[update create]
|
||||
|
||||
def index
|
||||
respond_with(@collection) do |format|
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
module Spree
|
||||
module Admin
|
||||
class ZonesController < ::Admin::ResourceController
|
||||
before_action :load_data, except: [:index]
|
||||
before_action :load_data
|
||||
|
||||
def new
|
||||
@zone.zone_members.build
|
||||
|
||||
@@ -10,8 +10,8 @@ module Spree
|
||||
|
||||
invisible_captcha only: [:create], on_timestamp_spam: :render_alert_timestamp_error_message
|
||||
skip_before_action :set_current_order, only: :show
|
||||
prepend_before_action :load_object, only: [:show, :edit, :update]
|
||||
prepend_before_action :authorize_actions, only: :new
|
||||
prepend_before_action :load_object, only: %i[show update]
|
||||
prepend_before_action :authorize_actions
|
||||
|
||||
before_action :set_locale
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ class EnterpriseFeesBulkUpdate
|
||||
private
|
||||
|
||||
def check_enterprise_fee_input
|
||||
enterprise_fee_bulk_params['collection_attributes'].each do |_, fee_row|
|
||||
enterprise_fee_bulk_params['collection_attributes'].each_value do |fee_row|
|
||||
enterprise_fees = fee_row['calculator_attributes']&.slice(
|
||||
:preferred_flat_percent, :preferred_amount,
|
||||
:preferred_first_item, :preferred_additional_item,
|
||||
@@ -40,7 +40,7 @@ class EnterpriseFeesBulkUpdate
|
||||
|
||||
next unless enterprise_fees
|
||||
|
||||
enterprise_fees.each do |_, enterprise_amount|
|
||||
enterprise_fees.each_value do |enterprise_amount|
|
||||
unless enterprise_amount.nil? || Float(enterprise_amount, exception: false)
|
||||
@errors.add(:base, I18n.t(:calculator_preferred_value_error))
|
||||
end
|
||||
@@ -49,7 +49,7 @@ class EnterpriseFeesBulkUpdate
|
||||
end
|
||||
|
||||
def check_calculators_compatibility_with_taxes
|
||||
enterprise_fee_bulk_params['collection_attributes'].each do |_, enterprise_fee|
|
||||
enterprise_fee_bulk_params['collection_attributes'].each_value do |enterprise_fee|
|
||||
next unless enterprise_fee['inherits_tax_category'] == "true"
|
||||
next unless EnterpriseFee::PER_ORDER_CALCULATORS.include?(enterprise_fee['calculator_type'])
|
||||
|
||||
|
||||
@@ -6,7 +6,8 @@ module CalculatedAdjustments
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
has_one :calculator, as: :calculable, class_name: "Spree::Calculator", dependent: :destroy
|
||||
has_one :calculator, as: :calculable, class_name: "Spree::Calculator", dependent: :destroy,
|
||||
inverse_of: :calculable
|
||||
accepts_nested_attributes_for :calculator
|
||||
validates :calculator, presence: true
|
||||
end
|
||||
|
||||
@@ -46,7 +46,7 @@ module ProductImport
|
||||
end
|
||||
|
||||
def count_existing_items
|
||||
@spreadsheet_data.enterprises_index.each do |_enterprise_name, attrs|
|
||||
@spreadsheet_data.enterprises_index.each_value do |attrs|
|
||||
enterprise_id = attrs[:id]
|
||||
next unless enterprise_id && permission_by_id?(enterprise_id)
|
||||
|
||||
|
||||
@@ -36,7 +36,8 @@ module Spree
|
||||
# So we don't need the option `dependent: :destroy` as long as
|
||||
# AdjustmentMetadata has no destroy logic itself.
|
||||
has_one :metadata, class_name: 'AdjustmentMetadata', dependent: nil
|
||||
has_many :adjustments, as: :adjustable, dependent: :destroy
|
||||
has_many :adjustments, as: :adjustable, dependent: :destroy,
|
||||
inverse_of: :adjustments
|
||||
|
||||
belongs_to :adjustable, polymorphic: true
|
||||
belongs_to :originator, -> { with_deleted }, polymorphic: true
|
||||
|
||||
@@ -4,7 +4,7 @@ module Spree
|
||||
class Calculator < ApplicationRecord
|
||||
self.belongs_to_required_by_default = false
|
||||
|
||||
belongs_to :calculable, polymorphic: true
|
||||
belongs_to :calculable, polymorphic: true, inverse_of: :calculator
|
||||
|
||||
# This method must be overriden in concrete calculator.
|
||||
#
|
||||
|
||||
@@ -7,7 +7,8 @@ module Spree
|
||||
belongs_to :payment_method
|
||||
belongs_to :user
|
||||
|
||||
has_many :payments, as: :source, dependent: :nullify
|
||||
has_many :payments, as: :source, dependent: :nullify,
|
||||
inverse_of: :payments
|
||||
|
||||
before_save :set_last_digits
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ module Spree
|
||||
|
||||
# Persist the state on the order
|
||||
after_transition do |order|
|
||||
order.state = order.state
|
||||
order = order.state
|
||||
order.save
|
||||
end
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ module Spree
|
||||
end
|
||||
|
||||
def reset
|
||||
preferences.each do |name, _value|
|
||||
preferences.each_value do |name|
|
||||
set_preference name, preference_default(name)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -187,7 +187,7 @@ module Spree
|
||||
.with_permission(:add_to_order_cycle)
|
||||
.where(enterprises: { is_primary_producer: true })
|
||||
.pluck(:parent_id)
|
||||
where(spree_products: { supplier_id: [enterprise.id] | permitted_producer_ids })
|
||||
where('spree_products.supplier_id IN (?)', [enterprise.id] | permitted_producer_ids)
|
||||
}
|
||||
|
||||
scope :active, lambda { where(spree_products: { deleted_at: nil }) }
|
||||
|
||||
@@ -12,10 +12,11 @@ module Spree
|
||||
|
||||
has_many :shipping_rates, dependent: :delete_all
|
||||
has_many :shipping_methods, through: :shipping_rates
|
||||
has_many :state_changes, as: :stateful, dependent: :destroy
|
||||
has_many :state_changes, as: :stateful, dependent: :destroy,
|
||||
inverse_of: :state_changes
|
||||
has_many :inventory_units, dependent: :delete_all
|
||||
has_many :adjustments, as: :adjustable, dependent: :destroy
|
||||
|
||||
has_many :adjustments, as: :adjustable, dependent: :destroy,
|
||||
inverse_of: :adjustments
|
||||
before_create :generate_shipment_number
|
||||
after_save :ensure_correct_adjustment, :update_adjustments
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ module Spree
|
||||
|
||||
belongs_to :zone, class_name: "Spree::Zone", inverse_of: :tax_rates
|
||||
belongs_to :tax_category, class_name: "Spree::TaxCategory", inverse_of: :tax_rates
|
||||
has_many :adjustments, as: :originator, dependent: nil
|
||||
has_many :adjustments, as: :originator, inverse_of: :adjustments
|
||||
|
||||
validates :amount, presence: true, numericality: true
|
||||
validates :tax_category, presence: true
|
||||
|
||||
@@ -12,7 +12,8 @@ class Voucher < ApplicationRecord
|
||||
has_many :adjustments,
|
||||
as: :originator,
|
||||
class_name: 'Spree::Adjustment',
|
||||
dependent: nil
|
||||
dependent: nil,
|
||||
inverse_of: :adjustments
|
||||
|
||||
validates :code, presence: true, uniqueness: { scope: :enterprise_id }
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ module Sets
|
||||
end
|
||||
|
||||
def collection_attributes=(collection_attributes)
|
||||
collection_attributes.each do |_k, attributes|
|
||||
collection_attributes.each_value do |attributes|
|
||||
# attributes == {:id => 123, :next_collection_at => '...'}
|
||||
found_element = @collection.detect do |element|
|
||||
element.id.to_s == attributes[:id].to_s && !element.id.nil?
|
||||
|
||||
@@ -82,7 +82,7 @@ module Reporting
|
||||
sorted_groups = sort_groups_with_rule(groups, rule)
|
||||
|
||||
sorted_groups.map do |group_value, group_datas|
|
||||
{
|
||||
result << {
|
||||
is_group: true,
|
||||
header: @builder.build_header(rule, group_value, group_datas),
|
||||
header_class: rule[:header_class],
|
||||
|
||||
@@ -37,7 +37,7 @@ module Reporting
|
||||
hash[:line_item].order.distributor_id,
|
||||
hash[:line_item].order.order_cycle_id
|
||||
]
|
||||
end.each do |_, v|
|
||||
end.each_value do |v|
|
||||
v.map!{ |item| item[:line_item] }
|
||||
end
|
||||
end
|
||||
|
||||
@@ -8,7 +8,7 @@ module Spree
|
||||
def add_class(name)
|
||||
instance_variable_set "@#{name}", Set.new
|
||||
|
||||
create_method( :"#{name}=" ) { |val|
|
||||
create_method( "#{name}=".to_sym ) { |val|
|
||||
instance_variable_set( "@" + name, val)
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ module Spree
|
||||
delegate :cents, to: :money
|
||||
|
||||
def initialize(amount, options = {})
|
||||
@money = ::Monetize.parse([amount, options[:currency] || CurrentConfig.get(:currency)].join)
|
||||
@money = ::Monetize.parse[amount, options[:currency] || Spree::Config[:currency]].join
|
||||
|
||||
if options.key?(:symbol_position)
|
||||
options[:format] = position_to_format(options.delete(:symbol_position))
|
||||
|
||||
@@ -53,8 +53,10 @@ RSpec.describe Api::V0::ReportsController, type: :controller do
|
||||
private
|
||||
|
||||
def report_output(order, user_type)
|
||||
results = order.line_items.map do |line_item|
|
||||
__send__("#{user_type}_report_row", line_item)
|
||||
results = []
|
||||
|
||||
order.line_items.map do |line_item|
|
||||
results << __send__("#{user_type}_report_row", line_item)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -1020,7 +1020,7 @@ end
|
||||
|
||||
def filter(type, entries)
|
||||
valid_count = 0
|
||||
entries.each do |_line_number, entry|
|
||||
entries.each_value do |entry|
|
||||
validates_as = entry['validates_as']
|
||||
|
||||
valid_count += 1 if type == 'valid' && (validates_as != '')
|
||||
|
||||
@@ -15,7 +15,7 @@ module OpenFoodNetwork
|
||||
end
|
||||
|
||||
def json_response_ids
|
||||
json_response[:data]&.map{ |item| item["id"] }
|
||||
json_response[:data].pluck(:id)
|
||||
end
|
||||
|
||||
def json_error_detail
|
||||
|
||||
@@ -17,7 +17,7 @@ module Spree
|
||||
member.merge(i => true)
|
||||
}
|
||||
end
|
||||
ability_hash.each do |action, _true_or_false|
|
||||
ability_hash.each_key do |action|
|
||||
@ability_result[action] = ability.can?(action, target)
|
||||
end
|
||||
|
||||
|
||||
@@ -32,8 +32,10 @@ RSpec.describe "
|
||||
|
||||
# And markdown is rendered
|
||||
# expect(page).to have_link "markdown link" and the correct href
|
||||
expect(page).to have_selector :link, "markdown link", href:
|
||||
"/:/?#@!$&'()*+,;=0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||
expect(page).to have_selector :link,
|
||||
"markdown link",
|
||||
href: "/:/?#@!$&'()*+,;=0123456789abcdefghijklmnopqrstuvwxy
|
||||
zABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||
end
|
||||
|
||||
it "uploads logos" do
|
||||
|
||||
@@ -7,8 +7,10 @@ RSpec.describe 'As an enterprise user, I can manage my products', feature: :admi
|
||||
include AuthenticationHelper
|
||||
include FileHelper
|
||||
|
||||
let(:producer) { create(:supplier_enterprise) }
|
||||
let(:user) { create(:user, enterprises: [producer]) }
|
||||
# create lot of products
|
||||
70.times do |i|
|
||||
let!(:"product_#{i}") { create(:simple_product, name: "product #{i}") }
|
||||
end
|
||||
|
||||
before do
|
||||
login_as user
|
||||
|
||||
@@ -134,17 +134,17 @@ RSpec.describe "
|
||||
within "tr#v_#{variant.id}" do
|
||||
click_button 'Hide'
|
||||
end
|
||||
expect(page).not_to have_selector "tr#v_#{variant.id}"
|
||||
expect(page).to have_no_selector "tr#v_#{variant.id}"
|
||||
expect(page).to have_selector "tr#v_#{variant_related.id}"
|
||||
first("div#views-dropdown").click
|
||||
first("div#views-dropdown div.menu div.menu_item", text: "Hidden Products").click
|
||||
expect(page).to have_selector "tr#v_#{variant.id}"
|
||||
expect(page).not_to have_selector "tr#v_#{variant_related.id}"
|
||||
expect(page).to have_no_selector "tr#v_#{variant_related.id}"
|
||||
within "tr#v_#{variant.id}" do
|
||||
click_button 'Add'
|
||||
end
|
||||
expect(page).not_to have_selector "tr#v_#{variant.id}"
|
||||
expect(page).not_to have_selector "tr#v_#{variant_related.id}"
|
||||
expect(page).to have_no_selector "tr#v_#{variant.id}"
|
||||
expect(page).to have_no_selector "tr#v_#{variant_related.id}"
|
||||
first("div#views-dropdown").click
|
||||
first("div#views-dropdown div.menu div.menu_item", text: "Inventory Products").click
|
||||
expect(page).to have_selector "tr#v_#{variant.id}"
|
||||
@@ -502,8 +502,8 @@ RSpec.describe "
|
||||
within "table#new-products tr#v_#{variant2.id}" do
|
||||
click_button 'Hide'
|
||||
end
|
||||
expect(page).not_to have_selector "table#new-products tr#v_#{variant1.id}"
|
||||
expect(page).not_to have_selector "table#new-products tr#v_#{variant2.id}"
|
||||
expect(page).to have_no_selector "table#new-products tr#v_#{variant1.id}"
|
||||
expect(page).to have_no_selector "table#new-products tr#v_#{variant2.id}"
|
||||
click_button "Back to my inventory"
|
||||
|
||||
expect(page).to have_selector "table#variant-overrides tr#v_#{variant1.id}"
|
||||
|
||||
23
spec/system/support/precompile_assets.rb
Normal file
23
spec/system/support/precompile_assets.rb
Normal file
@@ -0,0 +1,23 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
RSpec.configure do |config|
|
||||
# Skip assets precompilcation if we exclude system specs.
|
||||
# For example, you can run all non-system tests via the following command:
|
||||
#
|
||||
# rspec --tag ~type:system
|
||||
#
|
||||
# In this case, we don't need to precompile assets.
|
||||
next if
|
||||
config.filter.opposite.rules[:type] == "system" ||
|
||||
config.exclude_pattern.match?(%r{spec/system})
|
||||
|
||||
config.before(:suite) do
|
||||
# We can use webpack-dev-server for tests, too!
|
||||
# Useful if you working on a frontend code fixes and want to verify them via system tests.
|
||||
next if Webpacker.dev_server.running?
|
||||
|
||||
$stdout.puts "\n Precompiling assets.\n"
|
||||
|
||||
Webpacker.compile
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user