mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Fixes rubocop offense inverse_of on payment model
- some clean up unused method too
This commit is contained in:
@@ -474,13 +474,12 @@ RSpecRails/InferredSpecType:
|
||||
- 'spec/requests/voucher_adjustments_spec.rb'
|
||||
- 'spec/routing/stripe_spec.rb'
|
||||
|
||||
# Offense count: 2
|
||||
# Offense count: 1
|
||||
# Configuration parameters: IgnoreScopes, Include.
|
||||
# Include: app/models/**/*.rb
|
||||
Rails/InverseOf:
|
||||
Exclude:
|
||||
- 'app/models/spree/order.rb'
|
||||
- 'app/models/spree/payment.rb'
|
||||
|
||||
# Offense count: 35
|
||||
# Configuration parameters: Include.
|
||||
|
||||
@@ -22,6 +22,7 @@ module Spree
|
||||
|
||||
has_many :offsets, -> { where("source_type = 'Spree::Payment' AND amount < 0").completed },
|
||||
class_name: "Spree::Payment", foreign_key: :source_id,
|
||||
inverse_of: :source,
|
||||
dependent: :restrict_with_exception
|
||||
has_many :log_entries, as: :source, dependent: :destroy
|
||||
|
||||
@@ -115,10 +116,6 @@ module Spree
|
||||
amount - offsets_total
|
||||
end
|
||||
|
||||
def can_credit?
|
||||
credit_allowed.positive?
|
||||
end
|
||||
|
||||
def build_source
|
||||
return if source_attributes.nil?
|
||||
return unless payment_method&.payment_source_class
|
||||
|
||||
@@ -607,19 +607,6 @@ RSpec.describe Spree::Payment do
|
||||
end
|
||||
end
|
||||
|
||||
context "#can_credit?" do
|
||||
it "is true if credit_allowed > 0" do
|
||||
payment = build_stubbed(:payment)
|
||||
allow(payment).to receive(:credit_allowed) { 100 }
|
||||
expect(payment.can_credit?).to be true
|
||||
end
|
||||
it "is false if credit_allowed is 0" do
|
||||
payment = build_stubbed(:payment)
|
||||
allow(payment).to receive(:credit_allowed) { 0 }
|
||||
expect(payment.can_credit?).to be false
|
||||
end
|
||||
end
|
||||
|
||||
context "#save" do
|
||||
context "completed payments" do
|
||||
it "updates order payment total" do
|
||||
|
||||
Reference in New Issue
Block a user