Fix authorization of new and create in ConferenceRegistrationsController

Before authorization we need to set conference relation.
Change in proposal spec cause conference has to have valid registration
period for successful redirect to registration after confirm proposal.
This commit is contained in:
Aditya Prakash 2016-02-28 12:07:13 +05:30
parent b18e302224
commit c71d15565e
5 changed files with 32 additions and 5 deletions

View file

@ -49,5 +49,16 @@ feature Registration do
expect(conference.user_registered?(participant)).to be(true)
end
end
context 'registration is closed' do
let(:conference_with_closed_registration) { create(:conference, registration_period: create(:registration_period)) }
scenario 'registers for a conference', feature: true do
participant.is_admin = false
visit new_conference_conference_registrations_path(conference_with_closed_registration.short_title)
expect(current_path).to eq(root_path)
expect(flash).to eq 'You are not authorized to access this page.'
end
end
end
end

View file

@ -2,6 +2,7 @@ require 'spec_helper'
feature Event do
let!(:conference) { create(:conference) }
let!(:registration_period) { create(:registration_period, conference: conference, start_date: Date.current) }
let!(:cfp) { create(:cfp, program_id: conference.program.id) }
let!(:organizer_role) { Role.find_by(name: 'organizer', resource: conference) }
let!(:organizer) { create(:user, email: 'admin@example.com', role_ids: [organizer_role.id]) }
@ -134,6 +135,7 @@ feature Event do
click_link "confirm_proposal_#{@event.id}"
expect(flash).
to eq('The proposal was confirmed. Please register to attend the conference.')
expect(current_path).to eq(new_conference_conference_registrations_path(conference.short_title))
@event.reload
expect(@event.state).to eq('confirmed')
end