hyrax 3.0.0.pre.beta1 → 3.0.0.pre.beta2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.circleci/config.yml +157 -68
- data/.travis.yml +4 -1
- data/Gemfile +1 -0
- data/README.md +3 -3
- data/app/actors/hyrax/actors/collections_membership_actor.rb +5 -55
- data/app/actors/hyrax/actors/create_with_remote_files_ordered_members_actor.rb +6 -8
- data/app/actors/hyrax/actors/environment.rb +15 -0
- data/app/actors/hyrax/actors/interpret_visibility_actor.rb +22 -37
- data/app/assets/javascripts/hyrax/editor/controlled_vocabulary.es6 +1 -1
- data/app/assets/stylesheets/hyrax/_collections.scss +5 -3
- data/app/assets/stylesheets/hyrax/dashboard.scss +3 -3
- data/app/controllers/concerns/hyrax/works_controller_behavior.rb +21 -2
- data/app/controllers/hyrax/homepage_controller.rb +1 -1
- data/app/forms/hyrax/forms/work_form.rb +1 -1
- data/app/helpers/hyrax/collections_helper.rb +13 -0
- data/app/helpers/hyrax/hyrax_helper_behavior.rb +3 -3
- data/app/indexers/hyrax/admin_set_indexer.rb +1 -1
- data/app/indexers/hyrax/basic_metadata_indexer.rb +1 -1
- data/app/indexers/hyrax/collection_indexer.rb +3 -3
- data/app/indexers/hyrax/deep_indexing_service.rb +12 -12
- data/app/indexers/hyrax/file_set_indexer.rb +1 -1
- data/app/indexers/hyrax/indexes_workflow.rb +4 -4
- data/app/indexers/hyrax/work_indexer.rb +1 -1
- data/app/models/concerns/hyrax/basic_metadata.rb +2 -0
- data/app/models/concerns/hyrax/collection_behavior.rb +3 -3
- data/app/models/concerns/hyrax/file_set/querying.rb +1 -1
- data/app/models/concerns/hyrax/human_readable_type.rb +2 -2
- data/app/models/concerns/hyrax/solr_document/characterization.rb +23 -23
- data/app/models/concerns/hyrax/solr_document/metadata.rb +3 -2
- data/app/models/concerns/hyrax/solr_document_behavior.rb +3 -3
- data/app/models/concerns/hyrax/user.rb +10 -2
- data/app/presenters/hyrax/work_show_presenter.rb +2 -2
- data/app/renderers/hyrax/renderers/faceted_attribute_renderer.rb +1 -1
- data/app/search_builders/hyrax/collection_search_builder.rb +1 -1
- data/app/search_builders/hyrax/deposit_search_builder.rb +1 -1
- data/app/search_builders/hyrax/embargo_search_builder.rb +1 -1
- data/app/search_builders/hyrax/lease_search_builder.rb +1 -1
- data/app/services/hyrax/default_middleware_stack.rb +0 -4
- data/app/services/hyrax/statistics/file_sets/by_format.rb +1 -1
- data/app/services/hyrax/statistics/works/by_resource_type.rb +1 -1
- data/app/services/hyrax/visibility_intention.rb +78 -0
- data/app/views/catalog/_index_list_default.html.erb +3 -3
- data/app/views/catalog/_thumbnail_list_collection.html.erb +3 -2
- data/app/views/hyrax/base/_attribute_rows.html.erb +1 -0
- data/app/views/hyrax/base/_form_files.html.erb +2 -2
- data/app/views/hyrax/base/_form_visibility_component.html.erb +1 -1
- data/app/views/hyrax/base/_show_actions.html.erb +6 -6
- data/app/views/hyrax/base/show.html.erb +2 -2
- data/app/views/hyrax/batch_edits/_check_all.html.erb +1 -1
- data/app/views/hyrax/batch_edits/_delete_selected.html.erb +1 -1
- data/app/views/hyrax/collections/_show_document_list_row.html.erb +1 -1
- data/app/views/hyrax/dashboard/collections/_show_document_list_row.html.erb +1 -1
- data/app/views/hyrax/dashboard/show_admin.html.erb +4 -4
- data/app/views/records/show_fields/_based_near.html.erb +1 -1
- data/app/views/records/show_fields/_creator.html.erb +1 -1
- data/app/views/records/show_fields/_keyword.html.erb +1 -1
- data/app/views/records/show_fields/_language.html.erb +1 -1
- data/app/views/records/show_fields/_publisher.html.erb +1 -1
- data/app/views/records/show_fields/_resource_type.html.erb +1 -1
- data/app/views/records/show_fields/_subject.html.erb +1 -1
- data/config/initializers/samvera-nesting_indexer_initializer.rb +3 -3
- data/config/locales/hyrax.de.yml +35 -22
- data/config/locales/hyrax.en.yml +22 -2
- data/config/locales/hyrax.es.yml +21 -1
- data/config/locales/hyrax.fr.yml +21 -1
- data/config/locales/hyrax.it.yml +21 -1
- data/config/locales/hyrax.pt-BR.yml +21 -1
- data/config/locales/hyrax.zh.yml +21 -1
- data/hyrax.gemspec +7 -9
- data/lib/generators/hyrax/templates/catalog_controller.rb +1 -1
- data/lib/generators/hyrax/templates/config/locales/hyrax.pt-BR.yml +10 -10
- data/lib/generators/hyrax/work/templates/locale.pt-BR.yml.erb +1 -1
- data/lib/hyrax/configuration.rb +18 -0
- data/lib/hyrax/engine.rb +8 -0
- data/lib/hyrax/transactions/container.rb +6 -0
- data/lib/hyrax/transactions/destroy_work.rb +21 -0
- data/lib/hyrax/transactions/steps/destroy_work.rb +24 -0
- data/lib/hyrax/version.rb +1 -1
- data/lib/wings.rb +45 -0
- data/lib/wings/active_fedora_converter.rb +56 -0
- data/lib/wings/model_transformer.rb +158 -0
- data/lib/wings/resource_factory.rb +8 -0
- data/lib/wings/valkyrie/metadata_adapter.rb +29 -0
- data/lib/wings/valkyrie/persister.rb +50 -0
- data/lib/wings/valkyrie/query_service.rb +43 -0
- data/lib/wings/valkyrie/resource_factory.rb +45 -0
- data/lib/wings/valkyrizable.rb +24 -0
- data/lib/wings/value_mapper.rb +59 -0
- data/spec/abilities/collection_ability_spec.rb +5 -5
- data/spec/abilities/permission_template_ability_spec.rb +1 -1
- data/spec/actors/hyrax/actors/collections_membership_actor_spec.rb +6 -175
- data/spec/actors/hyrax/actors/create_with_remote_files_ordered_members_actor_spec.rb +30 -22
- data/spec/actors/hyrax/actors/interpret_visibility_actor_spec.rb +2 -0
- data/spec/controllers/catalog_controller_spec.rb +1 -1
- data/spec/controllers/hyrax/admin/collection_types_controller_spec.rb +1 -1
- data/spec/controllers/hyrax/batch_edits_controller_spec.rb +9 -9
- data/spec/controllers/hyrax/collections_controller_spec.rb +5 -5
- data/spec/controllers/hyrax/dashboard/collection_members_controller_spec.rb +16 -13
- data/spec/controllers/hyrax/dashboard/collections_controller_spec.rb +9 -9
- data/spec/controllers/hyrax/dashboard/nest_collections_controller_spec.rb +1 -1
- data/spec/controllers/hyrax/generic_works_controller_spec.rb +10 -1
- data/spec/controllers/hyrax/homepage_controller_spec.rb +3 -3
- data/spec/controllers/hyrax/my/shares_controller_spec.rb +1 -1
- data/spec/features/actor_stack_spec.rb +48 -0
- data/spec/features/catalog_search_spec.rb +2 -2
- data/spec/features/collection_multi_membership_spec.rb +2 -2
- data/spec/features/collection_spec.rb +7 -7
- data/spec/features/collection_type_spec.rb +2 -2
- data/spec/features/dashboard/collection_spec.rb +18 -18
- data/spec/features/delete_work_spec.rb +1 -1
- data/spec/features/search_spec.rb +2 -2
- data/spec/features/work_show_spec.rb +5 -2
- data/spec/forms/hyrax/forms/batch_upload_form_spec.rb +1 -0
- data/spec/forms/hyrax/forms/collection_form_spec.rb +5 -5
- data/spec/forms/hyrax/forms/permission_template_form_spec.rb +1 -1
- data/spec/forms/hyrax/forms/work_form_spec.rb +2 -0
- data/spec/helpers/blacklight_helper_spec.rb +3 -1
- data/spec/helpers/hyrax/collections_helper_spec.rb +42 -0
- data/spec/helpers/hyrax/dashboard_helper_behavior_spec.rb +4 -4
- data/spec/helpers/hyrax_helper_spec.rb +8 -4
- data/spec/hyrax/transactions/destroy_work_spec.rb +35 -0
- data/spec/hyrax/transactions/steps/destroy_work_spec.rb +33 -0
- data/spec/indexers/hyrax/collection_indexer_spec.rb +1 -1
- data/spec/jobs/characterize_job_spec.rb +1 -1
- data/spec/lib/hyrax/resource_sync/change_list_writer_spec.rb +35 -21
- data/spec/lib/hyrax/resource_sync/resource_list_writer_spec.rb +1 -1
- data/spec/models/collection_spec.rb +18 -18
- data/spec/models/concerns/hyrax/collection_nesting_spec.rb +2 -2
- data/spec/models/file_set_spec.rb +2 -2
- data/spec/models/hyrax/collection_type_spec.rb +2 -2
- data/spec/models/user_spec.rb +26 -1
- data/spec/presenters/hyrax/collection_presenter_spec.rb +11 -11
- data/spec/presenters/hyrax/work_show_presenter_spec.rb +11 -0
- data/spec/search_builders/hyrax/collection_member_search_builder_spec.rb +1 -1
- data/spec/search_builders/hyrax/collection_search_builder_spec.rb +1 -1
- data/spec/search_builders/hyrax/dashboard/nested_collections_search_builder_spec.rb +1 -1
- data/spec/search_builders/hyrax/work_relation_spec.rb +1 -1
- data/spec/services/hyrax/adapters/nesting_index_adapter_spec.rb +2 -2
- data/spec/services/hyrax/collections/collection_member_service_spec.rb +2 -2
- data/spec/services/hyrax/collections/migration_service_spec.rb +27 -27
- data/spec/services/hyrax/collections/nested_collection_persistence_service_spec.rb +1 -1
- data/spec/services/hyrax/collections/nested_collection_query_service_spec.rb +38 -38
- data/spec/services/hyrax/curation_concern_spec.rb +1 -1
- data/spec/services/hyrax/default_middleware_stack_spec.rb +1 -2
- data/spec/services/hyrax/statistics/depositors/summary_spec.rb +1 -1
- data/spec/services/hyrax/statistics/works/by_resource_type_spec.rb +11 -4
- data/spec/services/hyrax/visibility_intention_spec.rb +144 -0
- data/spec/services/hyrax/workflow/changes_required_notification_spec.rb +1 -1
- data/spec/spec_helper.rb +10 -8
- data/spec/support/selectors.rb +10 -1
- data/spec/test_app_templates/Gemfile.extra +2 -0
- data/spec/test_app_templates/lib/generators/test_app_generator.rb +6 -0
- data/spec/views/catalog/_index_list_default.html.erb_spec.rb +3 -2
- data/spec/views/catalog/_thumbnail_list_collection.html.erb_spec.rb +38 -5
- data/spec/views/hyrax/base/_attributes.html.erb_spec.rb +1 -1
- data/spec/views/hyrax/base/_show_actions.html.erb_spec.rb +9 -9
- data/spec/views/hyrax/base/show.html.erb_spec.rb +3 -2
- data/spec/views/hyrax/collections/_show_document_list_row.html.erb_spec.rb +3 -2
- data/spec/views/hyrax/dashboard/collections/_show_document_list_row.html.erb_spec.rb +3 -2
- data/spec/wings/active_fedora_converter_spec.rb +31 -0
- data/spec/wings/model_transformer_spec.rb +288 -0
- data/spec/wings/valkyrie/metadata_adapter_spec.rb +10 -0
- data/spec/wings/valkyrie/persister_spec.rb +71 -0
- data/spec/wings/valkyrie/query_service_spec.rb +81 -0
- data/spec/wings/valkyrie/resource_factory_spec.rb +32 -0
- data/spec/wings/value_mapper_spec.rb +60 -0
- data/spec/wings_spec.rb +8 -0
- data/template.rb +3 -1
- metadata +86 -36
@@ -1,4 +1,5 @@
|
|
1
1
|
RSpec.describe Hyrax::Actors::CreateWithRemoteFilesOrderedMembersActor do
|
2
|
+
let(:null_operation) { class_double('Hyrax::Operation').as_null_object }
|
2
3
|
let(:terminator) { Hyrax::Actors::Terminator.new }
|
3
4
|
let(:actor) { stack.build(terminator) }
|
4
5
|
let(:stack) do
|
@@ -9,41 +10,48 @@ RSpec.describe Hyrax::Actors::CreateWithRemoteFilesOrderedMembersActor do
|
|
9
10
|
let(:user) { create(:user) }
|
10
11
|
let(:ability) { Ability.new(user) }
|
11
12
|
let(:work) { create(:generic_work, user: user) }
|
12
|
-
let(:
|
13
|
-
let(:
|
13
|
+
let(:urls) { ["https://dl.dropbox.com/fake/blah-blah.filepicker-demo.txt.txt", "https://dl.dropbox.com/fake/blah-blah.Getting%20Started.pdf"] }
|
14
|
+
let(:filenames) { ['filepicker-demo.txt.txt', 'Getting%20Started.pdf'] }
|
14
15
|
|
15
16
|
let(:remote_files) do
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
{ url: url2,
|
20
|
-
expires: "2014-03-31T20:37:36.731Z",
|
21
|
-
file_name: "Getting+Started.pdf" }]
|
17
|
+
urls.collect.with_index do |url, index|
|
18
|
+
{ url: url, expires: "2014-03-31T20:37:36.214Z", file_name: filenames[index] }
|
19
|
+
end
|
22
20
|
end
|
21
|
+
|
23
22
|
let(:attributes) { { remote_files: remote_files } }
|
24
23
|
let(:environment) { Hyrax::Actors::Environment.new(work, ability, attributes) }
|
25
24
|
|
26
25
|
before do
|
26
|
+
allow(Hyrax::Operation).to receive(:create!).and_return(null_operation)
|
27
27
|
allow(terminator).to receive(:create).and_return(true)
|
28
28
|
end
|
29
29
|
|
30
30
|
context "with two file_sets" do
|
31
|
-
let(:remote_files) do
|
32
|
-
[{ url: url1,
|
33
|
-
expires: "2014-03-31T20:37:36.214Z",
|
34
|
-
file_name: "filepicker-demo.txt.txt" },
|
35
|
-
{ url: url2,
|
36
|
-
expires: "2014-03-31T20:37:36.731Z",
|
37
|
-
file_name: "Getting+Started.pdf" }]
|
38
|
-
end
|
39
|
-
|
40
31
|
it "attaches files and passes ordered_members to OrderedMembersActor in correct order" do
|
41
|
-
expect(
|
42
|
-
expect(Hyrax::Actors::OrderedMembersActor).to receive(:attach_ordered_members_to_work).with(work)
|
43
|
-
expect(ImportUrlJob).to receive(:perform_later).with(FileSet, Hyrax::Operation, {}).twice
|
32
|
+
expect(ImportUrlJob).to receive(:perform_later).with(FileSet, null_operation, {}).twice
|
44
33
|
expect(actor.create(environment)).to be true
|
45
|
-
expect(
|
46
|
-
|
34
|
+
expect(work.ordered_members.to_a.collect(&:label)).to eq(filenames)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
context "with two environments processed by the same actor instance simultaneously" do
|
39
|
+
let(:work2) { create(:generic_work, user: user) }
|
40
|
+
let(:environments) { [environment, Hyrax::Actors::Environment.new(work2, ability, attributes)] }
|
41
|
+
|
42
|
+
# rubocop:disable RSpec/ExampleLength
|
43
|
+
it "attaches the correct FileSets to the correct works in the correct order" do
|
44
|
+
expect(ImportUrlJob).to receive(:perform_later).with(FileSet, null_operation, {}).exactly(4).times
|
45
|
+
threads = environments.collect do |env|
|
46
|
+
Thread.new do
|
47
|
+
Rails.application.reloader.wrap do
|
48
|
+
expect(actor.create(env)).to be true
|
49
|
+
expect(env.curation_concern.ordered_members.to_a.collect(&:label)).to eq(filenames)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
threads.each(&:join)
|
47
54
|
end
|
55
|
+
# rubocop:enable RSpec/ExampleLength
|
48
56
|
end
|
49
57
|
end
|
@@ -114,6 +114,7 @@ RSpec.describe Hyrax::Actors::InterpretVisibilityActor do
|
|
114
114
|
expect(curation_concern.visibility_during_embargo).to eq 'authenticated'
|
115
115
|
expect(curation_concern.visibility_after_embargo).to eq 'open'
|
116
116
|
expect(curation_concern.visibility).to eq 'authenticated'
|
117
|
+
expect(curation_concern.reload).to be_under_embargo
|
117
118
|
end
|
118
119
|
end
|
119
120
|
|
@@ -429,6 +430,7 @@ RSpec.describe Hyrax::Actors::InterpretVisibilityActor do
|
|
429
430
|
expect(curation_concern.visibility_during_lease).to eq 'open'
|
430
431
|
expect(curation_concern.visibility_after_lease).to eq 'restricted'
|
431
432
|
expect(curation_concern.visibility).to eq 'open'
|
433
|
+
expect(curation_concern.reload.lease).not_to be_new_record
|
432
434
|
end
|
433
435
|
end
|
434
436
|
|
@@ -39,7 +39,7 @@ RSpec.describe CatalogController, type: :controller do
|
|
39
39
|
end
|
40
40
|
|
41
41
|
context 'with collections' do
|
42
|
-
let(:collection) { create(:
|
42
|
+
let(:collection) { create(:public_collection_lw, keyword: ['rocks']) }
|
43
43
|
let(:objects) { [collection, rocks, clouds] }
|
44
44
|
|
45
45
|
it 'finds collections' do
|
@@ -306,7 +306,7 @@ RSpec.describe Hyrax::Admin::CollectionTypesController, type: :controller, clean
|
|
306
306
|
end
|
307
307
|
|
308
308
|
context "when collections exist of this type" do
|
309
|
-
let!(:collection) { create(:
|
309
|
+
let!(:collection) { create(:collection_lw, collection_type_gid: collection_type_to_destroy.gid) }
|
310
310
|
|
311
311
|
it "doesn't delete the collection type or collection" do
|
312
312
|
delete :destroy, params: { id: collection_type_to_destroy }
|
@@ -174,15 +174,15 @@ RSpec.describe Hyrax::BatchEditsController, type: :controller do
|
|
174
174
|
let(:user) { create(:user) }
|
175
175
|
|
176
176
|
let(:collection1) do
|
177
|
-
create(:
|
178
|
-
|
179
|
-
|
177
|
+
create(:public_collection_lw, title: ["My First Collection"],
|
178
|
+
description: ["My incredibly detailed description of the collection"],
|
179
|
+
user: user)
|
180
180
|
end
|
181
181
|
|
182
182
|
let(:collection2) do
|
183
|
-
create(:
|
184
|
-
|
185
|
-
|
183
|
+
create(:public_collection_lw, title: ["My Other Collection"],
|
184
|
+
description: ["My incredibly detailed description of the other collection"],
|
185
|
+
user: user)
|
186
186
|
end
|
187
187
|
|
188
188
|
let!(:work1) { create(:work, title: ["First of the Assets"], member_of_collections: [collection1], user: user) }
|
@@ -204,9 +204,9 @@ RSpec.describe Hyrax::BatchEditsController, type: :controller do
|
|
204
204
|
let(:user2) { create(:user) }
|
205
205
|
|
206
206
|
let(:collection3) do
|
207
|
-
create(:
|
208
|
-
|
209
|
-
|
207
|
+
create(:public_collection_lw, title: ["User2's Collection"],
|
208
|
+
description: ["Collection created by user2"],
|
209
|
+
user: user2)
|
210
210
|
end
|
211
211
|
|
212
212
|
before do
|
@@ -4,16 +4,16 @@ RSpec.describe Hyrax::CollectionsController do
|
|
4
4
|
let(:other) { build(:user) }
|
5
5
|
|
6
6
|
let(:collection) do
|
7
|
-
create(:
|
8
|
-
|
9
|
-
|
7
|
+
create(:public_collection_lw, title: ["My collection"],
|
8
|
+
description: ["My incredibly detailed description of the collection"],
|
9
|
+
user: user)
|
10
10
|
end
|
11
11
|
|
12
12
|
let(:asset1) { create(:work, title: ["First of the Assets"], user: user) }
|
13
13
|
let(:asset2) { create(:work, title: ["Second of the Assets"], user: user) }
|
14
14
|
let(:asset3) { create(:work, title: ["Third of the Assets"], user: user) }
|
15
|
-
let(:asset4) {
|
16
|
-
let(:asset5) {
|
15
|
+
let(:asset4) { build(:collection_lw, title: ["First subcollection"], user: user) }
|
16
|
+
let(:asset5) { build(:collection_lw, title: ["Second subcollection"], user: user) }
|
17
17
|
let(:unowned_asset) { create(:work, user: other) }
|
18
18
|
|
19
19
|
let(:collection_attrs) do
|
@@ -10,20 +10,23 @@ RSpec.describe Hyrax::Dashboard::CollectionMembersController, :clean_repo do
|
|
10
10
|
let(:work_5_read) { create(:work, id: 'work-5-read', title: ["Other's work with read access"], user: other, read_users: [user]) }
|
11
11
|
let(:work_6_noaccess) { create(:work, id: 'work-6-no_access', title: ["Other's work with no access"], user: other) }
|
12
12
|
|
13
|
-
let(:coll_1_own) { create(:
|
13
|
+
let(:coll_1_own) { create(:private_collection_lw, id: 'col-1-own', title: ['User created'], user: user, with_permission_template: true) }
|
14
14
|
let(:coll_2_mgr) do
|
15
|
-
create(:
|
16
|
-
|
15
|
+
create(:private_collection_lw, id: 'col-2-mgr', title: ['User has manage access'], user: other,
|
16
|
+
with_permission_template: { manage_users: [user] })
|
17
17
|
end
|
18
18
|
let(:coll_3_dep) do
|
19
|
-
create(:
|
20
|
-
|
19
|
+
create(:private_collection_lw, id: 'col-3-dep', title: ['User has deposit access'], user: other,
|
20
|
+
with_permission_template: { deposit_users: [user] })
|
21
21
|
end
|
22
22
|
let(:coll_4_view) do
|
23
|
-
create(:
|
24
|
-
|
23
|
+
create(:private_collection_lw, id: 'col-4-dep', title: ['User has view access'], user: other,
|
24
|
+
with_permission_template: { view_users: [user] })
|
25
|
+
end
|
26
|
+
let(:coll_5_noaccess) do
|
27
|
+
create(:private_collection_lw, id: 'col-5-no_access', title: ['Other user created'],
|
28
|
+
user: other, with_permission_template: true)
|
25
29
|
end
|
26
|
-
let(:coll_5_noaccess) { create(:private_collection, id: 'col-5-no_access', title: ['Other user created'], user: other, create_access: true) }
|
27
30
|
|
28
31
|
describe '#update_members' do
|
29
32
|
context 'when user created the collection' do
|
@@ -95,7 +98,7 @@ RSpec.describe Hyrax::Dashboard::CollectionMembersController, :clean_repo do
|
|
95
98
|
end
|
96
99
|
|
97
100
|
context 'and user adds a subcollection' do
|
98
|
-
let(:parent_collection) { create(:
|
101
|
+
let(:parent_collection) { create(:private_collection_lw, id: 'pcol', title: ['User created another'], user: user, with_permission_template: true) }
|
99
102
|
|
100
103
|
it 'adds collection user created' do
|
101
104
|
expect do
|
@@ -209,8 +212,8 @@ RSpec.describe Hyrax::Dashboard::CollectionMembersController, :clean_repo do
|
|
209
212
|
|
210
213
|
context 'and user adds a subcollection' do
|
211
214
|
let(:parent_collection) do
|
212
|
-
create(:
|
213
|
-
|
215
|
+
create(:private_collection_lw, id: 'pcol-mgr', title: ['User has manage access to another'], user: other,
|
216
|
+
with_permission_template: { manage_users: [user] })
|
214
217
|
end
|
215
218
|
|
216
219
|
it 'adds collection user created' do
|
@@ -325,8 +328,8 @@ RSpec.describe Hyrax::Dashboard::CollectionMembersController, :clean_repo do
|
|
325
328
|
|
326
329
|
context 'and user adds a subcollection' do
|
327
330
|
let(:parent_collection) do
|
328
|
-
create(:
|
329
|
-
|
331
|
+
create(:private_collection_lw, id: 'pcol-dep', title: ['User has deposit access to another'], user: other,
|
332
|
+
with_permission_template: { deposit_users: [user] })
|
330
333
|
end
|
331
334
|
|
332
335
|
it 'adds collection user created' do
|
@@ -5,16 +5,16 @@ RSpec.describe Hyrax::Dashboard::CollectionsController, :clean_repo do
|
|
5
5
|
let(:collection_type_gid) { create(:user_collection_type).gid }
|
6
6
|
|
7
7
|
let(:collection) do
|
8
|
-
create(:
|
9
|
-
|
10
|
-
|
8
|
+
create(:public_collection_lw, title: ["My collection"],
|
9
|
+
description: ["My incredibly detailed description of the collection"],
|
10
|
+
user: user)
|
11
11
|
end
|
12
12
|
|
13
13
|
let(:asset1) { create(:work, title: ["First of the Assets"], user: user) }
|
14
14
|
let(:asset2) { create(:work, title: ["Second of the Assets"], user: user) }
|
15
15
|
let(:asset3) { create(:work, title: ["Third of the Assets"], user: user) }
|
16
|
-
let(:asset4) {
|
17
|
-
let(:asset5) {
|
16
|
+
let(:asset4) { build(:collection_lw, title: ["First subcollection"], user: user) }
|
17
|
+
let(:asset5) { build(:collection_lw, title: ["Second subcollection"], user: user) }
|
18
18
|
let(:unowned_asset) { create(:work, user: other) }
|
19
19
|
|
20
20
|
let(:collection_attrs) do
|
@@ -82,7 +82,7 @@ RSpec.describe Hyrax::Dashboard::CollectionsController, :clean_repo do
|
|
82
82
|
}
|
83
83
|
|
84
84
|
expect(assigns[:collection].member_objects).to eq [asset1]
|
85
|
-
asset_results = ActiveFedora::SolrService.instance.conn.get "select", params: { fq: ["id:\"#{asset1.id}\""], fl: ['id',
|
85
|
+
asset_results = ActiveFedora::SolrService.instance.conn.get "select", params: { fq: ["id:\"#{asset1.id}\""], fl: ['id', ActiveFedora.index_field_mapper.solr_name(:collection)] }
|
86
86
|
expect(asset_results["response"]["numFound"]).to eq 1
|
87
87
|
doc = asset_results["response"]["docs"].first
|
88
88
|
expect(doc["id"]).to eq asset1.id
|
@@ -112,7 +112,7 @@ RSpec.describe Hyrax::Dashboard::CollectionsController, :clean_repo do
|
|
112
112
|
end
|
113
113
|
|
114
114
|
context "when params includes parent_id" do
|
115
|
-
let(:parent_collection) { create(:
|
115
|
+
let(:parent_collection) { create(:collection_lw, title: ['Parent']) }
|
116
116
|
|
117
117
|
it "creates a collection as a subcollection of parent" do
|
118
118
|
parent_collection
|
@@ -189,7 +189,7 @@ RSpec.describe Hyrax::Dashboard::CollectionsController, :clean_repo do
|
|
189
189
|
let(:asset1) { create(:generic_work, user: user) }
|
190
190
|
let(:asset2) { create(:generic_work, user: user) }
|
191
191
|
let(:asset3) { create(:generic_work, user: user) }
|
192
|
-
let(:collection2) { create(:
|
192
|
+
let(:collection2) { create(:collection_lw, title: ['Some Collection'], user: user) }
|
193
193
|
|
194
194
|
before do
|
195
195
|
[asset1, asset2, asset3].each do |asset|
|
@@ -233,7 +233,7 @@ RSpec.describe Hyrax::Dashboard::CollectionsController, :clean_repo do
|
|
233
233
|
end
|
234
234
|
|
235
235
|
context "when update fails" do
|
236
|
-
let(:collection) {
|
236
|
+
let(:collection) { build(:collection_lw, id: '12345') }
|
237
237
|
let(:repository) { instance_double(Blacklight::Solr::Repository, search: result) }
|
238
238
|
let(:result) { double(documents: [], total: 0) }
|
239
239
|
|
@@ -2,7 +2,7 @@ RSpec.describe Hyrax::Dashboard::NestCollectionsController do
|
|
2
2
|
routes { Hyrax::Engine.routes }
|
3
3
|
let(:child_id) { 'child1' }
|
4
4
|
let(:child) { instance_double(Collection, title: ["Awesome Child"]) }
|
5
|
-
let(:parent) { create(:
|
5
|
+
let(:parent) { create(:collection_lw, id: 'parent1', collection_type_settings: :nestable, title: ["Uncool Parent"]) }
|
6
6
|
|
7
7
|
describe '#blacklight_config' do
|
8
8
|
subject { controller.blacklight_config }
|
@@ -534,7 +534,7 @@ RSpec.describe Hyrax::GenericWorksController do
|
|
534
534
|
|
535
535
|
describe '#destroy' do
|
536
536
|
let(:work_to_be_deleted) { create(:private_generic_work, user: user) }
|
537
|
-
let(:parent_collection) {
|
537
|
+
let(:parent_collection) { build(:collection_lw) }
|
538
538
|
|
539
539
|
it 'deletes the work' do
|
540
540
|
delete :destroy, params: { id: work_to_be_deleted }
|
@@ -618,5 +618,14 @@ RSpec.describe Hyrax::GenericWorksController do
|
|
618
618
|
get :manifest, params: { id: work, format: :html }
|
619
619
|
expect(response.body).to eq "{\"test\":\"manifest\"}"
|
620
620
|
end
|
621
|
+
|
622
|
+
describe "when there are html tags in the labels or description" do
|
623
|
+
let(:manifest_factory) { double(to_h: { label: "The title<img src=xx:x onerror=eval('\x61ler\x74(1)') />", description: ["Some description <script>something</script> here..."] }) }
|
624
|
+
|
625
|
+
it "sanitizes the labels and description" do
|
626
|
+
get :manifest, params: { id: work, format: :json }
|
627
|
+
expect(response.body).to include "{\"label\":\"The title\\u003cimg\\u003e\",\"description\":[\"Some description here...\"]}"
|
628
|
+
end
|
629
|
+
end
|
621
630
|
end
|
622
631
|
end
|
@@ -48,7 +48,7 @@ RSpec.describe Hyrax::HomepageController, type: :controller do
|
|
48
48
|
it "includes only GenericWork objects in recent documents" do
|
49
49
|
get :index
|
50
50
|
assigns(:recent_documents).each do |doc|
|
51
|
-
expect(doc[
|
51
|
+
expect(doc[ActiveFedora.index_field_mapper.solr_name("has_model", :symbol)]).to eql ["GenericWork"]
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
@@ -60,8 +60,8 @@ RSpec.describe Hyrax::HomepageController, type: :controller do
|
|
60
60
|
old_to_solr = gw3.method(:to_solr)
|
61
61
|
allow(gw3).to receive(:to_solr) do
|
62
62
|
old_to_solr.call.merge(
|
63
|
-
|
64
|
-
|
63
|
+
ActiveFedora.index_field_mapper.solr_name('system_create', :stored_sortable, type: :date) => 1.day.ago.iso8601,
|
64
|
+
ActiveFedora.index_field_mapper.solr_name('date_uploaded', :stored_sortable, type: :date) => 1.day.ago.iso8601
|
65
65
|
)
|
66
66
|
end
|
67
67
|
gw3.save
|
@@ -15,7 +15,7 @@ RSpec.describe Hyrax::My::SharesController, type: :controller do
|
|
15
15
|
let!(:shared_with_me) { create(:work, user: other_user, edit_users: [user, other_user]) }
|
16
16
|
let!(:read_shared_with_me) { create(:work, user: other_user, read_users: [user, other_user]) }
|
17
17
|
let!(:shared_with_someone_else) { create(:work, user: other_user, edit_users: [someone_else, other_user]) }
|
18
|
-
let!(:my_collection) { create(:
|
18
|
+
let!(:my_collection) { create(:public_collection_lw, user: user) }
|
19
19
|
|
20
20
|
it "responds with success" do
|
21
21
|
get :index
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
# Integration tests for the full midddleware stack
|
4
|
+
RSpec.describe Hyrax::DefaultMiddlewareStack, :clean_repo do
|
5
|
+
subject(:actor) { stack.build(Hyrax::Actors::Terminator.new) }
|
6
|
+
let(:ability) { ::Ability.new(user) }
|
7
|
+
let(:attributes) { {} }
|
8
|
+
let(:stack) { described_class.build_stack }
|
9
|
+
let(:terminator) { Hyrax::Actors::Terminator.new }
|
10
|
+
let(:user) { FactoryBot.create(:user) }
|
11
|
+
let(:work) { FactoryBot.build(:work) }
|
12
|
+
let(:env) { Hyrax::Actors::Environment.new(work, ability, attributes) }
|
13
|
+
|
14
|
+
let(:delayed_failure_actor) do
|
15
|
+
Class.new(Hyrax::Actors::AbstractActor) do
|
16
|
+
def create(env)
|
17
|
+
next_actor.create(env) && raise('ALWAYS RAISE')
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe '#create' do
|
23
|
+
it 'persists the work' do
|
24
|
+
expect { actor.create(env) }
|
25
|
+
.to change { work.persisted? }
|
26
|
+
.to true
|
27
|
+
end
|
28
|
+
|
29
|
+
context 'when failing on the way back up the actor stack' do
|
30
|
+
before { stack.insert_before(Hyrax::Actors::ModelActor, delayed_failure_actor) }
|
31
|
+
|
32
|
+
before(:context) do
|
33
|
+
Hyrax.config.enable_noids = true
|
34
|
+
# we need to mint once to set the `rand` database column and
|
35
|
+
# make minter behavior predictable
|
36
|
+
::Noid::Rails.config.minter_class.new.mint
|
37
|
+
end
|
38
|
+
|
39
|
+
after(:context) { Hyrax.config.enable_noids = false }
|
40
|
+
|
41
|
+
it 'leaves a valid minter state', :aggregate_failures do
|
42
|
+
expect { actor.create(env) }.to raise_error 'ALWAYS RAISE'
|
43
|
+
|
44
|
+
expect(GenericWork.new.assign_id).not_to eq work.id
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -14,7 +14,7 @@ RSpec.describe 'catalog searching', type: :feature do
|
|
14
14
|
create(:public_work, title: ["Jack's Research"], keyword: ['jacks_keyword', 'shared_keyword'])
|
15
15
|
end
|
16
16
|
|
17
|
-
let!(:collection) { create(:
|
17
|
+
let!(:collection) { create(:public_collection_lw, keyword: ['collection_keyword', 'shared_keyword']) }
|
18
18
|
|
19
19
|
it 'performing a search' do
|
20
20
|
within('#search-form-header') do
|
@@ -30,7 +30,7 @@ RSpec.describe 'catalog searching', type: :feature do
|
|
30
30
|
end
|
31
31
|
|
32
32
|
context 'with public works and private collections', clean_repo: true do
|
33
|
-
let!(:collection) {
|
33
|
+
let!(:collection) { build(:private_collection_lw) }
|
34
34
|
|
35
35
|
let!(:jills_work) do
|
36
36
|
create(:public_work, title: ["Jill's Research"], keyword: ['jills_keyword'], member_of_collections: [collection])
|
@@ -11,7 +11,7 @@ RSpec.describe 'Adding a work to multiple collections', type: :feature, clean_re
|
|
11
11
|
end
|
12
12
|
|
13
13
|
describe 'when both collections support multiple membership' do
|
14
|
-
let(:old_collection) {
|
14
|
+
let(:old_collection) { build(:collection_lw, user: admin_user, collection_type_gid: multi_membership_type_1.gid, title: ['OldCollectionTitle']) }
|
15
15
|
let!(:work) { create(:generic_work, user: admin_user, member_of_collections: [old_collection], title: ['The highly valued work that everyone wants in their collection']) }
|
16
16
|
|
17
17
|
context 'and are of different types' do
|
@@ -56,7 +56,7 @@ RSpec.describe 'Adding a work to multiple collections', type: :feature, clean_re
|
|
56
56
|
end
|
57
57
|
|
58
58
|
describe 'when both collections require single membership' do
|
59
|
-
let(:old_collection) {
|
59
|
+
let(:old_collection) { build(:collection_lw, user: admin_user, collection_type_gid: single_membership_type_1.gid, title: ['OldCollectionTitle']) }
|
60
60
|
let!(:work) do
|
61
61
|
create(:generic_work,
|
62
62
|
user: admin_user,
|
@@ -1,17 +1,17 @@
|
|
1
1
|
RSpec.describe 'collection', type: :feature, clean_repo: true do
|
2
2
|
let(:user) { create(:user) }
|
3
3
|
|
4
|
-
let(:collection1) { create(:
|
5
|
-
let(:collection2) { create(:
|
4
|
+
let(:collection1) { create(:public_collection_lw, user: user) }
|
5
|
+
let(:collection2) { create(:public_collection_lw, user: user) }
|
6
6
|
|
7
7
|
describe 'collection show page' do
|
8
8
|
let(:collection) do
|
9
|
-
create(:
|
9
|
+
create(:public_collection_lw, user: user, description: ['collection description'], collection_type_settings: :nestable)
|
10
10
|
end
|
11
11
|
let!(:work1) { create(:work, title: ["King Louie"], member_of_collections: [collection], user: user) }
|
12
12
|
let!(:work2) { create(:work, title: ["King Kong"], member_of_collections: [collection], user: user) }
|
13
|
-
let!(:col1) { create(:
|
14
|
-
let!(:col2) { create(:
|
13
|
+
let!(:col1) { create(:public_collection_lw, title: ["Sub-collection 1"], member_of_collections: [collection], user: user) }
|
14
|
+
let!(:col2) { create(:public_collection_lw, title: ["Sub-collection 2"], member_of_collections: [collection], user: user) }
|
15
15
|
|
16
16
|
before do
|
17
17
|
sign_in user
|
@@ -90,7 +90,7 @@ RSpec.describe 'collection', type: :feature, clean_repo: true do
|
|
90
90
|
|
91
91
|
sign_in user
|
92
92
|
end
|
93
|
-
let(:collection) { create(:
|
93
|
+
let(:collection) { create(:named_collection_lw, user: user) }
|
94
94
|
|
95
95
|
it "shows a collection with a listing of Descriptive Metadata and catalog-style search results" do
|
96
96
|
visit "/collections/#{collection.id}"
|
@@ -112,7 +112,7 @@ RSpec.describe 'collection', type: :feature, clean_repo: true do
|
|
112
112
|
|
113
113
|
sign_in user
|
114
114
|
end
|
115
|
-
let(:collection) { create(:
|
115
|
+
let(:collection) { create(:named_collection_lw, user: user) }
|
116
116
|
|
117
117
|
it "shows a collection with a listing of Descriptive Metadata and catalog-style search results" do
|
118
118
|
visit "/collections/#{collection.id}"
|