move revision history of users to be accessed only by site admins

This commit is contained in:
shlok007 2017-08-25 03:04:41 +05:30
parent 16f294f3e8
commit 590c3a91ea
2 changed files with 465 additions and 437 deletions

View file

@ -167,7 +167,6 @@ class AdminAbility
role.resource_type == 'Track' && (track_ids.include? role.resource_id) role.resource_type == 'Track' && (track_ids.include? role.resource_id)
end end
can [:index, :revert_object, :revert_attribute], PaperTrail::Version, item_type: 'User'
can [:index, :revert_object, :revert_attribute], PaperTrail::Version, conference_id: conf_ids can [:index, :revert_object, :revert_attribute], PaperTrail::Version, conference_id: conf_ids
end end

View file

@ -1,12 +1,14 @@
require 'spec_helper' require 'spec_helper'
feature 'Version' do feature 'Version' do
let(:admin) { create(:admin) }
let!(:conference) { create(:conference) } let!(:conference) { create(:conference) }
let!(:organizer_role) { Role.find_by(name: 'organizer', resource: conference) } let!(:organizer_role) { Role.find_by(name: 'organizer', resource: conference) }
let!(:organizer) { create(:user, role_ids: [organizer_role.id]) } let!(:organizer) { create(:user, role_ids: [organizer_role.id]) }
let(:event_with_commercial) { create(:event, program: conference.program) } let(:event_with_commercial) { create(:event, program: conference.program) }
let(:event_commercial) { create(:event_commercial, commercialable: event_with_commercial, url: 'https://www.youtube.com/watch?v=M9bq_alk-sw') } let(:event_commercial) { create(:event_commercial, commercialable: event_with_commercial, url: 'https://www.youtube.com/watch?v=M9bq_alk-sw') }
context 'signed in as organizer' do
before(:each) do before(:each) do
sign_in organizer sign_in organizer
end end
@ -301,18 +303,6 @@ feature 'Version' do
expect(page).to have_no_text('Someone (probably via the console) created new commercial') expect(page).to have_no_text('Someone (probably via the console) created new commercial')
end end
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 scenario 'display changes in users_role for organization role', feature: true, versioning: true, js: true do
user = create(:user) user = create(:user)
role = Role.find_by(resource_id: conference.organization.id, resource_type: 'Organization') role = Role.find_by(resource_id: conference.organization.id, resource_type: 'Organization')
@ -424,6 +414,44 @@ feature 'Version' do
expect(page).to have_text("Someone (probably via the console) deleted campaign Test Campaign with ID #{campaign_id} in conference #{conference.short_title}") expect(page).to have_text("Someone (probably via the console) deleted campaign Test Campaign with ID #{campaign_id} in conference #{conference.short_title}")
end end
scenario 'does not display password reset requests', feature: true, versioning: true, js: true do
user = create(:user)
user.send_reset_password_instructions
visit admin_revision_history_path
expect(page).to_not have_text("Someone requested password reset of user #{user.name}")
end
scenario 'does not display user signups', feature: true, versioning: true, js: true do
create(:user, name: 'testname')
visit admin_revision_history_path
expect(page).to_not have_text('testname signed up')
end
scenario 'does not display updates to user', feature: true, versioning: true, js: true do
user = create(:user)
user.update_attributes(nickname: 'testnick', affiliation: 'openSUSE')
visit admin_revision_history_path
expect(page).to_not have_text("Someone (probably via the console) updated nickname and affiliation of user #{user.name}")
end
end
context 'signed in as admin' do
before do
sign_in admin
end
scenario 'display changes in organization', feature: true, versioning: true, js: true do
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 password reset requests', feature: true, versioning: true, js: true do scenario 'display password reset requests', feature: true, versioning: true, js: true do
user = create(:user) user = create(:user)
user.send_reset_password_instructions user.send_reset_password_instructions
@ -447,3 +475,4 @@ feature 'Version' do
expect(page).to have_text("Someone (probably via the console) updated nickname and affiliation of user #{user.name}") expect(page).to have_text("Someone (probably via the console) updated nickname and affiliation of user #{user.name}")
end end
end end
end