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

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
VivianChu committed Aug 6, 2018
1 parent 6f932af commit 0e7800c
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 13 deletions.
14 changes: 8 additions & 6 deletions app/views/dams_objects/_complex_object_viewer.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@
%>
<%# CHECK FOR RESTRICTED NOTICE %>
<% restrictedNotice = grabRestrictedText(@document['otherNote_json_tesim']) %>
<% unless restrictedNotice.nil? %>
<div class="restricted-notice">
<div>
<%= restrictedNotice %>
<% if cannot?(:read, @document) || cultural_sensitive?(@document) then %>
<% restrictedNotice = grabRestrictedText(@document['otherNote_json_tesim']) %>
<% unless restrictedNotice.nil? %>
<div class="restricted-notice">
<div>
<%= restrictedNotice %>
</div>
</div>
</div>
<% end %>
<% end %>
<% access_notice = grab_access_text(@document) if cannot?(:read, @document) %>

Expand Down
2 changes: 1 addition & 1 deletion app/views/dams_objects/_simple_object_viewer.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<% if defined?(fileType) %>
<% if cannot?(:read, @document) then %>
<% if cannot?(:read, @document) || cultural_sensitive?(@document) then %>
<% restrictedNotice = grabRestrictedText(@document['otherNote_json_tesim']) %>
<% unless restrictedNotice.nil? %>
<div class="restricted-notice">
Expand Down
2 changes: 2 additions & 0 deletions app/views/dams_objects/metadata.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
<%# BEGIN RESTRICTED NOTICE %>
<% if cannot?(:read, @document) || cultural_sensitive?(@document) then %>
<% restrictedNotice = grabRestrictedText(@document['otherNote_json_tesim']) %>
<% unless restrictedNotice.nil? %>
<div class="restricted-notice">
Expand All @@ -29,6 +30,7 @@
</div>
<div class="simple-object"></div>
<% end %>
<% end %>
<%# END RESTRICTED NOTICE %>
<% if cannot?(:read, @document) then %>
<% accessNotice = grab_access_text(@document) %>
Expand Down
6 changes: 6 additions & 0 deletions lib/dams/controller_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -918,6 +918,12 @@ def metadata_display?(data)
data.any? { |t| t.include?('localDisplay') || t.include?('metadataDisplay') }
end

def cultural_sensitive?(document)
data = Array(document['otherNote_json_tesim']).flatten.compact
return false if data.blank?
data.any? { |t| t.include?('Culturally sensitive content:') }
end

def total_count(collection_id)
solr_params = build_params("collections_tesim:#{collection_id}")
raw_solr(solr_params).response['numFound'].to_i
Expand Down
12 changes: 6 additions & 6 deletions spec/features/dams_object_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -765,15 +765,15 @@
expect(page).to have_no_selector('button#view-masked-object',:text=>'Yes, I would like to view this content.')
end

it "local user should see embargo banner" do
sign_in_anonymous '132.239.0.3'
it "public user should see Response Status Code 404 - not found page" do
visit dams_object_path(@damsEmbObj.pid)
expect(page).to have_selector('div.restricted-notice', text: embargo_note)
expect(page.driver.response.status).to eq( 404 )
end

it "public user should see embargo banner" do

scenario 'local user should see Response Status Code 404 - not found page' do
sign_in_anonymous '132.239.0.3'
visit dams_object_path(@damsEmbObj.pid)
expect(page).to have_selector('div.restricted-notice', text: embargo_note)
expect(page.driver.response.status).to eq( 404 )
end

end
Expand Down

0 comments on commit 0e7800c

Please sign in to comment.