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
@@ -10,6 +10,27 @@ RSpec.describe Hyrax::ResourceSync::ChangeListWriter, :clean_repo do
10
10
  described_class.new(resource_host: 'example.com',
11
11
  capability_list_url: capability_list)
12
12
  end
13
+ let(:namespaces) do
14
+ {
15
+ 'rs' => "http://www.openarchives.org/rs/terms/",
16
+ 'x' => sitemap
17
+ }
18
+ end
19
+ let(:capability_element) { xml.xpath('//rs:ln/@href', 'rs' => "http://www.openarchives.org/rs/terms/") }
20
+ # The creation and modified dates are used in order to determine whether or
21
+ # not the status is "created" or "updated"
22
+ # This avoids any potential delays/conflicts when testing against Solr and
23
+ # Fedora within the testing environment
24
+ # @see Hyrax::ResourceSync::ChangeListWriter#build_resource
25
+ let(:file_set_status) do
26
+ file_set.create_date.to_i == file_set.modified_date.to_i ? 'created' : 'updated'
27
+ end
28
+ let(:public_work_status) do
29
+ public_work.create_date.to_i == public_work.modified_date.to_i ? 'created' : 'updated'
30
+ end
31
+ let(:public_collection_status) do
32
+ public_collection.create_date.to_i == public_collection.modified_date.to_i ? 'created' : 'updated'
33
+ end
13
34
 
14
35
  subject { instance.write }
15
36
 
@@ -22,43 +43,36 @@ RSpec.describe Hyrax::ResourceSync::ChangeListWriter, :clean_repo do
22
43
  context "when resources exist" do
23
44
  before do
24
45
  # These private items should not show up.
25
- create(:private_collection)
46
+ build(:private_collection_lw)
26
47
  create(:work)
27
48
 
28
- # Sleep in between to ensure modified dates are different
29
49
  public_collection
30
- sleep(1)
31
50
  public_work
32
- sleep(1)
33
51
  file_set
34
52
  end
35
53
 
36
54
  it "has a list of resources" do
37
- capability = xml.xpath('//rs:ln/@href', 'rs' => "http://www.openarchives.org/rs/terms/").text
38
- expect(capability).to eq capability_list
39
-
40
- expect(location(1)).to eq "http://example.com/concern/file_sets/#{file_set.id}"
41
- expect(change(1)).to eq "created"
42
-
43
- expect(location(2)).to eq "http://example.com/concern/generic_works/#{public_work.id}"
44
- expect(change(2)).to eq "created"
45
-
46
- expect(location(3)).to eq "http://example.com/collections/#{public_collection.id}"
47
- expect(change(3)).to eq "created"
55
+ expect(capability_element.text).to eq capability_list
56
+ locations = location_elements(namespaces).map(&:text)
57
+ expect(locations).to include "http://example.com/concern/file_sets/#{file_set.id}"
58
+ expect(locations).to include "http://example.com/concern/generic_works/#{public_work.id}"
59
+ expect(locations).to include "http://example.com/collections/#{public_collection.id}"
60
+ changed = changed_elements(namespaces).map(&:value)
61
+ expect(changed).to match_array([public_collection_status, public_work_status, file_set_status])
48
62
 
49
63
  expect(url_list.count).to eq 3
50
64
  end
51
65
  end
52
66
 
53
- def change(n)
54
- query(n, 'rs:md/@change', 'rs' => "http://www.openarchives.org/rs/terms/")
67
+ def changed_elements(namespaces = {})
68
+ query("rs:md/@change", namespaces)
55
69
  end
56
70
 
57
- def location(n)
58
- query(n, 'x:loc')
71
+ def location_elements(namespaces = {})
72
+ query("x:loc", namespaces)
59
73
  end
60
74
 
61
- def query(n, part, ns = {})
62
- xml.xpath("//x:url[#{n}]/#{part}", ns.merge('x' => sitemap)).text
75
+ def query(part, ns = {})
76
+ xml.xpath("//x:url/#{part}", ns)
63
77
  end
64
78
  end
@@ -1,6 +1,6 @@
1
1
  RSpec.describe Hyrax::ResourceSync::ResourceListWriter, :clean_repo do
2
2
  let(:sitemap) { 'http://www.sitemaps.org/schemas/sitemap/0.9' }
3
- let!(:private_collection) { create(:private_collection) }
3
+ let!(:private_collection) { build(:private_collection_lw) }
4
4
  let!(:public_collection) { create(:public_collection) }
5
5
  let!(:public_work) { create(:public_generic_work) }
6
6
  let!(:private_work) { create(:work) }
@@ -1,5 +1,5 @@
1
1
  RSpec.describe Collection, type: :model do
2
- let(:collection) { build(:public_collection) }
2
+ let(:collection) { build(:public_collection_lw) }
3
3
 
4
4
  it "has open visibility" do
5
5
  expect(collection.read_groups).to eq ['public']
@@ -15,7 +15,7 @@ RSpec.describe Collection, type: :model do
15
15
 
16
16
  describe "#to_solr" do
17
17
  let(:user) { build(:user) }
18
- let(:collection) { build(:collection, user: user, title: ['A good title']) }
18
+ let(:collection) { build(:collection_lw, user: user, title: ['A good title']) }
19
19
 
20
20
  let(:solr_document) { collection.to_solr }
21
21
 
@@ -40,7 +40,7 @@ RSpec.describe Collection, type: :model do
40
40
  end
41
41
 
42
42
  describe "#members_objects", clean_repo: true do
43
- let(:collection) { create(:collection) }
43
+ let(:collection) { create(:collection_lw) }
44
44
 
45
45
  it "is empty by default" do
46
46
  expect(collection.member_objects).to match_array []
@@ -80,7 +80,7 @@ RSpec.describe Collection, type: :model do
80
80
  end
81
81
 
82
82
  describe "#destroy", clean_repo: true do
83
- let(:collection) { build(:collection) }
83
+ let(:collection) { build(:collection_lw) }
84
84
  let(:work1) { create(:work) }
85
85
 
86
86
  before do
@@ -130,7 +130,7 @@ RSpec.describe Collection, type: :model do
130
130
  end
131
131
 
132
132
  describe '#collection_type_gid=' do
133
- let(:collection) { build(:collection) }
133
+ let(:collection) { build(:collection_lw) }
134
134
  let(:collection_type) { create(:collection_type) }
135
135
 
136
136
  it 'sets gid' do
@@ -170,7 +170,7 @@ RSpec.describe Collection, type: :model do
170
170
  end
171
171
 
172
172
  describe 'collection type delegated methods' do
173
- subject { build(:collection) }
173
+ subject { build(:collection_lw) }
174
174
 
175
175
  it { is_expected.to delegate_method(:nestable?).to(:collection_type) }
176
176
  it { is_expected.to delegate_method(:discoverable?).to(:collection_type) }
@@ -185,7 +185,7 @@ RSpec.describe Collection, type: :model do
185
185
 
186
186
  describe '.after_destroy' do
187
187
  it 'will destroy the associated permission template' do
188
- collection = create(:collection, with_permission_template: true)
188
+ collection = build(:collection_lw, with_permission_template: true)
189
189
  expect { collection.destroy }.to change { Hyrax::PermissionTemplate.count }.by(-1)
190
190
  end
191
191
  end
@@ -193,7 +193,7 @@ RSpec.describe Collection, type: :model do
193
193
  describe '#reset_access_controls!' do
194
194
  let!(:user) { build(:user) }
195
195
  let(:collection_type) { create(:collection_type) }
196
- let!(:collection) { create(:collection, user: user, collection_type_gid: collection_type.gid) }
196
+ let!(:collection) { build(:collection_lw, user: user, collection_type_gid: collection_type.gid) }
197
197
  let!(:permission_template) { build(:permission_template) }
198
198
 
199
199
  before do
@@ -236,20 +236,20 @@ RSpec.describe Collection, type: :model do
236
236
 
237
237
  describe 'permission template' do
238
238
  it 'will be created when with_permission_template is true' do
239
- expect { create(:collection, with_permission_template: true) }.to change { Hyrax::PermissionTemplate.count }.by(1)
239
+ expect { build(:collection_lw, with_permission_template: true) }.to change { Hyrax::PermissionTemplate.count }.by(1)
240
240
  end
241
241
 
242
242
  it 'will be created when with_permission_template is set to attributes identifying access' do
243
- expect { create(:collection, with_permission_template: { manage_users: [user] }) }.to change { Hyrax::PermissionTemplate.count }.by(1)
244
- expect { create(:collection, with_permission_template: { manage_users: [user], deposit_users: [user] }) }.to change { Hyrax::PermissionTemplate.count }.by(1)
243
+ expect { build(:collection_lw, with_permission_template: { manage_users: [user] }) }.to change { Hyrax::PermissionTemplate.count }.by(1)
244
+ expect { build(:collection_lw, with_permission_template: { manage_users: [user], deposit_users: [user] }) }.to change { Hyrax::PermissionTemplate.count }.by(1)
245
245
  end
246
246
 
247
247
  it 'will be created when create_access is true' do
248
- expect { create(:collection, create_access: true) }.to change { Hyrax::PermissionTemplate.count }.by(1)
248
+ expect { create(:collection_lw, with_permission_template: true) }.to change { Hyrax::PermissionTemplate.count }.by(1)
249
249
  end
250
250
 
251
251
  it 'will not be created by default' do
252
- expect { create(:collection) }.not_to change { Hyrax::PermissionTemplate.count }
252
+ expect { build(:collection_lw) }.not_to change { Hyrax::PermissionTemplate.count }
253
253
  end
254
254
  end
255
255
 
@@ -264,11 +264,11 @@ RSpec.describe Collection, type: :model do
264
264
  end
265
265
 
266
266
  it 'will be created when create_access is true' do
267
- expect { create(:collection, user: user, create_access: true) }.to change { Hyrax::PermissionTemplate.count }.by(1)
267
+ expect { build(:collection_lw, user: user, with_permission_template: true) }.to change { Hyrax::PermissionTemplate.count }.by(1)
268
268
  end
269
269
 
270
270
  it 'will not be created by default' do
271
- expect { create(:collection) }.not_to change { Hyrax::PermissionTemplateAccess.count }
271
+ expect { build(:collection_lw) }.not_to change { Hyrax::PermissionTemplateAccess.count }
272
272
  end
273
273
  end
274
274
 
@@ -293,7 +293,7 @@ RSpec.describe Collection, type: :model do
293
293
 
294
294
  context 'when building a collection' do
295
295
  let(:coll123) do
296
- build(:collection,
296
+ build(:collection_lw,
297
297
  id: 'Collection123',
298
298
  collection_type_gid: collection_type.gid,
299
299
  with_nesting_attributes:
@@ -318,8 +318,8 @@ RSpec.describe Collection, type: :model do
318
318
  end
319
319
 
320
320
  describe '#update_nested_collection_relationship_indices', :with_nested_reindexing do
321
- it 'will be called after save' do
322
- expect(Samvera::NestingIndexer).to receive(:reindex_relationships).with(id: kind_of(String), extent: kind_of(String))
321
+ it 'will be called once for the Collection resource and once for the nested ACL permission resource' do
322
+ expect(Samvera::NestingIndexer).to receive(:reindex_relationships).exactly(2).times.with(id: kind_of(String), extent: kind_of(String))
323
323
  collection.save!
324
324
  end
325
325
  end
@@ -31,8 +31,8 @@ RSpec.describe Hyrax::CollectionNesting do
31
31
  end
32
32
 
33
33
  let(:user) { create(:user) }
34
- let!(:collection) { create(:collection, collection_type_settings: [:nestable]) }
35
- let!(:child_collection) { create(:collection, collection_type_settings: [:nestable]) }
34
+ let!(:collection) { build(:collection_lw, collection_type_settings: [:nestable]) }
35
+ let!(:child_collection) { create(:collection_lw, collection_type_settings: [:nestable]) }
36
36
  let(:extent) { Hyrax::Adapters::NestingIndexAdapter::FULL_REINDEX }
37
37
 
38
38
  before do
@@ -487,8 +487,8 @@ RSpec.describe FileSet do
487
487
  end
488
488
 
489
489
  let(:depositor) { 'jcoyne' }
490
- let(:depositor_key) { Solrizer.solr_name('depositor') }
491
- let(:title_key) { Solrizer.solr_name('title', :stored_searchable, type: :string) }
490
+ let(:depositor_key) { ActiveFedora.index_field_mapper.solr_name('depositor') }
491
+ let(:title_key) { ActiveFedora.index_field_mapper.solr_name('title', :stored_searchable, type: :string) }
492
492
  let(:title) { ['abc123'] }
493
493
  let(:no_terms) { described_class.find(subject.id).to_solr }
494
494
  let(:terms) do
@@ -134,7 +134,7 @@ RSpec.describe Hyrax::CollectionType, type: :model do
134
134
  end
135
135
 
136
136
  describe "collections" do
137
- let!(:collection) { create(:collection, collection_type_gid: collection_type.gid.to_s) }
137
+ let!(:collection) { create(:collection_lw, collection_type_gid: collection_type.gid.to_s) }
138
138
  let(:collection_type) { create(:collection_type) }
139
139
 
140
140
  it 'returns collections of this collection type' do
@@ -151,7 +151,7 @@ RSpec.describe Hyrax::CollectionType, type: :model do
151
151
  let(:collection_type) { create(:collection_type) }
152
152
 
153
153
  it 'returns true if there are any collections of this collection type' do
154
- create(:collection, collection_type_gid: collection_type.gid.to_s)
154
+ create(:collection_lw, collection_type_gid: collection_type.gid.to_s)
155
155
  expect(collection_type).to have_collections
156
156
  end
157
157
  it 'returns false if there are not any collections of this collection type' do
@@ -35,8 +35,33 @@ RSpec.describe User, type: :model do
35
35
  end
36
36
  end
37
37
 
38
+ describe '#user_key' do
39
+ it 'is email by default' do
40
+ expect(user.user_key).to eq user.email
41
+ end
42
+
43
+ context 'with a custom user_key_field' do
44
+ let(:user) { build(:user, display_name: value) }
45
+ let(:value) { 'moomin' }
46
+
47
+ before do
48
+ allow(Hydra.config).to receive(:user_key_field).and_return(:display_name)
49
+ end
50
+
51
+ it 'is email by default' do
52
+ expect(user.user_key).to eq value
53
+ end
54
+
55
+ it 'is findable by user_key' do
56
+ user.save
57
+
58
+ expect(User.find_by_user_key(value)).to eq user
59
+ end
60
+ end
61
+ end
62
+
38
63
  it "has an email" do
39
- expect(user.user_key).to be_kind_of String
64
+ expect(user.email).to be_kind_of String
40
65
  end
41
66
  it "has activity stream-related methods defined" do
42
67
  expect(user).to respond_to(:stream)
@@ -11,7 +11,7 @@ RSpec.describe Hyrax::CollectionPresenter do
11
11
  end
12
12
 
13
13
  let(:collection) do
14
- build(:collection,
14
+ build(:collection_lw,
15
15
  id: 'adc12v',
16
16
  description: ['a nice collection'],
17
17
  based_near: ['Over there'],
@@ -61,7 +61,7 @@ RSpec.describe Hyrax::CollectionPresenter do
61
61
  let(:collection_type) { create(:collection_type) }
62
62
 
63
63
  describe 'when solr_document#collection_type_gid exists' do
64
- let(:collection) { build(:collection, collection_type_gid: collection_type.gid) }
64
+ let(:collection) { build(:collection_lw, collection_type_gid: collection_type.gid) }
65
65
  let(:solr_doc) { SolrDocument.new(collection.to_solr) }
66
66
 
67
67
  it 'finds the collection type based on the solr_document#collection_type_gid if one exists' do
@@ -173,7 +173,7 @@ RSpec.describe Hyrax::CollectionPresenter do
173
173
  end
174
174
 
175
175
  context "collection with private collection" do
176
- let!(:work) { create(:private_collection, member_of_collections: [collection]) }
176
+ let!(:work) { build(:private_collection_lw, member_of_collections: [collection]) }
177
177
 
178
178
  it { is_expected.to eq 0 }
179
179
  end
@@ -185,14 +185,14 @@ RSpec.describe Hyrax::CollectionPresenter do
185
185
  end
186
186
 
187
187
  context "collection with public collection" do
188
- let!(:subcollection) { create(:public_collection, member_of_collections: [collection]) }
188
+ let!(:subcollection) { create(:public_collection_lw, member_of_collections: [collection]) }
189
189
 
190
190
  it { is_expected.to eq 1 }
191
191
  end
192
192
 
193
193
  context "collection with public work and sub-collection" do
194
194
  let!(:work) { create(:public_work, member_of_collections: [collection]) }
195
- let!(:subcollection) { create(:public_collection, member_of_collections: [collection]) }
195
+ let!(:subcollection) { create(:public_collection_lw, member_of_collections: [collection]) }
196
196
 
197
197
  it { is_expected.to eq 2 }
198
198
  end
@@ -232,7 +232,7 @@ RSpec.describe Hyrax::CollectionPresenter do
232
232
 
233
233
  context "collection with public work and sub-collection" do
234
234
  let!(:work) { create(:public_work, member_of_collections: [collection]) }
235
- let!(:subcollection) { create(:public_collection, member_of_collections: [collection]) }
235
+ let!(:subcollection) { create(:public_collection_lw, member_of_collections: [collection]) }
236
236
 
237
237
  it { is_expected.to eq 1 }
238
238
  end
@@ -259,20 +259,20 @@ RSpec.describe Hyrax::CollectionPresenter do
259
259
  end
260
260
 
261
261
  context "collection with private collection" do
262
- let!(:subcollection) { create(:private_collection, member_of_collections: [collection]) }
262
+ let!(:subcollection) { build(:private_collection_lw, member_of_collections: [collection]) }
263
263
 
264
264
  it { is_expected.to eq 0 }
265
265
  end
266
266
 
267
267
  context "collection with public collection" do
268
- let!(:subcollection) { create(:public_collection, member_of_collections: [collection]) }
268
+ let!(:subcollection) { create(:public_collection_lw, member_of_collections: [collection]) }
269
269
 
270
270
  it { is_expected.to eq 1 }
271
271
  end
272
272
 
273
273
  context "collection with public work and sub-collection" do
274
274
  let!(:work) { create(:public_work, member_of_collections: [collection]) }
275
- let!(:subcollection) { create(:public_collection, member_of_collections: [collection]) }
275
+ let!(:subcollection) { create(:public_collection_lw, member_of_collections: [collection]) }
276
276
 
277
277
  it { is_expected.to eq 1 }
278
278
  end
@@ -310,8 +310,8 @@ RSpec.describe Hyrax::CollectionPresenter do
310
310
  end
311
311
 
312
312
  context('when parent_collections is has collections') do
313
- let(:collection1) { build(:collection, title: ['col1']) }
314
- let(:collection2) { build(:collection, title: ['col2']) }
313
+ let(:collection1) { build(:collection_lw, title: ['col1']) }
314
+ let(:collection2) { build(:collection_lw, title: ['col2']) }
315
315
  let!(:parent_docs) { [collection1, collection2] }
316
316
 
317
317
  before do
@@ -22,6 +22,7 @@ RSpec.describe Hyrax::WorkShowPresenter do
22
22
  it { is_expected.to delegate_method(:date_modified).to(:solr_document) }
23
23
  it { is_expected.to delegate_method(:date_uploaded).to(:solr_document) }
24
24
  it { is_expected.to delegate_method(:rights_statement).to(:solr_document) }
25
+ it { is_expected.to delegate_method(:rights_notes).to(:solr_document) }
25
26
 
26
27
  it { is_expected.to delegate_method(:based_near_label).to(:solr_document) }
27
28
  it { is_expected.to delegate_method(:related_url).to(:solr_document) }
@@ -531,6 +532,16 @@ RSpec.describe Hyrax::WorkShowPresenter do
531
532
  expect(subject[0]['label']).to eq('Title')
532
533
  expect(subject[0]['value']).to include('Test title', 'Another test title')
533
534
  end
535
+
536
+ context "when there are html tags in the metadata" do
537
+ before do
538
+ work.title = ["The title<img src=xx:x onerror=eval('\x61ler\x74(1)') />", 'Another test title']
539
+ end
540
+
541
+ it "sanitizes the metadata values" do
542
+ expect(subject[0]['value']).to include('The title<img>', 'Another test title')
543
+ end
544
+ end
534
545
  end
535
546
  end
536
547
 
@@ -2,7 +2,7 @@ RSpec.describe Hyrax::CollectionMemberSearchBuilder do
2
2
  let(:context) { double("context", blacklight_config: CatalogController.blacklight_config) }
3
3
  let(:solr_params) { { fq: [] } }
4
4
  let(:include_models) { :both }
5
- let(:collection) { build(:collection, id: '12345') }
5
+ let(:collection) { build(:collection_lw, id: '12345') }
6
6
  let(:builder) { described_class.new(scope: context, collection: collection, search_includes_models: include_models) }
7
7
 
8
8
  describe ".default_processor_chain" do
@@ -50,7 +50,7 @@ RSpec.describe Hyrax::CollectionSearchBuilder do
50
50
 
51
51
  context 'when access is :deposit' do
52
52
  let(:access) { "deposit" }
53
- let!(:collection) { create(:collection, with_permission_template: attributes) }
53
+ let!(:collection) { create(:collection_lw, with_permission_template: attributes) }
54
54
 
55
55
  context 'and user has access' do
56
56
  let(:attributes) { { deposit_users: [user.user_key] } }
@@ -61,7 +61,7 @@ RSpec.describe Hyrax::Dashboard::NestedCollectionsSearchBuilder do
61
61
 
62
62
  context 'when access is :deposit' do
63
63
  let(:access) { "deposit" }
64
- let!(:collection) { create(:collection, with_permission_template: attributes) }
64
+ let!(:collection) { create(:collection_lw, with_permission_template: attributes) }
65
65
 
66
66
  context 'and user has access' do
67
67
  let(:attributes) { { deposit_users: [user.user_key] } }
@@ -1,7 +1,7 @@
1
1
  RSpec.describe Hyrax::WorkRelation, :clean_repo do
2
2
  let!(:work) { create(:generic_work) }
3
3
  let!(:file_set) { create(:file_set) }
4
- let!(:collection) { create(:collection) }
4
+ let!(:collection) { build(:collection_lw) }
5
5
 
6
6
  it 'has works and not collections or file sets' do
7
7
  expect(subject).to eq [work]
@@ -64,8 +64,8 @@ RSpec.describe Hyrax::Adapters::NestingIndexAdapter do
64
64
  end
65
65
 
66
66
  describe '.each_perservation_document_id_and_parent_ids', clean_repo: true do
67
- let!(:nested_parent) { create(:collection, member_of_collections: []) }
68
- let!(:nested_with_parent) { create(:collection, member_of_collections: [nested_parent]) }
67
+ let!(:nested_parent) { build(:collection_lw, member_of_collections: []) }
68
+ let!(:nested_with_parent) { create(:collection_lw, member_of_collections: [nested_parent]) }
69
69
  let!(:work) { create(:generic_work) }
70
70
  let(:count_of_items) { ActiveFedora::Base.descendant_uris(ActiveFedora.fedora.base_uri, exclude_uri: true).count }
71
71