mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-01-18 07:52:23 +01:00
(quality) disable Rails/RedundantPresenceValidationOnBelongsTo
This setting was disabled in config/application.rb: `config.active_record.belongs_to_required_by_default = false`, so we must configure the linter accordingly. Also: linting some little bit of code
This commit is contained in:
parent
3e6763f14a
commit
6df9724527
@ -36,3 +36,5 @@ Style/FormatString:
|
||||
EnforcedStyle: sprintf
|
||||
Style/FormatStringToken:
|
||||
EnforcedStyle: template
|
||||
Rails/RedundantPresenceValidationOnBelongsTo:
|
||||
Enabled: false
|
||||
|
@ -18,7 +18,7 @@ class API::WalletController < API::ApiController
|
||||
end
|
||||
|
||||
def credit
|
||||
return head 422 unless Setting.get('wallet_module')
|
||||
return head :unprocessable_entity unless Setting.get('wallet_module')
|
||||
|
||||
@wallet = Wallet.find(credit_params[:id])
|
||||
authorize @wallet
|
||||
@ -28,7 +28,7 @@ class API::WalletController < API::ApiController
|
||||
service.create_avoir(transaction, credit_params[:avoir_date], credit_params[:avoir_description]) if credit_params[:avoir]
|
||||
render :show
|
||||
else
|
||||
head 422
|
||||
head :unprocessable_entity
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -11,6 +11,8 @@ class Wallet < ApplicationRecord
|
||||
|
||||
validates :invoicing_profile, presence: true
|
||||
|
||||
delegate :user, to: :invoicing_profile
|
||||
|
||||
def credit(amount)
|
||||
if amount.is_a?(Numeric) && amount >= 0
|
||||
self.amount += amount
|
||||
@ -26,8 +28,4 @@ class Wallet < ApplicationRecord
|
||||
end
|
||||
false
|
||||
end
|
||||
|
||||
def user
|
||||
invoicing_profile.user
|
||||
end
|
||||
end
|
||||
|
@ -14,6 +14,7 @@ class WalletTransaction < ApplicationRecord
|
||||
has_one :invoice_item, as: :object, dependent: :destroy
|
||||
|
||||
validates :transaction_type, inclusion: { in: %w[credit debit] }
|
||||
validates :invoicing_profile, :wallet, presence: true
|
||||
|
||||
delegate :user, to: :invoicing_profile
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user