tests
This commit is contained in:
parent
439d632251
commit
2d3a1ef37e
1 changed files with 21 additions and 20 deletions
|
|
@ -6,7 +6,7 @@ describe 'User' do
|
|||
subject(:ability){ Ability.new(user) }
|
||||
let(:user){ nil }
|
||||
let(:conference_not_public) { create(:conference, make_conference_public: false) }
|
||||
let(:conference_public) { create(:conference)}
|
||||
let(:conference_public) { create(:conference, make_conference_public: true) }
|
||||
let(:event_confirmed) { create(:event, state: 'confirmed') }
|
||||
let(:someevent) { create(:event) }
|
||||
|
||||
|
|
@ -28,30 +28,40 @@ describe 'User' do
|
|||
|
||||
context 'when is a Signed In User' do # Test abilities for signed in users (without any role)
|
||||
let(:user) { create(:participant) }
|
||||
let(:someuser) { create(:participant) }
|
||||
let(:registration1) { create(:registration, conference: conference_public, user: user) }
|
||||
let(:registration2) { create(:registration, conference: conference_not_public, user: user) }
|
||||
let(:registration2) { create(:registration, conference: conference_not_public, user: someuser) }
|
||||
|
||||
it{ should be_able_to(:create, Event) } # Can create a new proposal
|
||||
it{ should be_able_to(:index, Event) } # Can access proposal index page
|
||||
it{ should_not be_able_to(:manage, Event.new) } # Cannot manage events that are not theirs
|
||||
it{ should be_able_to(:show, event_confirmed) } # Can only view confirmed events
|
||||
it{ should_not be_able_to(:show, someevent) }
|
||||
|
||||
it{ should be_able_to(:create, Event) }
|
||||
it{ should be_able_to(:index, Event) }
|
||||
it{ should_not be_able_to(:manage, Event.new) }
|
||||
it{ should be_able_to(:show, event_confirmed) }
|
||||
|
||||
it{ should be_able_to(:manage, registration1) }
|
||||
it{ should be_able_to(:manage, registration2) }
|
||||
# Can register for a conference
|
||||
it{ should be_able_to(:register, registration1) }
|
||||
it{ should be_able_to(:update, registration1) }
|
||||
it{ should be_able_to(:unregister, registration1) }
|
||||
# Cannot change the registration of other people
|
||||
it{ should_not be_able_to(:register, registration2) }
|
||||
it{ should_not be_able_to(:update, registration2) }
|
||||
it{ should_not be_able_to(:unregister, registration2) }
|
||||
|
||||
# Can see the conference splash page only if conference is public
|
||||
it{ should be_able_to(:show, conference_public)}
|
||||
it{ should_not be_able_to(:show, conference_not_public)}
|
||||
it{ should_not be_able_to(:manage, Conference) }
|
||||
|
||||
# Cannot manage a conference
|
||||
it{ should_not be_able_to(:manage, conference_public) }
|
||||
end
|
||||
|
||||
context '#is_admin?' do
|
||||
let(:user) { create(:admin) }
|
||||
|
||||
it{ should be_able_to(:manage, User) }
|
||||
end
|
||||
|
||||
context 'signed in users can manage their events' do
|
||||
>>>>>>> adding tests and some fixes in ability
|
||||
let(:user) { create(:participant) }
|
||||
let(:user2) { create(:participant) }
|
||||
let(:myevent) { create(:event, users: [user]) }
|
||||
|
|
@ -60,19 +70,11 @@ describe 'User' do
|
|||
# Users are able to update and destroy their own events
|
||||
it{ should be_able_to(:update, myevent) }
|
||||
it{ should be_able_to(:destroy, myevent) }
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
it{ should be_able_to(:manage, myevent) }
|
||||
>>>>>>> adding tests and some fixes in ability
|
||||
|
||||
# Users are not able to update and destroy other users events
|
||||
it{ should_not be_able_to(:update, someevent) }
|
||||
it{ should_not be_able_to(:destroy, someevent) }
|
||||
<<<<<<< HEAD
|
||||
end
|
||||
|
||||
=======
|
||||
it{ should_not be_able_to(:manage, someevent) }
|
||||
end
|
||||
|
||||
context 'when is an organizer' do
|
||||
|
|
@ -110,6 +112,5 @@ describe 'User' do
|
|||
it{ should be_able_to(:manage, create(:event_type, conference: conference1)) }
|
||||
# it{ should_not be_able_to(:create, Registration) }
|
||||
end
|
||||
>>>>>>> adding tests and some fixes in ability
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue