Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2025-06-18 14:45:47 UTC using RuboCop version 1.76.0.
# on 2025-06-23 09:07:03 UTC using RuboCop version 1.76.0.
# 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
Expand All @@ -14,7 +14,7 @@ Gemspec/OrderedDependencies:
Exclude:
- 'core/solidus_core.gemspec'

# Offense count: 182
# Offense count: 186
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle, IndentationWidth.
# SupportedStyles: with_first_argument, with_fixed_indentation
Expand Down Expand Up @@ -332,7 +332,7 @@ Rails/FilePath:
- 'core/lib/spree/testing_support/dummy_app.rb'
- 'sample/lib/spree/sample.rb'

# Offense count: 53
# Offense count: 49
# Configuration parameters: Include.
# Include: **/app/models/**/*.rb
Rails/HasManyOrHasOneDependent:
Expand Down Expand Up @@ -374,11 +374,24 @@ Rails/IndexWith:
- 'core/lib/spree/core/search/variant.rb'
- 'core/lib/spree/preferences/preferable.rb'

# Offense count: 26
# Offense count: 21
# Configuration parameters: IgnoreScopes, Include.
# Include: **/app/models/**/*.rb
Rails/InverseOf:
Enabled: false
Exclude:
- 'core/app/models/concerns/spree/user_methods.rb'
- 'core/app/models/spree/country.rb'
- 'core/app/models/spree/credit_card.rb'
- 'core/app/models/spree/inventory_unit.rb'
- 'core/app/models/spree/order.rb'
- 'core/app/models/spree/price.rb'
- 'core/app/models/spree/refund.rb'
- 'core/app/models/spree/return_authorization.rb'
- 'core/app/models/spree/return_item.rb'
- 'core/app/models/spree/shipping_method.rb'
- 'core/app/models/spree/store_credit.rb'
- 'core/app/models/spree/store_credit_type.rb'
- 'core/app/models/spree/variant.rb'

# Offense count: 24
# Configuration parameters: Include.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class CreateAdjustment < PromotionAction
include Spree::CalculatedAdjustments
include Spree::AdjustmentSource

has_many :adjustments, as: :source
has_many :adjustments, as: :source, dependent: :restrict_with_error

delegate :eligible?, to: :promotion

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class CreateItemAdjustments < PromotionAction
include Spree::CalculatedAdjustments
include Spree::AdjustmentSource

has_many :adjustments, as: :source
has_many :adjustments, as: :source, dependent: :restrict_with_error

delegate :eligible?, to: :promotion

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module Actions
class CreateQuantityAdjustments < CreateItemAdjustments
preference :group_size, :integer, default: 1

has_many :line_item_actions, foreign_key: :action_id, dependent: :destroy
has_many :line_item_actions, foreign_key: :action_id, dependent: :destroy, inverse_of: :action
has_many :line_items, through: :line_item_actions

##
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@ module Rules
# either come from assigned product group or are assingned directly to
# the rule.
class Product < PromotionRule
has_many :product_promotion_rules, dependent: :destroy, foreign_key: :promotion_rule_id,
class_name: 'Spree::ProductPromotionRule'
has_many :product_promotion_rules,
dependent: :destroy,
foreign_key: :promotion_rule_id,
class_name: 'Spree::ProductPromotionRule',
inverse_of: :promotion_rule
has_many :products, class_name: 'Spree::Product', through: :product_promotion_rules

def preload_relations
Expand Down
8 changes: 5 additions & 3 deletions legacy_promotions/app/models/spree/promotion/rules/store.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ module Spree
class Promotion
module Rules
class Store < PromotionRule
has_many :promotion_rule_stores, class_name: "Spree::PromotionRuleStore",
foreign_key: :promotion_rule_id,
dependent: :destroy
has_many :promotion_rule_stores,
class_name: "Spree::PromotionRuleStore",
foreign_key: :promotion_rule_id,
dependent: :destroy,
inverse_of: :promotion_rule
has_many :stores, through: :promotion_rule_stores, class_name: "Spree::Store"

def preload_relations
Expand Down
7 changes: 5 additions & 2 deletions legacy_promotions/app/models/spree/promotion/rules/taxon.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@ module Spree
class Promotion < Spree::Base
module Rules
class Taxon < PromotionRule
has_many :promotion_rule_taxons, class_name: 'Spree::PromotionRuleTaxon', foreign_key: :promotion_rule_id,
dependent: :destroy
has_many :promotion_rule_taxons,
class_name: 'Spree::PromotionRuleTaxon',
foreign_key: :promotion_rule_id,
dependent: :destroy,
inverse_of: :promotion_rule
has_many :taxons, through: :promotion_rule_taxons, class_name: 'Spree::Taxon'

def preload_relations
Expand Down
8 changes: 5 additions & 3 deletions legacy_promotions/app/models/spree/promotion/rules/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ module Spree
class Promotion < Spree::Base
module Rules
class User < PromotionRule
has_many :promotion_rule_users, class_name: 'Spree::PromotionRuleUser',
foreign_key: :promotion_rule_id,
dependent: :destroy
has_many :promotion_rule_users,
class_name: 'Spree::PromotionRuleUser',
foreign_key: :promotion_rule_id,
dependent: :destroy,
inverse_of: :promotion_rule
has_many :users, through: :promotion_rule_users, class_name: Spree::UserClassHandle.new

def preload_relations
Expand Down
2 changes: 1 addition & 1 deletion legacy_promotions/app/models/spree/promotion_category.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
module Spree
class PromotionCategory < Spree::Base
validates :name, presence: true
has_many :promotions
has_many :promotions, dependent: :nullify
end
end
2 changes: 1 addition & 1 deletion legacy_promotions/app/models/spree/promotion_code.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
class Spree::PromotionCode < Spree::Base
belongs_to :promotion, inverse_of: :codes, optional: true
belongs_to :promotion_code_batch, class_name: "Spree::PromotionCodeBatch", optional: true
has_many :adjustments
has_many :adjustments, dependent: :restrict_with_error

before_validation :normalize_code

Expand Down
Loading