Merge pull request #838 from sonalkr132/ticket-tests

Tests for ticket model
This commit is contained in:
Stella Rouzi 2016-03-09 12:03:52 +02:00
commit e560d263c9
2 changed files with 70 additions and 16 deletions

View file

@ -18,7 +18,7 @@ class Ticket < ActiveRecord::Base
end
def paid?(user)
ticket_purchases.where(user_id: user.id, paid: false).count == 0
ticket_purchases.find_by(user: user, paid: true).present?
end
def quantity_bought_by(user)
@ -52,7 +52,7 @@ class Ticket < ActiveRecord::Base
def tickets_of_conference_have_same_currency
unless Ticket.where(conference_id: conference_id).all?{|t| t.price_currency == self.price_currency }
errors.add(:price_currency, 'Currency is different from the exist ticktes of this conference.')
errors.add(:price_currency, 'is different from the existing tickets of this conference.')
end
end
end