mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Fixes NamingMethodParameterName rubocop offense
This commit is contained in:
@@ -221,13 +221,6 @@ Metrics/PerceivedComplexity:
|
||||
- 'app/models/spree/ability.rb'
|
||||
- 'app/models/spree/order/checkout.rb'
|
||||
|
||||
# Offense count: 1
|
||||
# Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames.
|
||||
# AllowedNames: as, at, by, cc, db, id, if, in, io, ip, of, on, os, pp, to
|
||||
Naming/MethodParameterName:
|
||||
Exclude:
|
||||
- 'app/services/process_payment_intent.rb'
|
||||
|
||||
# Offense count: 26
|
||||
# Configuration parameters: EnforcedStyle, CheckMethodNames, CheckSymbols, AllowedIdentifiers, AllowedPatterns.
|
||||
# SupportedStyles: snake_case, normalcase, non_integer
|
||||
|
||||
@@ -24,7 +24,7 @@ module PaymentGateways
|
||||
|
||||
result = ProcessPaymentIntent.new(params["payment_intent"], @order).call!
|
||||
|
||||
unless result.ok?
|
||||
unless result.success?
|
||||
flash.now[:error] = "#{I18n.t('payment_could_not_process')}. #{result.error}"
|
||||
end
|
||||
|
||||
|
||||
@@ -13,13 +13,13 @@ class ProcessPaymentIntent
|
||||
class Result
|
||||
attr_reader :error
|
||||
|
||||
def initialize(ok:, error: "")
|
||||
@ok = ok
|
||||
def initialize(success:, error: "")
|
||||
@success = success
|
||||
@error = error
|
||||
end
|
||||
|
||||
def ok?
|
||||
@ok
|
||||
def success?
|
||||
@success
|
||||
end
|
||||
end
|
||||
|
||||
@@ -30,8 +30,8 @@ class ProcessPaymentIntent
|
||||
end
|
||||
|
||||
def call!
|
||||
return Result.new(ok: false) unless payment.present? && ready_for_capture?
|
||||
return Result.new(ok: true) if already_processed?
|
||||
return Result.new(success: false) unless payment.present? && ready_for_capture?
|
||||
return Result.new(success: true) if already_processed?
|
||||
|
||||
process_payment
|
||||
|
||||
@@ -39,16 +39,16 @@ class ProcessPaymentIntent
|
||||
payment.complete_authorization
|
||||
payment.clear_authorization_url
|
||||
|
||||
Result.new(ok: true)
|
||||
Result.new(success: true)
|
||||
else
|
||||
payment.fail_authorization
|
||||
payment.clear_authorization_url
|
||||
Result.new(ok: false, error: I18n.t("payment_could_not_complete"))
|
||||
Result.new(success: false, error: I18n.t("payment_could_not_complete"))
|
||||
end
|
||||
rescue Stripe::StripeError => e
|
||||
payment.fail_authorization
|
||||
payment.clear_authorization_url
|
||||
Result.new(ok: false, error: e.message)
|
||||
Result.new(success: false, error: e.message)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -39,7 +39,7 @@ RSpec.describe ProcessPaymentIntent do
|
||||
it "returns false" do
|
||||
result = service.call!
|
||||
|
||||
expect(result.ok?).to eq(false)
|
||||
expect(result.success?).to eq(false)
|
||||
expect(result.error).to eq("")
|
||||
end
|
||||
|
||||
@@ -58,7 +58,7 @@ RSpec.describe ProcessPaymentIntent do
|
||||
it "returns returns the error message" do
|
||||
result = service.call!
|
||||
|
||||
expect(result.ok?).to eq(false)
|
||||
expect(result.success?).to eq(false)
|
||||
expect(result.error).to eq("error message")
|
||||
end
|
||||
|
||||
@@ -150,7 +150,7 @@ RSpec.describe ProcessPaymentIntent do
|
||||
it "does not return any error message" do
|
||||
result = service.call!
|
||||
|
||||
expect(result.ok?).to eq(false)
|
||||
expect(result.success?).to eq(false)
|
||||
expect(result.error).to eq("")
|
||||
end
|
||||
|
||||
@@ -173,7 +173,7 @@ RSpec.describe ProcessPaymentIntent do
|
||||
it "returns a failed result" do
|
||||
result = service.call!
|
||||
|
||||
expect(result.ok?).to eq(false)
|
||||
expect(result.success?).to eq(false)
|
||||
expect(result.error).to eq('The payment could not be completed')
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user