hyrax 2.1.0 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/ISSUE_TEMPLATE.md +1 -1
- data/.github/PULL_REQUEST_TEMPLATE.md +5 -0
- data/.rubocop.yml +8 -1
- data/README.md +3 -11
- data/app/actors/hyrax/actors/file_set_actor.rb +6 -1
- data/app/assets/javascripts/hyrax.js +1 -1
- data/app/assets/javascripts/hyrax/editor.es6 +8 -0
- data/app/assets/javascripts/hyrax/save_work/save_work_control.es6 +20 -1
- data/app/assets/javascripts/hyrax/save_work/uploaded_files.es6 +1 -0
- data/app/assets/stylesheets/hyrax/_breadcrumbs.scss +25 -0
- data/app/assets/stylesheets/hyrax/_collections.scss +6 -0
- data/app/assets/stylesheets/hyrax/_file-listing.scss +5 -0
- data/app/assets/stylesheets/hyrax/_file_upload.scss +14 -0
- data/app/assets/stylesheets/hyrax/_form-progress.scss +6 -0
- data/app/assets/stylesheets/hyrax/_hyrax.scss +1 -1
- data/app/assets/stylesheets/hyrax/_styles.scss +6 -0
- data/app/assets/stylesheets/hyrax/dashboard.scss +4 -5
- data/app/builders/hyrax/bootstrap_breadcrumbs_builder.rb +10 -4
- data/app/controllers/concerns/hyrax/admin/stats_behavior.rb +25 -1
- data/app/controllers/concerns/hyrax/breadcrumbs_for_collections.rb +6 -2
- data/app/controllers/concerns/hyrax/controller.rb +1 -1
- data/app/controllers/concerns/hyrax/deny_access_override_behavior.rb +1 -1
- data/app/controllers/concerns/hyrax/works_controller_behavior.rb +1 -1
- data/app/controllers/hyrax/admin/admin_sets_controller.rb +1 -1
- data/app/controllers/hyrax/dashboard/collections_controller.rb +2 -2
- data/app/controllers/hyrax/downloads_controller.rb +1 -1
- data/app/controllers/hyrax/featured_works_controller.rb +1 -5
- data/app/controllers/hyrax/homepage_controller.rb +1 -1
- data/app/controllers/hyrax/single_use_links_controller.rb +1 -1
- data/app/controllers/hyrax/transfers_controller.rb +1 -1
- data/app/controllers/hyrax/users_controller.rb +1 -0
- data/app/helpers/hyrax/citations_behaviors/publication_behavior.rb +2 -2
- data/app/helpers/hyrax/collections_helper.rb +1 -1
- data/app/helpers/hyrax/hyrax_helper_behavior.rb +2 -2
- data/app/jobs/characterize_job.rb +1 -1
- data/app/jobs/fixity_check_job.rb +1 -1
- data/app/jobs/import_url_job.rb +12 -1
- data/app/models/checksum_audit_log.rb +1 -1
- data/app/models/concerns/hyrax/ability.rb +1 -1
- data/app/models/hyrax/collection_type.rb +1 -1
- data/app/models/hyrax/operation.rb +4 -6
- data/app/models/hyrax/permission_template_access.rb +5 -5
- data/app/models/sipity/entity.rb +1 -1
- data/app/presenters/hyrax/admin_set_presenter.rb +9 -2
- data/app/presenters/hyrax/admin_stats_presenter.rb +52 -6
- data/app/presenters/hyrax/inspect_work_presenter.rb +1 -1
- data/app/presenters/hyrax/workflow_presenter.rb +1 -1
- data/app/search_builders/hyrax/dashboard/nested_collections_search_builder.rb +3 -5
- data/app/search_builders/hyrax/filter_suppressed_with_roles.rb +5 -1
- data/app/search_builders/hyrax/my/works_search_builder.rb +2 -1
- data/app/services/hyrax/collection_size_service.rb +12 -0
- data/app/services/hyrax/collections/nested_collection_query_service.rb +2 -2
- data/app/services/hyrax/graph_exporter.rb +6 -1
- data/app/services/hyrax/license_service.rb +1 -9
- data/app/services/hyrax/qa_select_service.rb +28 -0
- data/app/services/hyrax/rights_statement_service.rb +1 -1
- data/app/services/hyrax/tolerant_select_service.rb +23 -0
- data/app/services/hyrax/workflow/permission_query.rb +1 -1
- data/app/services/hyrax/workflow/sipity_actions_generator.rb +1 -1
- data/app/strategies/hyrax/strategies/yaml_strategy.rb +1 -1
- data/app/views/_logo.html.erb +1 -1
- data/app/views/catalog/_search_form.html.erb +1 -1
- data/app/views/hyrax/admin/collection_types/index.html.erb +1 -1
- data/app/views/hyrax/admin/workflow_roles/index.html.erb +4 -2
- data/app/views/hyrax/admin/workflows/index.html.erb +1 -1
- data/app/views/hyrax/base/_form_files.html.erb +7 -7
- data/app/views/hyrax/base/_form_progress.html.erb +10 -5
- data/app/views/hyrax/base/_share_with.html.erb +3 -11
- data/app/views/hyrax/base/_show_actions.html.erb +1 -3
- data/app/views/hyrax/batch_edits/_check_all.html.erb +15 -7
- data/app/views/hyrax/collections/_list_collections.html.erb +1 -1
- data/app/views/hyrax/dashboard/_index_partials/_transfers.html.erb +1 -1
- data/app/views/hyrax/dashboard/collections/_default_group.html.erb +7 -2
- data/app/views/hyrax/dashboard/collections/_edit_actions.html.erb +1 -2
- data/app/views/hyrax/dashboard/collections/_form.html.erb +1 -1
- data/app/views/hyrax/dashboard/collections/_form_branding.html.erb +6 -6
- data/app/views/hyrax/dashboard/collections/_list_collections.html.erb +1 -1
- data/app/views/hyrax/dashboard/collections/_show_actions.html.erb +1 -2
- data/app/views/hyrax/dashboard/collections/_show_add_items_actions.html.erb +1 -2
- data/app/views/hyrax/dashboard/sidebar/_repository_content.html.erb +1 -2
- data/app/views/hyrax/dashboard/works/_default_group.html.erb +1 -1
- data/app/views/hyrax/file_sets/_actions.html.erb +1 -1
- data/app/views/hyrax/file_sets/_form.html.erb +3 -3
- data/app/views/hyrax/file_sets/_permission.html.erb +2 -2
- data/app/views/hyrax/file_sets/_permission_form.html.erb +10 -10
- data/app/views/hyrax/file_sets/_show_actions.html.erb +1 -4
- data/app/views/hyrax/file_sets/_single_use_links.html.erb +5 -0
- data/app/views/hyrax/file_sets/_versioning.html.erb +9 -7
- data/app/views/hyrax/file_sets/edit.html.erb +6 -6
- data/app/views/hyrax/file_sets/media_display/_audio.html.erb +1 -1
- data/app/views/hyrax/file_sets/media_display/_image.html.erb +1 -1
- data/app/views/hyrax/file_sets/media_display/_office_document.html.erb +0 -1
- data/app/views/hyrax/file_sets/media_display/_pdf.html.erb +0 -1
- data/app/views/hyrax/file_sets/media_display/_video.html.erb +1 -1
- data/app/views/hyrax/my/collections/_default_group.html.erb +8 -3
- data/app/views/hyrax/my/collections/_list_collections.html.erb +1 -1
- data/app/views/hyrax/my/works/_batch_actions.html.erb +1 -1
- data/app/views/hyrax/my/works/_tabs.html.erb +3 -3
- data/app/views/hyrax/single_use_links_viewer/show.html.erb +1 -1
- data/app/views/hyrax/uploads/_js_templates.html.erb +11 -11
- data/app/views/hyrax/uploads/_js_templates_branding.html.erb +2 -2
- data/app/views/layouts/_head_tag_content.html.erb +1 -1
- data/app/views/layouts/hyrax.html.erb +1 -1
- data/app/views/layouts/hyrax/dashboard.html.erb +1 -1
- data/app/views/records/edit_fields/_license.html.erb +1 -1
- data/app/views/records/edit_fields/_rights_statement.html.erb +2 -1
- data/config/features.rb +4 -0
- data/config/locales/hyrax.de.yml +1 -0
- data/config/locales/hyrax.en.yml +39 -1
- data/config/locales/hyrax.es.yml +1 -0
- data/config/locales/hyrax.fr.yml +1 -0
- data/config/locales/hyrax.it.yml +1 -0
- data/config/locales/hyrax.pt-BR.yml +1 -0
- data/config/locales/hyrax.zh.yml +1 -0
- data/hyrax.gemspec +5 -2
- data/lib/generators/hyrax/templates/mediated_deposit_workflow.json.erb +1 -0
- data/lib/hyrax.rb +7 -1
- data/lib/hyrax/arkivo/create_subscription_job.rb +1 -1
- data/lib/hyrax/redis_event_store.rb +1 -1
- data/lib/hyrax/resource_sync/change_list_writer.rb +2 -2
- data/lib/hyrax/version.rb +1 -1
- data/spec/actors/hyrax/actors/file_set_actor_spec.rb +1 -1
- data/spec/controllers/hyrax/admin/stats_controller_spec.rb +31 -1
- data/spec/controllers/hyrax/collections_controller_spec.rb +2 -2
- data/spec/controllers/hyrax/dashboard/collections_controller_spec.rb +2 -2
- data/spec/controllers/hyrax/generic_works_controller_spec.rb +19 -3
- data/spec/controllers/hyrax/homepage_controller_spec.rb +1 -1
- data/spec/controllers/hyrax/users_controller_spec.rb +58 -0
- data/spec/features/batch_create_spec.rb +1 -1
- data/spec/features/create_work_spec.rb +22 -2
- data/spec/features/dashboard/collection_spec.rb +3 -3
- data/spec/features/homepage_spec.rb +20 -4
- data/spec/javascripts/save_work_spec.js +50 -0
- data/spec/jobs/import_url_job_spec.rb +10 -8
- data/spec/lib/hyrax_spec.rb +9 -0
- data/spec/models/flipflop_spec.rb +8 -0
- data/spec/models/solr_document_spec.rb +2 -2
- data/spec/presenters/hyrax/admin_stats_presenter_spec.rb +73 -0
- data/spec/search_builders/hyrax/my/works_search_builder_spec.rb +0 -2
- data/spec/services/hyrax/graph_exporter_spec.rb +18 -0
- data/spec/services/hyrax/qa_select_service_spec.rb +40 -17
- data/spec/services/hyrax/tolerant_select_service_spec.rb +80 -0
- data/spec/support/fakes/fake_authority.rb +13 -0
- data/spec/support/logging_formatter.rb +1 -1
- data/spec/support/matchers/collection_type_property_matchers.rb +5 -5
- data/spec/views/hyrax/base/_form_progress.html.erb_spec.rb +11 -1
- data/spec/views/hyrax/file_sets/_show_actions.html.erb_spec.rb +0 -1
- data/spec/views/hyrax/file_sets/_single_use_links.html.erb_spec.rb +4 -0
- data/spec/views/hyrax/single_use_links_viewer/show.html.erb_spec.rb +0 -4
- data/template.rb +1 -1
- metadata +24 -11
- data/app/views/kaminari/blacklight_compact/_paginator.html.erb +0 -22
@@ -39,7 +39,7 @@ RSpec.describe 'Batch creation of works', type: :feature do
|
|
39
39
|
it "allows on-behalf-of batch deposit", :js do
|
40
40
|
click_link "Files" # switch tab
|
41
41
|
expect(page).to have_content "Add files"
|
42
|
-
within('
|
42
|
+
within('button#addfiles') do
|
43
43
|
# two arbitrary files that aren't actually related, but should be
|
44
44
|
# small enough to require minimal processessing.
|
45
45
|
attach_file("files[]", "#{Hyrax::Engine.root}/spec/fixtures/small_file.txt", visible: false)
|
@@ -30,7 +30,7 @@ RSpec.describe 'Creating a new Work', :js, :workflow do
|
|
30
30
|
click_link "Files" # switch tab
|
31
31
|
expect(page).to have_content "Add files"
|
32
32
|
expect(page).to have_content "Add folder"
|
33
|
-
within('
|
33
|
+
within('button#addfiles') do
|
34
34
|
attach_file("files[]", "#{Hyrax::Engine.root}/spec/fixtures/image.jp2", visible: false)
|
35
35
|
attach_file("files[]", "#{Hyrax::Engine.root}/spec/fixtures/jp2_fits.xml", visible: false)
|
36
36
|
end
|
@@ -71,7 +71,7 @@ RSpec.describe 'Creating a new Work', :js, :workflow do
|
|
71
71
|
it "allows on-behalf-of deposit" do
|
72
72
|
click_link "Files" # switch tab
|
73
73
|
expect(page).to have_content "Add files"
|
74
|
-
within('
|
74
|
+
within('button#addfiles') do
|
75
75
|
attach_file("files[]", "#{Hyrax::Engine.root}/spec/fixtures/image.jp2", visible: false)
|
76
76
|
attach_file("files[]", "#{Hyrax::Engine.root}/spec/fixtures/jp2_fits.xml", visible: false)
|
77
77
|
end
|
@@ -101,4 +101,24 @@ RSpec.describe 'Creating a new Work', :js, :workflow do
|
|
101
101
|
expect(page).to have_content "My Test Work"
|
102
102
|
end
|
103
103
|
end
|
104
|
+
|
105
|
+
context "when a file uploaded and then deleted" do
|
106
|
+
before do
|
107
|
+
sign_in user
|
108
|
+
click_link 'Works'
|
109
|
+
click_link "Add new work"
|
110
|
+
choose "payload_concern", option: "GenericWork"
|
111
|
+
click_button 'Create work'
|
112
|
+
end
|
113
|
+
|
114
|
+
it 'updates the required file check status' do
|
115
|
+
click_link "Files" # switch to the Files tab
|
116
|
+
within('button#addfiles') do
|
117
|
+
attach_file("files[]", "#{Hyrax::Engine.root}/spec/fixtures/image.jp2", visible: false)
|
118
|
+
end
|
119
|
+
expect(page).to have_css('ul li#required-files.complete', text: 'Add files')
|
120
|
+
click_button 'Delete' # delete the file
|
121
|
+
expect(page).to have_css('ul li#required-files.incomplete', text: 'Add files')
|
122
|
+
end
|
123
|
+
end
|
104
124
|
end
|
@@ -631,14 +631,14 @@ RSpec.describe 'collection', type: :feature, clean_repo: true do
|
|
631
631
|
it "preselects the collection we are adding works to and adds the selected works" do
|
632
632
|
visit "/dashboard/collections/#{collection1.id}"
|
633
633
|
click_link 'Add existing works'
|
634
|
-
|
634
|
+
find('input#check_all').click
|
635
635
|
click_button "Add to collection"
|
636
636
|
expect(page).to have_selector "#member_of_collection_ids[value=\"#{collection1.id}\"]", visible: false
|
637
637
|
expect(page).to have_selector "#member_of_collection_label[value=\"#{collection1.title.first}\"]"
|
638
638
|
|
639
639
|
visit "/dashboard/collections/#{collection2.id}"
|
640
640
|
click_link 'Add existing works'
|
641
|
-
|
641
|
+
find('input#check_all').click
|
642
642
|
click_button "Add to collection"
|
643
643
|
expect(page).to have_selector "#member_of_collection_ids[value=\"#{collection2.id}\"]", visible: false
|
644
644
|
expect(page).to have_selector "#member_of_collection_label[value=\"#{collection2.title.first}\"]"
|
@@ -671,7 +671,7 @@ RSpec.describe 'collection', type: :feature, clean_repo: true do
|
|
671
671
|
|
672
672
|
# add required file
|
673
673
|
click_link "Files" # switch tab
|
674
|
-
within('
|
674
|
+
within('button#addfiles') do
|
675
675
|
attach_file("files[]", "#{Hyrax::Engine.root}/spec/fixtures/image.jp2", visible: false)
|
676
676
|
end
|
677
677
|
# set required metadata
|
@@ -1,5 +1,6 @@
|
|
1
|
-
RSpec.describe "The homepage" do
|
2
|
-
let(:work1) { create(:work, :public, title: [
|
1
|
+
RSpec.describe "The homepage", :clean_repo do
|
2
|
+
let(:work1) { create(:work, :public, title: ["Work 1"], date_uploaded: (DateTime.current - 1.day)) }
|
3
|
+
let(:work2) { create(:work, :public, title: ["Work 2"], date_uploaded: (DateTime.current - 1.year)) }
|
3
4
|
|
4
5
|
before do
|
5
6
|
create(:featured_work, work_id: work1.id)
|
@@ -7,7 +8,22 @@ RSpec.describe "The homepage" do
|
|
7
8
|
|
8
9
|
it 'shows featured works' do
|
9
10
|
visit root_path
|
10
|
-
expect(page).to have_link
|
11
|
+
expect(page).to have_link work1.title.first
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'shows recently uploaded' do
|
15
|
+
visit root_path
|
16
|
+
click_link("Recently Uploaded")
|
17
|
+
within '#recently_uploaded' do
|
18
|
+
# Expect to see the one with "date uploaded" of yesterday
|
19
|
+
expect(page).to have_link work1.title.first
|
20
|
+
# Do not expect to see the one with "date uploaded" of last year.
|
21
|
+
expect(page).not_to have_link work2.title.first
|
22
|
+
# Expect the system create of work2 to be later than that of work1.
|
23
|
+
# This helps verify that 'recently uploaded' is looking at
|
24
|
+
# 'date_uploaded_dtsi' and not 'system_create_dtsi'.
|
25
|
+
expect(DateTime.parse(work2.to_solr['system_create_dtsi']).getlocal).to be >= DateTime.parse(work1.to_solr['system_create_dtsi']).getlocal
|
26
|
+
end
|
11
27
|
end
|
12
28
|
|
13
29
|
context "as an admin" do
|
@@ -20,7 +36,7 @@ RSpec.describe "The homepage" do
|
|
20
36
|
it 'shows featured works that I can sort' do
|
21
37
|
visit root_path
|
22
38
|
within '.dd-item' do
|
23
|
-
expect(page).to have_link
|
39
|
+
expect(page).to have_link work1.title.first
|
24
40
|
end
|
25
41
|
end
|
26
42
|
end
|
@@ -173,6 +173,56 @@ describe("SaveWorkControl", function() {
|
|
173
173
|
|
174
174
|
});
|
175
175
|
|
176
|
+
describe('isSaveButtonEnabled helper method', function() {
|
177
|
+
const form_id = 'new_generic_work';
|
178
|
+
let buildTarget = function(form_id) {
|
179
|
+
let buildFixture = function(id) {
|
180
|
+
return setFixtures(
|
181
|
+
`<form id="${id}">
|
182
|
+
<aside id="form-progress">
|
183
|
+
<ul>
|
184
|
+
<li id="required-metadata"></li>
|
185
|
+
<li id="required-files"></li>
|
186
|
+
<li id="required-agreement"></li>
|
187
|
+
</ul>
|
188
|
+
<input type="checkbox" name="agreement" id="agreement" value="1" required="required" checked="checked" />
|
189
|
+
<input type="submit">
|
190
|
+
</aside>
|
191
|
+
</form>`
|
192
|
+
);
|
193
|
+
};
|
194
|
+
target = new SaveWorkControl(buildFixture(form_id).find('#form-progress'));
|
195
|
+
return target;
|
196
|
+
};
|
197
|
+
|
198
|
+
describe('returns a boolean value of', function() {
|
199
|
+
beforeEach(function() {
|
200
|
+
target = buildTarget(form_id);
|
201
|
+
target.uploads = {
|
202
|
+
hasFiles: true,
|
203
|
+
hasFileRequirement: true,
|
204
|
+
// mock current uploads getter value
|
205
|
+
inProgress: false
|
206
|
+
};
|
207
|
+
});
|
208
|
+
|
209
|
+
it('true when the form is valid and there are no in progress uploads', () => {
|
210
|
+
expect(target.isSaveButtonEnabled).toBeTruthy();
|
211
|
+
});
|
212
|
+
|
213
|
+
it('false when required files have not been added to the form', () => {
|
214
|
+
target.uploads.hasFiles = false;
|
215
|
+
expect(target.isSaveButtonEnabled).toBeFalsy();
|
216
|
+
});
|
217
|
+
|
218
|
+
it('false when file uploads are still in progress', () => {
|
219
|
+
target.uploads.inProgress = true;
|
220
|
+
expect(target.isSaveButtonEnabled).toBeFalsy();
|
221
|
+
});
|
222
|
+
});
|
223
|
+
});
|
224
|
+
|
225
|
+
|
176
226
|
describe("on submit", function() {
|
177
227
|
var target;
|
178
228
|
beforeEach(function() {
|
@@ -20,10 +20,14 @@ RSpec.describe ImportUrlJob do
|
|
20
20
|
before do
|
21
21
|
allow(Hyrax::Actors::FileSetActor).to receive(:new).with(file_set, user).and_return(actor)
|
22
22
|
|
23
|
-
response_headers = {
|
24
|
-
|
25
|
-
|
26
|
-
|
23
|
+
response_headers = {
|
24
|
+
'Content-Type' => 'image/png',
|
25
|
+
'Content-Length' => 1,
|
26
|
+
'Content-Range' => "0-0/#{File.size(File.expand_path(file_path, __FILE__))}"
|
27
|
+
}
|
28
|
+
|
29
|
+
stub_request(:get, "http://example.org#{file_hash}").with(headers: { 'Range' => 'bytes=0-0' }).to_return(
|
30
|
+
body: File.open(File.expand_path(file_path, __FILE__)).read(1), status: 206, headers: response_headers
|
27
31
|
)
|
28
32
|
|
29
33
|
stub_request(:get, "http://example.org#{file_hash}").to_return(
|
@@ -97,10 +101,8 @@ RSpec.describe ImportUrlJob do
|
|
97
101
|
|
98
102
|
context 'when the remote file is unavailable' do
|
99
103
|
before do
|
100
|
-
|
101
|
-
|
102
|
-
stub_request(:head, "http://example.org#{file_hash}").to_return(
|
103
|
-
body: "", status: 404, headers: response_headers
|
104
|
+
stub_request(:get, "http://example.org#{file_hash}").with(headers: { 'Range' => 'bytes=0-0' }).to_return(
|
105
|
+
body: '', status: 406, headers: {}
|
104
106
|
)
|
105
107
|
end
|
106
108
|
|
@@ -31,7 +31,7 @@ RSpec.describe ::SolrDocument, type: :model do
|
|
31
31
|
let(:attributes) { { 'date_uploaded_dtsi' => 'Test' } }
|
32
32
|
|
33
33
|
it "logs parse errors" do
|
34
|
-
expect(
|
34
|
+
expect(Hyrax.logger).to receive(:info).with(/Unable to parse date.*/)
|
35
35
|
subject
|
36
36
|
end
|
37
37
|
end
|
@@ -59,7 +59,7 @@ RSpec.describe ::SolrDocument, type: :model do
|
|
59
59
|
let(:attributes) { { 'system_create_dtsi' => 'Test' } }
|
60
60
|
|
61
61
|
it "logs parse errors" do
|
62
|
-
expect(
|
62
|
+
expect(Hyrax.logger).to receive(:info).with(/Unable to parse date.*/)
|
63
63
|
subject
|
64
64
|
end
|
65
65
|
end
|
@@ -16,6 +16,20 @@ RSpec.describe Hyrax::AdminStatsPresenter do
|
|
16
16
|
expect(Hyrax::Statistics::Works::ByDepositor).to receive(:query).with(limit: limit).and_return(:query_response)
|
17
17
|
expect(service.active_users).to eq(:query_response)
|
18
18
|
end
|
19
|
+
|
20
|
+
context 'with alternatate class' do
|
21
|
+
subject(:service) do
|
22
|
+
described_class.new(filters, limit, by_depositor: by_depositor_class)
|
23
|
+
end
|
24
|
+
|
25
|
+
let(:by_depositor_class) { spy('ByDepositor') }
|
26
|
+
|
27
|
+
it 'retrieves active_users from the class' do
|
28
|
+
service.active_users
|
29
|
+
|
30
|
+
expect(by_depositor_class).to have_received(:query).with(limit: limit)
|
31
|
+
end
|
32
|
+
end
|
19
33
|
end
|
20
34
|
|
21
35
|
describe "#top_formats" do
|
@@ -23,6 +37,20 @@ RSpec.describe Hyrax::AdminStatsPresenter do
|
|
23
37
|
expect(Hyrax::Statistics::FileSets::ByFormat).to receive(:query).with(limit: limit).and_return(:query_response)
|
24
38
|
expect(service.top_formats).to eq(:query_response)
|
25
39
|
end
|
40
|
+
|
41
|
+
context 'with alternatate class' do
|
42
|
+
subject(:service) do
|
43
|
+
described_class.new(filters, limit, by_format: by_format)
|
44
|
+
end
|
45
|
+
|
46
|
+
let(:by_format) { spy('ByFormat') }
|
47
|
+
|
48
|
+
it 'retrieves formats from the class' do
|
49
|
+
service.top_formats
|
50
|
+
|
51
|
+
expect(by_format).to have_received(:query).with(limit: limit)
|
52
|
+
end
|
53
|
+
end
|
26
54
|
end
|
27
55
|
|
28
56
|
describe "#works_count" do
|
@@ -30,6 +58,19 @@ RSpec.describe Hyrax::AdminStatsPresenter do
|
|
30
58
|
expect(Hyrax::Statistics::Works::Count).to receive(:by_permission).with(start_date: service.start_date, end_date: service.end_date).and_return(:query_response)
|
31
59
|
expect(service.works_count).to eq(:query_response)
|
32
60
|
end
|
61
|
+
|
62
|
+
context 'with alternatate class' do
|
63
|
+
subject(:service) { described_class.new(filters, limit, works_counter: works_counter) }
|
64
|
+
let(:works_counter) { spy('Works::Count') }
|
65
|
+
|
66
|
+
it 'retrieves count from the class' do
|
67
|
+
service.works_count
|
68
|
+
|
69
|
+
expect(works_counter)
|
70
|
+
.to have_received(:by_permission)
|
71
|
+
.with(start_date: service.start_date, end_date: service.end_date)
|
72
|
+
end
|
73
|
+
end
|
33
74
|
end
|
34
75
|
|
35
76
|
describe "#depositors" do
|
@@ -37,6 +78,22 @@ RSpec.describe Hyrax::AdminStatsPresenter do
|
|
37
78
|
expect(Hyrax::Statistics::Depositors::Summary).to receive(:depositors).with(start_date: service.start_date, end_date: service.end_date).and_return(:query_response)
|
38
79
|
expect(service.depositors).to eq(:query_response)
|
39
80
|
end
|
81
|
+
|
82
|
+
context 'with alternatate class' do
|
83
|
+
subject(:service) do
|
84
|
+
described_class.new(filters, limit, depositor_summary: summary_class)
|
85
|
+
end
|
86
|
+
|
87
|
+
let(:summary_class) { spy('depositor summary class') }
|
88
|
+
|
89
|
+
it 'retrieves depositors from the class' do
|
90
|
+
service.depositors
|
91
|
+
|
92
|
+
expect(summary_class)
|
93
|
+
.to have_received(:depositors)
|
94
|
+
.with(start_date: service.start_date, end_date: service.end_date)
|
95
|
+
end
|
96
|
+
end
|
40
97
|
end
|
41
98
|
|
42
99
|
describe "#recent_users" do
|
@@ -44,6 +101,22 @@ RSpec.describe Hyrax::AdminStatsPresenter do
|
|
44
101
|
expect(Hyrax::Statistics::SystemStats).to receive(:recent_users).with(limit: limit, start_date: service.start_date, end_date: service.end_date).and_return(:query_response)
|
45
102
|
expect(service.recent_users).to eq(:query_response)
|
46
103
|
end
|
104
|
+
|
105
|
+
context 'with alternatate class' do
|
106
|
+
subject(:service) do
|
107
|
+
described_class.new(filters, limit, system_stats: system_stats)
|
108
|
+
end
|
109
|
+
|
110
|
+
let(:system_stats) { spy('SystemStats') }
|
111
|
+
|
112
|
+
it 'retrieves users from the class' do
|
113
|
+
service.recent_users
|
114
|
+
|
115
|
+
expect(system_stats)
|
116
|
+
.to have_received(:recent_users)
|
117
|
+
.with(limit: limit, start_date: service.start_date, end_date: service.end_date)
|
118
|
+
end
|
119
|
+
end
|
47
120
|
end
|
48
121
|
|
49
122
|
describe '#date_filter_string' do
|
@@ -24,7 +24,6 @@ RSpec.describe Hyrax::My::WorksSearchBuilder do
|
|
24
24
|
|
25
25
|
it "filters works that we are the depositor of" do
|
26
26
|
expect(subject).to eq ["{!terms f=has_model_ssim}GenericWork",
|
27
|
-
"-suppressed_bsi:true",
|
28
27
|
"depositor"]
|
29
28
|
end
|
30
29
|
end
|
@@ -44,7 +43,6 @@ RSpec.describe Hyrax::My::WorksSearchBuilder do
|
|
44
43
|
:add_group_config_to_solr,
|
45
44
|
:add_facet_paging_to_solr,
|
46
45
|
:filter_models,
|
47
|
-
:only_active_works,
|
48
46
|
:show_only_resources_deposited_by_current_user
|
49
47
|
]
|
50
48
|
end
|
@@ -36,5 +36,23 @@ RSpec.describe Hyrax::GraphExporter do
|
|
36
36
|
expect { subject }.to raise_error ActiveFedora::ObjectNotFoundError
|
37
37
|
end
|
38
38
|
end
|
39
|
+
|
40
|
+
context 'with a nested work' do
|
41
|
+
let(:work) do
|
42
|
+
NamespacedWorks::NestedWork
|
43
|
+
.create(title: ['Comet in Moominland'],
|
44
|
+
created_attributes: [{ start: DateTime.now.utc - 1, finish: DateTime.now.utc },
|
45
|
+
{ start: DateTime.now.utc - 2, finish: DateTime.now.utc }])
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'includes each nested resources once' do
|
49
|
+
resource_fragments = work.created.map { |ts| ts.rdf_subject.fragment }
|
50
|
+
mapped_fragments = subject.query(predicate: RDF.type, object: RDF::Vocab::EDM.TimeSpan)
|
51
|
+
.subjects
|
52
|
+
.map(&:fragment)
|
53
|
+
|
54
|
+
expect(mapped_fragments).to contain_exactly(*resource_fragments)
|
55
|
+
end
|
56
|
+
end
|
39
57
|
end
|
40
58
|
end
|
@@ -1,21 +1,4 @@
|
|
1
1
|
RSpec.describe Hyrax::QaSelectService do
|
2
|
-
let(:authority) do
|
3
|
-
# Implementing an ActiveRecord interface as required for this spec
|
4
|
-
Class.new do
|
5
|
-
def initialize(map)
|
6
|
-
@map = map
|
7
|
-
end
|
8
|
-
|
9
|
-
def all
|
10
|
-
@map
|
11
|
-
end
|
12
|
-
|
13
|
-
def find(id)
|
14
|
-
@map.detect { |item| item[:id] == id }
|
15
|
-
end
|
16
|
-
end
|
17
|
-
# rubocop:enable RSpec/InstanceVariable
|
18
|
-
end
|
19
2
|
let(:authority_map) do
|
20
3
|
[
|
21
4
|
HashWithIndifferentAccess.new(term: 'Active Label', label: 'Active Label', id: 'active-id', active: true),
|
@@ -23,6 +6,8 @@ RSpec.describe Hyrax::QaSelectService do
|
|
23
6
|
HashWithIndifferentAccess.new(label: 'Active No Term', id: 'active-no-term-id', active: true)
|
24
7
|
]
|
25
8
|
end
|
9
|
+
|
10
|
+
let(:authority) { FakeAuthority }
|
26
11
|
let(:authority_name) { 'respect_my' }
|
27
12
|
let(:qa_select_service) { described_class.new(authority_name) }
|
28
13
|
|
@@ -44,6 +29,16 @@ RSpec.describe Hyrax::QaSelectService do
|
|
44
29
|
it 'will be Array of Arrays<label, id>' do
|
45
30
|
expect(subject).to eq([['Active Label', 'active-id'], ['Active No Term', 'active-no-term-id']])
|
46
31
|
end
|
32
|
+
|
33
|
+
context 'when a key has no active property' do
|
34
|
+
let(:no_state) { HashWithIndifferentAccess.new(term: 'term', label: 'label', id: 'no-state') }
|
35
|
+
|
36
|
+
before { authority_map << no_state }
|
37
|
+
|
38
|
+
it 'raises KeyError' do
|
39
|
+
expect { subject }.to raise_error(KeyError)
|
40
|
+
end
|
41
|
+
end
|
47
42
|
end
|
48
43
|
|
49
44
|
describe '#label' do
|
@@ -83,4 +78,32 @@ RSpec.describe Hyrax::QaSelectService do
|
|
83
78
|
end
|
84
79
|
end
|
85
80
|
end
|
81
|
+
|
82
|
+
describe '#include_current_value' do
|
83
|
+
let(:render_opts) { [] }
|
84
|
+
let(:html_opts) { { class: 'moomin' } }
|
85
|
+
|
86
|
+
let(:authority_map) do
|
87
|
+
[
|
88
|
+
HashWithIndifferentAccess.new(term: 'Active Label', label: 'Active Label', id: 'active-id', active: true),
|
89
|
+
HashWithIndifferentAccess.new(term: 'Inactive Label', label: 'Inactive Label', id: 'inactive-id', active: false),
|
90
|
+
HashWithIndifferentAccess.new(label: 'Inactive No Term', id: 'inactive-no-term-id', active: false)
|
91
|
+
]
|
92
|
+
end
|
93
|
+
|
94
|
+
it 'adds an inactive current value' do
|
95
|
+
expect(qa_select_service.include_current_value('inactive-id', :idx, render_opts, html_opts))
|
96
|
+
.to eq [[['Inactive Label', 'inactive-id']], { class: 'moomin force-select' }]
|
97
|
+
end
|
98
|
+
|
99
|
+
it 'adds an inactive current value with fallback label' do
|
100
|
+
expect(qa_select_service.include_current_value('inactive-no-term-id', :idx, render_opts, html_opts))
|
101
|
+
.to eq [[['inactive-no-term-id', 'inactive-no-term-id']], { class: 'moomin force-select' }]
|
102
|
+
end
|
103
|
+
|
104
|
+
it 'does not add an active current value' do
|
105
|
+
expect(qa_select_service.include_current_value('active-id', :idx, render_opts.dup, html_opts.dup))
|
106
|
+
.to eq [render_opts, html_opts]
|
107
|
+
end
|
108
|
+
end
|
86
109
|
end
|