conference: refactor code and tests

This commit is contained in:
Rishabh Saxena 2016-08-29 19:49:25 +05:30
parent 53291e25b5
commit fe828d24db
No known key found for this signature in database
GPG key ID: FA3BDC38A9CB6807
2 changed files with 2 additions and 2 deletions

View file

@ -654,7 +654,7 @@ class Conference < ActiveRecord::Base
# after the conference has been successfully created
# Will create 1 new record for 'free' ticket
def create_free_ticket
ticket = Ticket.where(conference: self, title: 'Free Access', price_cents: 0).first_or_create!(description: 'Get free access tickets for the conference.')
tickets.where(title: 'Free Access', price_cents: 0).first_or_create!(description: 'Get free access tickets for the conference.')
end
##

View file

@ -1588,7 +1588,7 @@ describe Conference do
let!(:conference) { create(:conference) }
it 'creates free tickets' do
free_ticket = Ticket.find_by(conference: conference)
free_ticket = conference.tickets.first
expect(free_ticket).not_to be_nil
expect(free_ticket.price_cents).to eq(0)
end