-
Notifications
You must be signed in to change notification settings - Fork 13
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 #1294 from CDL-Dryad/permissions
Additional Pundit scopes and variable fixes
- Loading branch information
Showing
14 changed files
with
79 additions
and
56 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
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 |
---|---|---|
|
@@ -8,7 +8,7 @@ def initialize(user, _record) | |
end | ||
|
||
def index? | ||
user.superuser? | ||
@user.superuser? | ||
end | ||
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
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 |
---|---|---|
|
@@ -1511,36 +1511,36 @@ module StashEngine | |
end | ||
|
||
it 'shows all resources for the identifier to the curator' do | ||
resources = @identifier.resources.visible_to_user(user: @user3) | ||
resources = StashEngine::ResourcePolicy::VersionScope.new(@user3, @identifier.resources).resolve | ||
expect(resources.count).to eq(3) | ||
end | ||
|
||
it 'shows all resources to the owner' do | ||
resources = @identifier.resources.visible_to_user(user: @user3) | ||
resources = StashEngine::ResourcePolicy::VersionScope.new(@user3, @identifier.resources).resolve | ||
expect(resources.count).to eq(3) | ||
end | ||
|
||
it 'only shows curated-visible resources to a non-user' do | ||
resources = @identifier.resources.visible_to_user(user: nil) | ||
resources = StashEngine::ResourcePolicy::VersionScope.new(nil, @identifier.resources).resolve | ||
expect(resources.count).to eq(2) | ||
end | ||
|
||
it 'shows all resources to an admin for this tenant (ucop)' do | ||
resources = @identifier.resources.visible_to_user(user: @user2) | ||
resources = StashEngine::ResourcePolicy::VersionScope.new(@user2, @identifier.resources).resolve | ||
expect(resources.count).to eq(3) | ||
end | ||
|
||
it 'shows all resources to an admin for this journal' do | ||
journal = Journal.create(title: 'Test Journal', issn: '1234-4321') | ||
InternalDatum.create(identifier_id: @identifier.id, data_type: 'publicationISSN', value: journal.single_issn) | ||
JournalRole.create(journal: journal, user: @user2, role: 'admin') | ||
resources = @identifier.resources.visible_to_user(user: @user2) | ||
resources = StashEngine::ResourcePolicy::VersionScope.new(@user2, @identifier.resources).resolve | ||
expect(resources.count).to eq(3) | ||
end | ||
|
||
it 'only shows curated-visible resources to a random user' do | ||
@user4 = create(:user, first_name: 'Gorgon', last_name: 'Grup', email: '[email protected]', tenant_id: 'ucb', role: 'user') | ||
resources = @identifier.resources.visible_to_user(user: @user4) | ||
resources = StashEngine::ResourcePolicy::VersionScope.new(@user4, @identifier.resources).resolve | ||
expect(resources.count).to eq(2) | ||
end | ||
end | ||
|