-
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.
Pass along the object's admin_set_id to the param sanitization to ens…
…ure that permissions params are returned or stripped based upon the active workflow for the admin set. Without this the batch edit of permissions silently fails because it doesn't see any params to operate on. This commit also fixes the params for the visibility tests based upon browser testing. The line reading the visibility from the bare param could be removed since it isn't used so I marked it as deprecated. Fix visibility and use actor to correctly handle params Make permissions collapsable like description tab
- Loading branch information
Showing
6 changed files
with
219 additions
and
28 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
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
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 |
---|---|---|
|
@@ -32,22 +32,27 @@ | |
|
||
describe "update" do | ||
let(:user) { build(:user) } | ||
let(:admin_set) { create(:admin_set) } | ||
let(:permission_template) { create(:permission_template, source_id: admin_set.id) } | ||
let!(:workflow) { create(:workflow, allows_access_grant: true, active: true, permission_template_id: permission_template.id) } | ||
let!(:one) do | ||
create(:work, creator: ["Fred"], title: ["abc"], language: ['en'], user: user) | ||
create(:work, admin_set_id: admin_set.id, creator: ["Fred"], title: ["abc"], language: ['en'], user: user) | ||
end | ||
|
||
let!(:two) do | ||
create(:work, creator: ["Fred"], title: ["abc"], language: ['en'], user: user) | ||
create(:work, admin_set_id: admin_set.id, creator: ["Fred"], title: ["abc"], language: ['en'], user: user) | ||
end | ||
|
||
let!(:three) do | ||
create(:work, creator: ["Fred"], title: ["abc"], language: ['en']) | ||
create(:work, admin_set_id: admin_set.id, creator: ["Fred"], title: ["abc"], language: ['en']) | ||
end | ||
|
||
let!(:file_set) do | ||
create(:file_set, creator: ["Fred"]) | ||
end | ||
|
||
let(:release_date) { Time.zone.today + 2 } | ||
|
||
let(:mycontroller) { "hyrax/my/works" } | ||
|
||
before do | ||
|
@@ -83,7 +88,7 @@ | |
end | ||
|
||
it "updates permissions" do | ||
put :update, params: { update_type: "update", visibility: "authenticated" } | ||
put :update, params: { update_type: "update", generic_work: { visibility: "authenticated" } } | ||
expect(response).to be_redirect | ||
|
||
work1 = GenericWork.find(one.id) | ||
|
@@ -93,6 +98,76 @@ | |
expect(GenericWork.find(two.id).visibility).to eq "authenticated" | ||
expect(GenericWork.find(three.id).visibility).to eq "restricted" | ||
end | ||
|
||
it 'creates leases' do | ||
put :update, params: { update_type: "update", | ||
generic_work: { visibility: "lease", lease_expiration_date: release_date, visibility_during_lease: 'open', visibility_after_lease: 'restricted' } } | ||
expect(response).to be_redirect | ||
|
||
work1 = GenericWork.find(one.id) | ||
expect(work1.visibility).to eq "open" | ||
expect(work1.visibility_during_lease).to eq 'open' | ||
expect(work1.visibility_after_lease).to eq 'restricted' | ||
expect(work1.lease_expiration_date).to eq release_date | ||
expect(work1.file_sets.map(&:visibility)).to eq ['open'] | ||
expect(work1.file_sets.map(&:visibility_during_lease)).to eq ['open'] | ||
expect(work1.file_sets.map(&:visibility_after_lease)).to eq ['restricted'] | ||
expect(work1.file_sets.map(&:lease_expiration_date)).to eq [release_date] | ||
|
||
work2 = GenericWork.find(two.id) | ||
expect(work2.visibility).to eq 'open' | ||
expect(work2.visibility_during_lease).to eq 'open' | ||
expect(work2.visibility_after_lease).to eq 'restricted' | ||
expect(work2.lease_expiration_date).to eq release_date | ||
|
||
work3 = GenericWork.find(three.id) | ||
expect(work3.visibility).to eq 'restricted' | ||
expect(work3.visibility_during_lease).to be_nil | ||
expect(work3.visibility_after_lease).to be_nil | ||
expect(work3.lease_expiration_date).to be_nil | ||
end | ||
|
||
it 'creates embargoes' do | ||
put :update, params: { update_type: "update", | ||
generic_work: { visibility: "embargo", embargo_release_date: release_date, visibility_during_embargo: 'authenticated', visibility_after_embargo: 'open' } } | ||
expect(response).to be_redirect | ||
|
||
work1 = GenericWork.find(one.id) | ||
expect(work1.visibility).to eq "authenticated" | ||
expect(work1.visibility_during_embargo).to eq 'authenticated' | ||
expect(work1.visibility_after_embargo).to eq 'open' | ||
expect(work1.embargo_release_date).to eq release_date | ||
expect(work1.file_sets.map(&:visibility)).to eq ['authenticated'] | ||
expect(work1.file_sets.map(&:visibility_during_embargo)).to eq ['authenticated'] | ||
expect(work1.file_sets.map(&:visibility_after_embargo)).to eq ['open'] | ||
expect(work1.file_sets.map(&:embargo_release_date)).to eq [release_date] | ||
|
||
work2 = GenericWork.find(two.id) | ||
expect(work2.visibility).to eq 'authenticated' | ||
expect(work2.visibility_during_embargo).to eq 'authenticated' | ||
expect(work2.visibility_after_embargo).to eq 'open' | ||
expect(work2.embargo_release_date).to eq release_date | ||
|
||
work3 = GenericWork.find(three.id) | ||
expect(work3.visibility).to eq 'restricted' | ||
expect(work3.visibility_during_embargo).to be_nil | ||
expect(work3.visibility_after_embargo).to be_nil | ||
expect(work3.embargo_release_date).to be_nil | ||
end | ||
|
||
context 'with roles' do | ||
it 'updates roles' do | ||
put :update, params: { update_type: "update", generic_work: { permissions_attributes: [{ type: 'person', access: 'read', name: '[email protected]' }] } } | ||
expect(response).to be_redirect | ||
|
||
work1 = GenericWork.find(one.id) | ||
expect(work1.read_users).to include "[email protected]" | ||
expect(work1.file_sets.map(&:read_users)).to eq [["[email protected]"]] | ||
|
||
expect(GenericWork.find(two.id).read_users).to eq ["[email protected]"] | ||
expect(GenericWork.find(three.id).read_users).to eq [] | ||
end | ||
end | ||
end | ||
|
||
describe "#destroy_collection" do | ||
|
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