rework roles with rolify

This commit is contained in:
Stella Rouzi 2014-07-11 18:41:35 +03:00
parent f9f840c811
commit 4af0e59ca6
40 changed files with 167 additions and 228 deletions

View file

@ -3,9 +3,8 @@ require 'spec_helper'
feature Campaign do
# It is necessary to use bang version of let to build roles before user
let!(:organizer_role) { create(:organizer_role) }
let!(:participant_role) { create(:participant_role) }
let!(:admin_role) { create(:admin_role) }
let!(:organizer_role) { create(:organizer_role) }
shared_examples 'add and update campaign' do |user|
scenario 'adds and update a campaign', feature: true, js: true do
@ -42,7 +41,7 @@ feature Campaign do
expect(Campaign.count).to eq(expected_count)
campaign = Campaign.where('name'=> 'Test Campaign').first
campaign = Campaign.where('name' => 'Test Campaign').first
visit edit_admin_conference_campaign_path(conference.short_title, campaign.id)
fill_in 'campaign_name', with: 'Test Campaign 42'
@ -52,8 +51,7 @@ feature Campaign do
end
end
describe 'admin' do
it_behaves_like 'add and update campaign', :admin
describe 'organizer' do
it_behaves_like 'add and update campaign', :organizer
end
end

View file

@ -3,9 +3,8 @@ require 'spec_helper'
feature Conference do
# It is necessary to use bang version of let to build roles before user
let!(:organizer_role) { create(:organizer_role) }
let!(:participant_role) { create(:participant_role) }
let!(:admin_role) { create(:admin_role) }
let!(:organizer_role) { create(:organizer_role) }
shared_examples 'add and update cfp' do |user|
scenario 'adds a new cfp', feature: true, js: true do
@ -87,8 +86,7 @@ feature Conference do
end
end
describe 'admin' do
it_behaves_like 'add and update cfp', :admin
describe 'organizer' do
it_behaves_like 'add and update cfp', :organizer
end
end

View file

@ -3,9 +3,8 @@ require 'spec_helper'
feature Conference do
# It is necessary to use bang version of let to build roles before user
let!(:organizer_role) { create(:organizer_role) }
let!(:participant_role) { create(:participant_role) }
let!(:admin_role) { create(:admin_role) }
let!(:organizer_role) { create(:organizer_role) }
shared_examples 'add and update conference' do |user|
scenario 'adds a new conference', feature: true, js: true do
@ -56,12 +55,7 @@ feature Conference do
end
end
describe 'admin' do
it_behaves_like 'add and update conference', :admin
end
describe 'organizer' do
it_behaves_like 'add and update conference', :organizer
end
end

View file

@ -2,9 +2,8 @@ require 'spec_helper'
feature DifficultyLevel do
# It is necessary to use bang version of let to build roles before user
let!(:organizer_role) { create(:organizer_role) }
let!(:participant_role) { create(:participant_role) }
let!(:admin_role) { create(:admin_role) }
let!(:organizer_role) { create(:organizer_role) }
shared_examples 'difficulty levels' do |user|
scenario 'adds and updates difficulty level', feature: true, js: true do
@ -50,10 +49,6 @@ feature DifficultyLevel do
end
end
describe 'admin' do
it_behaves_like 'difficulty levels', :admin
end
describe 'organizer' do
it_behaves_like 'difficulty levels', :organizer
end

View file

@ -2,9 +2,8 @@ require 'spec_helper'
feature Event do
# It is necessary to use bang version of let to build roles before user
let!(:organizer_role) { create(:organizer_role) }
let!(:participant_role) { create(:participant_role) }
let!(:admin_role) { create(:admin_role) }
let!(:organizer_role) { create(:organizer_role) }
shared_examples 'email settings' do |user|
scenario 'updates email settings',
@ -91,10 +90,6 @@ feature Event do
end
end
describe 'admin' do
it_behaves_like 'email settings', :admin
end
describe 'organizer' do
it_behaves_like 'email settings', :organizer
end

View file

@ -2,9 +2,8 @@ require 'spec_helper'
feature EventType do
# It is necessary to use bang version of let to build roles before user
let!(:organizer_role) { create(:organizer_role) }
let!(:participant_role) { create(:participant_role) }
let!(:admin_role) { create(:admin_role) }
let!(:organizer_role) { create(:organizer_role) }
shared_examples 'event types' do |user|
scenario 'adds and updates event type', feature: true, js: true do
@ -55,10 +54,6 @@ feature EventType do
end
end
describe 'admin' do
it_behaves_like 'event types', :admin
end
describe 'organizer' do
it_behaves_like 'event types', :organizer
end

View file

@ -2,9 +2,8 @@ require 'spec_helper'
feature Lodging do
# It is necessary to use bang version of let to build roles before user
let!(:organizer_role) { create(:organizer_role) }
let!(:participant_role) { create(:participant_role) }
let!(:admin_role) { create(:admin_role) }
let!(:organizer_role) { create(:organizer_role) }
shared_examples 'lodgings' do |user|
scenario 'adds and updates lodgings', feature: true, js: true do
@ -56,10 +55,6 @@ feature Lodging do
end
end
describe 'admin' do
it_behaves_like 'lodgings', :admin
end
describe 'organizer' do
it_behaves_like 'lodgings', :organizer
end

View file

@ -2,7 +2,7 @@ require 'spec_helper'
feature Openid do
let!(:participant_role) { create(:participant_role) }
let!(:admin_role) { create(:admin_role) }
let!(:organizer_role) { create(:organizer_role) }
shared_examples 'sign in with openid' do

View file

@ -2,16 +2,15 @@ require 'spec_helper'
feature Event do
# It is necessary to use bang version of let to build roles before user
let!(:organizer_role) { create(:organizer_role) }
let!(:participant_role) { create(:participant_role) }
let!(:admin_role) { create(:admin_role) }
let!(:organizer_role) { create(:organizer_role) }
shared_examples 'proposal workflow' do
scenario 'submitts a proposal, accepts and confirms',
feature: true, js: true do
admin = create(:admin, email: 'admin@example.com')
participant = create(:participant, email: 'participant@example.com', biography: "")
organizer = create(:organizer, email: 'admin@example.com')
participant = create(:participant, email: 'participant@example.com')
expected_count = Event.count + 1
conference = create(:conference)
@ -49,7 +48,7 @@ feature Event do
expect(page.has_content?('Example Proposal')).to be true
sign_out
sign_in admin
sign_in organizer
# Reject proposal
visit admin_conference_events_path(conference.short_title)

View file

@ -2,9 +2,8 @@ require 'spec_helper'
feature Room do
# It is necessary to use bang version of let to build roles before user
let!(:organizer_role) { create(:organizer_role) }
let!(:participant_role) { create(:participant_role) }
let!(:admin_role) { create(:admin_role) }
let!(:organizer_role) { create(:organizer_role) }
shared_examples 'rooms' do |user|
scenario 'adds and updates rooms', feature: true, js: true do
@ -43,10 +42,6 @@ feature Room do
end
end
describe 'admin' do
it_behaves_like 'rooms', :admin
end
describe 'organizer' do
it_behaves_like 'rooms', :organizer
end

View file

@ -2,9 +2,8 @@ require 'spec_helper'
feature Sponsor do
# It is necessary to use bang version of let to build roles before user
let!(:organizer_role) { create(:organizer_role) }
let!(:participant_role) { create(:participant_role) }
let!(:admin_role) { create(:admin_role) }
let!(:organizer_role) { create(:organizer_role) }
shared_examples 'sponsors' do |user|
scenario 'adds and updates sponsors', feature: true, js: true do
@ -69,10 +68,6 @@ feature Sponsor do
end
end
describe 'admin' do
it_behaves_like 'sponsors', :admin
end
describe 'organizer' do
it_behaves_like 'sponsors', :organizer
end

View file

@ -1,10 +1,9 @@
require 'spec_helper'
feature SponsorshipLevel do
# It is necessary to use bang version of let to build roles before user
let!(:organizer_role) { create(:organizer_role) }
# It is necessary to use bang version of let to build roles before user
let!(:participant_role) { create(:participant_role) }
let!(:admin_role) { create(:admin_role) }
let!(:organizer_role) { create(:organizer_role) }
shared_examples 'sponsorship levels' do |user|
scenario 'adds and updates sponsorship level', feature: true, js: true do
@ -36,10 +35,6 @@ feature SponsorshipLevel do
end
end
describe 'admin' do
it_behaves_like 'sponsorship levels', :admin
end
describe 'organizer' do
it_behaves_like 'sponsorship levels', :organizer
end

View file

@ -2,9 +2,8 @@ require 'spec_helper'
feature SupporterLevel do
# It is necessary to use bang version of let to build roles before user
let!(:organizer_role) { create(:organizer_role) }
let!(:participant_role) { create(:participant_role) }
let!(:admin_role) { create(:admin_role) }
let!(:organizer_role) { create(:organizer_role) }
shared_examples 'supporter levels' do |user|
scenario 'adds and updates supporter level', feature: true, js: true do
@ -43,10 +42,6 @@ feature SupporterLevel do
end
end
describe 'admin' do
it_behaves_like 'supporter levels', :admin
end
describe 'organizer' do
it_behaves_like 'supporter levels', :organizer
end

View file

@ -2,9 +2,8 @@ require 'spec_helper'
feature Track do
# It is necessary to use bang version of let to build roles before user
let!(:organizer_role) { create(:organizer_role) }
let!(:participant_role) { create(:participant_role) }
let!(:admin_role) { create(:admin_role) }
let!(:organizer_role) { create(:organizer_role) }
shared_examples 'tracks' do |user|
scenario 'adds and updates tracks', feature: true, js: true do
@ -50,10 +49,6 @@ feature Track do
end
end
describe 'admin' do
it_behaves_like 'tracks', :admin
end
describe 'organizer' do
it_behaves_like 'tracks', :organizer
end

View file

@ -1,14 +1,13 @@
require 'spec_helper'
feature User do
# It is necessary to use bang version of let to build roles before user
let!(:organizer_role) { create(:organizer_role) }
let!(:participant_role) { create(:participant_role) }
let!(:admin_role) { create(:admin_role) }
let(:admin) { create(:admin) }
let!(:organizer_role) { create(:organizer_role) }
let(:organizer) { create(:organizer) }
shared_examples 'admin ability' do
shared_examples 'organizer ability' do |_user|
scenario 'deletes a user', feature: true, js: true do
sign_in(admin)
sign_in(organizer)
visit admin_users_path
expected_count = User.count - 1
page.all('btn btn-primary btn-danger') do
@ -22,7 +21,7 @@ feature User do
end
scenario 'can modify roles', feature: true, js: true do
@user = create(:user)
sign_in(admin)
sign_in(organizer)
visit admin_users_path
find("#user-modify-role-#{@user.id}").click
if find("#user-role-selection-#{@user.id}").visible?
@ -36,7 +35,7 @@ feature User do
end
end
describe 'admin' do
it_behaves_like 'admin ability', :admin
describe 'organizer' do
it_behaves_like 'organizer ability', :organizer
end
end

View file

@ -3,9 +3,8 @@ require 'spec_helper'
feature Conference do
# It is necessary to use bang version of let to build roles before user
let!(:organizer_role) { create(:organizer_role) }
let!(:participant_role) { create(:participant_role) }
let!(:admin_role) { create(:admin_role) }
let!(:organizer_role) { create(:organizer_role) }
shared_examples 'venue' do |user|
scenario 'adds and updates venue' do
@ -59,10 +58,6 @@ feature Conference do
end
end
describe 'admin' do
it_behaves_like 'venue', :admin
end
describe 'organizer' do
it_behaves_like 'venue', :organizer
end

View file

@ -2,15 +2,14 @@ require 'spec_helper'
feature Conference do
# It is necessary to use bang version of let to build roles before user
let!(:organizer_role) { create(:organizer_role) }
let!(:participant_role) { create(:participant_role) }
let!(:admin_role) { create(:admin_role) }
let(:admin) { create(:admin) }
let!(:organizer_role) { create(:organizer_role) }
let(:organizer) { create(:organizer) }
let(:conference) { create(:conference) }
shared_examples 'volunteer' do
scenario 'adds and updates vdays', feature: true, js: true do
sign_in(admin)
sign_in(organizer)
visit admin_conference_volunteers_info_path(
conference_id: conference.short_title)
check('Enable Volunteering')
@ -54,7 +53,7 @@ feature Conference do
end
scenario 'adds and updates vpositions', feature: true, js: true do
sign_in(admin)
sign_in(organizer)
visit admin_conference_volunteers_info_path(
conference_id: conference.short_title)
@ -119,10 +118,6 @@ feature Conference do
end
end
describe 'admin' do
it_behaves_like 'volunteer', :admin
end
describe 'organizer' do
it_behaves_like 'volunteer', :organizer
end