This commit is contained in:
Rishabh Saxena 2017-04-18 07:29:47 +00:00 committed by GitHub
commit 938269681d
2 changed files with 7 additions and 0 deletions

View file

@ -83,7 +83,11 @@ class ConferenceRegistrationsController < ApplicationController
end end
def destroy def destroy
tickets_purchased = TicketPurchase.where(conference_id: @registration.conference_id)
if @registration.destroy if @registration.destroy
if tickets_purchased
tickets_purchased.destroy
end
redirect_to root_path, redirect_to root_path,
notice: "You are not registered for #{@conference.title} anymore!" notice: "You are not registered for #{@conference.title} anymore!"
else else

View file

@ -144,6 +144,9 @@ describe Admin::RegistrationPeriodsController do
it 'it deletes the registration period' do it 'it deletes the registration period' do
expect { delete :destroy, conference_id: conference.short_title }.to change(RegistrationPeriod, :count).by(-1) expect { delete :destroy, conference_id: conference.short_title }.to change(RegistrationPeriod, :count).by(-1)
end end
it 'it deletes the conference tickets' do
expect { delete :destroy, conference_id: conference.short_title }.to change(TicketPurchase, :count).by(-1)
end
it 'redirects to users#show' do it 'redirects to users#show' do
delete :destroy, conference_id: conference.short_title delete :destroy, conference_id: conference.short_title
expect(response).to redirect_to admin_conference_registration_period_path expect(response).to redirect_to admin_conference_registration_period_path