Merge branch 'master' into custom-domain
This commit is contained in:
commit
e3d41bcf7d
30 changed files with 271 additions and 21 deletions
|
|
@ -167,5 +167,32 @@ describe Admin::OrganizationsController do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'POST #assign_org_admins' do
|
||||
let(:org_admin_role) { Role.find_by(name: 'organization_admin', resource: organization) }
|
||||
|
||||
before do
|
||||
post :assign_org_admins, id: organization.id,
|
||||
user: { email: user.email }
|
||||
end
|
||||
|
||||
it 'assigns organization_admin role' do
|
||||
expect(user.roles).to eq [org_admin_role]
|
||||
end
|
||||
end
|
||||
|
||||
describe 'DELETE #unassign_org_admins' do
|
||||
let(:org_admin_role) { Role.find_by(name: 'organization_admin', resource: organization) }
|
||||
let!(:org_admin_user) { create(:user, role_ids: [org_admin_role.id]) }
|
||||
|
||||
before do
|
||||
delete :unassign_org_admins, id: organization.id,
|
||||
user: { email: org_admin_user.email }
|
||||
end
|
||||
|
||||
it 'unassigns organization_admin role' do
|
||||
expect(org_admin_user.reload.roles).to eq []
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ describe Admin::RegistrationPeriodsController do
|
|||
# It is necessary to use bang version of let to build roles before user
|
||||
let(:conference) { create(:conference) }
|
||||
let!(:organizer_role) { Role.find_by(name: 'organizer', resource: conference) }
|
||||
|
||||
let!(:registration_ticket) { create(:registration_ticket, conference: conference) }
|
||||
let(:organizer) { create(:user, role_ids: organizer_role.id) }
|
||||
let(:organizer2) { create(:user, email: 'organizer2@email.osem', role_ids: organizer_role.id) }
|
||||
let(:participant) { create(:user) }
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Admin::RolesController do
|
||||
|
||||
let(:conference) { create(:conference) }
|
||||
let(:organizer_role) { Role.find_by(name: 'organizer', resource: conference) }
|
||||
let(:cfp_role) { Role.find_by(name: 'cfp', resource: conference) }
|
||||
|
|
|
|||
|
|
@ -3,5 +3,8 @@ FactoryGirl.define do
|
|||
title { "#{Faker::Hipster.word} Ticket" }
|
||||
price_cents 1000
|
||||
price_currency 'USD'
|
||||
factory :registration_ticket do
|
||||
registration_ticket true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -2,13 +2,15 @@ require 'spec_helper'
|
|||
|
||||
feature Conference do
|
||||
let!(:user) { create(:admin) }
|
||||
|
||||
let!(:organization) { create(:organization) }
|
||||
shared_examples 'add and update conference' do
|
||||
scenario 'adds a new conference', feature: true, js: true do
|
||||
expected_count = Conference.count + 1
|
||||
sign_in user
|
||||
|
||||
visit new_admin_conference_path
|
||||
|
||||
select organization.name, from: 'conference_organization_id'
|
||||
fill_in 'conference_title', with: 'Example Con'
|
||||
fill_in 'conference_short_title', with: 'ExCon'
|
||||
|
||||
|
|
@ -27,7 +29,7 @@ feature Conference do
|
|||
expect(flash)
|
||||
.to eq('Conference was successfully created.')
|
||||
expect(Conference.count).to eq(expected_count)
|
||||
|
||||
expect(Conference.last.organization).to eq(organization)
|
||||
expect(user.has_role? :organizer, Conference.last).to eq(true)
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ feature 'Has correct abilities' do
|
|||
let(:conference) { create(:full_conference, organization: organization) }
|
||||
let(:role_organization_admin) { Role.find_by(name: 'organization_admin', resource: organization) }
|
||||
let(:user_organization_admin) { create(:user, role_ids: [role_organization_admin.id]) }
|
||||
let!(:registration_ticket) { create(:registration_ticket, conference: conference) }
|
||||
|
||||
context 'when user is organization_admin' do
|
||||
before do
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ feature 'Has correct abilities' do
|
|||
let(:role_organizer_conf) { Role.find_by(name: 'organizer', resource: conference) }
|
||||
let(:role_organizer_other_conf) { Role.find_by(name: 'organizer', resource: other_conference) }
|
||||
let(:user_organizer) { create(:user, role_ids: [role_organizer_conf.id, role_organizer_other_conf.id]) }
|
||||
let!(:registration_ticket) { create(:registration_ticket, conference: conference) }
|
||||
|
||||
context 'when user is organizer' do
|
||||
before do
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ feature RegistrationPeriod do
|
|||
let!(:conference) { create(:conference) }
|
||||
let!(:organizer_role) { Role.find_by(name: 'organizer', resource: conference) }
|
||||
let!(:organizer) { create(:user, email: 'admin@example.com', role_ids: [organizer_role.id]) }
|
||||
let!(:registration_ticket) { create(:registration_ticket, conference: conference) }
|
||||
|
||||
shared_examples 'successfully' do
|
||||
scenario 'create and update registration period', js: true do
|
||||
|
|
|
|||
|
|
@ -98,6 +98,51 @@ feature Role do
|
|||
end
|
||||
end
|
||||
|
||||
context 'organization_admin' do
|
||||
let!(:organization) { create(:organization) }
|
||||
let!(:org_admin_role) { Role.find_by(name: 'organization_admin', resource: organization) }
|
||||
let!(:organization_admin) { create(:user, role_ids: [org_admin_role.id]) }
|
||||
let(:user_with_no_role) { create :user }
|
||||
let!(:other_organization) { create(:organization) }
|
||||
|
||||
before do
|
||||
sign_in organization_admin
|
||||
visit admin_organizations_path
|
||||
end
|
||||
|
||||
context 'for the organization it belongs to' do
|
||||
scenario 'successfully adds role organization_admin' do
|
||||
click_link('Admins', href: admins_admin_organization_path(organization.id))
|
||||
|
||||
fill_in 'user_email', with: user_with_no_role.email
|
||||
click_button 'Add'
|
||||
user_with_no_role.reload
|
||||
|
||||
expect(user_with_no_role.has_role?('organization_admin', organization)).to eq true
|
||||
end
|
||||
|
||||
scenario 'successfully removes role organization_admin' do
|
||||
click_link('Admins', href: admins_admin_organization_path(organization.id))
|
||||
|
||||
first('tr').find('.btn-danger').click
|
||||
expect(organization_admin.has_role?('organization_admin', organization)).to eq false
|
||||
end
|
||||
end
|
||||
|
||||
context 'for the organizations it does not belong to' do
|
||||
scenario 'does not successfully add role organization_admin' do
|
||||
click_link('Admins', href: admins_admin_organization_path(other_organization.id))
|
||||
|
||||
expect(page.has_field?('user_email')).to eq false
|
||||
end
|
||||
|
||||
scenario 'does not successfully removes role organization_admin' do
|
||||
click_link('Admins', href: admins_admin_organization_path(other_organization.id))
|
||||
expect(page.has_css?('.btn-danger')).to eq false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'organizer' do
|
||||
Role.all.each.map(&:name).each do |role|
|
||||
it_behaves_like 'successfully', role, 'organizer'
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ describe 'User with admin role' do
|
|||
|
||||
let!(:organization) { create(:organization) }
|
||||
let!(:my_conference) { create(:full_conference, organization: organization) }
|
||||
let!(:registration_ticket) { create(:registration_ticket, conference: my_conference) }
|
||||
let(:my_venue) { my_conference.venue || create(:venue, conference: my_conference) }
|
||||
let(:my_registration) { create(:registration, conference: my_conference, user: admin) }
|
||||
|
||||
|
|
@ -62,7 +63,7 @@ describe 'User with admin role' do
|
|||
|
||||
it{ should_not be_able_to(:update, Role.find_by(name: 'organization_admin', resource: other_organization)) }
|
||||
it{ should_not be_able_to(:edit, Role.find_by(name: 'organization_admin', resource: other_organization)) }
|
||||
it{ should_not be_able_to(:show, Role.find_by(name: 'organization_admin', resource: other_organization)) }
|
||||
it{ should be_able_to(:admins, organization) }
|
||||
|
||||
it{ should_not be_able_to(:new, User.new) }
|
||||
it{ should_not be_able_to(:create, User.new) }
|
||||
|
|
@ -126,6 +127,8 @@ describe 'User with admin role' do
|
|||
let(:other_organization) { create(:organization) }
|
||||
let(:other_conference) { create(:conference, organization: other_organization) }
|
||||
|
||||
it{ should be_able_to(:assign_org_admins, organization) }
|
||||
it{ should be_able_to(:unassign_org_admins, organization) }
|
||||
it{ should be_able_to(:manage, my_conference) }
|
||||
it{ should be_able_to(:read, organization) }
|
||||
it{ should be_able_to(:update, organization) }
|
||||
|
|
@ -136,6 +139,8 @@ describe 'User with admin role' do
|
|||
it{ should_not be_able_to(:create, Conference.new(organization_id: other_organization.id)) }
|
||||
it{ should_not be_able_to(:new, Organization.new) }
|
||||
it{ should_not be_able_to(:create, Organization.new) }
|
||||
|
||||
it_behaves_like 'user with any role'
|
||||
end
|
||||
|
||||
context 'when user has the role organizer' do
|
||||
|
|
@ -213,6 +218,9 @@ describe 'User with admin role' do
|
|||
|
||||
it{ should be_able_to(:manage, resource) }
|
||||
|
||||
it{ should_not be_able_to(:assign_org_admins, organization) }
|
||||
it{ should_not be_able_to(:unassign_org_admins, organization) }
|
||||
|
||||
%w[organizer cfp info_desk volunteers_coordinator].each do |role|
|
||||
it{ should be_able_to(:toggle_user, Role.find_by(name: role, resource: my_conference)) }
|
||||
it{ should be_able_to(:edit, Role.find_by(name: role, resource: my_conference)) }
|
||||
|
|
@ -298,6 +306,8 @@ describe 'User with admin role' do
|
|||
it{ should be_able_to(:index, resource) }
|
||||
it{ should be_able_to(:show, resource) }
|
||||
it{ should be_able_to(:update, resource) }
|
||||
it{ should_not be_able_to(:assign_org_admins, organization) }
|
||||
it{ should_not be_able_to(:unassign_org_admins, organization) }
|
||||
|
||||
it_behaves_like 'user with any role'
|
||||
it_behaves_like 'user with non-organizer role', 'cfp'
|
||||
|
|
@ -365,6 +375,8 @@ describe 'User with admin role' do
|
|||
it{ should be_able_to(:index, resource) }
|
||||
it{ should be_able_to(:show, resource) }
|
||||
it{ should be_able_to(:update, resource) }
|
||||
it{ should_not be_able_to(:assign_org_admins, organization) }
|
||||
it{ should_not be_able_to(:unassign_org_admins, organization) }
|
||||
|
||||
it_behaves_like 'user with any role'
|
||||
it_behaves_like 'user with non-organizer role', 'info_desk'
|
||||
|
|
@ -432,6 +444,8 @@ describe 'User with admin role' do
|
|||
it{ should be_able_to(:index, resource) }
|
||||
it{ should be_able_to(:show, resource) }
|
||||
it{ should be_able_to(:update, resource) }
|
||||
it{ should_not be_able_to(:assign_org_admins, organization) }
|
||||
it{ should_not be_able_to(:unassign_org_admins, organization) }
|
||||
|
||||
it 'should be_able to :manage Vposition'
|
||||
it 'should be_able to :manage Vday'
|
||||
|
|
@ -508,6 +522,9 @@ describe 'User with admin role' do
|
|||
it{ should_not be_able_to(:edit, my_self_organized_track) }
|
||||
it{ should_not be_able_to(:update, my_self_organized_track) }
|
||||
|
||||
it{ should_not be_able_to(:assign_org_admins, organization) }
|
||||
it{ should_not be_able_to(:unassign_org_admins, organization) }
|
||||
|
||||
it_behaves_like 'user with any role'
|
||||
it_behaves_like 'user with non-organizer role', 'track_organizer'
|
||||
end
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ require 'spec_helper'
|
|||
|
||||
describe RegistrationPeriod do
|
||||
let!(:conference) { create(:conference, start_date: Date.today, end_date: Date.today + 6) }
|
||||
let!(:registration_ticket) { create(:registration_ticket, conference: conference) }
|
||||
let!(:registration_period) { create(:registration_period, start_date: Date.today - 2, end_date: Date.today - 1, conference: conference) }
|
||||
|
||||
describe 'validations' do
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue