mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-13 19:54:02 +00:00
fix conflicts
This commit is contained in:
parent
e2fb434dc7
commit
71dfb3b7e4
34 changed files with 160 additions and 211 deletions
|
|
@ -3,55 +3,51 @@ require 'spec_helper'
|
|||
describe User do
|
||||
|
||||
# It is necessary to use bang version of let to build roles before user
|
||||
let!(:user_admin) { create(:user) }
|
||||
let!(:admin) { create(:admin) }
|
||||
let!(:participant) { create(:participant) }
|
||||
let!(:organizer_conference_1) { create(:organizer_conference_1 ) }
|
||||
let!(:organizer_conference_1_role) { Role.where(resource_type: 'Conference', resource_id: 1).first }
|
||||
let!(:participant) { create(:user) }
|
||||
let!(:conference) { create(:conference) }
|
||||
let!(:organizer_role) { create(:organizer_role, resource: conference) }
|
||||
let!(:cfp_role) { create(:cfp_role, resource: conference) }
|
||||
let!(:organizer) { create(:user, role_ids: [organizer_role.id]) }
|
||||
|
||||
it 'returns the correct role' do
|
||||
expect(organizer_conference_1.roles.first).to eq(organizer_conference_1_role)
|
||||
expect(user_admin.is_admin).to eq(true)
|
||||
expect(organizer.roles.first).to eq(organizer_role)
|
||||
end
|
||||
|
||||
it 'returns the correct roles' do
|
||||
participant_role = create(:participant_role)
|
||||
roles = [participant_role.id, organizer_conference_1_role.id]
|
||||
user_with_all_roles = create(:user, email: 'participant@example.de')
|
||||
user_with_all_roles.role_ids = roles
|
||||
user_with_all_roles.save
|
||||
roles = [organizer_role.id, cfp_role.id]
|
||||
another_user = create(:user, email: 'participant@example.de')
|
||||
another_user.role_ids = roles
|
||||
another_user.save
|
||||
|
||||
expect(user_with_all_roles.roles.length).to eq(2)
|
||||
expect(user_with_all_roles.roles[0]).to eq(participant_role)
|
||||
expect(user_with_all_roles.roles[1]).to eq(organizer_conference_1_role )
|
||||
expect(another_user.roles.length).to eq(2)
|
||||
expect(another_user.roles[0]).to eq(organizer_role)
|
||||
expect(another_user.roles[1]).to eq(cfp_role)
|
||||
end
|
||||
|
||||
describe '#has_role?' do
|
||||
shared_examples '#role?' do |user, role, expected|
|
||||
it "returns #{expected} for #{role}" do
|
||||
user_obj = create(user, email: 'e@example.com')
|
||||
expect(user_obj.has_role?(role.downcase, :any)).to be expected
|
||||
user_obj = create(user)
|
||||
expect(user_obj.has_role?(role.downcase, conference)).to be expected
|
||||
end
|
||||
end
|
||||
|
||||
context 'organizer' do
|
||||
it_behaves_like '#role?', :organizer_conference_1, 'organizer', true
|
||||
it_behaves_like '#role?', :organizer_conference_1, 'participant', false
|
||||
it_behaves_like '#role?', :organizer, 'organizer', true
|
||||
it_behaves_like '#role?', :organizer, 'participant', false
|
||||
end
|
||||
|
||||
context 'admin' do
|
||||
it 'assigns first user admin role' do
|
||||
expect(User.first.is_admin).to be true
|
||||
expect(admin.is_admin).to eq(true)
|
||||
end
|
||||
end
|
||||
|
||||
context 'participant' do
|
||||
it_behaves_like '#role?', :participant, 'adMin', false
|
||||
it_behaves_like '#role?', :participant, 'participant', true
|
||||
|
||||
# it 'assigns second user participant role' do
|
||||
# participant = create(:user, email: 'participant@example.de')
|
||||
# expect(participant.role_ids).to match_array([participant_role.id])
|
||||
# end
|
||||
it_behaves_like '#role?', :user, 'adMin', false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue