sufia 7.0.0 → 7.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +8 -7
- data/app/assets/javascripts/sufia.js +3 -4
- data/app/assets/javascripts/sufia/app.js +8 -0
- data/app/assets/javascripts/sufia/relationships.js +2 -0
- data/app/assets/javascripts/sufia/relationships/table.es6 +206 -0
- data/app/assets/javascripts/sufia/relationships/table_row.es6 +79 -0
- data/app/assets/javascripts/sufia/save_work/save_work_control.es6 +3 -0
- data/app/assets/javascripts/sufia/save_work/uploaded_files.es6 +5 -0
- data/app/forms/sufia/forms/batch_edit_form.rb +2 -2
- data/app/forms/sufia/forms/work_form.rb +13 -1
- data/app/presenters/sufia/work_show_presenter.rb +11 -0
- data/app/views/curation_concerns/base/_form_child_work_relationships.html.erb +65 -0
- data/app/views/curation_concerns/base/_form_progress.html.erb +3 -1
- data/app/views/curation_concerns/base/_form_relationships.html.erb +11 -2
- data/app/views/curation_concerns/base/_metadata.html.erb +2 -2
- data/app/views/curation_concerns/base/_relationships.html.erb +7 -22
- data/app/views/curation_concerns/base/_relationships_member_rows.html.erb +24 -0
- data/app/views/curation_concerns/base/_relationships_parent_row.html.erb +16 -0
- data/app/views/curation_concerns/base/_relationships_parent_row_empty.html.erb +6 -0
- data/app/views/curation_concerns/base/_relationships_parent_rows.html.erb +23 -0
- data/app/views/curation_concerns/file_sets/_actions.html.erb +1 -1
- data/app/views/curation_concerns/file_sets/_show_actions.html.erb +8 -9
- data/app/views/curation_concerns/file_sets/_single_use_link_rows.html.erb +19 -0
- data/app/views/curation_concerns/file_sets/_single_use_links.html.erb +10 -0
- data/app/views/curation_concerns/file_sets/show.html.erb +1 -0
- data/app/views/records/edit_fields/_in_works_ids.html.erb +59 -0
- data/config/locales/sufia.en.yml +22 -3
- data/lib/generators/sufia/templates/config/sufia.rb +5 -0
- data/lib/sufia/configuration.rb +6 -0
- data/lib/sufia/engine.rb +0 -2
- data/lib/sufia/version.rb +1 -1
- data/spec/features/search_spec.rb +7 -2
- data/spec/forms/sufia/forms/work_form_spec.rb +20 -0
- data/spec/javascripts/helpers/test_fixtures.js.coffee +9 -0
- data/spec/javascripts/helpers/test_responses.js +10 -5
- data/spec/javascripts/relationships_table_spec.js.coffee +83 -0
- data/spec/javascripts/save_work_spec.js +4 -2
- data/spec/javascripts/support/jasmine.yml +1 -1
- data/spec/javascripts/uploaded_files_spec.js +23 -0
- data/spec/views/batch_edits/edit.html.erb_spec.rb +1 -1
- data/spec/views/catalog/index.html.erb_spec.rb +0 -4
- data/spec/views/curation_concerns/base/_form_child_work_relationships.html.erb_spec.rb +113 -0
- data/spec/views/curation_concerns/base/_relationships.html.erb_spec.rb +89 -3
- data/spec/views/curation_concerns/file_sets/_single_use_links.html.erb_spec.rb +32 -0
- data/spec/views/curation_concerns/file_sets/show.html.erb_spec.rb +4 -0
- data/spec/views/records/edit_fields/_in_works_ids.html.erb_spec.rb +113 -0
- data/sufia.gemspec +1 -2
- metadata +35 -21
- data/app/assets/javascripts/sufia/single_use_link.js +0 -30
- data/spec/javascripts/single_use_link_spec.js.coffee +0 -21
@@ -75,6 +75,11 @@ Sufia.config do |config|
|
|
75
75
|
# The default is true.
|
76
76
|
# config.active_deposit_agreement_acceptance = true
|
77
77
|
|
78
|
+
# Should work creation require file upload, or can a work be created first
|
79
|
+
# and a file added at a later time?
|
80
|
+
# The default is true.
|
81
|
+
# config.work_requires_files = true
|
82
|
+
|
78
83
|
# Should a button with "Share my work" show on the front page to all users (even those not logged in)?
|
79
84
|
# config.always_display_share_button = true
|
80
85
|
|
data/lib/sufia/configuration.rb
CHANGED
@@ -63,6 +63,12 @@ module Sufia
|
|
63
63
|
@active_deposit_agreement_acceptance
|
64
64
|
end
|
65
65
|
|
66
|
+
attr_writer :work_requires_files
|
67
|
+
def work_requires_files
|
68
|
+
return true if @work_requires_files.nil?
|
69
|
+
@work_requires_files
|
70
|
+
end
|
71
|
+
|
66
72
|
attr_writer :batch_user_key
|
67
73
|
def batch_user_key
|
68
74
|
@batch_user_key ||= 'batchuser@example.com'
|
data/lib/sufia/engine.rb
CHANGED
@@ -7,7 +7,6 @@ module Sufia
|
|
7
7
|
require 'jquery-ui-rails'
|
8
8
|
require 'flot-rails'
|
9
9
|
require 'almond-rails'
|
10
|
-
require 'zeroclipboard-rails'
|
11
10
|
|
12
11
|
config.autoload_paths += %W(
|
13
12
|
#{config.root}/app/controllers/concerns
|
@@ -58,7 +57,6 @@ module Sufia
|
|
58
57
|
app.config.assets.paths << config.root.join('app', 'assets', 'images', 'site_images')
|
59
58
|
|
60
59
|
app.config.assets.precompile << /fontawesome-webfont\.(?:svg|ttf|woff)$/
|
61
|
-
app.config.assets.precompile += %w( ZeroClipboard.swf )
|
62
60
|
app.config.assets.precompile += %w(*.png *.jpg *.ico *.gif *.svg)
|
63
61
|
|
64
62
|
Sprockets::ES6.configuration = { 'modules' => 'amd', 'moduleIds' => true }
|
data/lib/sufia/version.rb
CHANGED
@@ -1,8 +1,11 @@
|
|
1
1
|
describe 'searching' do
|
2
2
|
let(:user) { create :user }
|
3
|
-
let(:subject_value) { '
|
3
|
+
let(:subject_value) { 'mustache' }
|
4
4
|
let!(:work) do
|
5
|
-
create(:public_work,
|
5
|
+
create(:public_work,
|
6
|
+
title: ["Toothbrush"],
|
7
|
+
keyword: [subject_value, 'taco'],
|
8
|
+
user: user)
|
6
9
|
end
|
7
10
|
|
8
11
|
let!(:collection) do
|
@@ -44,6 +47,8 @@ describe 'searching' do
|
|
44
47
|
expect(page).to have_content "Toothbrush"
|
45
48
|
expect(page).to have_content('collection title abc')
|
46
49
|
expect(page).to have_css("span.collection-icon-search")
|
50
|
+
|
51
|
+
expect(page.body).to include "<span itemprop=\"keywords\"><a href=\"/catalog?f%5Bkeyword_sim%5D%5B%5D=taco\">taco</a></span> and <span itemprop=\"keywords\"><a href=\"/catalog?f%5Bkeyword_sim%5D%5B%5D=mustache\">mustache</a></span>"
|
47
52
|
end
|
48
53
|
|
49
54
|
it "does not display search options for dashboard files" do
|
@@ -0,0 +1,20 @@
|
|
1
|
+
describe Sufia::Forms::WorkForm do
|
2
|
+
let(:work) { GenericWork.new }
|
3
|
+
let(:form) { described_class.new(work, nil) }
|
4
|
+
let(:works) { [GenericWork.new, FileSet.new, GenericWork.new] }
|
5
|
+
let(:files) { [FileSet.new, GenericWork.new, FileSet.new] }
|
6
|
+
|
7
|
+
describe "#ordered_fileset_members" do
|
8
|
+
it "expects ordered fileset members" do
|
9
|
+
allow(work).to receive(:ordered_members).and_return(files)
|
10
|
+
expect(form.ordered_fileset_members.size).to eq(2)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "#ordered_work_members" do
|
15
|
+
it "expects ordered work members" do
|
16
|
+
allow(work).to receive(:ordered_members).and_return(works)
|
17
|
+
expect(form.ordered_work_members.size).to eq(2)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
window.TestFixtures = {
|
2
|
+
relationships_table: {
|
3
|
+
child_id: 'child1234',
|
4
|
+
parent_id: 'parent5678'
|
5
|
+
}
|
6
|
+
}
|
7
|
+
|
8
|
+
window.TestFixtures.relationships_table["html"] = "<form action='/concern/generic_works/#{TestFixtures.relationships_table.child_id}'><table class='table table-striped related-files relationships-ajax-enabled' data-query-url='/concern/generic_works/$id'> <thead> <tr> <th>Parent Work</th> <th>Actions</th> </tr> </thead> <tbody> <tr class='new-row'> <td> <a href='' class='title hidden'></a> <input class='new-form-control string multi_value optional related_works_ids form-control multi-text-field' name='generic_work[in_works_ids][]' value='' aria-labelledby='generic_work_in_works_ids_label' type='text'> <div class='message has-warning hidden'></div> </td> <td> <div class='child-actions'> <a href='' class='edit hidden btn btn-default' target='_blank'>Edit</a> <a class='btn btn-danger btn-remove-row hidden'>Remove</a> <a class='btn btn-primary btn-add-row'>Add</a></div></td></tr></tbody></table></form>"
|
9
|
+
|
@@ -1,8 +1,13 @@
|
|
1
1
|
var TestResponses = {
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
}
|
2
|
+
relationships_table: {
|
3
|
+
query_url_success: {
|
4
|
+
id: "parent5678",
|
5
|
+
title: ["Parent"]
|
6
|
+
},
|
7
|
+
ajax_add_success:{},
|
8
|
+
ajax_remove_success:{},
|
9
|
+
ajax_error: {
|
10
|
+
responseText: "Error"
|
11
|
+
},
|
7
12
|
}
|
8
13
|
}
|
@@ -0,0 +1,83 @@
|
|
1
|
+
describe 'RelationshipsTable', ->
|
2
|
+
control = require('sufia/relationships/table')
|
3
|
+
form = null
|
4
|
+
element = null
|
5
|
+
btn_remove = null
|
6
|
+
btn_add = null
|
7
|
+
btn_edit = null
|
8
|
+
input = null
|
9
|
+
message = null
|
10
|
+
test_fixtures = TestFixtures
|
11
|
+
test_responses = TestResponses
|
12
|
+
deferred_ajax = null
|
13
|
+
|
14
|
+
beforeEach ->
|
15
|
+
form = $(test_fixtures.relationships_table.html)
|
16
|
+
element = form.find("table")
|
17
|
+
btn_remove = element.find('.btn-remove-row')
|
18
|
+
btn_add = element.find('.btn-add-row')
|
19
|
+
btn_edit = element.find('.edit')
|
20
|
+
input = element.find('.new-form-control')
|
21
|
+
message = element.find('.message')
|
22
|
+
target = new control.RelationshipsTable(element)
|
23
|
+
jasmine.Ajax.install()
|
24
|
+
deferred_ajax = new jQuery.Deferred()
|
25
|
+
spyOn($,'ajax').and.returnValue(deferred_ajax)
|
26
|
+
spyOn($,'getJSON').and.callFake((url, success) ->
|
27
|
+
success(test_responses.relationships_table.query_url_success))
|
28
|
+
|
29
|
+
afterEach ->
|
30
|
+
jasmine.Ajax.uninstall()
|
31
|
+
|
32
|
+
describe 'when adding/removing a row', ->
|
33
|
+
# the new-row is properly rendered
|
34
|
+
it 'only displays one new row with an add button visible', ->
|
35
|
+
expect(btn_remove.hasClass("hidden")).toBeTruthy()
|
36
|
+
expect(btn_edit.hasClass("hidden")).toBeTruthy()
|
37
|
+
expect(btn_add.hasClass("hidden")).toBeFalsy()
|
38
|
+
|
39
|
+
it 'clicks add with a valid id', ->
|
40
|
+
input.val(test_fixtures.relationships_table.parent_id)
|
41
|
+
btn_add.click()
|
42
|
+
deferred_ajax.resolve(test_responses.relationships_table.ajax_add_success)
|
43
|
+
expect(message.hasClass("hidden")).toBeTruthy()
|
44
|
+
expect(element.find("tbody tr").length).toEqual(2)
|
45
|
+
|
46
|
+
it 'clicks add with an invalid id', ->
|
47
|
+
input.val('invalid')
|
48
|
+
btn_add.click()
|
49
|
+
deferred_ajax.reject(test_responses.relationships_table.ajax_error)
|
50
|
+
expect(message.hasClass("hidden")).toBeFalsy()
|
51
|
+
expect(element.find("tbody tr").length).toEqual(1)
|
52
|
+
|
53
|
+
it 'clicks add without an id', ->
|
54
|
+
expect(message.hasClass("hidden")).toBeTruthy()
|
55
|
+
btn_add.click()
|
56
|
+
expect(message.hasClass("hidden")).toBeFalsy()
|
57
|
+
expect(message.text()).toContain("ID cannot be empty")
|
58
|
+
expect(element.find("tbody tr").length).toEqual(1)
|
59
|
+
|
60
|
+
it 'clicks remove to remove a work', ->
|
61
|
+
input.val(test_fixtures.relationships_table.parent_id)
|
62
|
+
btn_add.click()
|
63
|
+
deferred_ajax.resolve(test_responses.relationships_table.ajax_add_success)
|
64
|
+
expect(element.find("tbody tr").length).toEqual(2)
|
65
|
+
parent_row = element.find("tbody tr:first")
|
66
|
+
parent_delete = parent_row.find(".btn-remove-row")
|
67
|
+
parent_delete.click()
|
68
|
+
deferred_ajax.resolve(test_responses.relationships_table.ajax_remove_success)
|
69
|
+
expect(element.find("tbody tr").length).toEqual(1)
|
70
|
+
|
71
|
+
it 'clicks add with a duplicate id', ->
|
72
|
+
input.val(test_fixtures.relationships_table.parent_id)
|
73
|
+
btn_add.click()
|
74
|
+
deferred_ajax.resolve(test_responses.relationships_table.ajax_add_success)
|
75
|
+
expect(element.find("tbody tr").length).toEqual(2)
|
76
|
+
input = element.find("tbody tr:nth-child(2) .new-form-control")
|
77
|
+
input.val(test_fixtures.relationships_table.parent_id)
|
78
|
+
btn_add = element.find("tbody tr:nth-child(2) .btn-add-row")
|
79
|
+
btn_add.click()
|
80
|
+
message = element.find("tbody tr:nth-child(2) .message")
|
81
|
+
expect(element.find("tbody tr").length).toEqual(2)
|
82
|
+
expect(message.hasClass("hidden")).toBeFalsy()
|
83
|
+
expect(message.text()).toContain("Work is already related")
|
@@ -98,7 +98,8 @@ describe("SaveWorkControl", function() {
|
|
98
98
|
beforeEach(function() {
|
99
99
|
target = buildTarget(form_id)
|
100
100
|
target.uploads = {
|
101
|
-
hasFiles: true
|
101
|
+
hasFiles: true,
|
102
|
+
hasFileRequirement: true
|
102
103
|
};
|
103
104
|
});
|
104
105
|
it("is complete", function() {
|
@@ -112,7 +113,8 @@ describe("SaveWorkControl", function() {
|
|
112
113
|
beforeEach(function() {
|
113
114
|
target = buildTarget(form_id)
|
114
115
|
target.uploads = {
|
115
|
-
hasFiles: false
|
116
|
+
hasFiles: false,
|
117
|
+
hasFileRequirement: true
|
116
118
|
};
|
117
119
|
});
|
118
120
|
|
@@ -0,0 +1,23 @@
|
|
1
|
+
describe("UploadedFiles", function() {
|
2
|
+
var control = require('sufia/save_work/uploaded_files');
|
3
|
+
|
4
|
+
describe("hasFileRequirement", function() {
|
5
|
+
describe("with required file element", function() {
|
6
|
+
it("returns true", function() {
|
7
|
+
var fixture = setFixtures('<form><ul class="requirements"><li class="incomplete" id="required-files">Add files</li></ul></form>');
|
8
|
+
var element = fixture.find('form');
|
9
|
+
target = new control.UploadedFiles(element);
|
10
|
+
expect(target.hasFileRequirement).toBe(true);
|
11
|
+
});
|
12
|
+
});
|
13
|
+
|
14
|
+
describe("without required file element", function() {
|
15
|
+
it("returns false", function() {
|
16
|
+
var fixture = setFixtures('<form><ul class="requirements"><li>Not files</li></ul></form>');
|
17
|
+
var element = fixture.find('form');
|
18
|
+
target = new control.UploadedFiles(element);
|
19
|
+
expect(target.hasFileRequirement).toBe(false);
|
20
|
+
});
|
21
|
+
});
|
22
|
+
});
|
23
|
+
});
|
@@ -4,7 +4,7 @@ describe 'batch_edits/edit.html.erb', type: :view do
|
|
4
4
|
let(:form) { Sufia::Forms::BatchEditForm.new(generic_work, nil, batch) }
|
5
5
|
|
6
6
|
before do
|
7
|
-
allow(GenericWork).to receive(:
|
7
|
+
allow(GenericWork).to receive(:find).and_return(generic_work)
|
8
8
|
|
9
9
|
# this prevents AF from hitting Fedora (permissions is a related object)
|
10
10
|
allow(generic_work).to receive(:permissions_attributes=)
|
@@ -1,4 +1,3 @@
|
|
1
|
-
|
2
1
|
describe 'catalog/index.html.erb', type: :view do
|
3
2
|
let(:collection) { build(:collection, id: "abc123") }
|
4
3
|
let(:doc) { SolrDocument.new(collection.to_solr) }
|
@@ -32,9 +31,6 @@ describe 'catalog/index.html.erb', type: :view do
|
|
32
31
|
allow(resp).to receive(:limit_value).and_return(10)
|
33
32
|
allow(resp).to receive(:empty?).and_return(false)
|
34
33
|
|
35
|
-
# This stubs out the SolrDocument#to_model
|
36
|
-
allow(ActiveFedora::Base).to receive(:load_instance_from_solr).with('abc123', doc).and_return(collection)
|
37
|
-
|
38
34
|
assign(:document_list, [doc])
|
39
35
|
end
|
40
36
|
|
@@ -0,0 +1,113 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "curation_concerns/base/_form_child_work_relationships.html.erb", type: :view do
|
4
|
+
let(:work) do
|
5
|
+
stub_model(GenericWork, id: '456', title: ["MyWork"])
|
6
|
+
end
|
7
|
+
|
8
|
+
let(:work_2) do
|
9
|
+
stub_model(GenericWork, id: '567', title: ["Child Work"])
|
10
|
+
end
|
11
|
+
|
12
|
+
let(:ability) { double }
|
13
|
+
|
14
|
+
let(:form) do
|
15
|
+
Sufia::Forms::WorkForm.new(work, ability)
|
16
|
+
end
|
17
|
+
|
18
|
+
let(:f) { double }
|
19
|
+
|
20
|
+
let(:page) do
|
21
|
+
render
|
22
|
+
Capybara::Node::Simple.new(rendered)
|
23
|
+
end
|
24
|
+
|
25
|
+
before do
|
26
|
+
view.lookup_context.view_paths.push 'app/views/curation_concerns'
|
27
|
+
allow(view).to receive(:params).and_return(id: work.id)
|
28
|
+
allow(view).to receive(:curation_concern).and_return(work)
|
29
|
+
allow(view).to receive(:f).and_return(f)
|
30
|
+
allow(f).to receive(:object).and_return(form)
|
31
|
+
allow(controller).to receive(:current_user).and_return(stub_model(User))
|
32
|
+
assign(:form, form)
|
33
|
+
end
|
34
|
+
|
35
|
+
context "When editing a work" do
|
36
|
+
context "and no children works are present" do
|
37
|
+
before do
|
38
|
+
allow(work).to receive(:ordered_members).and_return([])
|
39
|
+
end
|
40
|
+
it "has 1 empty child work input" do
|
41
|
+
expect(page).to have_selector("input[value='']", count: 1)
|
42
|
+
end
|
43
|
+
|
44
|
+
it "will not display the remove button in the actions" do
|
45
|
+
expect(page).to have_selector(".btn-remove-row", visible: false)
|
46
|
+
end
|
47
|
+
|
48
|
+
it "will display the add button in the actions" do
|
49
|
+
expect(page).to have_selector(".btn-add-row", visible: true, count: 1)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
context "When 1 child work is present" do
|
53
|
+
let(:work_2) do
|
54
|
+
stub_model(GenericWork, id: '567', title: ["Test Child Work"])
|
55
|
+
end
|
56
|
+
|
57
|
+
before do
|
58
|
+
allow(work).to receive(:ordered_members).and_return([work_2])
|
59
|
+
end
|
60
|
+
it "has 1 empty child work input with add button" do
|
61
|
+
expect(page).to have_selector("input[value='']", count: 1)
|
62
|
+
expect(page).to have_selector(".btn-add-row", visible: true, count: 1)
|
63
|
+
end
|
64
|
+
|
65
|
+
it "has an input box that is filled in with the child id" do
|
66
|
+
expect(page).to have_selector("input[value='#{work_2.id}']", count: 1)
|
67
|
+
end
|
68
|
+
|
69
|
+
it "generates a link for the childs first title" do
|
70
|
+
expect(page).to have_link("Test Child Work")
|
71
|
+
end
|
72
|
+
|
73
|
+
it "has an edit and remove button" do
|
74
|
+
within ".old-row" do
|
75
|
+
expect(page).to have_selector(".btn-remove-row", visible: true, count: 1)
|
76
|
+
expect(page).to have_selector(".btn-edit-row", visible: true, count: 1)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
context "When multiple child works are present" do
|
81
|
+
let(:work_2) do
|
82
|
+
stub_model(GenericWork, id: '567', title: ["Test Child Work"])
|
83
|
+
end
|
84
|
+
let(:work_3) do
|
85
|
+
stub_model(GenericWork, id: '789', title: ["Test Child Work 2"])
|
86
|
+
end
|
87
|
+
before do
|
88
|
+
allow(work).to receive(:ordered_members).and_return([work_2, work_3])
|
89
|
+
end
|
90
|
+
it "has 1 empty child work input with add button" do
|
91
|
+
expect(page).to have_selector("input[value='']", count: 1)
|
92
|
+
expect(page).to have_selector(".btn-add-row", visible: true, count: 1)
|
93
|
+
end
|
94
|
+
|
95
|
+
it "has an input box that is filled in with the child ids" do
|
96
|
+
expect(page).to have_selector("input[value='#{work_2.id}']", count: 1)
|
97
|
+
expect(page).to have_selector("input[value='#{work_3.id}']", count: 1)
|
98
|
+
end
|
99
|
+
|
100
|
+
it "generates a link for the childs first title" do
|
101
|
+
expect(page).to have_link("Test Child Work")
|
102
|
+
expect(page).to have_link("Test Child Work 2")
|
103
|
+
end
|
104
|
+
|
105
|
+
it "has an edit and remove button" do
|
106
|
+
within ".old-row" do
|
107
|
+
expect(page).to have_selector(".btn-remove-row", visible: true, count: 2)
|
108
|
+
expect(page).to have_selector(".btn-edit-row", visible: true, count: 2)
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
@@ -4,20 +4,41 @@ describe 'curation_concerns/base/relationships', type: :view do
|
|
4
4
|
let(:ability) { double }
|
5
5
|
let(:solr_doc) { double(id: '123', human_readable_type: 'Work') }
|
6
6
|
let(:presenter) { Sufia::WorkShowPresenter.new(solr_doc, ability) }
|
7
|
+
let(:generic_work) { GenericWork.new(id: '456', title: ['Containing work', 'barbaz']) }
|
8
|
+
let(:collection) { Collection.new(id: '345', title: ['Containing collection', 'foobar']) }
|
7
9
|
|
8
10
|
context "when collections are not present" do
|
9
11
|
before do
|
10
12
|
render 'curation_concerns/base/relationships', presenter: presenter
|
11
13
|
end
|
12
14
|
it "shows the message" do
|
13
|
-
expect(rendered).to match %r{
|
15
|
+
expect(rendered).to match %r{There are no Collection relationships\.}
|
14
16
|
end
|
15
17
|
end
|
16
18
|
|
17
|
-
context "when
|
18
|
-
|
19
|
+
context "when children are not present" do
|
20
|
+
before do
|
21
|
+
render 'curation_concerns/base/relationships', presenter: presenter
|
22
|
+
end
|
23
|
+
it "shows the message" do
|
24
|
+
expect(rendered).to match %r{This Work does not have any related works\.}
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
context "when parents are not present" do
|
29
|
+
before do
|
30
|
+
render 'curation_concerns/base/relationships', presenter: presenter
|
31
|
+
end
|
32
|
+
it "shows the message" do
|
33
|
+
expect(rendered).to match %r{There are no Generic work relationships\.}
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
context "when collections are present and no parents are present" do
|
38
|
+
let(:collection_presenters) { [collection] }
|
19
39
|
let(:page) { Capybara::Node::Simple.new(rendered) }
|
20
40
|
before do
|
41
|
+
allow(view).to receive(:contextual_path).and_return("/collections/456")
|
21
42
|
allow(presenter).to receive(:collection_presenters).and_return(collection_presenters)
|
22
43
|
render 'curation_concerns/base/relationships', presenter: presenter
|
23
44
|
end
|
@@ -27,5 +48,70 @@ describe 'curation_concerns/base/relationships', type: :view do
|
|
27
48
|
it "labels the link using the presenter's #to_s method" do
|
28
49
|
expect(page).not_to have_content 'foobar'
|
29
50
|
end
|
51
|
+
it "shows the empty messages for parents" do
|
52
|
+
expect(page).not_to have_content "There are no Collection relationships."
|
53
|
+
expect(page).to have_content "There are no Generic work relationships."
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
context "when parents are present and no collections are present" do
|
58
|
+
let(:collection_presenters) { [generic_work] }
|
59
|
+
let(:page) { Capybara::Node::Simple.new(rendered) }
|
60
|
+
before do
|
61
|
+
allow(view).to receive(:contextual_path).and_return("/concern/generic_works/456")
|
62
|
+
allow(presenter).to receive(:collection_presenters).and_return(collection_presenters)
|
63
|
+
render 'curation_concerns/base/relationships', presenter: presenter
|
64
|
+
end
|
65
|
+
it "links to work" do
|
66
|
+
expect(page).to have_link 'Containing work'
|
67
|
+
end
|
68
|
+
it "labels the link using the presenter's #to_s method" do
|
69
|
+
expect(page).not_to have_content 'barbaz'
|
70
|
+
end
|
71
|
+
it "shows the empty messages for collections" do
|
72
|
+
expect(page).to have_content "There are no Collection relationships."
|
73
|
+
expect(page).not_to have_content "There are no Generic work relationships."
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
context "when parents are present and collections are present" do
|
78
|
+
let(:collection_presenters) { [generic_work, collection] }
|
79
|
+
let(:page) { Capybara::Node::Simple.new(rendered) }
|
80
|
+
before do
|
81
|
+
allow(view).to receive(:contextual_path).and_return("/concern/generic_works/456")
|
82
|
+
allow(presenter).to receive(:collection_presenters).and_return(collection_presenters)
|
83
|
+
render 'curation_concerns/base/relationships', presenter: presenter
|
84
|
+
end
|
85
|
+
it "links to work and collection" do
|
86
|
+
expect(page).to have_link 'Containing work'
|
87
|
+
expect(page).to have_link 'Containing collection'
|
88
|
+
end
|
89
|
+
it "labels the link using the presenter's #to_s method" do
|
90
|
+
expect(page).not_to have_content 'barbaz'
|
91
|
+
expect(page).not_to have_content 'foobar'
|
92
|
+
end
|
93
|
+
it "does not show the empty messages" do
|
94
|
+
expect(page).not_to have_content "There are no Collection relationships."
|
95
|
+
expect(page).not_to have_content "There are no Generic work relationships."
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
context "when children are present" do
|
100
|
+
let(:member_presenters) { [generic_work] }
|
101
|
+
let(:page) { Capybara::Node::Simple.new(rendered) }
|
102
|
+
before do
|
103
|
+
allow(view).to receive(:contextual_path).and_return("/concern/generic_works/456")
|
104
|
+
allow(presenter).to receive(:member_presenters).and_return(member_presenters)
|
105
|
+
render 'curation_concerns/base/relationships', presenter: presenter
|
106
|
+
end
|
107
|
+
it "links to child work" do
|
108
|
+
expect(page).to have_link 'Containing work'
|
109
|
+
end
|
110
|
+
it "labels the link using the presenter's #to_s method" do
|
111
|
+
expect(page).not_to have_content 'barbaz'
|
112
|
+
end
|
113
|
+
it "does not show the empty message" do
|
114
|
+
expect(page).not_to have_content "This Work does not have any related works."
|
115
|
+
end
|
30
116
|
end
|
31
117
|
end
|