Skip to content

Commit

Permalink
Merge pull request #876 from scientist-softserv/i864-deposit-to-admin…
Browse files Browse the repository at this point in the history
…-set

🐛 Fix user despositing to specific admin sets
  • Loading branch information
ShanaLMoore committed Oct 19, 2023
2 parents df964ac + 4172c5c commit d40f22c
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/models/ability.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class Ability
user_roles
work_roles
featured_collection_abilities
everyone_can_create_curation_concerns
]
# If the Groups with Roles feature is disabled, allow registered users to create curation concerns
# (Works, Collections, and FileSets). Otherwise, omit this ability logic as to not
Expand Down
50 changes: 50 additions & 0 deletions spec/features/create_work_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,54 @@
click_link "Share Your Work"
expect(page).to have_button "Create work"
end

context 'as a user with no roles' do
let(:user) { create(:user) }

it 'cannot see the add new work button' do
visit '/dashboard/my/works'
expect(page).not_to have_link "Add New Work"
end

context 'who has deposit access for a specific admin set' do
let(:admin_set_2) do
create(:admin_set, title: ["Another Admin Set"],
description: ["A description"])
end

before do
create(:permission_template_access,
:deposit,
permission_template: create(:permission_template, source_id: admin_set_2.id, with_admin_set: true, with_active_workflow: true),
agent_type: 'user',
agent_id: user.user_key)
end

it 'can see the add new work button' do
visit '/dashboard/my/works'
expect(page).to have_link "Add New Work"
end
end

context 'who belongs to a group with deposit access for a specific admin set' do
let(:admin_set_3) do
create(:admin_set, title: ["Yet Another Admin Set"],
description: ["A description"])
end
let(:depositors_group) { create(:depositors_group, name: 'deposit', member_users: [user]) }

before do
create(:permission_template_access,
:deposit,
permission_template: create(:permission_template, source_id: admin_set_3.id, with_admin_set: true, with_active_workflow: true),
agent_type: 'group',
agent_id: depositors_group.name)
end

it 'can see the add new work button' do
visit '/dashboard/my/works'
expect(page).to have_link "Add New Work"
end
end
end
end

0 comments on commit d40f22c

Please sign in to comment.