Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move child works from 'relationships' to 'items' on work show page #2468

Merged
merged 1 commit into from
Aug 16, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions app/views/curation_concerns/base/_items.html.erb
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
<h2><%= t('.header') %></h2>
<% if presenter.file_set_presenters.present? %>
<% if presenter.member_presenters.present? %>
<table class="table table-striped related-files">
<thead>
<tr>
<th>File</th>
<th>Filename</th>
<th>Date Uploaded</th>
<th>Visibility</th>
<th>Actions</th>
<th><%= t('.thumbnail') %></th>
<th><%= t('.title') %></th>
<th><%= t('.date_uploaded') %></th>
<th><%= t('.visibility') %></th>
<th><%= t('.actions') %></th>
</tr>
</thead>
<tbody>
<%= render partial: 'member', collection: presenter.file_set_presenters %>
<%= render partial: 'member', collection: presenter.member_presenters %>
</tbody>
</table>
<% elsif can? :edit, presenter.id %>
Expand Down
1 change: 0 additions & 1 deletion app/views/curation_concerns/base/_relationships.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@
<table class="table table-striped relationships">
<tbody>
<%= render 'relationships_parent_rows', presenter: presenter %>
<%= render 'relationships_member_rows', presenter: presenter %>
</tbody>
</table>

This file was deleted.

8 changes: 5 additions & 3 deletions config/locales/sufia.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -354,15 +354,17 @@ en:
relationships_parent_row_empty:
label: "In %{type}:"
empty: "There are no %{type} relationships."
relationships_member_rows:
label: "Has related %{type}:"
empty: "This %{type} does not have any related works."
metadata:
header: Descriptions
attribute_name_label: Attribute Name
attribute_values_label: Values
items:
header: Items
thumbnail: Thumbnail
title: Title
date_uploaded: "Date Uploaded"
visibility: Visibility
actions: Actions
empty: "This %{type} has no files associated with it. Click \"edit\" to add more files."
citations:
header: 'Citations:'
Expand Down
48 changes: 48 additions & 0 deletions spec/views/curation_concerns/base/_items.html.erb_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
require 'spec_helper'

describe 'curation_concerns/base/items', type: :view do
let(:ability) { double }
let(:presenter) { Sufia::WorkShowPresenter.new(solr_doc, ability) }
let(:file_set) { Sufia::FileSetPresenter.new(solr_doc_file, ability) }
let(:member) { Sufia::WorkShowPresenter.new(solr_doc_work, ability) }
let(:solr_doc) { double(id: '123', human_readable_type: 'Work') }
let(:solr_doc_file) do
SolrDocument.new(
FactoryGirl.build(:file_set).to_solr.merge(
id: "file",
title_tesim: "Child File",
label_tesim: "Child File"
)
)
end
let(:solr_doc_work) do
SolrDocument.new(
FactoryGirl.build(:generic_work).to_solr.merge(
id: "work",
title_tesim: "Child Work"
)
)
end
let(:blacklight_config) { CatalogController.new.blacklight_config }
let(:blacklight_configuration_context) do
Blacklight::Configuration::Context.new(controller)
end

context "when children are present" do
before do
stub_template 'curation_concerns/base/_actions.html.erb' => 'Actions'
allow(presenter).to receive(:member_presenters).and_return([file_set, member])
allow(view).to receive(:blacklight_config).and_return(Blacklight::Configuration.new)
allow(view).to receive(:blacklight_configuration_context).and_return(blacklight_configuration_context)
allow(view).to receive(:contextual_path).and_return("/whocares")
allow(ability).to receive(:can?).and_return(true)
render 'curation_concerns/base/items', presenter: presenter
end
it "links to child work" do
expect(rendered).to have_link 'Child Work'
end
it "links to child file" do
expect(rendered).to have_link 'Child File'
end
end
end
28 changes: 0 additions & 28 deletions spec/views/curation_concerns/base/_relationships.html.erb_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,6 @@
end
end

context "when children are not present" do
before do
render 'curation_concerns/base/relationships', presenter: presenter
end
it "shows the message" do
expect(rendered).to match %r{This Work does not have any related works\.}
end
end

context "when parents are not present" do
before do
render 'curation_concerns/base/relationships', presenter: presenter
Expand Down Expand Up @@ -95,23 +86,4 @@
expect(page).not_to have_content "There are no Generic work relationships."
end
end

context "when children are present" do
let(:member_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(:member_presenters).and_return(member_presenters)
render 'curation_concerns/base/relationships', presenter: presenter
end
it "links to child 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 "does not show the empty message" do
expect(page).not_to have_content "This Work does not have any related works."
end
end
end