minor inprovements and included organizations in changelog

This commit is contained in:
shlok007 2017-08-23 19:53:35 +05:30 committed by Shlok Srivastava
parent 68788ce9fc
commit 16f294f3e8
12 changed files with 199 additions and 90 deletions

View file

@ -4,6 +4,9 @@ describe Admin::VersionsController do
let!(:conference) { create(:conference, short_title: 'exampletitle', description: 'Example Description') }
let(:admin) { create(:admin) }
let(:role_organizer) { conference.roles.find_by(name: 'organizer') }
let(:role_cfp) { conference.roles.find_by(name: 'cfp') }
let(:role_info_desk) { conference.roles.find_by(name: 'info_desk') }
with_versioning do
describe 'GET #revert' do
@ -99,11 +102,54 @@ describe Admin::VersionsController do
end
describe 'GET #index' do
it 'raises error if user is not an organizer of specified conference' do
it 'raises error if user is not of any role' do
user = create(:user)
sign_in user
get :index, conference_id: conference.short_title
expect(flash[:alert]).to match('You are not authorized to access this area.')
expect(flash[:alert]).to match('You are not authorized to access this page.')
end
context 'with conference' do
before :each do
@user = create(:user)
conference.update_attributes(short_title: 'testtitle', description: 'Some random text')
@version_organizer = PaperTrail::Version.last
create(:cfp, program: conference.program)
@version_cfp = PaperTrail::Version.last
registration = create(:registration, conference: conference)
registration.update_attributes(attended: true)
@version_info_desk = PaperTrail::Version.last
end
it 'when user has role cfp' do
@user.roles = [role_cfp]
sign_in @user
get :index, conference_id: conference.short_title
expect(assigns(:versions).include?(@version_cfp)).to eq true
expect(assigns(:versions).include?(@version_organizer)).to eq false
end
it 'when user has role info_desk' do
@user.roles = [role_info_desk]
sign_in @user
get :index, conference_id: conference.short_title
expect(assigns(:versions).include?(@version_info_desk)).to eq true
expect(assigns(:versions).include?(@version_organizer)).to eq false
expect(assigns(:versions).include?(@version_cfp)).to eq false
end
it 'when user has role organizer' do
@user.roles = [role_organizer]
sign_in @user
get :index, conference_id: conference.short_title
expect(assigns(:versions).include?(@version_organizer)).to eq true
expect(assigns(:versions).include?(@version_cfp)).to eq true
expect(assigns(:versions).include?(@version_info_desk)).to eq true
end
end
end
end

View file

@ -298,7 +298,7 @@ feature 'Has correct abilities' do
expect(current_path).to eq(root_path)
visit admin_revision_history_path
expect(current_path).to eq(root_path)
expect(current_path).to eq(admin_revision_history_path)
end
end
end

View file

@ -160,7 +160,7 @@ feature 'Has correct abilities' do
expect(current_path).to eq(edit_admin_conference_resource_path(conference.short_title, conference.resources.first))
visit admin_revision_history_path
expect(current_path).to eq(root_path)
expect(current_path).to eq(admin_revision_history_path)
visit admin_conference_path(conference.short_title)
expect(current_path).to eq(admin_conference_path(conference.short_title))

View file

@ -93,7 +93,7 @@ feature 'Version' do
expect(page).to have_text("Someone (probably via the console) deleted lodging Hotel XYZ with ID #{lodging_id} in conference #{conference.short_title}")
end
scenario 'display changes in role', feature: true, versioning: true, js: true do
scenario 'display changes in conference role', feature: true, versioning: true, js: true do
visit edit_admin_conference_role_path(conference.short_title, 'cfp')
fill_in 'role_description', with: 'For the members of the call for papers team'
click_button 'Update Role'
@ -301,14 +301,40 @@ feature 'Version' do
expect(page).to have_no_text('Someone (probably via the console) created new commercial')
end
scenario 'display changes in users_role', feature: true, versioning: true, js: true do
scenario 'display changes in organization', feature: true, versioning: true, js: true do
admin = create(:admin)
sign_in admin
visit new_admin_organization_path
fill_in 'organization_name', with: 'New org'
click_button 'Create Organization'
visit admin_revision_history_path
expect(page).to have_text('created new organization New org')
end
scenario 'display changes in users_role for organization role', feature: true, versioning: true, js: true do
user = create(:user)
role = Role.find_by(resource_id: conference.organization.id, resource_type: 'Organization')
user.add_role :organization_admin, conference.organization
user_role = UsersRole.find_by(user_id: user.id, role_id: role.id)
user.remove_role :organization_admin, conference.organization
visit admin_revision_history_path
expect(page).to have_text("added role organization_admin with ID #{user_role.id} to user #{user.name} in organization #{conference.organization.name}")
expect(page).to have_text("removed role organization_admin with ID #{user_role.id} from user #{user.name} in organization #{conference.organization.name}")
end
scenario 'display changes in users_role for conference role', feature: true, versioning: true, js: true do
user = create(:user)
role = Role.find_by(name: 'cfp', resource_id: conference.id, resource_type: 'Conference')
user.add_role :cfp, conference
user_role = UsersRole.find_by(user_id: user.id, role_id: role.id)
user.remove_role :cfp, conference
visit admin_revision_history_path
expect(page).to have_text("added role cfp to user #{user.name} in conference #{conference.short_title}")
expect(page).to have_text("removed role cfp from user #{user.name} in conference #{conference.short_title}")
expect(page).to have_text("added role cfp with ID #{user_role.id} to user #{user.name} in conference #{conference.short_title}")
expect(page).to have_text("removed role cfp with ID #{user_role.id} from user #{user.name} in conference #{conference.short_title}")
end
scenario 'display changes in email settings', feature: true, versioning: true, js: true do