Skip to content
This repository has been archived by the owner on Mar 24, 2020. It is now read-only.

Commit

Permalink
Add test for culturally sensitive restricted object
Browse files Browse the repository at this point in the history
Revert db schema.rb change

Add test for public and locan user

Fix embargo banner view issue

Update tests

Show generic thumbnail for click-thru object

Add more test for mixed objects collection

Update collection query

Update query

Update access label

Update access label function
  • Loading branch information
VivianChu committed Aug 28, 2018
1 parent 2f16eac commit 486b528
Show file tree
Hide file tree
Showing 5 changed files with 106 additions and 67 deletions.
25 changes: 15 additions & 10 deletions app/controllers/catalog_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ def index
end

(@response, @document_list) = get_search_results
@metadata_colls = metadata_only_collections(params)
@metadata_colls = metadata_only_collections(@document_list)

@filters = params[:f] || []

Expand Down Expand Up @@ -316,17 +316,22 @@ def collection_search
search[:fq] = params[:fq] if params[:fq]
search[:total] = @response.response['numFound']
session[:search] = search
@metadata_colls = metadata_only_collections(params)
@metadata_colls = metadata_only_collections(@document_list)
end

def metadata_only_collections(params)
meta_colls = []
solr_params = { q: "{!join from=collections_tesim to=id}#{metadata_only_fquery}", fq: 'type_tesim:Collection', rows: 300 }
response = raw_solr(solr_params.merge(params))
response.docs.each do |doc|
mix_obj = mix_objects?(doc['id_t'], metadata_obj_count(doc['id_t']))
val = mix_obj ? "#{doc['id_t']}#{mix_obj}" : doc['id_t']
meta_colls << val
def metadata_only_collections(docs)
meta_colls = Array.new
docs.each do |doc|
if !doc['has_model_ssim'].include?('DamsObject')
coll_solr_params = build_params("collections_tesim:#{doc['id']}", metadata_only_fquery)
coll_response = raw_solr(coll_solr_params)
metadata_only = coll_response.response['numFound'].to_i > 0
if metadata_only
mix_obj = mix_objects?(doc['id'], metadata_obj_count(doc['id']))
val = mix_obj ? "#{doc['id']}#{mix_obj}" : doc['id']
meta_colls << val
end
end
end
meta_colls
end
Expand Down
6 changes: 3 additions & 3 deletions app/helpers/catalog_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,14 @@ def display_access_control_level(document, metadata_colls, mix_obj, meta_only_ob
access_group = document['read_access_group_ssim'] # "public" > "local" > "dams-curator" == "dams-rci" == default
view_access = 'Curator Only'
if access_group
if metadata_colls.include?("#{document['id']}true") || mix_obj
if access_group.include?('local') && !mix_obj && !metadata_colls.include?("#{document['id']}true")
view_access = 'Restricted to UC San Diego use only'
elsif metadata_colls.include?("#{document['id']}true") || mix_obj
view_access = hide_label?(document) ? nil : 'Some items restricted'
elsif metadata_colls.include?(document['id']) || meta_only_obj
view_access = hide_label?(document) ? nil : 'Restricted View'
elsif access_group.include?('public')
view_access = nil
elsif access_group.include?('local')
view_access = 'Restricted to UC San Diego use only'
end

end
Expand Down
48 changes: 4 additions & 44 deletions spec/features/catalog_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -522,14 +522,14 @@
scenario 'public user should see the grey generic thumbnail and restricted access info' do
visit catalog_index_path({:q => 'xx909090zz'})
expect(page).to have_css('img.dams-search-thumbnail[src="https://library.ucsd.edu/assets/dams/site/thumb-restricted.png"]')
expect(page).to have_content('Restricted View')
expect(page).to have_content('Restricted to UC San Diego use only')
end

scenario 'curator user should not see the grey generic thumbnail and still see restricted access info' do
sign_in_developer
visit catalog_index_path({:q => 'xx909090zz'})
expect(page).to_not have_css('img.dams-search-thumbnail[src="https://library.ucsd.edu/assets/dams/site/thumb-restricted.png"]')
expect(page).to have_content('Restricted View')
expect(page).to have_content('Restricted to UC San Diego use only')
end

scenario 'local user should not see the grey generic thumbnail and restricted access info' do
Expand Down Expand Up @@ -562,7 +562,7 @@
sign_in_developer
visit catalog_index_path({:q => @localObj.pid})
expect(page).to_not have_css('img.dams-search-thumbnail[src="https://library.ucsd.edu/assets/dams/site/thumb-restricted.png"]')
expect(page).to have_content('Restricted View')
expect(page).to have_content('Restricted to UC San Diego use only')
end

scenario 'local user should not see the grey generic thumbnail and restricted access info' do
Expand All @@ -575,7 +575,7 @@
scenario 'public user should see the grey generic thumbnail and restricted access info' do
visit catalog_index_path({:q => @localObj.pid})
expect(page).to have_css('img.dams-search-thumbnail[src="https://library.ucsd.edu/assets/dams/site/thumb-restricted.png"]')
expect(page).to have_content('Restricted View')
expect(page).to have_content('Restricted to UC San Diego use only')
end
end

Expand All @@ -588,46 +588,6 @@
end
end

feature 'Visitor wants to view object for public metadata-only collection in the search result page' do
before(:all) do
ns = Rails.configuration.id_namespace
@note = DamsNote.create type: "local attribution", value: "Digital Library Development Program, UC San Diego, La Jolla, 92093-0175"
@localDisplay = DamsOtherRight.create permissionType: "localDisplay"
@publicCollection = DamsProvenanceCollection.create titleValue: "Test Public Collection", visibility: "public"
@localObj = DamsObject.create pid: 'xx909090zz', titleValue: 'Test Object with localDisplay', provenanceCollectionURI: @publicCollection.pid, otherRightsURI: @localDisplay.pid, note_attributes: [{ id: RDF::URI.new("#{ns}#{@note.pid}") }], copyright_attributes: [{status: 'Under Copyright'}]
solr_index @note.pid
solr_index @localDisplay.pid
solr_index @publicCollection.pid
solr_index @localObj.pid
end
after(:all) do
@note.delete
@localDisplay.delete
@publicCollection.delete
@localObj.delete
end

scenario 'public user should see the grey generic thumbnail and restricted access info' do
visit catalog_index_path({:q => 'xx909090zz'})
expect(page).to have_css('img.dams-search-thumbnail[src="https://library.ucsd.edu/assets/dams/site/thumb-restricted.png"]')
expect(page).to have_content('Restricted View')
end

scenario 'local user should not see the grey generic thumbnail and restricted access label' do
sign_in_anonymous '132.239.0.3'
visit catalog_index_path({:q => 'xx909090zz'})
expect(page).to_not have_css('img.dams-search-thumbnail[src="https://library.ucsd.edu/assets/dams/site/thumb-restricted.png"]')
expect(page).to_not have_content('Restricted View')
end

scenario 'curator user should not see the grey generic thumbnail and still see restricted access info' do
sign_in_developer
visit catalog_index_path({:q => 'xx909090zz'})
expect(page).to_not have_css('img.dams-search-thumbnail[src="https://library.ucsd.edu/assets/dams/site/thumb-restricted.png"]')
expect(page).to have_content('Restricted View')
end
end

feature 'Visitor wants to view metdatadataDisplay object for public collection in the search result page' do
before(:all) do
ns = Rails.configuration.id_namespace
Expand Down
77 changes: 77 additions & 0 deletions spec/features/dams_collections_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,15 @@
visit '/collections'
expect(page).to_not have_content('Restricted View')
end

scenario 'curator user should not see Restricted View access label' do
sign_in_developer
visit catalog_index_path( {:q => @localOnlyCollection.pid} )
expect(page).to_not have_content('Restricted View')
expect(page).to have_content('Restricted to UC San Diego use only')
visit dams_collection_path @localOnlyCollection.pid
expect(page).to have_content('Restricted to UC San Diego use only')
end
end

feature "Visitor wants to view a public collection's page with metadata-only objects" do
Expand Down Expand Up @@ -649,3 +658,71 @@
expect(page).to have_content('Restricted View')
end
end

feature "Visitor wants to view a local collection's page with mixed objects" do
before(:all) do
@otherRight = DamsOtherRight.create restrictionType: "display"
@localDisplay = DamsOtherRight.create permissionType: "localDisplay", basis: "fair use (UCSD)"
@localCollection = DamsProvenanceCollection.create titleValue: "ABCD Visibility Testing Collection [Local collection/Mixed]", visibility: "local"
@copyright = DamsCopyright.create status: 'Under copyright'
@otherObj = DamsObject.create titleValue: 'UCSD IP / Campus Access Only', provenanceCollectionURI: @localCollection.pid, copyrightURI: @copyright.pid, otherRightsURI: @localDisplay.pid
@dogObj = DamsObject.create titleValue: 'Curator and Dogs Only', provenanceCollectionURI: @localCollection.pid, copyrightURI: @copyright.pid, otherRightsURI: @otherRight.pid
@catObj = DamsObject.create titleValue: 'Curator and Cats Only', provenanceCollectionURI: @localCollection.pid, copyrightURI: @copyright.pid, otherRightsURI: @otherRight.pid

solr_index @otherRight.pid
solr_index @localDisplay.pid
solr_index @localCollection.pid
solr_index @copyright.pid
solr_index @otherObj.pid
solr_index @dogObj.pid
solr_index @catObj.pid
end

after(:all) do
@otherRight.delete
@localDisplay.delete
@localCollection.delete
@copyright.delete
@otherObj.delete
@dogObj.delete
@catObj.delete
end

scenario 'public user should see some items restricted information' do
visit dams_collection_path @localCollection.pid
expect(page).to_not have_content('Restricted View')
expect(page).to have_content('Some items restricted')
end

scenario 'public user should see some items restricted access information when visit browse by collection page' do
visit '/collections'
expect(page).to_not have_content('Restricted View')
expect(page).to have_content('Some items restricted')
end

scenario 'public user should see some items restricted access information when search for collection' do
visit catalog_index_path( {:q => @localCollection.pid} )
expect(page).to_not have_content('Restricted View')
expect(page).to have_content('Some items restricted')
end

scenario 'local user should not see access label when visit browse by collection page or search for collection' do
sign_in_anonymous '132.239.0.3'
visit '/collections'
expect(page).to_not have_content('Restricted View')
expect(page).to_not have_content('Some items restricted')

visit catalog_index_path( {:q => @localCollection.pid} )
expect(page).to_not have_content('Restricted View')
expect(page).to_not have_content('Some items restricted')
end

scenario 'curator user should see access label when visit browse by collection page or search for collection' do
sign_in_developer
visit '/collections'
expect(page).to have_content('Some items restricted')

visit catalog_index_path( {:q => @localCollection.pid} )
expect(page).to have_content('Some items restricted')
end
end
17 changes: 7 additions & 10 deletions spec/features/dams_object_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -726,20 +726,20 @@
@metadataOnlyObj.delete
end

scenario 'should see Restricted View access control information but not banner access text' do
scenario 'should see Restricted access control information but not banner access text' do
visit dams_object_path @metadataOnlyObj.pid
expect(page).to have_selector('#component-pager-label', :text=>'Component 1 of 4')
expect(page).to have_content('Interval 1 (dredge, rock)')
expect(page).to have_selector('div.file-metadata', text: 'Access Restricted View')
expect(page).to have_selector('div.file-metadata', text: 'Restricted to UC San Diego use only')
expect(page).to_not have_selector('div.restricted-notice-complex', text: restricted_note)
end

scenario 'should see Restricted View access control info in other component' do
scenario 'should see Restricted access control info in other component' do
visit dams_object_path @metadataOnlyObj.pid
click_button 'component-pager-forward'
find('#component-pager-label').should have_content('Component 2 of 4')
expect(page).to have_content('Files')
expect(page).to have_selector('div.file-metadata', text: 'Access Restricted View')
expect(page).to have_selector('div.file-metadata', text: 'Access Restricted to UC San Diego use only')
end
end

Expand Down Expand Up @@ -960,13 +960,13 @@
@obj.delete
end

scenario 'curator user should see Restricted View access control information and download link' do
scenario 'curator user should see Restricted access control information and download link' do
sign_in_developer
visit dams_object_path @metadataOnlyObj.pid
expect(page).to have_content('Restricted View')
expect(page).to have_content('Restricted to UC San Diego use only')
expect(page).to have_link('', href:"/object/#{@metadataOnlyObj.id}/_1.mp4/download?access=curator")
visit dams_object_path @localObj.pid
expect(page).to have_content('Restricted View')
expect(page).to have_content('Restricted to UC San Diego use only')
end

scenario 'curator user should not see Restricted View access control information' do
Expand Down Expand Up @@ -1564,20 +1564,17 @@
scenario 'curator user should not see the grey generic thumbnail' do
sign_in_developer
visit catalog_index_path({:q => @sensitiveObj.pid})
#puts page.body
expect(page).to_not have_css('img.dams-search-thumbnail[src="https://library.ucsd.edu/assets/dams/site/thumb-restricted.png"]')
end

scenario 'local user should see the grey generic thumbnail' do
sign_in_anonymous '132.239.0.3'
visit catalog_index_path({:q => @sensitiveObj.pid})
#puts page.body
expect(page).to have_css('img.dams-search-thumbnail[src="https://library.ucsd.edu/assets/dams/site/thumb-restricted.png"]')
end

scenario 'public user should see the grey generic thumbnail' do
visit catalog_index_path({:q => @sensitiveObj.pid})
#puts page.body
expect(page).to have_css('img.dams-search-thumbnail[src="https://library.ucsd.edu/assets/dams/site/thumb-restricted.png"]')
end
end

0 comments on commit 486b528

Please sign in to comment.