-
Notifications
You must be signed in to change notification settings - Fork 78
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 #2567 from andjsmit/2400-collection-menu-options
Remove edit option from collection menu if not available to user.
- Loading branch information
Showing
2 changed files
with
33 additions
and
11 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
24 changes: 22 additions & 2 deletions
24
spec/views/collections/_show_document_list_menu.html.erb_spec.rb
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 |
---|---|---|
@@ -1,18 +1,38 @@ | ||
|
||
describe 'collections/_show_document_list_menu.html.erb', type: :view do | ||
context 'when user logged in displaying the collections of current user' do | ||
context 'when user is viewing a collection' do | ||
let(:user) { create :user } | ||
let(:ability) { instance_double("Ability") } | ||
let(:document) { SolrDocument.new(id: '1234') } | ||
before do | ||
allow(document).to receive(:to_model).and_return(stub_model(GenericWork)) | ||
allow(controller).to receive(:current_ability).and_return(ability) | ||
end | ||
|
||
it "displays the action list in individual work drop down" do | ||
it "displays the action list in a drop down for an individual work user can edit" do | ||
allow(ability).to receive(:can?).with(:edit, document).and_return(true) | ||
render('collections/show_document_list_menu.html.erb', document: document, current_user: user) | ||
expect(rendered).to have_content 'Select an action' | ||
expect(rendered).to have_content 'Edit' | ||
expect(rendered).not_to have_content 'Download File' | ||
expect(rendered).to have_content 'Highlight Work on Profile' | ||
end | ||
|
||
it "displays the action list in a drop down for individual work user can not edit" do | ||
allow(ability).to receive(:can?).with(:edit, document).and_return(false) | ||
render('collections/show_document_list_menu.html.erb', document: document, current_user: user) | ||
expect(rendered).to have_content 'Select an action' | ||
expect(rendered).not_to have_content 'Edit' | ||
expect(rendered).not_to have_content 'Download File' | ||
expect(rendered).to have_content 'Highlight Work on Profile' | ||
end | ||
|
||
it "displays the action list in a drop down for individual work without being logged in" do | ||
render('collections/show_document_list_menu.html.erb', document: document, current_user: false) | ||
expect(rendered).to have_content 'Select an action' | ||
expect(rendered).not_to have_content 'Edit' | ||
expect(rendered).not_to have_content 'Download File' | ||
expect(rendered).not_to have_content 'Highlight Work on Profile' | ||
end | ||
end | ||
end |