mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-17 21:54:06 +00:00
Roles into their own controller. Rework interface. Add flash messages to ajax calls. Add description to roles. Possible to edit roles in use.
This commit is contained in:
parent
eda5c2bc07
commit
ccd7ecbb90
59 changed files with 618 additions and 356 deletions
|
|
@ -1,26 +0,0 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'admin/conference/roles' do
|
||||
let(:conference) { create(:conference) }
|
||||
let(:organizer_role) { create(:organizer_role, description: 'My description for organizer role', resource: conference) }
|
||||
let(:organizer) { create(:user, name: 'test name', email: 'test@email.com', role_ids: [organizer_role.id]) }
|
||||
|
||||
it 'renders the roles template for the conference' do
|
||||
assign :conference, conference
|
||||
assign :selection, 'organizer'
|
||||
assign :role, [organizer_role]
|
||||
assign :role_users, 'organizer' => [organizer]
|
||||
render
|
||||
expect(rendered).to include('Show users for role:')
|
||||
expect(rendered).to include(organizer_role.description)
|
||||
expect(rendered).to include("Add role 'Organizer' to user:")
|
||||
expect(rendered).to include('Add role')
|
||||
expect(rendered).to include('Users with role Organizer')
|
||||
expect(rendered).to have_selector('table thead th:nth-of-type(1)', text: 'ID')
|
||||
expect(rendered).to have_selector('table thead th:nth-of-type(2)', text: 'Name')
|
||||
expect(rendered).to have_selector('table thead th:nth-of-type(3)', text: 'Email')
|
||||
expect(rendered).to have_selector('table tbody tr:nth-of-type(1) td:nth-of-type(1)', text: organizer.id)
|
||||
expect(rendered).to have_selector('table tbody tr:nth-of-type(1) td:nth-of-type(2)', text: 'test name')
|
||||
expect(rendered).to have_selector('table tbody tr:nth-of-type(1) td:nth-of-type(3)', text: 'test@email.com')
|
||||
end
|
||||
end
|
||||
41
spec/views/admin/roles/index.html.haml_spec.rb
Normal file
41
spec/views/admin/roles/index.html.haml_spec.rb
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'admin/roles/index' do
|
||||
let(:conference) { create(:conference) }
|
||||
let(:organizer_role) { Role.find_by(name: 'organizer', resource: conference) }
|
||||
let!(:organizer) { create(:user, name: 'user name for organizer', email: 'organizer@osem.io', role_ids: organizer_role.id) }
|
||||
|
||||
let(:cfp_role) { Role.find_by(name: 'cfp', resource: conference) }
|
||||
let!(:cfp_user) { create(:user, name: 'user name for cfp', email: 'cfp@osem.io', role_ids: [cfp_role.id]) }
|
||||
|
||||
let(:info_desk_role) { Role.find_by(name: 'info_desk', resource: conference) }
|
||||
let(:volunteers_coordinator_role) { Role.find_by(name: 'volunteers_coordinator', resource: conference) }
|
||||
|
||||
before(:each) do
|
||||
assign :conference, conference
|
||||
assign :roles, [organizer_role, cfp_role, info_desk_role, volunteers_coordinator_role]
|
||||
|
||||
render
|
||||
end
|
||||
|
||||
it 'renders index' do
|
||||
expect(organizer_role.users.count).to eq 1
|
||||
expect(rendered).to have_selector('table thead th:nth-of-type(1)', text: 'ID')
|
||||
expect(rendered).to have_selector('table thead th:nth-of-type(2)', text: 'Name')
|
||||
expect(rendered).to have_selector('table thead th:nth-of-type(3)', text: 'Description')
|
||||
expect(rendered).to have_selector('table thead th:nth-of-type(4)', text: 'Users')
|
||||
expect(rendered).to have_selector('table thead th:nth-of-type(5)', text: 'Actions')
|
||||
|
||||
expect(rendered).to have_selector('table tbody tr:nth-of-type(1) td:nth-of-type(1)', text: organizer_role.id)
|
||||
expect(rendered).to have_selector('table tbody tr:nth-of-type(1) td:nth-of-type(2)', text: 'Organizer')
|
||||
expect(rendered).to have_selector('table tbody tr:nth-of-type(1) td:nth-of-type(3)', text: 'For the organizers of the conference (who shall have full access)')
|
||||
expect(rendered).to have_selector('table tbody tr:nth-of-type(1) td:nth-of-type(4)', text: 'user name for organizer')
|
||||
expect(rendered).to have_selector('table tbody tr:nth-of-type(1) td:nth-of-type(5)', text: 'Users')
|
||||
|
||||
expect(rendered).to have_selector('table tbody tr:nth-of-type(2) td:nth-of-type(1)', text: cfp_role.id)
|
||||
expect(rendered).to have_selector('table tbody tr:nth-of-type(2) td:nth-of-type(2)', text: 'Cfp')
|
||||
expect(rendered).to have_selector('table tbody tr:nth-of-type(2) td:nth-of-type(3)', text: 'For the members of the CfP team')
|
||||
expect(rendered).to have_selector('table tbody tr:nth-of-type(2) td:nth-of-type(4)', text: 'user name for cfp')
|
||||
expect(rendered).to have_selector('table tbody tr:nth-of-type(2) td:nth-of-type(5)', text: 'Users')
|
||||
end
|
||||
end
|
||||
28
spec/views/admin/roles/show.html.haml_spec.rb
Normal file
28
spec/views/admin/roles/show.html.haml_spec.rb
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'admin/roles/show' do
|
||||
let(:conference) { create(:conference) }
|
||||
let(:organizer_role) { Role.find_by(name: 'organizer', resource: conference) }
|
||||
let(:organizer) { create(:user, name: 'test name', email: 'test@email.osem', role_ids: [organizer_role.id]) }
|
||||
|
||||
before(:each) do
|
||||
sign_in organizer
|
||||
assign :conference, conference
|
||||
assign :selection, 'organizer'
|
||||
assign :role, organizer_role
|
||||
assign :users, [organizer]
|
||||
render
|
||||
end
|
||||
|
||||
it 'renders show properly' do
|
||||
expect(rendered).to include(organizer_role.name.capitalize)
|
||||
expect(rendered).to include('Add user by email:')
|
||||
expect(rendered).to have_selector('table thead th:nth-of-type(1)', text: '')
|
||||
expect(rendered).to have_selector('table thead th:nth-of-type(2)', text: 'ID')
|
||||
expect(rendered).to have_selector('table thead th:nth-of-type(3)', text: 'Name')
|
||||
expect(rendered).to have_selector('table thead th:nth-of-type(4)', text: 'Email')
|
||||
expect(rendered).to have_selector('table tbody tr:nth-of-type(1) td:nth-of-type(2)', text: organizer.id)
|
||||
expect(rendered).to have_selector('table tbody tr:nth-of-type(1) td:nth-of-type(3)', text: 'test name')
|
||||
expect(rendered).to have_selector('table tbody tr:nth-of-type(1) td:nth-of-type(4)', text: 'test@email.osem')
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue