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.
- 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
|
@@ -13,7 +13,7 @@ RSpec.describe Hyrax::Workflow::ChangesRequiredNotification do
|
|
|
13
13
|
expect(approver).to receive(:send_message)
|
|
14
14
|
.with(anything,
|
|
15
15
|
"Test title (<a href=\"/concern/generic_works/#{work.id}\">#{work.id}</a>) " \
|
|
16
|
-
"requires additional changes before approval.\n
|
|
16
|
+
"requires additional changes before approval.\n 'A pleasant read'",
|
|
17
17
|
anything).exactly(3).times.and_call_original
|
|
18
18
|
|
|
19
19
|
expect { described_class.send_notification(entity: entity, user: approver, comment: comment, recipients: recipients) }
|
data/spec/spec_helper.rb
CHANGED
|
@@ -40,6 +40,7 @@ require 'rspec/active_model/mocks'
|
|
|
40
40
|
require 'capybara/rspec'
|
|
41
41
|
require 'capybara/rails'
|
|
42
42
|
require 'selenium-webdriver'
|
|
43
|
+
require 'chromedriver-helper'
|
|
43
44
|
require 'equivalent-xml'
|
|
44
45
|
require 'equivalent-xml/rspec_matchers'
|
|
45
46
|
require 'database_cleaner'
|
|
@@ -169,13 +170,6 @@ RSpec.configure do |config|
|
|
|
169
170
|
DatabaseCleaner.start
|
|
170
171
|
end
|
|
171
172
|
|
|
172
|
-
if example.metadata[:type] == :view
|
|
173
|
-
# View tests should not hit any services. This ensures the tests are unit
|
|
174
|
-
# testing only the views and run fast.
|
|
175
|
-
WebMock.disable_net_connect!(allow_localhost: false)
|
|
176
|
-
else
|
|
177
|
-
WebMock.disable_net_connect!(allow_localhost: true)
|
|
178
|
-
end
|
|
179
173
|
# using :workflow is preferable to :clean_repo, use the former if possible
|
|
180
174
|
# It's important that this comes after DatabaseCleaner.start
|
|
181
175
|
ensure_deposit_available_for(user) if example.metadata[:workflow]
|
|
@@ -195,7 +189,15 @@ RSpec.configure do |config|
|
|
|
195
189
|
end
|
|
196
190
|
|
|
197
191
|
config.include(ControllerLevelHelpers, type: :view)
|
|
198
|
-
|
|
192
|
+
|
|
193
|
+
config.before(:each, type: :view) do
|
|
194
|
+
initialize_controller_helpers(view)
|
|
195
|
+
WebMock.disable_net_connect!(allow_localhost: false)
|
|
196
|
+
end
|
|
197
|
+
|
|
198
|
+
config.after(:each, type: :view) do
|
|
199
|
+
WebMock.disable_net_connect!(allow_localhost: true)
|
|
200
|
+
end
|
|
199
201
|
|
|
200
202
|
config.before(:all, type: :feature) do
|
|
201
203
|
# Assets take a long time to compile. This causes two problems:
|
data/spec/support/selectors.rb
CHANGED
|
@@ -43,7 +43,16 @@ module Selectors
|
|
|
43
43
|
def select_member_of_collection(collection)
|
|
44
44
|
find('#s2id_member_of_collection_ids').click
|
|
45
45
|
find('.select2-input').set(collection.title.first)
|
|
46
|
-
|
|
46
|
+
# Crude way of waiting for the AJAX response
|
|
47
|
+
select2_results = []
|
|
48
|
+
time_elapsed = 0
|
|
49
|
+
while select2_results.empty? && time_elapsed < 30
|
|
50
|
+
begin_time = Time.now.to_f
|
|
51
|
+
doc = Nokogiri::XML.parse(page.body)
|
|
52
|
+
select2_results = doc.xpath('//html:li[contains(@class,"select2-result")]', html: 'http://www.w3.org/1999/xhtml')
|
|
53
|
+
end_time = Time.now.to_f
|
|
54
|
+
time_elapsed += end_time - begin_time
|
|
55
|
+
end
|
|
47
56
|
expect(page).to have_css('.select2-result')
|
|
48
57
|
within ".select2-result" do
|
|
49
58
|
find("span", text: collection.title.first).click
|
|
@@ -5,6 +5,12 @@ class TestAppGenerator < Rails::Generators::Base
|
|
|
5
5
|
# so the following path gets us to /path/to/hyrax/spec/test_app_templates/
|
|
6
6
|
source_root File.expand_path('../../../../spec/test_app_templates/', __FILE__)
|
|
7
7
|
|
|
8
|
+
def require_bootsnap
|
|
9
|
+
inject_into_file 'config/boot.rb', after: "require 'bundler/setup' # Set up gems listed in the Gemfile.\n" do
|
|
10
|
+
"require 'bootsnap/setup'\n"
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
|
|
8
14
|
def install_engine
|
|
9
15
|
generate 'hyrax:install', '-f'
|
|
10
16
|
end
|
|
@@ -8,14 +8,15 @@ RSpec.describe 'catalog/_index_list_default', type: :view do
|
|
|
8
8
|
'date_modified_dtsi' => 'a date',
|
|
9
9
|
'rights_statement_tesim' => [''],
|
|
10
10
|
'embargo_release_date_dtsi' => 'a date',
|
|
11
|
-
'lease_expiration_date_dtsi' => 'a date'
|
|
11
|
+
'lease_expiration_date_dtsi' => 'a date',
|
|
12
|
+
'has_model_ssim' => 'GenericWork' }
|
|
12
13
|
end
|
|
13
14
|
let(:document) { SolrDocument.new(attributes) }
|
|
14
15
|
let(:presenter) { double }
|
|
15
16
|
|
|
16
17
|
before do
|
|
17
18
|
allow(view).to receive(:index_presenter).and_return(presenter)
|
|
18
|
-
allow(presenter).to receive(:field_value) { |field| "Test #{field}" }
|
|
19
|
+
allow(presenter).to receive(:field_value) { |field| "Test #{field.field}" }
|
|
19
20
|
render 'catalog/index_list_default', document: document
|
|
20
21
|
end
|
|
21
22
|
|
|
@@ -1,10 +1,43 @@
|
|
|
1
1
|
RSpec.describe 'catalog/_thumbnail_list_collection.html.erb', type: :view do
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
context "When the collection thumbnail is attached" do
|
|
3
|
+
let(:attributes) do
|
|
4
|
+
{ id: "xxx",
|
|
5
|
+
"has_model_ssim": ["Collection"],
|
|
6
|
+
"title_tesim": ["Collection Title"],
|
|
7
|
+
"description_tesim": ["Collection Description"],
|
|
8
|
+
"system_modified_dtsi": 'date',
|
|
9
|
+
"thumbnail_path_ss": '/xxx/yyy?file=thumbnail' }
|
|
10
|
+
end
|
|
11
|
+
let(:doc) { SolrDocument.new(attributes) }
|
|
12
|
+
let(:current_ability) { Ability.new(build(:user)) }
|
|
13
|
+
|
|
14
|
+
before do
|
|
15
|
+
render 'catalog/thumbnail_list_collection', document: doc
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
it 'displays the collection thumbnail in the search results' do
|
|
19
|
+
expect(rendered).to include '/xxx/yyy?file=thumbnail'
|
|
20
|
+
end
|
|
5
21
|
end
|
|
6
22
|
|
|
7
|
-
|
|
8
|
-
|
|
23
|
+
context "When the collection thumbnail is not attached" do
|
|
24
|
+
let(:attributes) do
|
|
25
|
+
{ id: "xxx",
|
|
26
|
+
"has_model_ssim": ["Collection"],
|
|
27
|
+
"title_tesim": ["Collection Title"],
|
|
28
|
+
"description_tesim": ["Collection Description"],
|
|
29
|
+
"system_modified_dtsi": 'date',
|
|
30
|
+
"thumbnail_path_ss" => Hyrax::CollectionIndexer.thumbnail_path_service.default_image }
|
|
31
|
+
end
|
|
32
|
+
let(:doc) { SolrDocument.new(attributes) }
|
|
33
|
+
let(:current_ability) { Ability.new(build(:user)) }
|
|
34
|
+
|
|
35
|
+
before do
|
|
36
|
+
render 'catalog/thumbnail_list_collection', document: doc
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
it 'displays the collection icon in the search results' do
|
|
40
|
+
expect(rendered).to include '/assets/collection-'
|
|
41
|
+
end
|
|
9
42
|
end
|
|
10
43
|
end
|
|
@@ -7,7 +7,7 @@ RSpec.describe 'hyrax/base/_attributes.html.erb' do
|
|
|
7
7
|
let(:solr_document) { SolrDocument.new(attributes) }
|
|
8
8
|
let(:attributes) do
|
|
9
9
|
{
|
|
10
|
-
|
|
10
|
+
ActiveFedora.index_field_mapper.solr_name('has_model', :symbol) => ["GenericWork"],
|
|
11
11
|
subject_tesim: subject,
|
|
12
12
|
contributor_tesim: contributor,
|
|
13
13
|
creator_tesim: creator,
|
|
@@ -15,7 +15,7 @@ RSpec.describe 'hyrax/base/_show_actions.html.erb', type: :view do
|
|
|
15
15
|
before do
|
|
16
16
|
allow(presenter).to receive(:show_deposit_for?).with(anything).and_return(false)
|
|
17
17
|
allow(presenter).to receive(:editor?).and_return(false)
|
|
18
|
-
render 'hyrax/base/show_actions
|
|
18
|
+
render 'hyrax/base/show_actions', presenter: presenter
|
|
19
19
|
end
|
|
20
20
|
it "doesn't show edit / delete / Add to collection links" do
|
|
21
21
|
expect(rendered).not_to have_link 'Edit'
|
|
@@ -32,7 +32,7 @@ RSpec.describe 'hyrax/base/_show_actions.html.erb', type: :view do
|
|
|
32
32
|
context "when the work does not contain children" do
|
|
33
33
|
before do
|
|
34
34
|
allow(presenter).to receive(:member_presenters).and_return([])
|
|
35
|
-
render 'hyrax/base/show_actions
|
|
35
|
+
render 'hyrax/base/show_actions', presenter: presenter
|
|
36
36
|
end
|
|
37
37
|
it "does not show file manager link" do
|
|
38
38
|
expect(rendered).not_to have_link 'File Manager'
|
|
@@ -46,7 +46,7 @@ RSpec.describe 'hyrax/base/_show_actions.html.erb', type: :view do
|
|
|
46
46
|
context "when the work contains 1 child" do
|
|
47
47
|
before do
|
|
48
48
|
allow(presenter).to receive(:member_presenters).and_return([member])
|
|
49
|
-
render 'hyrax/base/show_actions
|
|
49
|
+
render 'hyrax/base/show_actions', presenter: presenter
|
|
50
50
|
end
|
|
51
51
|
it "does not show file manager link" do
|
|
52
52
|
expect(rendered).not_to have_link 'File Manager'
|
|
@@ -60,7 +60,7 @@ RSpec.describe 'hyrax/base/_show_actions.html.erb', type: :view do
|
|
|
60
60
|
|
|
61
61
|
before do
|
|
62
62
|
allow(presenter).to receive(:member_presenters).and_return([member, file_member])
|
|
63
|
-
render 'hyrax/base/show_actions
|
|
63
|
+
render 'hyrax/base/show_actions', presenter: presenter
|
|
64
64
|
end
|
|
65
65
|
it "shows file manager link" do
|
|
66
66
|
expect(rendered).to have_link 'File Manager'
|
|
@@ -70,7 +70,7 @@ RSpec.describe 'hyrax/base/_show_actions.html.erb', type: :view do
|
|
|
70
70
|
context "when there are valid_child_concerns" do
|
|
71
71
|
before do
|
|
72
72
|
allow(presenter).to receive(:member_presenters).and_return([])
|
|
73
|
-
render 'hyrax/base/show_actions
|
|
73
|
+
render 'hyrax/base/show_actions', presenter: presenter
|
|
74
74
|
end
|
|
75
75
|
it "creates a link to add child work" do
|
|
76
76
|
expect(rendered).to have_link 'Attach Generic Work', href: "/concern/parent/#{presenter.id}/generic_works/new"
|
|
@@ -87,7 +87,7 @@ RSpec.describe 'hyrax/base/_show_actions.html.erb', type: :view do
|
|
|
87
87
|
context "and user is editor" do
|
|
88
88
|
before do
|
|
89
89
|
allow(presenter).to receive(:editor?).and_return(true)
|
|
90
|
-
render 'hyrax/base/show_actions
|
|
90
|
+
render 'hyrax/base/show_actions', presenter: presenter
|
|
91
91
|
end
|
|
92
92
|
|
|
93
93
|
it "shows editor related buttons" do
|
|
@@ -101,7 +101,7 @@ RSpec.describe 'hyrax/base/_show_actions.html.erb', type: :view do
|
|
|
101
101
|
context "and user is viewer" do
|
|
102
102
|
before do
|
|
103
103
|
allow(presenter).to receive(:editor?).and_return(false)
|
|
104
|
-
render 'hyrax/base/show_actions
|
|
104
|
+
render 'hyrax/base/show_actions', presenter: presenter
|
|
105
105
|
end
|
|
106
106
|
it "shows only Add to collection link" do
|
|
107
107
|
expect(rendered).not_to have_link 'File Manager'
|
|
@@ -121,7 +121,7 @@ RSpec.describe 'hyrax/base/_show_actions.html.erb', type: :view do
|
|
|
121
121
|
context "and user is editor" do
|
|
122
122
|
before do
|
|
123
123
|
allow(presenter).to receive(:editor?).and_return(true)
|
|
124
|
-
render 'hyrax/base/show_actions
|
|
124
|
+
render 'hyrax/base/show_actions', presenter: presenter
|
|
125
125
|
end
|
|
126
126
|
|
|
127
127
|
it "shows editor related buttons" do
|
|
@@ -135,7 +135,7 @@ RSpec.describe 'hyrax/base/_show_actions.html.erb', type: :view do
|
|
|
135
135
|
context "and user is viewer" do
|
|
136
136
|
before do
|
|
137
137
|
allow(presenter).to receive(:editor?).and_return(false)
|
|
138
|
-
render 'hyrax/base/show_actions
|
|
138
|
+
render 'hyrax/base/show_actions', presenter: presenter
|
|
139
139
|
end
|
|
140
140
|
|
|
141
141
|
it "shows only Add to collection link" do
|
|
@@ -9,6 +9,7 @@ RSpec.describe 'hyrax/base/show.html.erb', type: :view do
|
|
|
9
9
|
description_tesim: ['Lorem ipsum lorem ipsum.'],
|
|
10
10
|
keyword_tesim: ['bacon', 'sausage', 'eggs'],
|
|
11
11
|
rights_statement_tesim: ['http://example.org/rs/1'],
|
|
12
|
+
rights_notes_tesim: ['Notes on the rights'],
|
|
12
13
|
date_created_tesim: ['1984-01-02'])
|
|
13
14
|
end
|
|
14
15
|
|
|
@@ -62,7 +63,7 @@ RSpec.describe 'hyrax/base/show.html.erb', type: :view do
|
|
|
62
63
|
stub_template 'hyrax/base/_workflow_actions_widget.html.erb' => ''
|
|
63
64
|
stub_template '_masthead.html.erb' => ''
|
|
64
65
|
assign(:presenter, presenter)
|
|
65
|
-
render template: 'hyrax/base/show
|
|
66
|
+
render template: 'hyrax/base/show', layout: 'layouts/hyrax/1_column'
|
|
66
67
|
end
|
|
67
68
|
|
|
68
69
|
it 'shows workflow badge' do
|
|
@@ -72,7 +73,7 @@ RSpec.describe 'hyrax/base/show.html.erb', type: :view do
|
|
|
72
73
|
describe 'IIIF viewer integration' do
|
|
73
74
|
before do
|
|
74
75
|
allow(presenter).to receive(:iiif_viewer?).and_return(viewer_enabled)
|
|
75
|
-
render template: 'hyrax/base/show
|
|
76
|
+
render template: 'hyrax/base/show'
|
|
76
77
|
end
|
|
77
78
|
|
|
78
79
|
context 'when presenter says it is enabled' do
|
|
@@ -15,15 +15,16 @@ RSpec.describe 'hyrax/collections/_show_document_list_row.html.erb', type: :view
|
|
|
15
15
|
context 'when not logged in' do
|
|
16
16
|
before do
|
|
17
17
|
view.blacklight_config = Blacklight::Configuration.new
|
|
18
|
+
assign(:presenter, collection)
|
|
18
19
|
allow(view).to receive(:current_user).and_return(nil)
|
|
19
20
|
allow(work).to receive(:title_or_label).and_return("One Hundred Years of Solitude")
|
|
20
21
|
allow(work).to receive(:edit_people).and_return([])
|
|
21
|
-
allow(view).to receive(:
|
|
22
|
+
allow(view).to receive(:render_other_collection_links).and_return([])
|
|
22
23
|
end
|
|
23
24
|
|
|
24
25
|
it "renders collections links" do
|
|
25
26
|
render('hyrax/collections/show_document_list_row.html.erb', document: work)
|
|
26
|
-
expect(rendered).
|
|
27
|
+
expect(rendered).not_to have_content 'My awesome collection'
|
|
27
28
|
end
|
|
28
29
|
|
|
29
30
|
it "renders works" do
|
|
@@ -15,15 +15,16 @@ RSpec.describe 'hyrax/dashboard/collections/_show_document_list_row.html.erb', t
|
|
|
15
15
|
context 'when not logged in' do
|
|
16
16
|
before do
|
|
17
17
|
view.blacklight_config = Blacklight::Configuration.new
|
|
18
|
+
assign(:presenter, collection)
|
|
18
19
|
allow(view).to receive(:current_user).and_return(nil)
|
|
19
20
|
allow(work).to receive(:title_or_label).and_return("One Hundred Years of Solitude")
|
|
20
21
|
allow(work).to receive(:edit_people).and_return([])
|
|
21
|
-
allow(view).to receive(:
|
|
22
|
+
allow(view).to receive(:render_other_collection_links).and_return([])
|
|
22
23
|
end
|
|
23
24
|
|
|
24
25
|
it "renders collections links" do
|
|
25
26
|
render('show_document_list_row', document: work)
|
|
26
|
-
expect(rendered).
|
|
27
|
+
expect(rendered).not_to have_content 'My awesome collection'
|
|
27
28
|
end
|
|
28
29
|
|
|
29
30
|
it "renders works" do
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
require 'spec_helper'
|
|
3
|
+
require 'wings'
|
|
4
|
+
require 'wings/active_fedora_converter'
|
|
5
|
+
|
|
6
|
+
RSpec.describe Wings::ActiveFedoraConverter do
|
|
7
|
+
subject(:converter) { described_class.new(resource: resource) }
|
|
8
|
+
let(:adapter) { Valkyrie::Persistence::Memory::MetadataAdapter.new }
|
|
9
|
+
let(:attributes) { { id: id } }
|
|
10
|
+
let(:id) { 'moomin_id' }
|
|
11
|
+
let(:resource) { work.valkyrie_resource }
|
|
12
|
+
let(:work) { GenericWork.new(attributes) }
|
|
13
|
+
|
|
14
|
+
describe '#convert' do
|
|
15
|
+
it 'returns the ActiveFedora model' do
|
|
16
|
+
expect(converter.convert).to eq work
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
context 'with attributes' do
|
|
20
|
+
let(:attributes) do
|
|
21
|
+
FactoryBot.attributes_for(:generic_work)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
it 'repopulates the attributes' do
|
|
25
|
+
expect(converter.convert).to have_attributes(attributes)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
it 'populates reflections'
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
require 'spec_helper'
|
|
3
|
+
require 'wings/model_transformer'
|
|
4
|
+
|
|
5
|
+
RSpec.describe Wings::ModelTransformer do
|
|
6
|
+
subject(:factory) { described_class.new(pcdm_object: pcdm_object) }
|
|
7
|
+
let(:pcdm_object) { work }
|
|
8
|
+
let(:adapter) { Valkyrie::MetadataAdapter.find(:memory) }
|
|
9
|
+
let(:id) { 'moomin123' }
|
|
10
|
+
let(:persister) { adapter.persister }
|
|
11
|
+
let(:work) { GenericWork.new(id: id, **attributes) }
|
|
12
|
+
|
|
13
|
+
let(:uris) do
|
|
14
|
+
[RDF::URI('http://example.com/fake1'),
|
|
15
|
+
RDF::URI('http://example.com/fake2')]
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
let(:attributes) do
|
|
19
|
+
{
|
|
20
|
+
title: ['fake title'],
|
|
21
|
+
date_created: [Time.now.utc],
|
|
22
|
+
depositor: 'user1',
|
|
23
|
+
description: ['a description'],
|
|
24
|
+
import_url: uris.first,
|
|
25
|
+
publisher: [false],
|
|
26
|
+
related_url: uris,
|
|
27
|
+
source: [1.125, :moomin]
|
|
28
|
+
}
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
before(:context) do
|
|
32
|
+
Valkyrie::MetadataAdapter.register(
|
|
33
|
+
Valkyrie::Persistence::Memory::MetadataAdapter.new,
|
|
34
|
+
:memory
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
Valkyrie::StorageAdapter.register(
|
|
38
|
+
Valkyrie::Storage::Memory.new,
|
|
39
|
+
:memory
|
|
40
|
+
)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
# TODO: extract to Valkyrie?
|
|
44
|
+
define :have_a_valkyrie_alternate_id_of do |expected_id_str|
|
|
45
|
+
match do |valkyrie_resource|
|
|
46
|
+
valkyrie_resource.alternate_ids.map(&:id).include?(expected_id_str)
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
describe '.convert_class_name_to_valkyrie_resource_class' do
|
|
51
|
+
context 'when given a ActiveFedora class name (eg. a constant that responds to #properties)' do
|
|
52
|
+
it 'creates a Valkyrie::Resource class' do
|
|
53
|
+
subject = described_class.convert_class_name_to_valkyrie_resource_class('GenericWork')
|
|
54
|
+
expect(subject.new).to be_a Valkyrie::Resource
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
describe '.to_valkyrie_resource_class' do
|
|
60
|
+
context 'when given a ActiveFedora class (eg. a constant that responds to #properties)' do
|
|
61
|
+
context 'for the returned object (e.g. a class)' do
|
|
62
|
+
subject { described_class.to_valkyrie_resource_class(klass: GenericWork) }
|
|
63
|
+
it 'will be Valkyrie::Resource build' do
|
|
64
|
+
expect(subject.new).to be_a Valkyrie::Resource
|
|
65
|
+
end
|
|
66
|
+
it 'has a to_s instance that delegates to the given klass' do
|
|
67
|
+
expect(subject.to_s).to eq(GenericWork.to_s)
|
|
68
|
+
end
|
|
69
|
+
it 'has a internal_resource instance that is the given klass' do
|
|
70
|
+
expect(subject.internal_resource).to eq(GenericWork)
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
context 'when given a non-ActiveFedora class' do
|
|
75
|
+
it 'raises an exception' do
|
|
76
|
+
expect { described_class.to_valkyrie_resource_class(klass: String) }.to raise_error
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
describe '.for' do
|
|
82
|
+
it 'returns a Valkyrie::Resource' do
|
|
83
|
+
expect(described_class.for(work)).to be_a Valkyrie::Resource
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
describe '#build' do
|
|
88
|
+
it 'returns a Valkyrie::Resource' do
|
|
89
|
+
expect(factory.build).to be_a Valkyrie::Resource
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
it 'has the id of the pcdm_object' do
|
|
93
|
+
expect(factory.build).to have_a_valkyrie_alternate_id_of work.id
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
it 'has attributes matching the pcdm_object' do
|
|
97
|
+
expect(factory.build)
|
|
98
|
+
.to have_attributes title: work.title,
|
|
99
|
+
date_created: work.date_created,
|
|
100
|
+
depositor: work.depositor,
|
|
101
|
+
description: work.description
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
it 'round trips attributes' do # rubocop:disable RSpec/ExampleLength
|
|
105
|
+
persister.save(resource: factory.build)
|
|
106
|
+
|
|
107
|
+
expect(adapter.query_service.find_by_alternate_identifier(alternate_identifier: work.id))
|
|
108
|
+
.to have_attributes title: work.title,
|
|
109
|
+
date_created: work.date_created,
|
|
110
|
+
depositor: work.depositor,
|
|
111
|
+
description: work.description,
|
|
112
|
+
import_url: work.import_url,
|
|
113
|
+
publisher: work.publisher,
|
|
114
|
+
related_url: work.related_url,
|
|
115
|
+
source: work.source
|
|
116
|
+
end
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
context 'with relationship properties' do
|
|
120
|
+
let(:pcdm_object) { book }
|
|
121
|
+
let(:id) { 'moomin123' }
|
|
122
|
+
let(:book) { book_class.new(id: id, **attributes) }
|
|
123
|
+
let(:page1) { page_class.new(id: 'pg1') }
|
|
124
|
+
let(:page2) { page_class.new(id: 'pg2') }
|
|
125
|
+
|
|
126
|
+
let(:book_class) do
|
|
127
|
+
Book = Class.new(ActiveFedora::Base) do
|
|
128
|
+
has_many :pages
|
|
129
|
+
property :title, predicate: ::RDF::Vocab::DC.title
|
|
130
|
+
property :contributor, predicate: ::RDF::Vocab::DC.contributor
|
|
131
|
+
property :description, predicate: ::RDF::Vocab::DC.description
|
|
132
|
+
end
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
let(:page_class) do
|
|
136
|
+
Page = Class.new(ActiveFedora::Base) do
|
|
137
|
+
belongs_to :book_with_pages, predicate: ActiveFedora::RDF::Fcrepo::RelsExt.isPartOf
|
|
138
|
+
end
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
after do
|
|
142
|
+
Object.send(:remove_const, :Page)
|
|
143
|
+
Object.send(:remove_const, :Book)
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
let(:attributes) do
|
|
147
|
+
{
|
|
148
|
+
title: ['fake title', 'fake title 2'],
|
|
149
|
+
contributor: ['user1'],
|
|
150
|
+
description: ['a description'],
|
|
151
|
+
pages: [page1, page2]
|
|
152
|
+
}
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
describe '.for' do
|
|
156
|
+
it 'returns a Valkyrie::Resource' do
|
|
157
|
+
expect(described_class.for(book)).to be_a Valkyrie::Resource
|
|
158
|
+
end
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
describe '#build' do
|
|
162
|
+
it 'returns a Valkyrie::Resource' do
|
|
163
|
+
expect(subject.build).to be_a Valkyrie::Resource
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
it 'has the id of the active_fedora_object' do
|
|
167
|
+
expect(subject.build).to have_a_valkyrie_alternate_id_of book.id
|
|
168
|
+
end
|
|
169
|
+
|
|
170
|
+
it 'has attributes matching the active_fedora_object' do
|
|
171
|
+
expect(subject.build)
|
|
172
|
+
.to have_attributes title: book.title,
|
|
173
|
+
contributor: book.contributor,
|
|
174
|
+
description: book.description
|
|
175
|
+
expect_ids_to_match(subject.build.page_ids, ['pg1', 'pg2'])
|
|
176
|
+
end
|
|
177
|
+
end
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
context 'for PCDM & Hydra-Works models', :clean_repo do
|
|
181
|
+
let(:collection1) { build(:public_collection_lw, id: 'col1', title: ['Collection 1']) }
|
|
182
|
+
let(:collection2) { build(:public_collection_lw, id: 'col2', title: ['Collection 2']) }
|
|
183
|
+
let(:collection3) { build(:public_collection_lw, id: 'col3', title: ['Collection 3']) }
|
|
184
|
+
let(:work1) { build(:work, id: 'wk1', title: ['Work 1']) }
|
|
185
|
+
let(:work2) { build(:work, id: 'wk2', title: ['Work 2']) }
|
|
186
|
+
let(:work3) { build(:work, id: 'wk3', title: ['Work 3']) }
|
|
187
|
+
let(:fileset1) { build(:file_set, id: 'fs1', title: ['Fileset 1']) }
|
|
188
|
+
let(:fileset2) { build(:file_set, id: 'fs2', title: ['Fileset 2']) }
|
|
189
|
+
|
|
190
|
+
describe '#build' do
|
|
191
|
+
context 'for parent collection' do
|
|
192
|
+
before do
|
|
193
|
+
collection1.members = [work1, work2, collection2, collection3]
|
|
194
|
+
collection1.save!
|
|
195
|
+
end
|
|
196
|
+
|
|
197
|
+
let(:pcdm_object) { collection1 }
|
|
198
|
+
|
|
199
|
+
it 'returns a Valkyrie::Resource' do
|
|
200
|
+
expect(subject.build).to be_a Valkyrie::Resource
|
|
201
|
+
end
|
|
202
|
+
|
|
203
|
+
it 'has the id of the active_fedora_object' do
|
|
204
|
+
expect(subject.build).to have_a_valkyrie_alternate_id_of collection1.id
|
|
205
|
+
end
|
|
206
|
+
|
|
207
|
+
it 'has attributes for the PCDM model' do
|
|
208
|
+
expect(subject.build)
|
|
209
|
+
.to have_attributes title: collection1.title
|
|
210
|
+
expect_ids_to_match(subject.build.member_ids, [work1.id, work2.id, collection2.id, collection3.id])
|
|
211
|
+
end
|
|
212
|
+
end
|
|
213
|
+
|
|
214
|
+
context 'for child collection' do
|
|
215
|
+
let(:pcdm_object) { collection3 }
|
|
216
|
+
|
|
217
|
+
before do
|
|
218
|
+
collection3.member_of_collections = [collection1, collection2]
|
|
219
|
+
collection3.save!
|
|
220
|
+
end
|
|
221
|
+
|
|
222
|
+
it 'returns a Valkyrie::Resource' do
|
|
223
|
+
expect(subject.build).to be_a Valkyrie::Resource
|
|
224
|
+
end
|
|
225
|
+
|
|
226
|
+
it 'has the id of the active_fedora_object' do ###
|
|
227
|
+
expect(subject.build).to have_a_valkyrie_alternate_id_of collection3.id
|
|
228
|
+
end
|
|
229
|
+
|
|
230
|
+
it 'has attributes matching the active_fedora_object' do
|
|
231
|
+
expect(subject.build)
|
|
232
|
+
.to have_attributes title: collection3.title
|
|
233
|
+
expect_ids_to_match(subject.build.member_of_collection_ids, ['col1', 'col2'])
|
|
234
|
+
end
|
|
235
|
+
end
|
|
236
|
+
|
|
237
|
+
context 'for work in collection' do
|
|
238
|
+
let(:pcdm_object) { work1 }
|
|
239
|
+
|
|
240
|
+
before do
|
|
241
|
+
work1.member_of_collections = [collection1, collection2]
|
|
242
|
+
work1.save!
|
|
243
|
+
end
|
|
244
|
+
|
|
245
|
+
it 'returns a Valkyrie::Resource' do
|
|
246
|
+
expect(subject.build).to be_a Valkyrie::Resource
|
|
247
|
+
end
|
|
248
|
+
|
|
249
|
+
it 'has the id of the active_fedora_object' do ###
|
|
250
|
+
expect(subject.build).to have_a_valkyrie_alternate_id_of work1.id
|
|
251
|
+
end
|
|
252
|
+
|
|
253
|
+
it 'has attributes matching the active_fedora_object' do
|
|
254
|
+
expect(subject.build)
|
|
255
|
+
.to have_attributes title: work1.title
|
|
256
|
+
expect_ids_to_match(subject.build.member_of_collection_ids, ['col1', 'col2'])
|
|
257
|
+
end
|
|
258
|
+
end
|
|
259
|
+
|
|
260
|
+
context 'work with works and filesets' do
|
|
261
|
+
let(:pcdm_object) { work1 }
|
|
262
|
+
|
|
263
|
+
before do
|
|
264
|
+
work1.members = [work2, work3, fileset1, fileset2]
|
|
265
|
+
work1.save!
|
|
266
|
+
end
|
|
267
|
+
|
|
268
|
+
it 'returns a Valkyrie::Resource' do
|
|
269
|
+
expect(subject.build).to be_a Valkyrie::Resource
|
|
270
|
+
end
|
|
271
|
+
|
|
272
|
+
it 'has the id of the active_fedora_object' do ###
|
|
273
|
+
expect(subject.build).to have_a_valkyrie_alternate_id_of work1.id
|
|
274
|
+
end
|
|
275
|
+
|
|
276
|
+
it 'has attributes matching the active_fedora_object' do
|
|
277
|
+
expect(subject.build)
|
|
278
|
+
.to have_attributes title: work1.title
|
|
279
|
+
expect_ids_to_match(subject.build.member_ids, [work2.id, work3.id, fileset1.id, fileset2.id])
|
|
280
|
+
end
|
|
281
|
+
end
|
|
282
|
+
end
|
|
283
|
+
end
|
|
284
|
+
|
|
285
|
+
def expect_ids_to_match(valkyrie_ids, expected_ids)
|
|
286
|
+
expect(valkyrie_ids.map(&:id)).to match_array expected_ids
|
|
287
|
+
end
|
|
288
|
+
end
|