mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-13 19:54:02 +00:00
Remove assumption from test that first user is admin
This commit is contained in:
parent
0619eb7963
commit
d2b392e119
8 changed files with 6 additions and 21 deletions
|
|
@ -4,7 +4,6 @@ describe Admin::CommentsController, type: :controller do
|
|||
|
||||
# It is necessary to use bang version of let to build roles before user
|
||||
let(:conference) { create(:conference) }
|
||||
let!(:first_user) { create(:user) }
|
||||
let!(:organizer_role) { Role.find_by(name: 'organizer', resource: conference) }
|
||||
let(:organizer) { create(:user, role_ids: organizer_role.id, last_sign_in_at: Time.now - 1.day) }
|
||||
let(:participant) { create(:user) }
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ describe Admin::ConferenceController do
|
|||
|
||||
# It is necessary to use bang version of let to build roles before user
|
||||
let(:conference) { create(:conference, end_date: Date.new(2014, 05, 26) + 15) }
|
||||
let!(:first_user) { create(:user) }
|
||||
let!(:organizer_role) { Role.find_by(name: 'organizer', resource: conference) }
|
||||
|
||||
let(:organizer) { create(:user, role_ids: organizer_role.id) }
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ describe Admin::ProgramsController, type: :controller do
|
|||
|
||||
# It is necessary to use bang version of let to build roles before user
|
||||
let(:conference) { create(:conference) }
|
||||
let!(:first_user) { create(:user) }
|
||||
let!(:organizer_role) { Role.find_by(name: 'organizer', resource: conference) }
|
||||
let(:organizer) { create(:user, role_ids: organizer_role.id, last_sign_in_at: Time.now - 1.day) }
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ describe Admin::RegistrationPeriodsController do
|
|||
|
||||
# It is necessary to use bang version of let to build roles before user
|
||||
let(:conference) { create(:conference) }
|
||||
let!(:first_user) { create(:user) }
|
||||
let!(:organizer_role) { Role.find_by(name: 'organizer', resource: conference) }
|
||||
|
||||
let(:organizer) { create(:user, role_ids: organizer_role.id) }
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ require 'spec_helper'
|
|||
describe Admin::RolesController do
|
||||
|
||||
let(:conference) { create(:conference) }
|
||||
let!(:first_user) { create(:user) }
|
||||
let(:organizer_role) { Role.find_by(name: 'organizer', resource: conference) }
|
||||
let(:cfp_role) { Role.find_by(name: 'cfp', resource: conference) }
|
||||
let(:admin) { create(:admin) }
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ feature 'Has correct abilities' do
|
|||
let(:user_volunteer_coordinator) { create(:user, role_ids: [role_volunteer_coordinator.id]) }
|
||||
|
||||
scenario 'when user has no role' do
|
||||
user.is_admin = false
|
||||
sign_in user
|
||||
|
||||
visit admin_conference_path(conference1.short_title)
|
||||
|
|
@ -29,7 +28,6 @@ feature 'Has correct abilities' do
|
|||
end
|
||||
|
||||
scenario 'when user is organizer' do
|
||||
user_organizer.is_admin = false
|
||||
sign_in user_organizer
|
||||
|
||||
visit admin_conference_path(conference1.short_title)
|
||||
|
|
@ -107,7 +105,6 @@ feature 'Has correct abilities' do
|
|||
end
|
||||
|
||||
scenario 'when user is cfp' do
|
||||
user_cfp.is_admin = false
|
||||
sign_in user_cfp
|
||||
|
||||
visit admin_conference_path(conference2.short_title)
|
||||
|
|
@ -182,7 +179,6 @@ feature 'Has correct abilities' do
|
|||
end
|
||||
|
||||
scenario 'when user is info desk' do
|
||||
user_info_desk.is_admin = false
|
||||
sign_in user_info_desk
|
||||
|
||||
visit admin_conference_path(conference3.short_title)
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ feature 'BaseController' do
|
|||
end
|
||||
|
||||
it 'not an admin it redirects to root_path' do
|
||||
user.is_admin = false
|
||||
visit admin_conference_index_path
|
||||
expect(current_path).to eq root_path
|
||||
expect(flash).to eq 'You are not authorized to access this area!'
|
||||
|
|
@ -36,28 +35,24 @@ feature 'BaseController' do
|
|||
end
|
||||
|
||||
it 'an organizer he can access the admin area' do
|
||||
user.is_admin = false
|
||||
user.role_ids = organizer_role.id
|
||||
visit admin_conference_index_path
|
||||
expect(current_path).to eq admin_conference_index_path
|
||||
end
|
||||
|
||||
it 'a volunteers_coordinator he can access the admin area' do
|
||||
user.is_admin = false
|
||||
user.role_ids = volunteers_coordinator_role.id
|
||||
visit admin_conference_index_path
|
||||
expect(current_path).to eq admin_conference_index_path
|
||||
end
|
||||
|
||||
it 'a cfp he can access the admin area' do
|
||||
user.is_admin = false
|
||||
user.role_ids = cfp_role.id
|
||||
visit admin_conference_index_path
|
||||
expect(current_path).to eq admin_conference_index_path
|
||||
end
|
||||
|
||||
it 'an info_desk he can access the admin area' do
|
||||
user.is_admin = false
|
||||
user.role_ids = info_desk_role.id
|
||||
visit admin_conference_index_path
|
||||
expect(current_path).to eq admin_conference_index_path
|
||||
|
|
|
|||
|
|
@ -3,8 +3,7 @@ require 'cancan/matchers'
|
|||
|
||||
describe 'User' do
|
||||
describe 'Abilities' do
|
||||
# automatically becomes admin
|
||||
let!(:first_user) { create(:user) }
|
||||
let!(:admin) { create(:admin) }
|
||||
|
||||
# see https://github.com/CanCanCommunity/cancancan/wiki/Testing-Abilities
|
||||
subject(:ability){ Ability.new(user) }
|
||||
|
|
@ -13,7 +12,7 @@ describe 'User' do
|
|||
let!(:my_conference) { create(:full_conference) }
|
||||
let!(:my_cfp) { create(:cfp, program: my_conference.program) }
|
||||
let(:my_venue) { my_conference.venue || create(:venue, conference: my_conference) }
|
||||
let(:my_registration) { create(:registration, conference: my_conference, user: first_user) }
|
||||
let(:my_registration) { create(:registration, conference: my_conference, user: admin) }
|
||||
|
||||
let(:other_registration) { create(:registration, conference: conference_public) }
|
||||
let(:my_event) { create(:event_full, program: my_conference.program) }
|
||||
|
|
@ -109,7 +108,7 @@ describe 'User' do
|
|||
context 'when user has the role organizer' do
|
||||
let!(:my_conference) { create(:full_conference) }
|
||||
let(:role) { Role.find_by(name: 'organizer', resource: my_conference) }
|
||||
let(:user) { create(:user, role_ids: [role.id], is_admin: false) }
|
||||
let(:user) { create(:user, role_ids: [role.id]) }
|
||||
|
||||
it{ should_not be_able_to(:destroy, my_conference.program) }
|
||||
it 'when there is a room assigned to an event' do
|
||||
|
|
@ -175,7 +174,7 @@ describe 'User' do
|
|||
context 'when user has the role cfp' do
|
||||
let!(:my_conference) { create(:full_conference) }
|
||||
let(:role) { Role.find_by(name: 'cfp', resource: my_conference) }
|
||||
let(:user) { create(:user, role_ids: [role.id], is_admin: false) }
|
||||
let(:user) { create(:user, role_ids: [role.id]) }
|
||||
|
||||
it{ should_not be_able_to([:create, :new], Conference.new) }
|
||||
it{ should_not be_able_to(:manage, my_conference) }
|
||||
|
|
@ -230,7 +229,7 @@ describe 'User' do
|
|||
context 'when user has the role info_desk' do
|
||||
let!(:my_conference) { create(:full_conference) }
|
||||
let(:role) { Role.find_by(name: 'info_desk', resource: my_conference) }
|
||||
let(:user) { create(:user, role_ids: [role.id], is_admin: false) }
|
||||
let(:user) { create(:user, role_ids: [role.id]) }
|
||||
|
||||
it{ should_not be_able_to([:create, :new], Conference.new) }
|
||||
it{ should_not be_able_to(:manage, my_conference) }
|
||||
|
|
@ -285,7 +284,7 @@ describe 'User' do
|
|||
context 'when user has the role volunteers_coordinator' do
|
||||
let!(:my_conference) { create(:full_conference) }
|
||||
let(:role) { Role.find_by(name: 'volunteers_coordinator', resource: my_conference) }
|
||||
let(:user) { create(:user, role_ids: [role.id], is_admin: false) }
|
||||
let(:user) { create(:user, role_ids: [role.id]) }
|
||||
|
||||
it{ should_not be_able_to([:create, :new], Conference.new) }
|
||||
it{ should_not be_able_to(:manage, my_conference) }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue