hyrax 3.0.0.pre.beta1 → 3.0.0.pre.beta2

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.
Files changed (170) hide show
  1. checksums.yaml +5 -5
  2. data/.circleci/config.yml +157 -68
  3. data/.travis.yml +4 -1
  4. data/Gemfile +1 -0
  5. data/README.md +3 -3
  6. data/app/actors/hyrax/actors/collections_membership_actor.rb +5 -55
  7. data/app/actors/hyrax/actors/create_with_remote_files_ordered_members_actor.rb +6 -8
  8. data/app/actors/hyrax/actors/environment.rb +15 -0
  9. data/app/actors/hyrax/actors/interpret_visibility_actor.rb +22 -37
  10. data/app/assets/javascripts/hyrax/editor/controlled_vocabulary.es6 +1 -1
  11. data/app/assets/stylesheets/hyrax/_collections.scss +5 -3
  12. data/app/assets/stylesheets/hyrax/dashboard.scss +3 -3
  13. data/app/controllers/concerns/hyrax/works_controller_behavior.rb +21 -2
  14. data/app/controllers/hyrax/homepage_controller.rb +1 -1
  15. data/app/forms/hyrax/forms/work_form.rb +1 -1
  16. data/app/helpers/hyrax/collections_helper.rb +13 -0
  17. data/app/helpers/hyrax/hyrax_helper_behavior.rb +3 -3
  18. data/app/indexers/hyrax/admin_set_indexer.rb +1 -1
  19. data/app/indexers/hyrax/basic_metadata_indexer.rb +1 -1
  20. data/app/indexers/hyrax/collection_indexer.rb +3 -3
  21. data/app/indexers/hyrax/deep_indexing_service.rb +12 -12
  22. data/app/indexers/hyrax/file_set_indexer.rb +1 -1
  23. data/app/indexers/hyrax/indexes_workflow.rb +4 -4
  24. data/app/indexers/hyrax/work_indexer.rb +1 -1
  25. data/app/models/concerns/hyrax/basic_metadata.rb +2 -0
  26. data/app/models/concerns/hyrax/collection_behavior.rb +3 -3
  27. data/app/models/concerns/hyrax/file_set/querying.rb +1 -1
  28. data/app/models/concerns/hyrax/human_readable_type.rb +2 -2
  29. data/app/models/concerns/hyrax/solr_document/characterization.rb +23 -23
  30. data/app/models/concerns/hyrax/solr_document/metadata.rb +3 -2
  31. data/app/models/concerns/hyrax/solr_document_behavior.rb +3 -3
  32. data/app/models/concerns/hyrax/user.rb +10 -2
  33. data/app/presenters/hyrax/work_show_presenter.rb +2 -2
  34. data/app/renderers/hyrax/renderers/faceted_attribute_renderer.rb +1 -1
  35. data/app/search_builders/hyrax/collection_search_builder.rb +1 -1
  36. data/app/search_builders/hyrax/deposit_search_builder.rb +1 -1
  37. data/app/search_builders/hyrax/embargo_search_builder.rb +1 -1
  38. data/app/search_builders/hyrax/lease_search_builder.rb +1 -1
  39. data/app/services/hyrax/default_middleware_stack.rb +0 -4
  40. data/app/services/hyrax/statistics/file_sets/by_format.rb +1 -1
  41. data/app/services/hyrax/statistics/works/by_resource_type.rb +1 -1
  42. data/app/services/hyrax/visibility_intention.rb +78 -0
  43. data/app/views/catalog/_index_list_default.html.erb +3 -3
  44. data/app/views/catalog/_thumbnail_list_collection.html.erb +3 -2
  45. data/app/views/hyrax/base/_attribute_rows.html.erb +1 -0
  46. data/app/views/hyrax/base/_form_files.html.erb +2 -2
  47. data/app/views/hyrax/base/_form_visibility_component.html.erb +1 -1
  48. data/app/views/hyrax/base/_show_actions.html.erb +6 -6
  49. data/app/views/hyrax/base/show.html.erb +2 -2
  50. data/app/views/hyrax/batch_edits/_check_all.html.erb +1 -1
  51. data/app/views/hyrax/batch_edits/_delete_selected.html.erb +1 -1
  52. data/app/views/hyrax/collections/_show_document_list_row.html.erb +1 -1
  53. data/app/views/hyrax/dashboard/collections/_show_document_list_row.html.erb +1 -1
  54. data/app/views/hyrax/dashboard/show_admin.html.erb +4 -4
  55. data/app/views/records/show_fields/_based_near.html.erb +1 -1
  56. data/app/views/records/show_fields/_creator.html.erb +1 -1
  57. data/app/views/records/show_fields/_keyword.html.erb +1 -1
  58. data/app/views/records/show_fields/_language.html.erb +1 -1
  59. data/app/views/records/show_fields/_publisher.html.erb +1 -1
  60. data/app/views/records/show_fields/_resource_type.html.erb +1 -1
  61. data/app/views/records/show_fields/_subject.html.erb +1 -1
  62. data/config/initializers/samvera-nesting_indexer_initializer.rb +3 -3
  63. data/config/locales/hyrax.de.yml +35 -22
  64. data/config/locales/hyrax.en.yml +22 -2
  65. data/config/locales/hyrax.es.yml +21 -1
  66. data/config/locales/hyrax.fr.yml +21 -1
  67. data/config/locales/hyrax.it.yml +21 -1
  68. data/config/locales/hyrax.pt-BR.yml +21 -1
  69. data/config/locales/hyrax.zh.yml +21 -1
  70. data/hyrax.gemspec +7 -9
  71. data/lib/generators/hyrax/templates/catalog_controller.rb +1 -1
  72. data/lib/generators/hyrax/templates/config/locales/hyrax.pt-BR.yml +10 -10
  73. data/lib/generators/hyrax/work/templates/locale.pt-BR.yml.erb +1 -1
  74. data/lib/hyrax/configuration.rb +18 -0
  75. data/lib/hyrax/engine.rb +8 -0
  76. data/lib/hyrax/transactions/container.rb +6 -0
  77. data/lib/hyrax/transactions/destroy_work.rb +21 -0
  78. data/lib/hyrax/transactions/steps/destroy_work.rb +24 -0
  79. data/lib/hyrax/version.rb +1 -1
  80. data/lib/wings.rb +45 -0
  81. data/lib/wings/active_fedora_converter.rb +56 -0
  82. data/lib/wings/model_transformer.rb +158 -0
  83. data/lib/wings/resource_factory.rb +8 -0
  84. data/lib/wings/valkyrie/metadata_adapter.rb +29 -0
  85. data/lib/wings/valkyrie/persister.rb +50 -0
  86. data/lib/wings/valkyrie/query_service.rb +43 -0
  87. data/lib/wings/valkyrie/resource_factory.rb +45 -0
  88. data/lib/wings/valkyrizable.rb +24 -0
  89. data/lib/wings/value_mapper.rb +59 -0
  90. data/spec/abilities/collection_ability_spec.rb +5 -5
  91. data/spec/abilities/permission_template_ability_spec.rb +1 -1
  92. data/spec/actors/hyrax/actors/collections_membership_actor_spec.rb +6 -175
  93. data/spec/actors/hyrax/actors/create_with_remote_files_ordered_members_actor_spec.rb +30 -22
  94. data/spec/actors/hyrax/actors/interpret_visibility_actor_spec.rb +2 -0
  95. data/spec/controllers/catalog_controller_spec.rb +1 -1
  96. data/spec/controllers/hyrax/admin/collection_types_controller_spec.rb +1 -1
  97. data/spec/controllers/hyrax/batch_edits_controller_spec.rb +9 -9
  98. data/spec/controllers/hyrax/collections_controller_spec.rb +5 -5
  99. data/spec/controllers/hyrax/dashboard/collection_members_controller_spec.rb +16 -13
  100. data/spec/controllers/hyrax/dashboard/collections_controller_spec.rb +9 -9
  101. data/spec/controllers/hyrax/dashboard/nest_collections_controller_spec.rb +1 -1
  102. data/spec/controllers/hyrax/generic_works_controller_spec.rb +10 -1
  103. data/spec/controllers/hyrax/homepage_controller_spec.rb +3 -3
  104. data/spec/controllers/hyrax/my/shares_controller_spec.rb +1 -1
  105. data/spec/features/actor_stack_spec.rb +48 -0
  106. data/spec/features/catalog_search_spec.rb +2 -2
  107. data/spec/features/collection_multi_membership_spec.rb +2 -2
  108. data/spec/features/collection_spec.rb +7 -7
  109. data/spec/features/collection_type_spec.rb +2 -2
  110. data/spec/features/dashboard/collection_spec.rb +18 -18
  111. data/spec/features/delete_work_spec.rb +1 -1
  112. data/spec/features/search_spec.rb +2 -2
  113. data/spec/features/work_show_spec.rb +5 -2
  114. data/spec/forms/hyrax/forms/batch_upload_form_spec.rb +1 -0
  115. data/spec/forms/hyrax/forms/collection_form_spec.rb +5 -5
  116. data/spec/forms/hyrax/forms/permission_template_form_spec.rb +1 -1
  117. data/spec/forms/hyrax/forms/work_form_spec.rb +2 -0
  118. data/spec/helpers/blacklight_helper_spec.rb +3 -1
  119. data/spec/helpers/hyrax/collections_helper_spec.rb +42 -0
  120. data/spec/helpers/hyrax/dashboard_helper_behavior_spec.rb +4 -4
  121. data/spec/helpers/hyrax_helper_spec.rb +8 -4
  122. data/spec/hyrax/transactions/destroy_work_spec.rb +35 -0
  123. data/spec/hyrax/transactions/steps/destroy_work_spec.rb +33 -0
  124. data/spec/indexers/hyrax/collection_indexer_spec.rb +1 -1
  125. data/spec/jobs/characterize_job_spec.rb +1 -1
  126. data/spec/lib/hyrax/resource_sync/change_list_writer_spec.rb +35 -21
  127. data/spec/lib/hyrax/resource_sync/resource_list_writer_spec.rb +1 -1
  128. data/spec/models/collection_spec.rb +18 -18
  129. data/spec/models/concerns/hyrax/collection_nesting_spec.rb +2 -2
  130. data/spec/models/file_set_spec.rb +2 -2
  131. data/spec/models/hyrax/collection_type_spec.rb +2 -2
  132. data/spec/models/user_spec.rb +26 -1
  133. data/spec/presenters/hyrax/collection_presenter_spec.rb +11 -11
  134. data/spec/presenters/hyrax/work_show_presenter_spec.rb +11 -0
  135. data/spec/search_builders/hyrax/collection_member_search_builder_spec.rb +1 -1
  136. data/spec/search_builders/hyrax/collection_search_builder_spec.rb +1 -1
  137. data/spec/search_builders/hyrax/dashboard/nested_collections_search_builder_spec.rb +1 -1
  138. data/spec/search_builders/hyrax/work_relation_spec.rb +1 -1
  139. data/spec/services/hyrax/adapters/nesting_index_adapter_spec.rb +2 -2
  140. data/spec/services/hyrax/collections/collection_member_service_spec.rb +2 -2
  141. data/spec/services/hyrax/collections/migration_service_spec.rb +27 -27
  142. data/spec/services/hyrax/collections/nested_collection_persistence_service_spec.rb +1 -1
  143. data/spec/services/hyrax/collections/nested_collection_query_service_spec.rb +38 -38
  144. data/spec/services/hyrax/curation_concern_spec.rb +1 -1
  145. data/spec/services/hyrax/default_middleware_stack_spec.rb +1 -2
  146. data/spec/services/hyrax/statistics/depositors/summary_spec.rb +1 -1
  147. data/spec/services/hyrax/statistics/works/by_resource_type_spec.rb +11 -4
  148. data/spec/services/hyrax/visibility_intention_spec.rb +144 -0
  149. data/spec/services/hyrax/workflow/changes_required_notification_spec.rb +1 -1
  150. data/spec/spec_helper.rb +10 -8
  151. data/spec/support/selectors.rb +10 -1
  152. data/spec/test_app_templates/Gemfile.extra +2 -0
  153. data/spec/test_app_templates/lib/generators/test_app_generator.rb +6 -0
  154. data/spec/views/catalog/_index_list_default.html.erb_spec.rb +3 -2
  155. data/spec/views/catalog/_thumbnail_list_collection.html.erb_spec.rb +38 -5
  156. data/spec/views/hyrax/base/_attributes.html.erb_spec.rb +1 -1
  157. data/spec/views/hyrax/base/_show_actions.html.erb_spec.rb +9 -9
  158. data/spec/views/hyrax/base/show.html.erb_spec.rb +3 -2
  159. data/spec/views/hyrax/collections/_show_document_list_row.html.erb_spec.rb +3 -2
  160. data/spec/views/hyrax/dashboard/collections/_show_document_list_row.html.erb_spec.rb +3 -2
  161. data/spec/wings/active_fedora_converter_spec.rb +31 -0
  162. data/spec/wings/model_transformer_spec.rb +288 -0
  163. data/spec/wings/valkyrie/metadata_adapter_spec.rb +10 -0
  164. data/spec/wings/valkyrie/persister_spec.rb +71 -0
  165. data/spec/wings/valkyrie/query_service_spec.rb +81 -0
  166. data/spec/wings/valkyrie/resource_factory_spec.rb +32 -0
  167. data/spec/wings/value_mapper_spec.rb +60 -0
  168. data/spec/wings_spec.rb +8 -0
  169. data/template.rb +3 -1
  170. metadata +86 -36
@@ -292,7 +292,7 @@ RSpec.describe 'collection_type', type: :feature, clean_repo: true do
292
292
  end
293
293
 
294
294
  context 'when collections exist of this type' do
295
- let!(:collection1) { create(:public_collection, user: build(:user), collection_type_gid: exhibit_collection_type.gid) }
295
+ let!(:collection1) { create(:public_collection_lw, user: build(:user), collection_type_gid: exhibit_collection_type.gid) }
296
296
 
297
297
  before do
298
298
  exhibit_collection_type
@@ -352,7 +352,7 @@ RSpec.describe 'collection_type', type: :feature, clean_repo: true do
352
352
 
353
353
  context 'when collections exist of this type' do
354
354
  let!(:not_empty_collection_type) { create(:collection_type, title: 'Not Empty Type', creator_user: admin_user) }
355
- let!(:collection1) { create(:public_collection, user: admin_user, collection_type_gid: not_empty_collection_type.gid) }
355
+ let!(:collection1) { create(:public_collection_lw, user: admin_user, collection_type_gid: not_empty_collection_type.gid) }
356
356
  let(:deny_delete_modal_text) do
357
357
  'You cannot delete this collection type because one or more collections of this type have already been created. ' \
358
358
  'To delete this collection type, first ensure that all collections of this type have been deleted.'
@@ -11,10 +11,10 @@ RSpec.describe 'collection', type: :feature, clean_repo: true do
11
11
  # Setting Title on admin sets to avoid false positive matches with collections.
12
12
  let(:admin_set_a) { create(:admin_set, creator: [admin_user.user_key], title: ['Set A'], with_permission_template: true) }
13
13
  let(:admin_set_b) { create(:admin_set, creator: [user.user_key], title: ['Set B'], edit_users: [user.user_key], with_permission_template: true) }
14
- let(:collection1) { create(:public_collection, user: user, collection_type_gid: collection_type.gid, create_access: true) }
15
- let(:collection2) { create(:public_collection, user: user, collection_type_gid: collection_type.gid, create_access: true) }
16
- let(:collection3) { create(:public_collection, user: admin_user, collection_type_gid: collection_type.gid, create_access: true) }
17
- let(:collection4) { create(:public_collection, user: admin_user, collection_type_gid: user_collection_type.gid, create_access: true) }
14
+ let(:collection1) { create(:public_collection_lw, user: user, collection_type_gid: collection_type.gid, with_permission_template: true) }
15
+ let(:collection2) { create(:public_collection_lw, user: user, collection_type_gid: collection_type.gid, with_permission_template: true) }
16
+ let(:collection3) { create(:public_collection_lw, user: admin_user, collection_type_gid: collection_type.gid, with_permission_template: true) }
17
+ let(:collection4) { create(:public_collection_lw, user: admin_user, collection_type_gid: user_collection_type.gid, with_permission_template: true) }
18
18
 
19
19
  describe 'Your Collections tab' do
20
20
  context 'when non-admin user' do
@@ -250,7 +250,7 @@ RSpec.describe 'collection', type: :feature, clean_repo: true do
250
250
  expect(page).to have_selector "input.collection_creator.multi_value"
251
251
 
252
252
  fill_in('Title', with: title)
253
- fill_in('Abstract or Summary', with: description)
253
+ fill_in('Description', with: description)
254
254
  fill_in('Related URL', with: 'http://example.com/')
255
255
 
256
256
  click_button("Save")
@@ -281,7 +281,7 @@ RSpec.describe 'collection', type: :feature, clean_repo: true do
281
281
  expect(page).to have_selector "input.collection_creator.multi_value"
282
282
 
283
283
  fill_in('Title', with: title)
284
- fill_in('Abstract or Summary', with: description)
284
+ fill_in('Description', with: description)
285
285
  fill_in('Related URL', with: 'http://example.com/')
286
286
 
287
287
  click_button("Save")
@@ -328,8 +328,8 @@ RSpec.describe 'collection', type: :feature, clean_repo: true do
328
328
  end
329
329
 
330
330
  describe 'delete collection' do
331
- let!(:empty_collection) { create(:public_collection, title: ['Empty Collection'], user: user, create_access: true) }
332
- let!(:collection) { create(:public_collection, title: ['Collection with Work'], user: user, create_access: true) }
331
+ let!(:empty_collection) { create(:public_collection_lw, title: ['Empty Collection'], user: user, with_permission_template: true) }
332
+ let!(:collection) { create(:public_collection_lw, title: ['Collection with Work'], user: user, with_permission_template: true) }
333
333
  let!(:admin_user) { create(:admin) }
334
334
  let!(:empty_adminset) { create(:admin_set, title: ['Empty Admin Set'], creator: [admin_user.user_key], with_permission_template: true) }
335
335
  let!(:adminset) { create(:admin_set, title: ['Admin Set with Work'], creator: [admin_user.user_key], with_permission_template: true) }
@@ -564,7 +564,7 @@ RSpec.describe 'collection', type: :feature, clean_repo: true do
564
564
 
565
565
  describe 'collection show page' do
566
566
  let(:collection) do
567
- create(:public_collection, user: user, description: ['collection description'], create_access: true)
567
+ build(:public_collection_lw, user: user, description: ['collection description'], with_permission_template: true)
568
568
  end
569
569
  let!(:work1) { create(:work, title: ["King Louie"], member_of_collections: [collection], user: user) }
570
570
  let!(:work2) { create(:work, title: ["King Kong"], member_of_collections: [collection], user: user) }
@@ -707,7 +707,7 @@ RSpec.describe 'collection', type: :feature, clean_repo: true do
707
707
 
708
708
  sign_in user
709
709
  end
710
- let(:collection) { create(:named_collection, user: user, create_access: true) }
710
+ let(:collection) { create(:named_collection_lw, user: user, with_permission_template: true) }
711
711
 
712
712
  it "shows a collection with a listing of Descriptive Metadata and catalog-style search results" do
713
713
  visit '/dashboard/my/collections'
@@ -762,7 +762,7 @@ RSpec.describe 'collection', type: :feature, clean_repo: true do
762
762
  end
763
763
 
764
764
  describe 'edit collection' do
765
- let(:collection) { create(:named_collection, user: user, create_access: true) }
765
+ let(:collection) { build(:named_collection_lw, user: user, with_permission_template: true) }
766
766
  let!(:work1) { create(:work, title: ["King Louie"], member_of_collections: [collection], user: user) }
767
767
  let!(:work2) { create(:work, title: ["King Kong"], member_of_collections: [collection], user: user) }
768
768
 
@@ -815,7 +815,7 @@ RSpec.describe 'collection', type: :feature, clean_repo: true do
815
815
  creators = ["Dorje Trollo", "Vajrayogini"]
816
816
 
817
817
  fill_in('Title', with: new_title)
818
- fill_in('Abstract or Summary', with: new_description)
818
+ fill_in('Description', with: new_description)
819
819
  fill_in('Creator', with: creators.first)
820
820
  within('.panel-footer') do
821
821
  click_button('Save changes')
@@ -856,8 +856,8 @@ RSpec.describe 'collection', type: :feature, clean_repo: true do
856
856
  end
857
857
 
858
858
  context 'with brandable set' do
859
- let(:brandable_collection_id) { create(:collection, user: user, collection_type_settings: [:brandable], create_access: true).id }
860
- let(:not_brandable_collection_id) { create(:collection, user: user, collection_type_settings: [:not_brandable], create_access: true).id }
859
+ let(:brandable_collection_id) { create(:collection_lw, user: user, collection_type_settings: [:brandable], with_permission_template: true).id }
860
+ let(:not_brandable_collection_id) { create(:collection_lw, user: user, collection_type_settings: [:not_brandable], with_permission_template: true).id }
861
861
 
862
862
  it 'to true, it shows Branding tab' do
863
863
  visit "/dashboard/collections/#{brandable_collection_id}/edit"
@@ -871,8 +871,8 @@ RSpec.describe 'collection', type: :feature, clean_repo: true do
871
871
  end
872
872
 
873
873
  context 'with discoverable set' do
874
- let(:discoverable_collection_id) { create(:collection, user: user, collection_type_settings: [:discoverable], create_access: true).id }
875
- let(:not_discoverable_collection_id) { create(:collection, user: user, collection_type_settings: [:not_discoverable], create_access: true).id }
874
+ let(:discoverable_collection_id) { create(:collection_lw, user: user, collection_type_settings: [:discoverable], with_permission_template: true).id }
875
+ let(:not_discoverable_collection_id) { create(:collection_lw, user: user, collection_type_settings: [:not_discoverable], with_permission_template: true).id }
876
876
 
877
877
  it 'to true, it shows Discovery tab' do
878
878
  visit "/dashboard/collections/#{discoverable_collection_id}/edit"
@@ -886,8 +886,8 @@ RSpec.describe 'collection', type: :feature, clean_repo: true do
886
886
  end
887
887
 
888
888
  context 'with sharable set' do
889
- let(:sharable_collection_id) { create(:collection, user: user, collection_type_settings: [:sharable], create_access: true).id }
890
- let(:not_sharable_collection_id) { create(:collection, user: user, collection_type_settings: [:not_sharable], create_access: true).id }
889
+ let(:sharable_collection_id) { create(:collection_lw, user: user, collection_type_settings: [:sharable], with_permission_template: true).id }
890
+ let(:not_sharable_collection_id) { create(:collection_lw, user: user, collection_type_settings: [:not_sharable], with_permission_template: true).id }
891
891
 
892
892
  it 'to true, it shows Sharable tab' do
893
893
  visit "/dashboard/collections/#{sharable_collection_id}/edit"
@@ -16,7 +16,7 @@ RSpec.describe 'Deleting a work', type: :feature do
16
16
  it 'redirects to my dashboard' do
17
17
  visit hyrax_generic_work_path(work)
18
18
  click_on('Delete', match: :first)
19
- expect(page).to have_current_path(hyrax.my_works_path, only_path: true)
19
+ expect(page).to have_current_path(hyrax.my_works_path, ignore_query: true)
20
20
  expect(page).to have_content 'Deleted Test title'
21
21
  end
22
22
  end
@@ -9,7 +9,7 @@ RSpec.describe 'searching' do
9
9
  end
10
10
 
11
11
  let!(:collection) do
12
- create(:public_collection, title: ['collection title abc'], description: [subject_value], user: user, members: [work])
12
+ create(:public_collection_lw, title: ['collection title abc'], description: [subject_value], user: user, members: [work])
13
13
  end
14
14
 
15
15
  context "as a public user", :clean_repo do
@@ -53,7 +53,7 @@ RSpec.describe 'searching' do
53
53
  expect(page).to have_content('Search Results')
54
54
  expect(page).to have_content "Toothbrush"
55
55
  expect(page).to have_content('collection title abc')
56
- expect(page).to have_css("span.collection-icon-search")
56
+ expect(page).to have_selector("//img")
57
57
 
58
58
  expect(page.body).to include "<span itemprop=\"keywords\"><a href=\"/catalog?f%5Bkeyword_sim%5D%5B%5D=taco&amp;locale=en\">taco</a></span>"
59
59
  expect(page.body).to include "<span itemprop=\"keywords\"><a href=\"/catalog?f%5Bkeyword_sim%5D%5B%5D=mustache&amp;locale=en\">mustache</a></span>"
@@ -53,11 +53,14 @@ RSpec.describe "work show view" do
53
53
  it "allows adding work to a collection", clean_repo: true, js: true do
54
54
  optional 'ability to get capybara to find css select2-result (see Issue #3038)' if ci_build?
55
55
  click_button "Add to collection" # opens the modal
56
- select_member_of_collection(collection)
56
+ # Really ensure that this Collection model is persisted
57
+ Collection.all.map(&:destroy!)
58
+ persisted_collection = create(:collection_lw, user: user, collection_type_gid: multi_membership_type_1.gid)
59
+ select_member_of_collection(persisted_collection)
57
60
  click_button 'Save changes'
58
61
 
59
62
  # forwards to collection show page
60
- expect(page).to have_content collection.title.first
63
+ expect(page).to have_content persisted_collection.title.first
61
64
  expect(page).to have_content work.title.first
62
65
  expect(page).to have_selector '.alert-success', text: 'Collection was successfully updated.'
63
66
  end
@@ -47,6 +47,7 @@ RSpec.describe Hyrax::Forms::BatchUploadForm do
47
47
  :keyword,
48
48
  :license,
49
49
  :rights_statement,
50
+ :rights_notes,
50
51
  :publisher,
51
52
  :date_created,
52
53
  :subject,
@@ -24,7 +24,7 @@ RSpec.describe Hyrax::Forms::CollectionForm do
24
24
  end
25
25
  end
26
26
 
27
- let(:collection) { build(:collection) }
27
+ let(:collection) { build(:collection_lw) }
28
28
  let(:ability) { Ability.new(create(:user)) }
29
29
  let(:repository) { double }
30
30
  let(:form) { described_class.new(collection, ability, repository) }
@@ -74,8 +74,8 @@ RSpec.describe Hyrax::Forms::CollectionForm do
74
74
  end
75
75
 
76
76
  context "nested relationships" do
77
- let(:child_collection) { build(:collection) }
78
- let(:parent_collection) { build(:collection) }
77
+ let(:child_collection) { build(:collection_lw) }
78
+ let(:parent_collection) { build(:collection_lw) }
79
79
  let(:service_object) { double(available_member_subcollections: double(documents: [child_collection])) }
80
80
 
81
81
  before do
@@ -174,7 +174,7 @@ RSpec.describe Hyrax::Forms::CollectionForm do
174
174
  subject { form.permission_template }
175
175
 
176
176
  context "when the PermissionTemplate doesn't exist" do
177
- let(:model) { create(:collection) }
177
+ let(:model) { build(:collection_lw) }
178
178
 
179
179
  it "gets created" do
180
180
  expect(subject).to be_instance_of Hyrax::Forms::PermissionTemplateForm
@@ -185,7 +185,7 @@ RSpec.describe Hyrax::Forms::CollectionForm do
185
185
  context "when the PermissionTemplate exists" do
186
186
  let(:form) { described_class.new(model, ability, repository) }
187
187
  let(:permission_template) { Hyrax::PermissionTemplate.find_by(source_id: model.id) }
188
- let(:model) { create(:collection, with_permission_template: true) }
188
+ let(:model) { build(:collection_lw, with_permission_template: true) }
189
189
 
190
190
  it "uses the existing template" do
191
191
  expect(subject).to be_instance_of Hyrax::Forms::PermissionTemplateForm
@@ -3,7 +3,7 @@ RSpec.describe Hyrax::Forms::PermissionTemplateForm do
3
3
  let(:form) { described_class.new(permission_template) }
4
4
  let(:today) { Time.zone.today }
5
5
  let(:admin_set) { create(:admin_set) }
6
- let(:collection) { create(:collection) }
6
+ let(:collection) { build(:collection_lw) }
7
7
 
8
8
  subject { form }
9
9
 
@@ -109,6 +109,7 @@ RSpec.describe Hyrax::Forms::WorkForm do
109
109
  keyword: ['penguin'],
110
110
  source: ['related'],
111
111
  rights_statement: 'http://rightsstatements.org/vocab/InC-EDU/1.0/',
112
+ rights_notes: ['Notes on the rights'],
112
113
  license: ['http://creativecommons.org/licenses/by/3.0/us/']
113
114
  }
114
115
  end
@@ -121,6 +122,7 @@ RSpec.describe Hyrax::Forms::WorkForm do
121
122
  expect(subject['visibility']).to eq 'open'
122
123
  expect(subject['license']).to eq ['http://creativecommons.org/licenses/by/3.0/us/']
123
124
  expect(subject['rights_statement']).to eq 'http://rightsstatements.org/vocab/InC-EDU/1.0/'
125
+ expect(subject['rights_notes']).to eq ['Notes on the rights']
124
126
  expect(subject['keyword']).to eq ['penguin']
125
127
  expect(subject['source']).to eq ['related']
126
128
  end
@@ -33,7 +33,9 @@ RSpec.describe BlacklightHelper, type: :helper do
33
33
  search_catalog_path(stuff)
34
34
  end
35
35
 
36
- subject { index_presenter(document).field_value field_name }
36
+ let(:presenter) { index_presenter(document) }
37
+ let(:field) { blacklight_config.index_fields.fetch(field_name) }
38
+ subject { presenter.field_value field }
37
39
 
38
40
  context "description_tesim" do
39
41
  let(:field_name) { 'description_tesim' }
@@ -47,6 +47,48 @@ RSpec.describe Hyrax::CollectionsHelper do
47
47
  end
48
48
  end
49
49
 
50
+ describe '#render_other_collection_links' do
51
+ before do
52
+ allow(controller).to receive(:current_ability).and_return(ability)
53
+ end
54
+
55
+ context 'when a GenericWork belongs to one collection' do
56
+ let(:coll_ids) { ['111'] }
57
+ let(:coll_titles) { ['Collection 111'] }
58
+ let(:coll1_attrs) { { id: coll_ids[0], title_tesim: [coll_titles[0]] } }
59
+ let!(:work_doc) { SolrDocument.new(id: '123', title_tesim: ['My GenericWork'], member_of_collection_ids_ssim: coll_ids) }
60
+
61
+ before do
62
+ ActiveFedora::SolrService.add(coll1_attrs)
63
+ ActiveFedora::SolrService.commit
64
+ end
65
+
66
+ it 'renders nothing' do
67
+ expect(helper.render_other_collection_links(work_doc, coll_ids[0])).to be_nil
68
+ end
69
+ end
70
+
71
+ context 'when a GenericWork belongs to more than one collection' do
72
+ let(:coll_ids) { ['111', '222'] }
73
+ let(:coll_titles) { ['Collection 111', 'Collection 222'] }
74
+ let(:coll1_attrs) { { id: coll_ids[0], title_tesim: [coll_titles[0]] } }
75
+ let(:coll2_attrs) { { id: coll_ids[1], title_tesim: [coll_titles[1]] } }
76
+ let!(:work_doc) { SolrDocument.new(id: '123', title_tesim: ['My GenericWork'], member_of_collection_ids_ssim: coll_ids) }
77
+
78
+ before do
79
+ ActiveFedora::SolrService.add(coll1_attrs)
80
+ ActiveFedora::SolrService.add(coll2_attrs)
81
+ ActiveFedora::SolrService.commit
82
+ end
83
+
84
+ it 'renders a list of links to the collections' do
85
+ expect(helper.render_other_collection_links(work_doc, coll_ids[0])).to match(/This work also belongs to/i)
86
+ expect(helper.render_other_collection_links(work_doc, coll_ids[0])).to match("href=\"/collections/#{coll_ids[1]}\"")
87
+ expect(helper.render_other_collection_links(work_doc, coll_ids[0])).to match(coll_titles[1])
88
+ end
89
+ end
90
+ end
91
+
50
92
  describe "has_collection_search_parameters?" do
51
93
  subject { helper }
52
94
 
@@ -62,13 +62,13 @@ RSpec.describe Hyrax::DashboardHelperBehavior, type: :helper do
62
62
  def create_models(model, user1, user2)
63
63
  # deposited by the first user
64
64
  3.times do |t|
65
- conn.add id: "199#{t}", Solrizer.solr_name('depositor', :stored_searchable) => user1.user_key, "has_model_ssim" => [model],
66
- Solrizer.solr_name('depositor', :symbol) => user1.user_key
65
+ conn.add id: "199#{t}", ActiveFedora.index_field_mapper.solr_name('depositor', :stored_searchable) => user1.user_key, "has_model_ssim" => [model],
66
+ ActiveFedora.index_field_mapper.solr_name('depositor', :symbol) => user1.user_key
67
67
  end
68
68
 
69
69
  # deposited by the second user, but editable by the first
70
- conn.add id: "1994", Solrizer.solr_name('depositor', :stored_searchable) => user2.user_key, "has_model_ssim" => [model],
71
- Solrizer.solr_name('depositor', :symbol) => user2.user_key, "edit_access_person_ssim" => user1.user_key
70
+ conn.add id: "1994", ActiveFedora.index_field_mapper.solr_name('depositor', :stored_searchable) => user2.user_key, "has_model_ssim" => [model],
71
+ ActiveFedora.index_field_mapper.solr_name('depositor', :symbol) => user2.user_key, "edit_access_person_ssim" => user1.user_key
72
72
  conn.commit
73
73
  end
74
74
  end
@@ -117,7 +117,7 @@ RSpec.describe HyraxHelper, type: :helper do
117
117
  subject { helper.link_to_each_facet_field(options) }
118
118
 
119
119
  context "with helper_facet and default separator" do
120
- let(:options) { { config: { helper_facet: Solrizer.solr_name("document_types", :facetable).to_sym }, value: ["Imaging > Object Photography"] } }
120
+ let(:options) { { config: { helper_facet: ActiveFedora.index_field_mapper.solr_name("document_types", :facetable).to_sym }, value: ["Imaging > Object Photography"] } }
121
121
 
122
122
  it do
123
123
  is_expected.to eq("<a href=\"/catalog?f%5Bdocument_types_sim%5D%5B%5D=Imaging\">" \
@@ -127,7 +127,7 @@ RSpec.describe HyraxHelper, type: :helper do
127
127
  end
128
128
 
129
129
  context "with helper_facet and optional separator" do
130
- let(:options) { { config: { helper_facet: Solrizer.solr_name("document_types", :facetable).to_sym, separator: " : " }, value: ["Imaging : Object Photography"] } }
130
+ let(:options) { { config: { helper_facet: ActiveFedora.index_field_mapper.solr_name("document_types", :facetable).to_sym, separator: " : " }, value: ["Imaging : Object Photography"] } }
131
131
 
132
132
  it do
133
133
  is_expected.to eq("<a href=\"/catalog?f%5Bdocument_types_sim%5D%5B%5D=Imaging\">" \
@@ -137,7 +137,9 @@ RSpec.describe HyraxHelper, type: :helper do
137
137
  end
138
138
 
139
139
  context "with :output_separator" do
140
- let(:options) { { config: { helper_facet: Solrizer.solr_name("document_types", :facetable).to_sym, output_separator: ' ~ ', separator: ":" }, value: ["Imaging : Object Photography"] } }
140
+ let(:options) do
141
+ { config: { helper_facet: ActiveFedora.index_field_mapper.solr_name("document_types", :facetable).to_sym, output_separator: ' ~ ', separator: ":" }, value: ["Imaging : Object Photography"] }
142
+ end
141
143
 
142
144
  it do
143
145
  is_expected.to eq("<a href=\"/catalog?f%5Bdocument_types_sim%5D%5B%5D=Imaging\">" \
@@ -147,7 +149,9 @@ RSpec.describe HyraxHelper, type: :helper do
147
149
  end
148
150
 
149
151
  context "with :no_spaces_around_separator" do
150
- let(:options) { { config: { helper_facet: Solrizer.solr_name("document_types", :facetable).to_sym, output_separator: '~', separator: ":" }, value: ["Imaging : Object Photography"] } }
152
+ let(:options) do
153
+ { config: { helper_facet: ActiveFedora.index_field_mapper.solr_name("document_types", :facetable).to_sym, output_separator: '~', separator: ":" }, value: ["Imaging : Object Photography"] }
154
+ end
151
155
 
152
156
  it do
153
157
  is_expected.to eq("<a href=\"/catalog?f%5Bdocument_types_sim%5D%5B%5D=Imaging\">" \
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+ require 'spec_helper'
3
+ require 'hyrax/transactions'
4
+
5
+ RSpec.describe Hyrax::Transactions::DestroyWork do
6
+ subject(:transaction) { described_class.new }
7
+ let(:work) { create(:generic_work) }
8
+
9
+ describe '#call' do
10
+ it 'is a success' do
11
+ expect(transaction.call(work)).to be_success
12
+ end
13
+
14
+ it 'destroys the work' do
15
+ expect { transaction.call(work) }
16
+ .to change { work.persisted? }
17
+ .from(true)
18
+ .to false
19
+ end
20
+
21
+ context 'with an unsaved work' do
22
+ let(:work) { build(:generic_work) }
23
+
24
+ it 'is a success' do
25
+ expect(transaction.call(work)).to be_success
26
+ end
27
+
28
+ it 'leaves the work unpersisted' do
29
+ expect { transaction.call(work) }
30
+ .not_to change { work.persisted? }
31
+ .from false
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+ require 'spec_helper'
3
+ require 'hyrax/transactions'
4
+
5
+ RSpec.describe Hyrax::Transactions::Steps::DestroyWork do
6
+ subject(:step) { described_class.new }
7
+ let(:work) { build(:generic_work) }
8
+
9
+ it 'is a success' do
10
+ expect(step.call(work)).to be_success
11
+ end
12
+
13
+ context 'with an existing work' do
14
+ let(:work) { create(:generic_work) }
15
+
16
+ it 'destroys the work' do
17
+ expect { step.call(work) }
18
+ .to change { work.persisted? }
19
+ .from(true)
20
+ .to false
21
+ end
22
+
23
+ context 'when destruction fails for an unknown reason' do
24
+ let(:message) { 'moomin message' }
25
+
26
+ before { allow(work).to receive(:destroy).and_raise(message) }
27
+
28
+ it 'is a failure' do
29
+ expect(step.call(work).failure).to have_attributes(message: message)
30
+ end
31
+ end
32
+ end
33
+ end
@@ -1,6 +1,6 @@
1
1
  RSpec.describe Hyrax::CollectionIndexer do
2
2
  let(:indexer) { described_class.new(collection) }
3
- let(:collection) { build(:collection) }
3
+ let(:collection) { build(:collection_lw) }
4
4
  let(:col1id) { 'col1' }
5
5
  let(:col2id) { 'col2' }
6
6
  let(:col1title) { 'col1 title' }
@@ -52,7 +52,7 @@ RSpec.describe CharacterizeJob do
52
52
 
53
53
  context "when the file set's work is in a collection" do
54
54
  let(:work) { build(:generic_work) }
55
- let(:collection) { build(:collection) }
55
+ let(:collection) { build(:collection_lw) }
56
56
 
57
57
  before do
58
58
  allow(file_set).to receive(:parent).and_return(work)