Rubocop autocorrections

This commit is contained in:
James Mason 2018-11-13 18:01:49 -08:00
parent 299738f58d
commit 43bef689fc
85 changed files with 622 additions and 578 deletions

View file

@ -5,7 +5,7 @@ class Ticket < ApplicationRecord
has_many :ticket_purchases, dependent: :destroy
has_many :buyers, -> { distinct }, through: :ticket_purchases, source: :user
has_paper_trail meta: { conference_id: :conference_id },
has_paper_trail meta: { conference_id: :conference_id },
ignore: %i[updated_at]
monetize :price_cents, with_model_currency: :price_currency
@ -66,6 +66,7 @@ class Ticket < ApplicationRecord
def tickets_turnover_total(id)
ticket = Ticket.find(id)
return Money.new(0, 'USD') unless ticket
sum = ticket.ticket_purchases.paid.total
Money.new(sum, ticket.price_currency)
end
@ -79,6 +80,7 @@ class Ticket < ApplicationRecord
def tickets_of_conference_have_same_currency
tickets = Ticket.where(conference_id: conference_id)
return if tickets.count.zero? || (tickets.count == 1 && self == tickets.first)
unless tickets.all?{|t| t.price_currency == price_currency }
errors.add(:price_currency, 'is different from the existing tickets of this conference.')
end