currency of a single ticket could be updated now

closes #1913

fixed travis faliures

minor changes

removed empty file

added tests regarding currency updation
This commit is contained in:
ViditChitkara 2017-12-22 23:05:13 +05:30 committed by Stella Rouzi
parent 769cc6c970
commit 33d32b9294
2 changed files with 25 additions and 1 deletions

View file

@ -76,7 +76,9 @@ class Ticket < ApplicationRecord
private
def tickets_of_conference_have_same_currency
unless Ticket.where(conference_id: conference_id).all?{|t| t.price_currency == price_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
end