Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mark ActiveFedora-specific AdminSet ability tests as :active_fedroa #6249

Merged
merged 1 commit into from
Aug 29, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 18 additions & 20 deletions spec/abilities/admin_set_ability_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,16 @@
require 'cancan/matchers'

RSpec.describe Hyrax::Ability, :clean_repo do
subject { ability }

let(:ability) { Ability.new(current_user) }
let(:user) { create(:user, email: 'user@example.com') }
subject(:ability) { Ability.new(current_user) }
let(:admin) { FactoryBot.create(:admin, email: 'admin@example.com') }
let(:user) { FactoryBot.create(:user, email: 'user@example.com') }
let(:current_user) { user }

context 'when admin user' do
let(:current_user) { admin }
let(:admin) { FactoryBot.create(:admin, email: 'admin@example.com') }

context 'and admin set is an ActiveFedora::Base' do
let(:admin_set) { create(:adminset_lw, user: user, with_permission_template: true) }
context 'and admin set is an ActiveFedora::Base', :active_fedora do
let(:admin_set) { FactoryBot.create(:adminset_lw, user: user, with_permission_template: true) }
let!(:solr_document) { SolrDocument.new(admin_set.to_solr) }

context 'for abilities open to admins' do
Expand Down Expand Up @@ -65,18 +63,18 @@

context 'when admin set manager' do
let(:current_user) { manager }
let(:manager) { create(:user, email: 'manager@example.com') }
let(:manager) { FactoryBot.create(:user, email: 'manager@example.com') }

context 'and admin set is an ActiveFedora::Base' do
let!(:admin_set) { create(:adminset_lw, id: 'as_mu', user: user, with_permission_template: true) }
context 'and admin set is an ActiveFedora::Base', :active_fedora do
let!(:admin_set) { FactoryBot.create(:adminset_lw, id: 'as_mu', user: user, with_permission_template: true) }
let!(:solr_document) { SolrDocument.new(admin_set.to_solr) }

before do
create(:permission_template_access,
:manage,
permission_template: admin_set.permission_template,
agent_type: 'user',
agent_id: manager.user_key)
FactoryBot.create(:permission_template_access,
:manage,
permission_template: admin_set.permission_template,
agent_type: 'user',
agent_id: manager.user_key)
admin_set.permission_template.reset_access_controls_for(collection: admin_set)
end

Expand Down Expand Up @@ -147,7 +145,7 @@
let(:current_user) { depositor }
let(:depositor) { create(:user, email: 'depositor@example.com') }

context 'and admin set is an ActiveFedora::Base' do
context 'and admin set is an ActiveFedora::Base', :active_fedora do
let!(:admin_set) { create(:adminset_lw, id: 'as_du', user: user, with_permission_template: true) }
let!(:solr_document) { SolrDocument.new(admin_set.to_solr) }

Expand Down Expand Up @@ -235,7 +233,7 @@
let(:current_user) { viewer }
let(:viewer) { create(:user, email: 'viewer@example.com') }

context 'and admin set is an ActiveFedora::Base' do
context 'and admin set is an ActiveFedora::Base', :active_fedora do
let!(:admin_set) { create(:adminset_lw, id: 'as_vu', user: user, with_permission_template: true) }
let!(:solr_document) { SolrDocument.new(admin_set.to_solr) }

Expand Down Expand Up @@ -319,10 +317,10 @@

context 'when user has no special access' do
let(:current_user) { other_user }
let(:other_user) { create(:user, email: 'other_user@example.com') }
let(:other_user) { FactoryBot.create(:user, email: 'other_user@example.com') }

context 'and admin set is an ActiveFedora::Base' do
let(:admin_set) { create(:adminset_lw, id: 'as', user: user, with_permission_template: true) }
context 'and admin set is an ActiveFedora::Base', :active_fedora do
let(:admin_set) { FactoryBot.create(:adminset_lw, id: 'as', user: user, with_permission_template: true) }
let!(:solr_document) { SolrDocument.new(admin_set.to_solr) }

context 'for abilities NOT open to general user' do
Expand Down