curation_concerns 1.5.0 → 1.6.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/.rubocop.yml +1 -1
- data/Gemfile +0 -4
- data/app/actors/curation_concerns/actors/file_actor.rb +19 -3
- data/app/assets/javascripts/curation_concerns/curation_concerns.js +1 -0
- data/app/assets/javascripts/curation_concerns/file_manager/sorting.es6 +44 -5
- data/app/assets/javascripts/curation_concerns/file_manager.es6 +9 -2
- data/app/controllers/concerns/curation_concerns/collections_controller_behavior.rb +57 -18
- data/app/controllers/concerns/curation_concerns/permissions_controller_behavior.rb +23 -0
- data/app/controllers/concerns/curation_concerns/selects_collections.rb +2 -0
- data/app/controllers/curation_concerns/permissions_controller.rb +1 -16
- data/app/forms/curation_concerns/forms/work_form.rb +0 -7
- data/app/helpers/batch_select_helper.rb +0 -15
- data/app/helpers/curation_concerns/collections_helper.rb +40 -6
- data/app/helpers/curation_concerns/main_app_helpers.rb +0 -2
- data/app/jobs/characterize_job.rb +5 -3
- data/app/jobs/create_derivatives_job.rb +3 -2
- data/app/jobs/ingest_file_job.rb +16 -16
- data/app/models/concerns/curation_concerns/admin_set_behavior.rb +5 -0
- data/app/models/concerns/curation_concerns/basic_metadata.rb +8 -0
- data/app/models/concerns/curation_concerns/collection_behavior.rb +2 -3
- data/app/models/concerns/curation_concerns/serializers.rb +2 -2
- data/app/models/concerns/curation_concerns/solr_document_behavior.rb +3 -2
- data/app/models/concerns/curation_concerns/work_behavior.rb +1 -1
- data/app/presenters/curation_concerns/work_show_presenter.rb +2 -1
- data/app/renderers/curation_concerns/renderers/external_link_attribute_renderer.rb +13 -0
- data/app/renderers/{renderers.rb → curation_concerns/renderers.rb} +0 -0
- data/app/search_builders/curation_concerns/admin_set_search_builder.rb +3 -3
- data/app/search_builders/curation_concerns/collection_search_builder.rb +6 -4
- data/app/search_builders/curation_concerns/file_set_search_builder.rb +3 -3
- data/app/search_builders/curation_concerns/filter_by_type.rb +17 -5
- data/app/search_builders/curation_concerns/member_search_builder.rb +7 -3
- data/app/search_builders/curation_concerns/single_result.rb +1 -1
- data/app/services/curation_concerns/admin_set_service.rb +6 -8
- data/app/services/curation_concerns/indexes_thumbnails.rb +0 -1
- data/app/services/curation_concerns/license_service.rb +8 -0
- data/app/services/curation_concerns/working_directory.rb +4 -2
- data/app/views/collections/_search_form.html.erb +2 -2
- data/app/views/curation_concerns/base/_file_manager_actions.html.erb +1 -0
- data/app/views/curation_concerns/base/_file_manager_member_resource_options.html.erb +4 -0
- data/app/views/curation_concerns/base/_file_manager_resource_form.html.erb +1 -0
- data/app/views/curation_concerns/base/_form_rights.html.erb +3 -2
- data/config/locales/curation_concerns.en.yml +4 -0
- data/curation_concerns.gemspec +3 -3
- data/lib/curation_concerns/version.rb +1 -1
- data/lib/generators/curation_concerns/models_generator.rb +8 -0
- data/lib/generators/curation_concerns/templates/spec/models/collection_spec.rb +7 -0
- data/lib/generators/curation_concerns/templates/spec/models/file_set_spec.rb +7 -0
- data/spec/actors/curation_concerns/file_actor_spec.rb +17 -3
- data/spec/actors/curation_concerns/file_set_actor_spec.rb +34 -8
- data/spec/controllers/curation_concerns/collections_controller_spec.rb +3 -4
- data/spec/controllers/selects_collections_controller_spec.rb +7 -2
- data/spec/factories/generic_works.rb +3 -1
- data/spec/features/collection_spec.rb +2 -0
- data/spec/helpers/curation_concerns/collections_helper_spec.rb +87 -3
- data/spec/indexers/file_set_indexer_spec.rb +3 -0
- data/spec/indexers/work_indexer_spec.rb +2 -1
- data/spec/javascripts/file_manager_member_spec.coffee +2 -1
- data/spec/javascripts/file_manager_sorting_spec.coffee +23 -0
- data/spec/javascripts/fixtures/sortable.html +182 -0
- data/spec/javascripts/save_manager_spec.coffee +2 -1
- data/spec/jobs/characterize_job_spec.rb +18 -1
- data/spec/jobs/ingest_file_job_spec.rb +18 -13
- data/spec/models/admin_set_spec.rb +5 -3
- data/spec/models/file_set_spec.rb +2 -4
- data/spec/models/solr_document_spec.rb +17 -3
- data/spec/presenters/curation_concerns/collection_presenter_spec.rb +5 -0
- data/spec/renderers/curation_concerns/renderers/external_link_attribute_renderer_spec.rb +22 -0
- data/spec/search_builders/curation_concerns/admin_set_search_builder_spec.rb +8 -5
- data/spec/search_builders/curation_concerns/file_set_search_builder_spec.rb +2 -2
- data/spec/services/curation_concerns/admin_set_service_spec.rb +53 -22
- data/spec/spec_helper.rb +1 -2
- data/spec/test_app_templates/Gemfile.extra +4 -0
- data/spec/views/curation_concerns/base/_attributes.html.erb_spec.rb +10 -4
- data/spec/views/curation_concerns/base/file_manager.html.erb_spec.rb +8 -0
- data/spec/views/curation_concerns/base/show.json.jbuilder_spec.rb +1 -1
- data/spec/views/curation_concerns/file_sets/show.json.jbuilder_spec.rb +1 -1
- metadata +19 -22
- data/app/helpers/collections_helper.rb +0 -4
- data/app/helpers/curation_concerns/collections_helper_behavior.rb +0 -41
- data/app/helpers/curation_concerns/permissions_helper.rb +0 -19
- data/app/helpers/curation_concerns/rights_helper.rb +0 -9
- data/app/models/collection.rb +0 -6
- data/spec/helpers/collections_helper_spec.rb +0 -88
|
@@ -18,6 +18,7 @@ describe CurationConcerns::FileSetIndexer do
|
|
|
18
18
|
subject: ['Theology'],
|
|
19
19
|
language: ['Arabic'],
|
|
20
20
|
rights: ['Wide open, buddy.'],
|
|
21
|
+
rights_statement: ['No Known Copyright'],
|
|
21
22
|
resource_type: ['Book'],
|
|
22
23
|
identifier: ['urn:isbn:1234567890'],
|
|
23
24
|
based_near: ['Medina, Saudi Arabia'],
|
|
@@ -58,12 +59,14 @@ describe CurationConcerns::FileSetIndexer do
|
|
|
58
59
|
|
|
59
60
|
it 'has fields' do
|
|
60
61
|
expect(subject[Solrizer.solr_name('hasRelatedMediaFragment', :symbol)]).to eq 'foo123'
|
|
62
|
+
expect(subject[Solrizer.solr_name('hasRelatedImage', :symbol)]).to eq 'foo123'
|
|
61
63
|
expect(subject[Solrizer.solr_name('part_of')]).to be_nil
|
|
62
64
|
expect(subject[Solrizer.solr_name('date_uploaded')]).to be_nil
|
|
63
65
|
expect(subject[Solrizer.solr_name('date_modified')]).to be_nil
|
|
64
66
|
expect(subject[Solrizer.solr_name('date_uploaded', :stored_sortable, type: :date)]).to eq '2011-01-01T00:00:00Z'
|
|
65
67
|
expect(subject[Solrizer.solr_name('date_modified', :stored_sortable, type: :date)]).to eq '2012-01-01T00:00:00Z'
|
|
66
68
|
expect(subject[Solrizer.solr_name('rights')]).to eq ['Wide open, buddy.']
|
|
69
|
+
expect(subject[Solrizer.solr_name('rights_statement')]).to eq ['No Known Copyright']
|
|
67
70
|
expect(subject[Solrizer.solr_name('related_url')]).to eq ['http://example.org/TheWork/']
|
|
68
71
|
expect(subject[Solrizer.solr_name('contributor')]).to eq ['Mohammad']
|
|
69
72
|
expect(subject[Solrizer.solr_name('creator')]).to eq ['Allah']
|
|
@@ -22,7 +22,8 @@ describe CurationConcerns::WorkIndexer do
|
|
|
22
22
|
expect(solr_document['member_ids_ssim']).to eq work.member_ids
|
|
23
23
|
expect(solr_document['generic_type_sim']).to eq ['Work']
|
|
24
24
|
expect(solr_document.fetch('thumbnail_path_ss')).to eq "/downloads/#{file.id}?file=thumbnail"
|
|
25
|
-
expect(subject.fetch('
|
|
25
|
+
expect(subject.fetch('hasRelatedImage_ssim').first).to eq file.id
|
|
26
|
+
expect(subject.fetch('hasRelatedMediaFragment_ssim').first).to eq file.id
|
|
26
27
|
end
|
|
27
28
|
|
|
28
29
|
context "when thumbnail_field is configured" do
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
describe "FileManagerMember", ->
|
|
2
|
+
filemm = require('curation_concerns/file_manager/member')
|
|
2
3
|
file_manager_member = null
|
|
3
4
|
save_manager = null
|
|
4
5
|
beforeEach () ->
|
|
@@ -7,7 +8,7 @@ describe "FileManagerMember", ->
|
|
|
7
8
|
push_changed: () -> {},
|
|
8
9
|
mark_unchanged: () -> {}
|
|
9
10
|
}
|
|
10
|
-
file_manager_member = new FileManagerMember($("li"), save_manager)
|
|
11
|
+
file_manager_member = new filemm.FileManagerMember($("li"), save_manager)
|
|
11
12
|
describe "#is_changed", ->
|
|
12
13
|
it "is true when the form's label input is changed", ->
|
|
13
14
|
$("#file_set_title").val("testing")
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
describe "FileManagerSorting", ->
|
|
2
|
+
sortm = require('curation_concerns/file_manager/sorting')
|
|
3
|
+
sort_manager = null
|
|
4
|
+
save_manager = null
|
|
5
|
+
titles = null
|
|
6
|
+
beforeEach () ->
|
|
7
|
+
loadFixtures('sortable.html')
|
|
8
|
+
save_manager = {
|
|
9
|
+
push_changed: () -> {},
|
|
10
|
+
mark_unchanged: () -> {}
|
|
11
|
+
}
|
|
12
|
+
sort_manager= new sortm(save_manager)
|
|
13
|
+
describe "sort_alpha", ->
|
|
14
|
+
it "sorts correctly, ignoring capitalization", ->
|
|
15
|
+
expect(sort_manager.order).toEqual(sort_manager.element.data("current-order"))
|
|
16
|
+
sort_manager.sort_alpha()
|
|
17
|
+
# order has changed
|
|
18
|
+
expect(sort_manager.order).not.toEqual(sort_manager.element.data("current-order"))
|
|
19
|
+
# order is now alphabetical
|
|
20
|
+
titles = $("input.title").map( ->
|
|
21
|
+
return $(@).val()
|
|
22
|
+
).get()
|
|
23
|
+
expect(titles).toEqual([ 'child1', 'child2', 'CIMG1815.JPG', 'CIMG1816 copy.JPG', 'zeldogbeach2.jpg' ])
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
<ul id="sortable" data-id="st74cq794" data-class-name="generic_works" data-singular-class-name="generic_work" class="list-unstyled grid clearfix ui-sortable">
|
|
2
|
+
<li data-reorder-id="m326m2125">
|
|
3
|
+
<div class="panel panel-default">
|
|
4
|
+
<form data-type="json" novalidate="novalidate" class="simple_form edit_file_set" id="edit_file_set_m326m2125" action="/concern/file_sets/m326m2125" accept-charset="UTF-8" data-remote="true" method="post"><input name="utf8" type="hidden" value="✓"><input type="hidden" name="_method" value="patch">
|
|
5
|
+
<div class="panel-heading ui-sortable-handle">
|
|
6
|
+
<div class="order-title">
|
|
7
|
+
<div class="form-group string required file_set_title"><input class="form-control string required title" name="file_set[title][]" type="text" value="CIMG1815.JPG" id="file_set_title"></div>
|
|
8
|
+
</div>
|
|
9
|
+
<div class="file-set-link pull-right">
|
|
10
|
+
<a title="Edit file" href="/concern/parent/st74cq794/file_sets/m326m2125">
|
|
11
|
+
<span class="glyphicon glyphicon-edit" aria-hidden="true"></span>
|
|
12
|
+
</a> </div>
|
|
13
|
+
<div class="order-filename">
|
|
14
|
+
<em title="CIMG1815.JPG">(CIMG1815.JPG)</em>
|
|
15
|
+
</div>
|
|
16
|
+
</div>
|
|
17
|
+
<div class="panel-body">
|
|
18
|
+
<div class="text-center thumbnail">
|
|
19
|
+
<a data-context-href="/catalog/m326m2125/track" href="/concern/file_sets/m326m2125"><img class="thumbnail-inner" src="/downloads/m326m2125?file=thumbnail" alt="M326m2125?file=thumbnail"></a>
|
|
20
|
+
|
|
21
|
+
</div>
|
|
22
|
+
<div class="attributes">
|
|
23
|
+
|
|
24
|
+
</div>
|
|
25
|
+
<div class="spacer">
|
|
26
|
+
</div>
|
|
27
|
+
</div>
|
|
28
|
+
</form> <div class="form-group radio_buttons member_resource_options">
|
|
29
|
+
<span class="radio">
|
|
30
|
+
<input type="radio" name="thumbnail_id" id="thumbnail_id_m326m2125" value="m326m2125" class="radio_buttons" checked="checked">
|
|
31
|
+
<label for="thumbnail_id_m326m2125">Thumbnail</label>
|
|
32
|
+
</span>
|
|
33
|
+
</div>
|
|
34
|
+
|
|
35
|
+
</div>
|
|
36
|
+
</li>
|
|
37
|
+
|
|
38
|
+
<li data-reorder-id="pr76f369j">
|
|
39
|
+
<div class="panel panel-default">
|
|
40
|
+
<form data-type="json" novalidate="novalidate" class="simple_form edit_file_set" id="edit_file_set_pr76f369j" action="/concern/file_sets/pr76f369j" accept-charset="UTF-8" data-remote="true" method="post"><input name="utf8" type="hidden" value="✓"><input type="hidden" name="_method" value="patch">
|
|
41
|
+
<div class="panel-heading ui-sortable-handle">
|
|
42
|
+
<div class="order-title">
|
|
43
|
+
<div class="form-group string required file_set_title"><input class="form-control string required title" name="file_set[title][]" type="text" value="zeldogbeach2.jpg" id="file_set_title"></div>
|
|
44
|
+
</div>
|
|
45
|
+
<div class="file-set-link pull-right">
|
|
46
|
+
<a title="Edit file" href="/concern/parent/st74cq794/file_sets/pr76f369j">
|
|
47
|
+
<span class="glyphicon glyphicon-edit" aria-hidden="true"></span>
|
|
48
|
+
</a> </div>
|
|
49
|
+
<div class="order-filename">
|
|
50
|
+
<em title="zeldogbeach2.jpg">(zeldogbeach2.jpg)</em>
|
|
51
|
+
</div>
|
|
52
|
+
</div>
|
|
53
|
+
<div class="panel-body">
|
|
54
|
+
<div class="text-center thumbnail">
|
|
55
|
+
<a data-context-href="/catalog/pr76f369j/track" href="/concern/file_sets/pr76f369j"><img class="thumbnail-inner" src="/downloads/pr76f369j?file=thumbnail" alt="Pr76f369j?file=thumbnail"></a>
|
|
56
|
+
|
|
57
|
+
</div>
|
|
58
|
+
<div class="attributes">
|
|
59
|
+
|
|
60
|
+
</div>
|
|
61
|
+
<div class="spacer">
|
|
62
|
+
</div>
|
|
63
|
+
</div>
|
|
64
|
+
</form> <div class="form-group radio_buttons member_resource_options">
|
|
65
|
+
<span class="radio">
|
|
66
|
+
<input type="radio" name="thumbnail_id" id="thumbnail_id_pr76f369j" value="pr76f369j" class="radio_buttons">
|
|
67
|
+
<label for="thumbnail_id_pr76f369j">Thumbnail</label>
|
|
68
|
+
</span>
|
|
69
|
+
</div>
|
|
70
|
+
|
|
71
|
+
</div>
|
|
72
|
+
</li>
|
|
73
|
+
|
|
74
|
+
<li data-reorder-id="3484zh205">
|
|
75
|
+
<div class="panel panel-default">
|
|
76
|
+
<form data-type="json" novalidate="novalidate" class="simple_form edit_file_set" id="edit_file_set_3484zh205" action="/concern/file_sets/3484zh205" accept-charset="UTF-8" data-remote="true" method="post"><input name="utf8" type="hidden" value="✓"><input type="hidden" name="_method" value="patch">
|
|
77
|
+
<div class="panel-heading ui-sortable-handle">
|
|
78
|
+
<div class="order-title">
|
|
79
|
+
<div class="form-group string required file_set_title"><input class="form-control string required title" name="file_set[title][]" type="text" value="CIMG1816 copy.JPG" id="file_set_title"></div>
|
|
80
|
+
</div>
|
|
81
|
+
<div class="file-set-link pull-right">
|
|
82
|
+
<a title="Edit file" href="/concern/parent/st74cq794/file_sets/3484zh205">
|
|
83
|
+
<span class="glyphicon glyphicon-edit" aria-hidden="true"></span>
|
|
84
|
+
</a> </div>
|
|
85
|
+
<div class="order-filename">
|
|
86
|
+
<em title="CIMG1816 copy.JPG">(CIMG1816 copy.JPG)</em>
|
|
87
|
+
</div>
|
|
88
|
+
</div>
|
|
89
|
+
<div class="panel-body">
|
|
90
|
+
<div class="text-center thumbnail">
|
|
91
|
+
<a data-context-href="/catalog/3484zh205/track" href="/concern/file_sets/3484zh205"><img class="thumbnail-inner" src="/downloads/3484zh205?file=thumbnail" alt="3484zh205?file=thumbnail"></a>
|
|
92
|
+
|
|
93
|
+
</div>
|
|
94
|
+
<div class="attributes">
|
|
95
|
+
|
|
96
|
+
</div>
|
|
97
|
+
<div class="spacer">
|
|
98
|
+
</div>
|
|
99
|
+
</div>
|
|
100
|
+
</form> <div class="form-group radio_buttons member_resource_options">
|
|
101
|
+
<span class="radio">
|
|
102
|
+
<input type="radio" name="thumbnail_id" id="thumbnail_id_3484zh205" value="3484zh205" class="radio_buttons">
|
|
103
|
+
<label for="thumbnail_id_3484zh205">Thumbnail</label>
|
|
104
|
+
</span>
|
|
105
|
+
</div>
|
|
106
|
+
|
|
107
|
+
</div>
|
|
108
|
+
</li>
|
|
109
|
+
|
|
110
|
+
<li data-reorder-id="sb397864f">
|
|
111
|
+
<div class="panel panel-default">
|
|
112
|
+
<form data-type="json" novalidate="novalidate" class="simple_form edit_generic_work" id="edit_generic_work_sb397864f" action="/concern/generic_works/sb397864f" accept-charset="UTF-8" data-remote="true" method="post"><input name="utf8" type="hidden" value="✓"><input type="hidden" name="_method" value="patch">
|
|
113
|
+
<div class="panel-heading ui-sortable-handle">
|
|
114
|
+
<div class="order-title">
|
|
115
|
+
<div class="form-group string required generic_work_title"><input class="form-control string required title" name="generic_work[title][]" type="text" value="child1" id="generic_work_title"></div>
|
|
116
|
+
</div>
|
|
117
|
+
<div class="file-set-link pull-right">
|
|
118
|
+
<a title="Edit file" href="/concern/parent/st74cq794/generic_works/sb397864f">
|
|
119
|
+
<span class="glyphicon glyphicon-edit" aria-hidden="true"></span>
|
|
120
|
+
</a> </div>
|
|
121
|
+
<div class="order-filename">
|
|
122
|
+
<em title="child1">(child1)</em>
|
|
123
|
+
</div>
|
|
124
|
+
</div>
|
|
125
|
+
<div class="panel-body">
|
|
126
|
+
<div class="text-center thumbnail">
|
|
127
|
+
<a data-context-href="/catalog/sb397864f/track" href="/concern/generic_works/sb397864f"><img class="thumbnail-inner" src="/assets/default-c6018ff301250c55bcc663293e1816c7daece4159cbc93fc03d9b35dbc3db30d.png" alt="Default"></a>
|
|
128
|
+
|
|
129
|
+
</div>
|
|
130
|
+
<div class="attributes">
|
|
131
|
+
|
|
132
|
+
</div>
|
|
133
|
+
<div class="spacer">
|
|
134
|
+
</div>
|
|
135
|
+
</div>
|
|
136
|
+
</form> <div class="form-group radio_buttons member_resource_options">
|
|
137
|
+
<span class="radio">
|
|
138
|
+
<input type="radio" name="thumbnail_id" id="thumbnail_id_sb397864f" value="sb397864f" class="radio_buttons">
|
|
139
|
+
<label for="thumbnail_id_sb397864f">Thumbnail</label>
|
|
140
|
+
</span>
|
|
141
|
+
</div>
|
|
142
|
+
|
|
143
|
+
</div>
|
|
144
|
+
</li>
|
|
145
|
+
|
|
146
|
+
<li data-reorder-id="bc386j55f">
|
|
147
|
+
<div class="panel panel-default">
|
|
148
|
+
<form data-type="json" novalidate="novalidate" class="simple_form edit_generic_work" id="edit_generic_work_bc386j55f" action="/concern/generic_works/bc386j55f" accept-charset="UTF-8" data-remote="true" method="post"><input name="utf8" type="hidden" value="✓"><input type="hidden" name="_method" value="patch">
|
|
149
|
+
<div class="panel-heading ui-sortable-handle">
|
|
150
|
+
<div class="order-title">
|
|
151
|
+
<div class="form-group string required generic_work_title"><input class="form-control string required title" name="generic_work[title][]" type="text" value="child2" id="generic_work_title"></div>
|
|
152
|
+
</div>
|
|
153
|
+
<div class="file-set-link pull-right">
|
|
154
|
+
<a title="Edit file" href="/concern/parent/st74cq794/generic_works/bc386j55f">
|
|
155
|
+
<span class="glyphicon glyphicon-edit" aria-hidden="true"></span>
|
|
156
|
+
</a> </div>
|
|
157
|
+
<div class="order-filename">
|
|
158
|
+
<em title="child2">(child2)</em>
|
|
159
|
+
</div>
|
|
160
|
+
</div>
|
|
161
|
+
<div class="panel-body">
|
|
162
|
+
<div class="text-center thumbnail">
|
|
163
|
+
<a data-context-href="/catalog/bc386j55f/track" href="/concern/generic_works/bc386j55f"><img class="thumbnail-inner" src="/assets/default-c6018ff301250c55bcc663293e1816c7daece4159cbc93fc03d9b35dbc3db30d.png" alt="Default"></a>
|
|
164
|
+
|
|
165
|
+
</div>
|
|
166
|
+
<div class="attributes">
|
|
167
|
+
|
|
168
|
+
</div>
|
|
169
|
+
<div class="spacer">
|
|
170
|
+
</div>
|
|
171
|
+
</div>
|
|
172
|
+
</form> <div class="form-group radio_buttons member_resource_options">
|
|
173
|
+
<span class="radio">
|
|
174
|
+
<input type="radio" name="thumbnail_id" id="thumbnail_id_bc386j55f" value="bc386j55f" class="radio_buttons">
|
|
175
|
+
<label for="thumbnail_id_bc386j55f">Thumbnail</label>
|
|
176
|
+
</span>
|
|
177
|
+
</div>
|
|
178
|
+
|
|
179
|
+
</div>
|
|
180
|
+
</li>
|
|
181
|
+
|
|
182
|
+
</ul>
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
describe "FileManager Save Button", ->
|
|
2
|
+
savem = require('curation_concerns/file_manager/save_manager')
|
|
2
3
|
save_manager = null
|
|
3
4
|
handler = null
|
|
4
5
|
deferred_result = null
|
|
5
6
|
beforeEach () ->
|
|
6
7
|
loadFixtures('save_button.html')
|
|
7
|
-
save_manager = new
|
|
8
|
+
save_manager = new savem
|
|
8
9
|
deferred_result = $.Deferred()
|
|
9
10
|
handler = {
|
|
10
11
|
persist: () =>
|
|
@@ -25,7 +25,7 @@ describe CharacterizeJob do
|
|
|
25
25
|
expect(Hydra::Works::CharacterizationService).to receive(:run).with(file, filename)
|
|
26
26
|
expect(file).to receive(:save!)
|
|
27
27
|
expect(file_set).to receive(:update_index)
|
|
28
|
-
expect(CreateDerivativesJob).to receive(:perform_later).with(file_set, file.id)
|
|
28
|
+
expect(CreateDerivativesJob).to receive(:perform_later).with(file_set, file.id, filename)
|
|
29
29
|
described_class.perform_now(file_set, file.id)
|
|
30
30
|
end
|
|
31
31
|
end
|
|
@@ -36,4 +36,21 @@ describe CharacterizeJob do
|
|
|
36
36
|
expect { described_class.perform_now(file_set, file.id) }.to raise_error(LoadError, 'original_file was not found')
|
|
37
37
|
end
|
|
38
38
|
end
|
|
39
|
+
|
|
40
|
+
context "when the file set's work is in a collection" do
|
|
41
|
+
let(:work) { build(:generic_work) }
|
|
42
|
+
let(:collection) { build(:collection) }
|
|
43
|
+
before do
|
|
44
|
+
allow(file_set).to receive(:parent).and_return(work)
|
|
45
|
+
allow(work).to receive(:in_collections).and_return([collection])
|
|
46
|
+
allow(Hydra::Works::CharacterizationService).to receive(:run).with(file, filename)
|
|
47
|
+
allow(file).to receive(:save!)
|
|
48
|
+
allow(file_set).to receive(:update_index)
|
|
49
|
+
allow(CreateDerivativesJob).to receive(:perform_later).with(file_set, file.id, filename)
|
|
50
|
+
end
|
|
51
|
+
it "reindexes the collection" do
|
|
52
|
+
expect(collection).to receive(:update_index)
|
|
53
|
+
described_class.perform_now(file_set, file.id)
|
|
54
|
+
end
|
|
55
|
+
end
|
|
39
56
|
end
|
|
@@ -20,28 +20,33 @@ describe IngestFileJob do
|
|
|
20
20
|
Object.send(:remove_const, :FileSetWithExtras)
|
|
21
21
|
end
|
|
22
22
|
it 'uses the provided relationship' do
|
|
23
|
-
expect(CharacterizeJob).to receive(:perform_later).with(file_set, String)
|
|
24
|
-
described_class.perform_now(file_set, filename, 'image/png',
|
|
23
|
+
expect(CharacterizeJob).to receive(:perform_later).with(file_set, String, filename)
|
|
24
|
+
described_class.perform_now(file_set, filename, user, mime_type: 'image/png', relation: 'remastered')
|
|
25
25
|
expect(file_set.reload.remastered.mime_type).to eq 'image/png'
|
|
26
26
|
end
|
|
27
27
|
end
|
|
28
28
|
|
|
29
29
|
context 'when given a mime_type' do
|
|
30
30
|
it 'uses the provided mime_type' do
|
|
31
|
-
expect(CharacterizeJob).to receive(:perform_later).with(file_set, String)
|
|
32
|
-
described_class.perform_now(file_set, filename, 'image/png'
|
|
31
|
+
expect(CharacterizeJob).to receive(:perform_later).with(file_set, String, filename)
|
|
32
|
+
described_class.perform_now(file_set, filename, user, mime_type: 'image/png')
|
|
33
33
|
expect(file_set.reload.original_file.mime_type).to eq 'image/png'
|
|
34
34
|
end
|
|
35
35
|
end
|
|
36
36
|
|
|
37
37
|
context 'when not given a mime_type' do
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
# The parameter versioning: false instructs the machinery in Hydra::Works NOT to do versioning
|
|
41
|
-
|
|
42
|
-
expect(Hydra::Works::AddFileToFileSet).to receive(:call).with(
|
|
43
|
-
|
|
44
|
-
|
|
38
|
+
before { allow(CurationConcerns::VersioningService).to receive(:create) }
|
|
39
|
+
it 'passes a decorated instance of the file with a nil mime_type' do
|
|
40
|
+
# The parameter versioning: false instructs the machinery in Hydra::Works NOT to do versioning
|
|
41
|
+
# so it can be handled later on.
|
|
42
|
+
expect(Hydra::Works::AddFileToFileSet).to receive(:call).with(
|
|
43
|
+
file_set,
|
|
44
|
+
instance_of(Hydra::Derivatives::IoDecorator),
|
|
45
|
+
:original_file,
|
|
46
|
+
versioning: false
|
|
47
|
+
).and_call_original
|
|
48
|
+
expect(CharacterizeJob).to receive(:perform_later).with(file_set, String, filename)
|
|
49
|
+
described_class.perform_now(file_set, filename, user)
|
|
45
50
|
end
|
|
46
51
|
end
|
|
47
52
|
|
|
@@ -53,8 +58,8 @@ describe IngestFileJob do
|
|
|
53
58
|
|
|
54
59
|
before do
|
|
55
60
|
allow(Hydra::Works::CharacterizationService).to receive(:run).with(any_args)
|
|
56
|
-
described_class.perform_now(file_set, file1, 'image/png'
|
|
57
|
-
described_class.perform_now(file_set, file2, 'text/plain'
|
|
61
|
+
described_class.perform_now(file_set, file1, user.user_key, mime_type: 'image/png')
|
|
62
|
+
described_class.perform_now(file_set, file2, user2.user_key, mime_type: 'text/plain')
|
|
58
63
|
end
|
|
59
64
|
|
|
60
65
|
it 'has two versions' do
|
|
@@ -12,12 +12,14 @@ RSpec.describe AdminSet, type: :model do
|
|
|
12
12
|
end
|
|
13
13
|
|
|
14
14
|
describe "#to_solr" do
|
|
15
|
-
let(:admin_set) { build(:admin_set, title: ['A good title']
|
|
15
|
+
let(:admin_set) { build(:admin_set, title: ['A good title'],
|
|
16
|
+
creator: ['jcoyne@justincoyne.com']) }
|
|
16
17
|
let(:solr_document) { admin_set.to_solr }
|
|
17
18
|
|
|
18
|
-
it "has title information" do
|
|
19
|
+
it "has title and creator information" do
|
|
19
20
|
expect(solr_document).to include 'title_tesim' => ['A good title'],
|
|
20
|
-
'title_sim' => ['A good title']
|
|
21
|
+
'title_sim' => ['A good title'],
|
|
22
|
+
'creator_ssim' => ['jcoyne@justincoyne.com']
|
|
21
23
|
end
|
|
22
24
|
end
|
|
23
25
|
|
|
@@ -27,10 +27,8 @@ describe FileSet do
|
|
|
27
27
|
end
|
|
28
28
|
|
|
29
29
|
context 'when it is initialized' do
|
|
30
|
-
it 'has empty arrays for
|
|
31
|
-
subject.
|
|
32
|
-
expect(Array.wrap(v)).to eq([])
|
|
33
|
-
end
|
|
30
|
+
it 'has empty arrays for the properties' do
|
|
31
|
+
expect(subject.title).to eq []
|
|
34
32
|
end
|
|
35
33
|
end
|
|
36
34
|
|
|
@@ -17,15 +17,29 @@ describe SolrDocument do
|
|
|
17
17
|
end
|
|
18
18
|
|
|
19
19
|
describe "thumbnail_id" do
|
|
20
|
-
let(:attributes) { { Solrizer.solr_name('
|
|
20
|
+
let(:attributes) { { Solrizer.solr_name('hasRelatedImage', :symbol) => ['one'] } }
|
|
21
21
|
subject { document.thumbnail_id }
|
|
22
22
|
it { is_expected.to eq 'one' }
|
|
23
23
|
end
|
|
24
24
|
|
|
25
25
|
describe "creator" do
|
|
26
|
-
let(:attributes) { { Solrizer.solr_name('creator') => ['one', 'two'] } }
|
|
27
26
|
subject { document.creator }
|
|
28
|
-
|
|
27
|
+
|
|
28
|
+
context "for a work" do
|
|
29
|
+
let(:attributes) do
|
|
30
|
+
{ Solrizer.solr_name('creator') => ['one', 'two'],
|
|
31
|
+
Solrizer.solr_name('has_model', :symbol) => ["GenericWork"] }
|
|
32
|
+
end
|
|
33
|
+
it { is_expected.to eq ['one', 'two'] }
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
context "for an admin set" do
|
|
37
|
+
let(:attributes) do
|
|
38
|
+
{ Solrizer.solr_name('creator', :symbol) => ['foo@example.com'],
|
|
39
|
+
Solrizer.solr_name('has_model', :symbol) => ["AdminSet"] }
|
|
40
|
+
end
|
|
41
|
+
it { is_expected.to eq ['foo@example.com'] }
|
|
42
|
+
end
|
|
29
43
|
end
|
|
30
44
|
|
|
31
45
|
describe "contributor" do
|
|
@@ -17,6 +17,11 @@ describe CurationConcerns::CollectionPresenter do
|
|
|
17
17
|
# Mock bytes so collection does not have to be saved.
|
|
18
18
|
before { allow(collection).to receive(:bytes).and_return(0) }
|
|
19
19
|
|
|
20
|
+
describe '#to_s' do
|
|
21
|
+
subject { presenter.to_s }
|
|
22
|
+
it { is_expected.to eq 'A clever title' }
|
|
23
|
+
end
|
|
24
|
+
|
|
20
25
|
describe '#title' do
|
|
21
26
|
subject { presenter.title }
|
|
22
27
|
it { is_expected.to eq ['A clever title'] }
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe CurationConcerns::Renderers::ExternalLinkAttributeRenderer do
|
|
4
|
+
let(:field) { :name }
|
|
5
|
+
let(:renderer) { described_class.new(field, ['http://example.com']) }
|
|
6
|
+
|
|
7
|
+
describe "#attribute_to_html" do
|
|
8
|
+
subject { Nokogiri::HTML(renderer.render) }
|
|
9
|
+
let(:expected) { Nokogiri::HTML(tr_content) }
|
|
10
|
+
|
|
11
|
+
let(:tr_content) {
|
|
12
|
+
"<tr><th>Name</th>\n" \
|
|
13
|
+
"<td><ul class='tabular'>" \
|
|
14
|
+
"<li class=\"attribute name\">"\
|
|
15
|
+
"<a href=\"http://example.com\">"\
|
|
16
|
+
"<span class='glyphicon glyphicon-new-window'></span> "\
|
|
17
|
+
"http://example.com</a></li>\n" \
|
|
18
|
+
"</ul></td></tr>"
|
|
19
|
+
}
|
|
20
|
+
it { expect(subject).to be_equivalent_to(expected) }
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
|
|
3
3
|
describe CurationConcerns::AdminSetSearchBuilder do
|
|
4
|
-
let(:processor_chain) { [:filter_models] }
|
|
5
4
|
let(:context) { double('context') }
|
|
6
|
-
let(:user) { double('user') }
|
|
7
5
|
let(:solr_params) { { fq: [] } }
|
|
8
6
|
|
|
9
|
-
|
|
7
|
+
let(:builder) { described_class.new(context, :read) }
|
|
10
8
|
describe '#filter_models' do
|
|
11
|
-
before {
|
|
9
|
+
before { builder.filter_models(solr_params) }
|
|
12
10
|
|
|
13
11
|
it 'adds AdminSet to query' do
|
|
14
|
-
expect(solr_params[:fq].first).to include('{!
|
|
12
|
+
expect(solr_params[:fq].first).to include('{!terms f=has_model_ssim}AdminSet')
|
|
15
13
|
end
|
|
16
14
|
end
|
|
15
|
+
|
|
16
|
+
describe ".default_processor_chain" do
|
|
17
|
+
subject { described_class.default_processor_chain }
|
|
18
|
+
it { is_expected.to include :filter_models }
|
|
19
|
+
end
|
|
17
20
|
end
|
|
@@ -12,7 +12,7 @@ describe CurationConcerns::FileSetSearchBuilder do
|
|
|
12
12
|
before { subject.filter_models(solr_params) }
|
|
13
13
|
|
|
14
14
|
it 'adds FileSet to query' do
|
|
15
|
-
expect(solr_params[:fq].first).to include('{!
|
|
15
|
+
expect(solr_params[:fq].first).to include('{!terms f=has_model_ssim}FileSet')
|
|
16
16
|
end
|
|
17
17
|
end
|
|
18
18
|
|
|
@@ -23,7 +23,7 @@ describe CurationConcerns::FileSetSearchBuilder do
|
|
|
23
23
|
end
|
|
24
24
|
|
|
25
25
|
it 'adds id to query' do
|
|
26
|
-
expect(solr_params[:fq].first).to include('{!
|
|
26
|
+
expect(solr_params[:fq].first).to include('{!raw f=id}12345')
|
|
27
27
|
end
|
|
28
28
|
end
|
|
29
29
|
end
|
|
@@ -1,37 +1,68 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
|
|
3
3
|
RSpec.describe CurationConcerns::AdminSetService do
|
|
4
|
-
|
|
5
|
-
let(:controller) { ::CatalogController.new }
|
|
4
|
+
let(:controller) { ::CatalogController.new }
|
|
6
5
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
let(:service) { described_class.new(context) }
|
|
13
|
-
let(:user) { create(:user) }
|
|
14
|
-
let!(:as1) { create(:admin_set, :public, title: ['foo']) }
|
|
15
|
-
let!(:as2) { create(:admin_set, :public, title: ['bar']) }
|
|
16
|
-
let!(:as3) { create(:admin_set, edit_users: [user.user_key], title: ['baz']) }
|
|
6
|
+
let(:context) do
|
|
7
|
+
double(current_ability: Ability.new(user),
|
|
8
|
+
repository: controller.repository,
|
|
9
|
+
blacklight_config: controller.blacklight_config)
|
|
10
|
+
end
|
|
17
11
|
|
|
12
|
+
let(:service) { described_class.new(context) }
|
|
13
|
+
let(:user) { create(:user) }
|
|
14
|
+
|
|
15
|
+
describe "#select_options" do
|
|
18
16
|
context "with default (read) access" do
|
|
19
17
|
subject { service.select_options }
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
18
|
+
let(:solr_doc1) { instance_double(SolrDocument, id: '123', to_s: 'foo') }
|
|
19
|
+
let(:solr_doc2) { instance_double(SolrDocument, id: '234', to_s: 'bar') }
|
|
20
|
+
let(:solr_doc3) { instance_double(SolrDocument, id: '345', to_s: 'baz') }
|
|
21
|
+
|
|
22
|
+
before do
|
|
23
|
+
allow(service).to receive(:search_results)
|
|
24
|
+
.with(:read)
|
|
25
|
+
.and_return([solr_doc1, solr_doc2, solr_doc3])
|
|
26
|
+
end
|
|
24
27
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
['bar', as2.id],
|
|
29
|
-
['baz', as3.id]] }
|
|
28
|
+
it { is_expected.to eq [['foo', '123'],
|
|
29
|
+
['bar', '234'],
|
|
30
|
+
['baz', '345']] }
|
|
30
31
|
end
|
|
31
32
|
|
|
32
33
|
context "with explicit edit access" do
|
|
33
34
|
subject { service.select_options(:edit) }
|
|
34
|
-
|
|
35
|
+
let(:solr_doc) { instance_double(SolrDocument, id: '123', to_s: 'baz') }
|
|
36
|
+
|
|
37
|
+
before do
|
|
38
|
+
allow(service).to receive(:search_results).with(:edit).and_return([solr_doc])
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
it { is_expected.to eq [['baz', '123']] }
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
describe "#search_results" do
|
|
46
|
+
subject { service.search_results(access) }
|
|
47
|
+
let!(:as1) { create(:admin_set, :public, title: ['foo']) }
|
|
48
|
+
let!(:as2) { create(:admin_set, :public, title: ['bar']) }
|
|
49
|
+
let!(:as3) { create(:admin_set, edit_users: [user.user_key], title: ['baz']) }
|
|
50
|
+
before do
|
|
51
|
+
create(:collection, :public) # this should never be returned.
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
context "with read access" do
|
|
55
|
+
let(:access) { :read }
|
|
56
|
+
it "returns three admin sets" do
|
|
57
|
+
expect(subject.map(&:id)).to match_array [as1.id, as2.id, as3.id]
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
context "with edit access" do
|
|
62
|
+
let(:access) { :edit }
|
|
63
|
+
it "returns one admin set" do
|
|
64
|
+
expect(subject.map(&:id)).to match_array [as3.id]
|
|
65
|
+
end
|
|
35
66
|
end
|
|
36
67
|
end
|
|
37
68
|
end
|
data/spec/spec_helper.rb
CHANGED
|
@@ -34,8 +34,7 @@ if ENV['COVERAGE'] || $in_travis
|
|
|
34
34
|
SimpleCov.formatters = $in_travis ? Coveralls::SimpleCov::Formatter : SimpleCov::Formatter::HTMLFormatter
|
|
35
35
|
SimpleCov.start('rails') do
|
|
36
36
|
add_filter '/spec'
|
|
37
|
-
add_filter '/lib/generators/curation_concerns
|
|
38
|
-
add_filter '/lib/generators/curation_concerns/install_generator.rb'
|
|
37
|
+
add_filter '/lib/generators/curation_concerns'
|
|
39
38
|
add_filter '/.internal_test_app'
|
|
40
39
|
end
|
|
41
40
|
SimpleCov.command_name('spec')
|
|
@@ -6,10 +6,16 @@ describe 'curation_concerns/base/_attributes.html.erb' do
|
|
|
6
6
|
let(:subject) { 'history' }
|
|
7
7
|
let(:description) { ['Lorem ipsum < lorem ipsum. http://my.link.com'] }
|
|
8
8
|
|
|
9
|
-
let(:solr_document) { SolrDocument.new(
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
let(:solr_document) { SolrDocument.new(attributes) }
|
|
10
|
+
let(:attributes) do
|
|
11
|
+
{
|
|
12
|
+
Solrizer.solr_name('has_model', :symbol) => ["GenericWork"],
|
|
13
|
+
subject_tesim: subject,
|
|
14
|
+
contributor_tesim: contributor,
|
|
15
|
+
creator_tesim: creator,
|
|
16
|
+
description_tesim: description
|
|
17
|
+
}
|
|
18
|
+
end
|
|
13
19
|
let(:ability) { nil }
|
|
14
20
|
let(:presenter) do
|
|
15
21
|
CurationConcerns::WorkShowPresenter.new(solr_document, ability)
|