Skip to content

Commit

Permalink
Merge pull request #1258 from uclibs/feature/#1230_modify_work_show
Browse files Browse the repository at this point in the history
Modifies the work show view for empty relationships.
  • Loading branch information
crowesn committed Apr 6, 2017
2 parents 94263d9 + f42b402 commit e52398b
Show file tree
Hide file tree
Showing 4 changed files with 108 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<tr>
</tr>
5 changes: 3 additions & 2 deletions app/views/curation_concerns/base/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@

</div>
<div class="col-sm-8">
<%= render 'representative_media', presenter: @presenter %>
<%= render 'representative_media', presenter: @presenter %>
<%= render 'work_description', presenter: @presenter %>
<%= render 'relationships', presenter: @presenter %>
<%= render 'metadata', presenter: @presenter %>
<%= render 'doi', presenter: @presenter unless @presenter.doi.nil? %>
<%= render 'relationships', presenter: @presenter %>

</div>
<div class="col-sm-4">
<%= render "show_actions", presenter: @presenter %>
Expand Down
5 changes: 5 additions & 0 deletions config/locales/sufia.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,8 @@ en:
terms_of_use_html: "<a class=\"a\" href=\"/terms\">Scholar@UC Terms of Use</a>"
non_discrimination_notice_html: "<a href=\"http://uc.edu/about/policies/non-discrimination.html\">Notice of Non-Discrimination</a>"
share_button: "Contribute"

curation_concerns:
base:
metadata:
header: Attributes
98 changes: 98 additions & 0 deletions spec/views/curation_concerns/base/_relationships.html.erb_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
# frozen_string_literal: true
require 'spec_helper'

describe 'curation_concerns/base/relationships', type: :view do
let(:ability) { double }
let(:solr_doc) { double(id: '123', human_readable_type: 'Work', admin_set: nil) }
let(:presenter) { Sufia::WorkShowPresenter.new(solr_doc, ability) }
let(:generic_work) { GenericWork.new(id: '456', title: ['Containing work']) }
let(:collection) { Collection.new(id: '345', title: ['Containing collection']) }

context "when collections are not present" do
before do
render 'curation_concerns/base/relationships', presenter: presenter
end
it "shows the message" do
expect(rendered).not_to match %r{There are no Collection relationships\.}
end
end

context "when parents are not present" do
before do
render 'curation_concerns/base/relationships', presenter: presenter
end
it "shows the message" do
expect(rendered).not_to match %r{There are no Generic work relationships\.}
end
end

context "when collections are present and no parents are present" do
let(:collection_presenters) { [collection] }
let(:page) { Capybara::Node::Simple.new(rendered) }
before do
allow(view).to receive(:contextual_path).and_return("/collections/456")
allow(presenter).to receive(:collection_presenters).and_return(collection_presenters)
render 'curation_concerns/base/relationships', presenter: presenter
end
it "links to collections" do
expect(page).to have_link 'Containing collection'
end
it "labels the link using the presenter's #to_s method" do
expect(page).not_to have_content 'foobar'
end
it "shows the empty messages for parents" do
expect(page).not_to have_content "There are no Collection relationships."
expect(page).not_to have_content "There are no Generic work relationships."
end
end

context "when parents are present and no collections are present" do
let(:collection_presenters) { [generic_work] }
let(:page) { Capybara::Node::Simple.new(rendered) }
before do
allow(view).to receive(:contextual_path).and_return("/concern/generic_works/456")
allow(presenter).to receive(:collection_presenters).and_return(collection_presenters)
render 'curation_concerns/base/relationships', presenter: presenter
end
it "links to work" do
expect(page).to have_link 'Containing work'
end
it "labels the link using the presenter's #to_s method" do
expect(page).not_to have_content 'barbaz'
end
it "shows the empty messages for collections" do
expect(page).not_to have_content "There are no Collection relationships."
expect(page).not_to have_content "There are no Generic work relationships."
end
end

context "when parents are present and collections are present" do
let(:collection_presenters) { [generic_work, collection] }
let(:page) { Capybara::Node::Simple.new(rendered) }
before do
allow(view).to receive(:contextual_path).and_return("/concern/generic_works/456")
allow(presenter).to receive(:collection_presenters).and_return(collection_presenters)
render 'curation_concerns/base/relationships', presenter: presenter
end
it "links to work and collection" do
expect(page).to have_link 'Containing work'
expect(page).to have_link 'Containing collection'
end
it "labels the link using the presenter's #to_s method" do
expect(page).not_to have_content 'barbaz'
expect(page).not_to have_content 'foobar'
end
it "does not show the empty messages" do
expect(page).not_to have_content "There are no Collection relationships."
expect(page).not_to have_content "There are no Generic work relationships."
end
end

context 'with admin sets' do
it 'renders using attribute_to_html' do
allow(solr_doc).to receive(:member_of_collection_ids).and_return([])
expect(presenter).to receive(:attribute_to_html).with(:admin_set, render_as: :faceted)
render 'curation_concerns/base/relationships', presenter: presenter
end
end
end

0 comments on commit e52398b

Please sign in to comment.