Skip to content

Commit e619671

Browse files
mamhofftvdeyen
authored andcommitted
AdjustmentReason: Add :dependent option
We should not delete adjustment reasons if there are adjustments created with them.
1 parent b67dbb7 commit e619671

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

.rubocop_todo.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This configuration was generated by
22
# `rubocop --auto-gen-config`
3-
# on 2025-06-26 11:28:28 UTC using RuboCop version 1.76.0.
3+
# on 2025-07-08 12:12:57 UTC using RuboCop version 1.76.0.
44
# The point is for the user to remove these configuration records
55
# one by one as the offenses are removed from the code base.
66
# Note that changes in the inspected code, or installation of new
@@ -332,7 +332,7 @@ Rails/FilePath:
332332
- "core/lib/spree/testing_support/dummy_app.rb"
333333
- "sample/lib/spree/sample.rb"
334334

335-
# Offense count: 43
335+
# Offense count: 42
336336
# Configuration parameters: Include.
337337
# Include: **/app/models/**/*.rb
338338
Rails/HasManyOrHasOneDependent:

core/app/models/spree/adjustment_reason.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
module Spree
44
class AdjustmentReason < Spree::Base
5-
has_many :adjustments, inverse_of: :adjustment_reason
5+
has_many :adjustments, inverse_of: :adjustment_reason, dependent: :restrict_with_error
66

77
validates :name, presence: true, uniqueness: { case_sensitive: false, allow_blank: true }
88
validates :code, presence: true, uniqueness: { case_sensitive: false, allow_blank: true }

0 commit comments

Comments
 (0)