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
@@ -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
|
-
|
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
|
-
|
38
|
-
|
39
|
-
|
40
|
-
expect(
|
41
|
-
expect(
|
42
|
-
|
43
|
-
expect(
|
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
|
54
|
-
query(
|
67
|
+
def changed_elements(namespaces = {})
|
68
|
+
query("rs:md/@change", namespaces)
|
55
69
|
end
|
56
70
|
|
57
|
-
def
|
58
|
-
query(
|
71
|
+
def location_elements(namespaces = {})
|
72
|
+
query("x:loc", namespaces)
|
59
73
|
end
|
60
74
|
|
61
|
-
def query(
|
62
|
-
xml.xpath("//x:url
|
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) {
|
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(:
|
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(:
|
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(:
|
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(:
|
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(:
|
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(:
|
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 =
|
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) {
|
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 {
|
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 {
|
244
|
-
expect {
|
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(:
|
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 {
|
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 {
|
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 {
|
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(:
|
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
|
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) {
|
35
|
-
let!(:child_collection) { create(:
|
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) {
|
491
|
-
let(:title_key) {
|
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(:
|
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(:
|
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
|
data/spec/models/user_spec.rb
CHANGED
@@ -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.
|
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(:
|
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(:
|
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) {
|
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(:
|
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(:
|
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(:
|
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) {
|
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(:
|
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(:
|
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(:
|
314
|
-
let(:collection2) { build(:
|
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(:
|
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(:
|
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(:
|
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) {
|
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) {
|
68
|
-
let!(:nested_with_parent) { create(:
|
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
|
|