-
Notifications
You must be signed in to change notification settings - Fork 126
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add spec coverage to grant/revoke jobs
Refs #1477
- Loading branch information
Showing
7 changed files
with
84 additions
and
0 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,11 @@ | ||
RSpec.describe Hyrax::GrantEditJob do | ||
let(:depositor) { create(:user) } | ||
let(:file_set) { build(:file_set) } | ||
|
||
it 'grants a user edit access to a FileSet' do | ||
expect(FileSet).to receive(:find).with(file_set.id).and_return(file_set) | ||
expect(file_set).to receive(:edit_users=).with(array_including(depositor.user_key)) | ||
expect(file_set).to receive(:save!) | ||
described_class.perform_now(file_set.id, depositor.user_key) | ||
end | ||
end |
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,16 @@ | ||
RSpec.describe Hyrax::GrantEditToMembersJob do | ||
let(:depositor) { create(:user) } | ||
let(:work) { build(:work) } | ||
let(:file_set_ids) { ['xyz123abc', 'abc789zyx'] } | ||
|
||
before do | ||
allow_any_instance_of(described_class).to receive(:file_set_ids).with(work).and_return(file_set_ids) | ||
end | ||
|
||
it 'loops over FileSet IDs, spawning a job for each' do | ||
file_set_ids.each do |file_set_id| | ||
expect(Hyrax::GrantEditJob).to receive(:perform_now).with(file_set_id, depositor.user_key).once | ||
end | ||
described_class.perform_now(work, depositor.user_key) | ||
end | ||
end |
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,11 @@ | ||
RSpec.describe Hyrax::GrantReadJob do | ||
let(:depositor) { create(:user) } | ||
let(:file_set) { build(:file_set) } | ||
|
||
it 'grants a user read access to a FileSet' do | ||
expect(FileSet).to receive(:find).with(file_set.id).and_return(file_set) | ||
expect(file_set).to receive(:read_users=).with(array_including(depositor.user_key)) | ||
expect(file_set).to receive(:save!) | ||
described_class.perform_now(file_set.id, depositor.user_key) | ||
end | ||
end |
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,16 @@ | ||
RSpec.describe Hyrax::GrantReadToMembersJob do | ||
let(:depositor) { create(:user) } | ||
let(:work) { build(:work) } | ||
let(:file_set_ids) { ['xyz123abc', 'abc789zyx'] } | ||
|
||
before do | ||
allow_any_instance_of(described_class).to receive(:file_set_ids).with(work).and_return(file_set_ids) | ||
end | ||
|
||
it 'loops over FileSet IDs, spawning a job for each' do | ||
file_set_ids.each do |file_set_id| | ||
expect(Hyrax::GrantReadJob).to receive(:perform_now).with(file_set_id, depositor.user_key).once | ||
end | ||
described_class.perform_now(work, depositor.user_key) | ||
end | ||
end |
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,16 @@ | ||
RSpec.describe Hyrax::RevokeEditFromMembersJob do | ||
let(:depositor) { create(:user) } | ||
let(:work) { build(:work) } | ||
let(:file_set_ids) { ['xyz123abc', 'abc789zyx'] } | ||
|
||
before do | ||
allow_any_instance_of(described_class).to receive(:file_set_ids).with(work).and_return(file_set_ids) | ||
end | ||
|
||
it 'loops over FileSet IDs, spawning a job for each' do | ||
file_set_ids.each do |file_set_id| | ||
expect(Hyrax::RevokeEditJob).to receive(:perform_now).with(file_set_id, depositor.user_key).once | ||
end | ||
described_class.perform_now(work, depositor.user_key) | ||
end | ||
end |
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,11 @@ | ||
RSpec.describe Hyrax::RevokeEditJob do | ||
let(:depositor) { create(:user) } | ||
let(:file_set) { build(:file_set, user: depositor) } | ||
|
||
it 'revokes edit access from a FileSet' do | ||
expect(FileSet).to receive(:find).with(file_set.id).and_return(file_set) | ||
expect(file_set).to receive(:edit_users=).with([]) | ||
expect(file_set).to receive(:save!) | ||
described_class.perform_now(file_set.id, depositor.user_key) | ||
end | ||
end |