Refactoring Tickets
- Tickets now independent from registration - Implemented money gem #419
This commit is contained in:
parent
5485fe0e7f
commit
5f8a8ac6d9
63 changed files with 1581 additions and 573 deletions
|
|
@ -34,7 +34,7 @@ feature 'Has correct abilities' do
|
|||
expect(page).to have_link('Lodgings', href: "/admin/conference/#{conference1.short_title}/lodgings")
|
||||
expect(page).to have_link('Sponsorship', href: "/admin/conference/#{conference1.short_title}/sponsorship_levels")
|
||||
expect(page).to have_link('Sponsors', href: "/admin/conference/#{conference1.short_title}/sponsors")
|
||||
expect(page).to have_link('Supporter Levels', href: "/admin/conference/#{conference1.short_title}/supporter_levels")
|
||||
expect(page).to have_link('Tickets', href: "/admin/conference/#{conference1.short_title}/tickets")
|
||||
expect(page).to have_link('E-Mails', href: "/admin/conference/#{conference1.short_title}/emails")
|
||||
expect(page).to have_link('Call for papers', href: "/admin/conference/#{conference1.short_title}/callforpapers")
|
||||
expect(page).to have_link('Tracks', href: "/admin/conference/#{conference1.short_title}/tracks")
|
||||
|
|
@ -70,8 +70,8 @@ feature 'Has correct abilities' do
|
|||
visit admin_conference_sponsorship_levels_path(conference1.short_title)
|
||||
expect(current_path).to eq(admin_conference_sponsorship_levels_path(conference1.short_title))
|
||||
|
||||
visit admin_conference_supporter_levels_path(conference1.short_title)
|
||||
expect(current_path).to eq(admin_conference_supporter_levels_path(conference1.short_title))
|
||||
visit admin_conference_tickets_path(conference1.short_title)
|
||||
expect(current_path).to eq(admin_conference_tickets_path(conference1.short_title))
|
||||
|
||||
visit admin_conference_emails_path(conference1.short_title)
|
||||
expect(current_path).to eq(admin_conference_emails_path(conference1.short_title))
|
||||
|
|
@ -141,7 +141,7 @@ feature 'Has correct abilities' do
|
|||
visit admin_conference_sponsorship_levels_path(conference2.short_title)
|
||||
expect(current_path).to eq(root_path)
|
||||
|
||||
visit admin_conference_supporter_levels_path(conference2.short_title)
|
||||
visit admin_conference_tickets_path(conference2.short_title)
|
||||
expect(current_path).to eq(root_path)
|
||||
|
||||
visit admin_conference_emails_path(conference2.short_title)
|
||||
|
|
@ -212,7 +212,7 @@ feature 'Has correct abilities' do
|
|||
visit admin_conference_sponsorship_levels_path(conference3.short_title)
|
||||
expect(current_path).to eq(root_path)
|
||||
|
||||
visit admin_conference_supporter_levels_path(conference3.short_title)
|
||||
visit admin_conference_tickets_path(conference3.short_title)
|
||||
expect(current_path).to eq(root_path)
|
||||
|
||||
visit admin_conference_emails_path(conference3.short_title)
|
||||
|
|
@ -284,7 +284,7 @@ feature 'Has correct abilities' do
|
|||
visit admin_conference_sponsorship_levels_path(conference4.short_title)
|
||||
expect(current_path).to eq(root_path)
|
||||
|
||||
visit admin_conference_supporter_levels_path(conference4.short_title)
|
||||
visit admin_conference_tickets_path(conference4.short_title)
|
||||
expect(current_path).to eq(root_path)
|
||||
|
||||
visit admin_conference_emails_path(conference4.short_title)
|
||||
|
|
|
|||
|
|
@ -5,17 +5,15 @@ feature Commercial do
|
|||
let!(:conference) { create(:conference) }
|
||||
let!(:organizer_role) { create(:organizer_role, resource: conference) }
|
||||
let!(:organizer) { create(:user, role_ids: [organizer_role.id]) }
|
||||
let!(:participant) { create(:user) }
|
||||
|
||||
shared_examples 'adds and updates a commercial' do
|
||||
scenario 'of a conference',
|
||||
feature: true, js: true do
|
||||
|
||||
context 'in admin area' do
|
||||
scenario 'adds, updates, deletes of a conference', feature: true, js: true do
|
||||
expected_count = conference.commercials.count + 1
|
||||
|
||||
sign_in organizer
|
||||
|
||||
visit admin_conference_commercials_path(conference.short_title)
|
||||
|
||||
click_link 'New Commercial'
|
||||
|
||||
# Create without an commercial id
|
||||
|
|
@ -60,7 +58,87 @@ feature Commercial do
|
|||
end
|
||||
end
|
||||
|
||||
describe 'organizer' do
|
||||
it_behaves_like 'adds and updates a commercial'
|
||||
context 'in public area' do
|
||||
let!(:event) { create(:event, conference: conference, title: 'Example Proposal') }
|
||||
|
||||
before(:each) do
|
||||
event.event_users = [create(:event_user,
|
||||
user_id: participant.id,
|
||||
event_id: event.id,
|
||||
event_role: 'submitter')]
|
||||
|
||||
@expected_count = Commercial.count + 1
|
||||
sign_in participant
|
||||
end
|
||||
|
||||
after(:each) do
|
||||
sign_out
|
||||
end
|
||||
|
||||
scenario 'adds a invalid commercial to an event', feature: true, js: true do
|
||||
visit edit_conference_proposal_path(conference.short_title, event.id)
|
||||
|
||||
click_link 'Commercials'
|
||||
click_link 'Add Commercial'
|
||||
|
||||
select('SlideShare', from: 'commercial_commercial_type')
|
||||
fill_in 'commercial_commercial_id', with: '12345'
|
||||
|
||||
click_button 'Create Commercial'
|
||||
expect(flash).to eq('Commercial was successfully created.')
|
||||
expect(event.commercials.count).to eq(@expected_count)
|
||||
end
|
||||
|
||||
scenario 'adds a valid commercial to an event', feature: true, js: true do
|
||||
visit edit_conference_proposal_path(conference.short_title, event.id)
|
||||
click_link 'Commercials'
|
||||
click_link 'Add Commercial'
|
||||
|
||||
select('SlideShare', from: 'commercial_commercial_type')
|
||||
|
||||
click_button 'Create Commercial'
|
||||
expect(flash).to eq("A error prohibited this Commercial from being saved: Commercial can't be blank.")
|
||||
expect(event.commercials.count).to eq(@expected_count - 1)
|
||||
end
|
||||
|
||||
scenario 'updates a valid commercial to an event', feature: true, js: true do
|
||||
create(:commercial,
|
||||
commercialable_id: event.id,
|
||||
commercialable_type: 'Event')
|
||||
visit edit_conference_proposal_path(conference.short_title, event.id)
|
||||
click_link 'Commercials'
|
||||
click_link 'Edit'
|
||||
select('SlideShare', from: 'commercial_commercial_type')
|
||||
fill_in 'commercial_commercial_id', with: '56789'
|
||||
click_button 'Update Commercial'
|
||||
expect(flash).to eq('Commercial was successfully updated.')
|
||||
expect(event.commercials.count).to eq(@expected_count)
|
||||
end
|
||||
|
||||
scenario 'updates a invalid commercial to an event', feature: true, js: true do
|
||||
create(:commercial,
|
||||
commercialable_id: event.id,
|
||||
commercialable_type: 'Event')
|
||||
visit edit_conference_proposal_path(conference.short_title, event.id)
|
||||
click_link 'Commercials'
|
||||
click_link 'Edit'
|
||||
select('SlideShare', from: 'commercial_commercial_type')
|
||||
fill_in 'commercial_commercial_id', with: ''
|
||||
click_button 'Update Commercial'
|
||||
expect(flash).to eq("A error prohibited this Commercial from being saved: Commercial can't be blank.")
|
||||
expect(event.commercials.count).to eq(@expected_count)
|
||||
end
|
||||
|
||||
scenario 'deletes a commercial to an event', feature: true, js: true do
|
||||
create(:commercial,
|
||||
commercialable_id: event.id,
|
||||
commercialable_type: 'Event')
|
||||
visit edit_conference_proposal_path(conference.short_title, event.id)
|
||||
click_link 'Commercials'
|
||||
click_link 'Delete'
|
||||
page.driver.network_traffic
|
||||
expect(flash).to eq('Commercial was successfully destroyed.')
|
||||
expect(event.commercials.count).to eq(@expected_count - 1)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
52
spec/features/conference_registration_spec.rb
Normal file
52
spec/features/conference_registration_spec.rb
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
require 'spec_helper'
|
||||
|
||||
feature Registration do
|
||||
let!(:conference) { create(:conference, registration_period: create(:registration_period, start_date: 3.days.ago)) }
|
||||
let!(:participant) { create(:user) }
|
||||
|
||||
context 'as a participant' do
|
||||
before(:each) do
|
||||
sign_in participant
|
||||
end
|
||||
|
||||
after(:each) do
|
||||
sign_out
|
||||
end
|
||||
|
||||
context 'who is already registered' do
|
||||
let!(:registration) { create(:registration, user: participant, conference: conference) }
|
||||
|
||||
scenario 'updates conference registration', feature: true, js: true do
|
||||
visit root_path
|
||||
click_link 'Modify Registration'
|
||||
|
||||
expect(current_path).to eq(edit_conference_conference_registrations_path(conference.short_title))
|
||||
click_button 'Update Registration'
|
||||
|
||||
expect(conference.user_registered?(participant)).to be(true)
|
||||
end
|
||||
|
||||
scenario 'unregisters for a conference', feature: true, js: true do
|
||||
visit root_path
|
||||
click_link 'Modify Registration'
|
||||
|
||||
expect(current_path).to eq(edit_conference_conference_registrations_path(conference.short_title))
|
||||
click_link 'Unregister'
|
||||
|
||||
expect(conference.user_registered?(participant)).to be(false)
|
||||
end
|
||||
end
|
||||
|
||||
context 'who is not registered' do
|
||||
scenario 'registers for a conference', feature: true, js: true do
|
||||
visit root_path
|
||||
click_link 'Register'
|
||||
|
||||
expect(current_path).to eq(new_conference_conference_registrations_path(conference.short_title))
|
||||
click_button 'Register'
|
||||
|
||||
expect(conference.user_registered?(participant)).to be(true)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -4,21 +4,76 @@ feature Event do
|
|||
let!(:conference) { create(:conference) }
|
||||
let!(:organizer_role) { create(:organizer_role, resource: conference) }
|
||||
let!(:organizer) { create(:user, email: 'admin@example.com', role_ids: [organizer_role.id]) }
|
||||
let!(:participant) { create(:user, biography: '') }
|
||||
let!(:participant) { create(:user) }
|
||||
let!(:participant_without_bio) { create(:user, biography: '') }
|
||||
|
||||
shared_examples 'proposal workflow' do
|
||||
scenario 'submitts a proposal, accepts and confirms',
|
||||
feature: true, js: true do
|
||||
before(:each) do
|
||||
conference.call_for_papers = create(:call_for_papers)
|
||||
conference.event_types = [create(:event_type)]
|
||||
|
||||
@options = {}
|
||||
@options[:send_mail] = 'false'
|
||||
|
||||
@event = create(:event, conference: conference, title: 'Example Proposal')
|
||||
end
|
||||
|
||||
after(:each) do
|
||||
sign_out
|
||||
end
|
||||
|
||||
context 'as an conference organizer' do
|
||||
before(:each) do
|
||||
sign_in organizer
|
||||
end
|
||||
|
||||
scenario 'rejects a proposal', feature: true, js: true do
|
||||
visit admin_conference_events_path(conference.short_title)
|
||||
expect(page.has_content?('Example Proposal')).to be true
|
||||
|
||||
click_button 'New'
|
||||
click_link "reject_event_#{@event.id}"
|
||||
expect(flash).to eq('Event rejected!')
|
||||
@event.reload
|
||||
expect(@event.state).to eq('rejected')
|
||||
end
|
||||
|
||||
scenario 'accepts a proposal', feature: true, js: true do
|
||||
visit admin_conference_events_path(conference.short_title)
|
||||
expect(page.has_content?('Example Proposal')).to be true
|
||||
|
||||
click_button 'New'
|
||||
click_link "accept_event_#{@event.id}"
|
||||
expect(flash).to eq('Event accepted!')
|
||||
expect(page.has_content?('Unconfirmed')).to be true
|
||||
@event.reload
|
||||
expect(@event.state).to eq('unconfirmed')
|
||||
end
|
||||
|
||||
scenario 'restarts review of a proposal', feature: true, js: true do
|
||||
@event.reject!(@options)
|
||||
visit admin_conference_events_path(conference.short_title)
|
||||
expect(page.has_content?('Example Proposal')).to be true
|
||||
|
||||
click_button 'Rejected'
|
||||
click_link "restart_event_#{@event.id}"
|
||||
expect(flash).to eq('Review started!')
|
||||
@event.reload
|
||||
expect(@event.state).to eq('new')
|
||||
end
|
||||
end
|
||||
|
||||
context 'as a participant' do
|
||||
before(:each) do
|
||||
@event.accept!(@options)
|
||||
@event.event_users = [create(:event_user,
|
||||
user_id: participant.id,
|
||||
event_id: @event.id,
|
||||
event_role: 'submitter')]
|
||||
end
|
||||
|
||||
scenario 'submits a valid proposal', feature: true, js: true do
|
||||
sign_in participant_without_bio
|
||||
expected_count = Event.count + 1
|
||||
|
||||
conference.call_for_papers = create(:call_for_papers)
|
||||
conference.email_settings = create(:email_settings)
|
||||
conference.event_types = [create(:event_type)]
|
||||
|
||||
# Submit a new proposal as participant
|
||||
sign_in participant
|
||||
|
||||
visit conference_proposal_index_path(conference.short_title)
|
||||
click_link 'New Proposal'
|
||||
|
||||
|
|
@ -36,109 +91,31 @@ feature Event do
|
|||
expect(flash).to eq('Event was successfully submitted. You should register for the conference now.')
|
||||
|
||||
expect(current_path).to eq(new_conference_conference_registrations_path(conference.short_title))
|
||||
|
||||
expect(Event.count).to eq(expected_count)
|
||||
end
|
||||
|
||||
event = Event.where(title: 'Example Proposal').first
|
||||
|
||||
visit conference_proposal_index_path(conference.short_title)
|
||||
expect(page.has_content?('Example Proposal')).to be true
|
||||
|
||||
expected_count_commercial = Commercial.count + 1
|
||||
# Add a invalid commercial
|
||||
visit edit_conference_proposal_path(conference.short_title, event.id)
|
||||
|
||||
click_link 'Commercials'
|
||||
click_link 'Add Commercial'
|
||||
|
||||
select('SlideShare', from: 'commercial_commercial_type')
|
||||
|
||||
click_button 'Create Commercial'
|
||||
expect(flash).to eq("A error prohibited this Commercial from being saved: Commercial can't be blank.")
|
||||
expect(event.commercials.count).to eq(expected_count_commercial - 1)
|
||||
|
||||
# Add a valid commercial
|
||||
visit edit_conference_proposal_path(conference.short_title, event.id)
|
||||
|
||||
click_link 'Commercials'
|
||||
click_link 'Add Commercial'
|
||||
|
||||
select('SlideShare', from: 'commercial_commercial_type')
|
||||
fill_in 'commercial_commercial_id', with: '12345'
|
||||
|
||||
click_button 'Create Commercial'
|
||||
expect(flash).to eq('Commercial was successfully created.')
|
||||
expect(event.commercials.count).to eq(expected_count_commercial)
|
||||
|
||||
# Edit an invalid commercial
|
||||
click_link 'Commercials'
|
||||
click_link 'Edit'
|
||||
|
||||
select('SlideShare', from: 'commercial_commercial_type')
|
||||
fill_in 'commercial_commercial_id', with: ''
|
||||
|
||||
click_button 'Update Commercial'
|
||||
expect(flash).to eq("A error prohibited this Commercial from being saved: Commercial can't be blank.")
|
||||
expect(event.commercials.count).to eq(expected_count_commercial)
|
||||
|
||||
# Edit a valid commercial
|
||||
select('SlideShare', from: 'commercial_commercial_type')
|
||||
fill_in 'commercial_commercial_id', with: '56789'
|
||||
|
||||
click_button 'Update Commercial'
|
||||
expect(flash).to eq('Commercial was successfully updated.')
|
||||
expect(event.commercials.count).to eq(expected_count_commercial)
|
||||
|
||||
# Delete a commercial
|
||||
click_link 'Commercials'
|
||||
click_link 'Delete'
|
||||
page.driver.network_traffic
|
||||
expect(flash).to eq('Commercial was successfully destroyed.')
|
||||
expect(event.commercials.count).to eq(expected_count_commercial - 1)
|
||||
|
||||
sign_out
|
||||
sign_in organizer
|
||||
|
||||
# Reject proposal
|
||||
visit admin_conference_events_path(conference.short_title)
|
||||
expect(page.has_content?('Example Proposal')).to be true
|
||||
|
||||
click_button 'New'
|
||||
click_link "reject_event_#{event.id}"
|
||||
expect(flash).to eq('Event rejected!')
|
||||
click_button 'Rejected'
|
||||
click_link "restart_event_#{event.id}"
|
||||
expect(flash).to eq('Review started!')
|
||||
|
||||
# Start review
|
||||
click_button 'New'
|
||||
click_link "accept_event_#{event.id}"
|
||||
expect(flash).to eq('Event accepted!')
|
||||
expect(page.has_content?('Unconfirmed')).to be true
|
||||
sign_out
|
||||
|
||||
# Confirm proposal as participant
|
||||
scenario 'confirms a proposal', feature: true, js: true do
|
||||
sign_in participant
|
||||
visit conference_proposal_index_path(conference.short_title)
|
||||
expect(page.has_content?('Example Proposal')).to be true
|
||||
expect(page.has_content?('Unconfirmed')).to be true
|
||||
click_link "confirm_proposal_#{event.id}"
|
||||
click_link "confirm_proposal_#{@event.id}"
|
||||
expect(flash).
|
||||
to eq('The proposal was confirmed. Please register to attend the conference.')
|
||||
@event.reload
|
||||
expect(@event.state).to eq('confirmed')
|
||||
end
|
||||
|
||||
# Register for conference
|
||||
find('#register').click
|
||||
expect(flash).to eq('You are now registered and will be receiving E-Mail notifications.')
|
||||
|
||||
# Withdraw proposal
|
||||
scenario 'withdraw a proposal', feature: true, js: true do
|
||||
sign_in participant
|
||||
@event.confirm!
|
||||
visit conference_proposal_index_path(conference.short_title)
|
||||
expect(page.has_content?('Example Proposal')).to be true
|
||||
expect(page.has_content?('Confirmed')).to be true
|
||||
click_link "delete_proposal_#{event.id}"
|
||||
click_link "delete_proposal_#{@event.id}"
|
||||
expect(flash).to eq('Proposal was successfully withdrawn.')
|
||||
@event.reload
|
||||
expect(@event.state).to eq('withdrawn')
|
||||
end
|
||||
end
|
||||
|
||||
describe 'proposal' do
|
||||
it_behaves_like 'proposal workflow'
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,46 +0,0 @@
|
|||
require 'spec_helper'
|
||||
|
||||
feature SupporterLevel do
|
||||
let!(:conference) { create(:conference) }
|
||||
let!(:organizer_role) { create(:organizer_role, resource: conference) }
|
||||
let!(:user) { create(:user, role_ids: [organizer_role.id]) }
|
||||
|
||||
shared_examples 'supporter levels' do
|
||||
scenario 'adds and updates supporter level', feature: true, js: true do
|
||||
sign_in user
|
||||
visit admin_conference_supporter_levels_path(conference_id: conference.short_title)
|
||||
|
||||
# Add supporter level
|
||||
click_link 'Add supporter_level'
|
||||
expect(page.all('div.nested-fields').count == 1).to be true
|
||||
|
||||
page.
|
||||
find('div.nested-fields:nth-of-type(1) div:nth-of-type(1) input').
|
||||
set('Example supporter level')
|
||||
|
||||
page.
|
||||
find('div.nested-fields:nth-of-type(1) div:nth-of-type(2) input').
|
||||
set('http://www.google.de')
|
||||
|
||||
click_button 'Update Conference'
|
||||
|
||||
# Validations
|
||||
expect(flash).to eq('Supporter levels were successfully updated.')
|
||||
expect(find('div.nested-fields:nth-of-type(1) div:nth-of-type(1) input').
|
||||
value).to eq('Example supporter level')
|
||||
expect(find('div.nested-fields:nth-of-type(1) div:nth-of-type(2) input').
|
||||
value).to eq('http://www.google.de')
|
||||
|
||||
# Remove supporter level
|
||||
click_link 'Remove supporter_level'
|
||||
expect(page.all('div.nested-fields').count == 0).to be true
|
||||
find('button', text: 'Update Conference').trigger('click')
|
||||
expect(flash).to eq('Supporter levels were successfully updated.')
|
||||
expect(page.all('div.nested-fields').count == 0).to be true
|
||||
end
|
||||
end
|
||||
|
||||
describe 'organizer' do
|
||||
it_behaves_like 'supporter levels'
|
||||
end
|
||||
end
|
||||
51
spec/features/ticket_purchases_spec.rb
Normal file
51
spec/features/ticket_purchases_spec.rb
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
require 'spec_helper'
|
||||
|
||||
feature Registration do
|
||||
let!(:ticket) { create(:ticket) }
|
||||
let!(:conference) { create(:conference, title: 'ExampleCon', tickets: [ticket]) }
|
||||
let!(:participant) { create(:user) }
|
||||
|
||||
context 'as a participant' do
|
||||
before(:each) do
|
||||
sign_in participant
|
||||
end
|
||||
|
||||
after(:each) do
|
||||
sign_out
|
||||
end
|
||||
|
||||
context 'who is not registered' do
|
||||
|
||||
scenario 'purchases a ticket', feature: true, js: true do
|
||||
visit root_path
|
||||
click_link 'Support'
|
||||
|
||||
fill_in "tickets__#{ticket.id}", with: '2'
|
||||
expect(current_path).to eq(conference_tickets_path(conference.short_title))
|
||||
|
||||
click_button 'Support'
|
||||
|
||||
purchase = TicketPurchase.where(user_id: participant.id, ticket_id: ticket.id).first
|
||||
expect(purchase.quantity).to eq(2)
|
||||
expect(current_path).to eq(conference_conference_registrations_path(conference.short_title))
|
||||
expect(flash).
|
||||
to eq('Congratulations, you have successfully purchased a ticket! You can pay it cash on check in! Thank you for supporting ExampleCon!')
|
||||
expect(page.has_content?('Business Ticket')).to be true
|
||||
end
|
||||
|
||||
scenario 'deletes a purchased ticket', feature: true, js: true do
|
||||
create(:ticket_purchase,
|
||||
user_id: participant.id,
|
||||
ticket_id: ticket.id,
|
||||
quantity: 2)
|
||||
|
||||
visit conference_conference_registrations_path(conference.short_title)
|
||||
expect(page.has_content?('Business Ticket')).to be true
|
||||
|
||||
click_link 'Delete'
|
||||
expect(flash).to eq('Ticket successfully destroyed.')
|
||||
expect(TicketPurchase.count).to eq(0)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
86
spec/features/tickets_spec.rb
Normal file
86
spec/features/tickets_spec.rb
Normal file
|
|
@ -0,0 +1,86 @@
|
|||
require 'spec_helper'
|
||||
|
||||
feature Ticket do
|
||||
let!(:conference) { create(:conference, title: 'ExampleCon') }
|
||||
let!(:organizer_role) { create(:organizer_role, resource: conference) }
|
||||
let!(:organizer) { create(:user, email: 'admin@example.com', role_ids: [organizer_role.id]) }
|
||||
|
||||
context 'as a organizer' do
|
||||
before(:each) do
|
||||
sign_in organizer
|
||||
end
|
||||
|
||||
after(:each) do
|
||||
sign_out
|
||||
end
|
||||
|
||||
scenario 'add a valid ticket', feature: true, js: true do
|
||||
visit admin_conference_tickets_path(conference.short_title)
|
||||
click_link 'Add Ticket'
|
||||
|
||||
fill_in 'ticket_title', with: 'Business Ticket'
|
||||
fill_in 'ticket_description', with: 'The business ticket'
|
||||
fill_in 'ticket_price', with: '100'
|
||||
|
||||
click_button 'Create Ticket'
|
||||
expect(flash).to eq('Ticket successfully created.')
|
||||
expect(Ticket.count).to eq(1)
|
||||
end
|
||||
|
||||
scenario 'add a invalid ticket', feature: true, js: true do
|
||||
visit admin_conference_tickets_path(conference.short_title)
|
||||
click_link 'Add Ticket'
|
||||
|
||||
fill_in 'ticket_title', with: ''
|
||||
fill_in 'ticket_price', with: '-1'
|
||||
|
||||
click_button 'Create Ticket'
|
||||
expect(flash).to eq("Creating Ticket failed: Title can't be blank. Price cents must be greater than 0.")
|
||||
expect(Ticket.count).to eq(0)
|
||||
end
|
||||
|
||||
context 'Ticket already created' do
|
||||
let!(:ticket) { create(:ticket, title: 'Business Ticket', price: 100, conference_id: conference.id) }
|
||||
|
||||
scenario 'edit valid ticket', feature: true, js: true do
|
||||
visit admin_conference_tickets_path(conference.short_title)
|
||||
click_link 'Edit'
|
||||
|
||||
fill_in 'ticket_title', with: 'Free Ticket'
|
||||
fill_in 'ticket_price', with: '50'
|
||||
|
||||
click_button 'Update Ticket'
|
||||
|
||||
ticket.reload
|
||||
expect(ticket.price).to eq(50)
|
||||
expect(ticket.title).to eq('Free Ticket')
|
||||
expect(flash).to eq('Ticket successfully updated.')
|
||||
expect(Ticket.count).to eq(1)
|
||||
end
|
||||
|
||||
scenario 'edit invalid ticket', feature: true, js: true do
|
||||
visit admin_conference_tickets_path(conference.short_title)
|
||||
click_link 'Edit'
|
||||
|
||||
fill_in 'ticket_title', with: ''
|
||||
fill_in 'ticket_price', with: '-5'
|
||||
|
||||
click_button 'Update Ticket'
|
||||
|
||||
ticket.reload
|
||||
expect(ticket.price).to eq(100)
|
||||
expect(ticket.title).to eq('Business Ticket')
|
||||
expect(flash).to eq("Ticket update failed: Title can't be blank. Price cents must be greater than 0.")
|
||||
expect(Ticket.count).to eq(1)
|
||||
end
|
||||
|
||||
scenario 'delete ticket', feature: true, js: true do
|
||||
visit admin_conference_tickets_path(conference.short_title)
|
||||
click_link 'Delete'
|
||||
|
||||
expect(flash).to eq('Ticket successfully destroyed.')
|
||||
expect(Ticket.count).to eq(0)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue