-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #107 from IUBLibTech/ius-2503_workflow_permissions
[IUS-2503] use depositor permissions for dataset creation
- Loading branch information
Showing
2 changed files
with
60 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
require 'rails_helper' | ||
|
||
RSpec.describe Ability do | ||
let(:user) { FactoryBot.create :user } | ||
let(:options) { {} } | ||
let(:ability) { described_class.new(user, options) } | ||
|
||
describe '#can_deposit?' do | ||
context 'when neither an admin nor depositor' do | ||
it 'returns false' do | ||
expect(ability.admin?).to be false | ||
expect(ability.depositor?).to be false | ||
expect(ability.can? :create, DataSet).to be false | ||
end | ||
end | ||
context 'when a depositor' do | ||
let(:admin_set) { AdminSet.find(AdminSet.find_or_create_default_admin_set_id) } | ||
before do | ||
# creates permission template and depositor permissions | ||
Hyrax::AdminSetCreateService.new(admin_set: admin_set, creating_user: user).create | ||
end | ||
it 'returns true' do | ||
expect(ability.admin?).to be false | ||
expect(ability.depositor?).to be true | ||
expect(ability.can? :create, DataSet).to be true | ||
end | ||
end | ||
context 'when an admin' do | ||
let(:user) { FactoryBot.create :admin } | ||
it 'returns true' do | ||
expect(ability.admin?).to be true | ||
expect(ability.depositor?).to be false | ||
expect(ability.can? :create, DataSet).to be true | ||
end | ||
end | ||
end | ||
end |