automatically create free ticket with new conf
This commit is contained in:
parent
a6f7516eae
commit
53291e25b5
2 changed files with 20 additions and 0 deletions
|
|
@ -64,6 +64,8 @@ class Conference < ActiveRecord::Base
|
||||||
before_create :add_color
|
before_create :add_color
|
||||||
before_create :create_email_settings
|
before_create :create_email_settings
|
||||||
|
|
||||||
|
after_create :create_free_ticket
|
||||||
|
|
||||||
def date_range_string
|
def date_range_string
|
||||||
startstr = 'Unknown - '
|
startstr = 'Unknown - '
|
||||||
endstr = 'Unknown'
|
endstr = 'Unknown'
|
||||||
|
|
@ -647,6 +649,14 @@ class Conference < ActiveRecord::Base
|
||||||
create_roles
|
create_roles
|
||||||
end
|
end
|
||||||
|
|
||||||
|
##
|
||||||
|
# Creates free ticket for the conference
|
||||||
|
# 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.')
|
||||||
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
# Creates the roles of the conference
|
# Creates the roles of the conference
|
||||||
# after the conference has been successfully created
|
# after the conference has been successfully created
|
||||||
|
|
|
||||||
|
|
@ -1583,4 +1583,14 @@ describe Conference do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe 'after_create' do
|
||||||
|
let!(:conference) { create(:conference) }
|
||||||
|
|
||||||
|
it 'creates free tickets' do
|
||||||
|
free_ticket = Ticket.find_by(conference: conference)
|
||||||
|
expect(free_ticket).not_to be_nil
|
||||||
|
expect(free_ticket.price_cents).to eq(0)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue