Merge pull request #13247 from cyrillefr/FixRailsRubocopIssueInverseOfInOrder

Fix Rubocop InverseOf offense in Order model
This commit is contained in:
David Cook
2025-04-07 16:45:50 +10:00
committed by GitHub
3 changed files with 2 additions and 9 deletions

View File

@@ -474,13 +474,6 @@ RSpecRails/InferredSpecType:
- 'spec/requests/voucher_adjustments_spec.rb'
- 'spec/routing/stripe_spec.rb'
# Offense count: 1
# Configuration parameters: IgnoreScopes, Include.
# Include: app/models/**/*.rb
Rails/InverseOf:
Exclude:
- 'app/models/spree/order.rb'
# Offense count: 35
# Configuration parameters: Include.
# Include: app/controllers/**/*.rb, app/mailers/**/*.rb

View File

@@ -43,7 +43,7 @@ module Spree
has_many :state_changes, as: :stateful, dependent: :destroy
has_many :line_items, -> {
order('created_at ASC')
}, class_name: "Spree::LineItem", dependent: :destroy
}, class_name: "Spree::LineItem", inverse_of: :order, dependent: :destroy
has_many :payments, dependent: :destroy
has_many :return_authorizations, dependent: :destroy, inverse_of: :order
has_many :adjustments, -> { order "#{Spree::Adjustment.table_name}.created_at ASC" },

View File

@@ -189,8 +189,8 @@ RSpec.describe Spree::OrderContents do
subject.update_item(line_item, { quantity: 3 })
end
it "updates the order's enterprise fees if completed" do
order.shipments << create(:shipment)
allow(order).to receive(:completed?) { true }
expect(order).to receive(:update_order_fees!)