hyrax 2.1.0.beta2 → 2.1.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/CODE_OF_CONDUCT.md +5 -5
- data/.github/CONTRIBUTING.md +2 -2
- data/.rubocop.yml +1 -0
- data/.rubocop_fixme.yml +2 -0
- data/Gemfile +1 -0
- data/README.md +3 -2
- data/app/actors/hyrax/actors/collections_membership_actor.rb +3 -0
- data/app/actors/hyrax/actors/create_with_remote_files_actor.rb +4 -3
- data/app/actors/hyrax/actors/default_admin_set_actor.rb +9 -6
- data/app/assets/javascripts/hyrax.js +3 -0
- data/app/assets/javascripts/hyrax/app.js.erb +14 -0
- data/app/assets/javascripts/hyrax/batch_edit.js +2 -1
- data/app/assets/javascripts/hyrax/collection_types.es6 +97 -36
- data/app/assets/javascripts/hyrax/collections.js +15 -49
- data/app/assets/javascripts/hyrax/collections_utils.es6 +116 -0
- data/app/assets/javascripts/hyrax/collections_v2.es6 +57 -0
- data/app/assets/javascripts/hyrax/content_blocks.js +1 -13
- data/app/assets/javascripts/hyrax/nav_safety.js +41 -0
- data/app/assets/javascripts/hyrax/turbolinks_events.js +3 -0
- data/app/assets/stylesheets/hyrax/_collection_types.scss +46 -2
- data/app/assets/stylesheets/hyrax/_work-show.scss +6 -9
- data/app/assets/stylesheets/hyrax/dashboard.scss +2 -0
- data/app/assets/stylesheets/hyrax/sidebar.scss +4 -0
- data/app/controllers/concerns/hyrax/works_controller_behavior.rb +10 -2
- data/app/controllers/hyrax/admin/admin_sets_controller.rb +2 -9
- data/app/controllers/hyrax/admin/collection_types_controller.rb +1 -1
- data/app/controllers/hyrax/batch_edits_controller.rb +30 -4
- data/app/controllers/hyrax/dashboard/collection_members_controller.rb +1 -0
- data/app/controllers/hyrax/dashboard/collections_controller.rb +4 -1
- data/app/controllers/hyrax/downloads_controller.rb +7 -1
- data/app/forms/hyrax/forms/admin/collection_type_form.rb +1 -1
- data/app/indexers/hyrax/repository_reindexer.rb +1 -1
- data/app/jobs/attach_files_to_work_job.rb +8 -4
- data/app/jobs/import_url_job.rb +11 -5
- data/app/models/admin_set.rb +25 -3
- data/app/models/concerns/hyrax/collection_behavior.rb +23 -11
- data/app/models/concerns/hyrax/collection_nesting.rb +22 -3
- data/app/models/hyrax/permission_template_access.rb +7 -4
- data/app/presenters/hyrax/admin_set_presenter.rb +21 -0
- data/app/presenters/hyrax/collection_presenter.rb +23 -1
- data/app/presenters/hyrax/dashboard/user_presenter.rb +4 -0
- data/app/presenters/hyrax/presents_attributes.rb +6 -2
- data/app/presenters/hyrax/work_show_presenter.rb +4 -0
- data/app/renderers/hyrax/renderers/attribute_renderer.rb +14 -0
- data/app/services/hyrax/adapters/nesting_index_adapter.rb +19 -39
- data/app/services/hyrax/admin_set_create_service.rb +1 -1
- data/app/services/hyrax/collection_types/create_service.rb +4 -0
- data/app/services/hyrax/collections/migration_service.rb +25 -2
- data/app/services/hyrax/collections/nested_collection_persistence_service.rb +8 -3
- data/app/services/hyrax/collections/nested_collection_query_service.rb +3 -3
- data/app/services/hyrax/default_middleware_stack.rb +3 -3
- data/app/services/hyrax/multiple_membership_checker.rb +4 -2
- data/app/views/catalog/_index_header_list_collection.html.erb +1 -1
- data/app/views/catalog/_search_form.html.erb +0 -4
- data/app/views/hyrax/admin/admin_sets/_show_actions.html.erb +27 -0
- data/app/views/hyrax/admin/admin_sets/show.html.erb +1 -25
- data/app/views/hyrax/admin/collection_types/_form.html.erb +17 -6
- data/app/views/hyrax/admin/collection_types/_form_appearance.html.erb +5 -0
- data/app/views/hyrax/admin/collection_types/_form_participant_table.html.erb +1 -1
- data/app/views/hyrax/admin/collection_types/_form_participants.html.erb +56 -52
- data/app/views/hyrax/admin/collection_types/edit.html.erb +9 -7
- data/app/views/hyrax/admin/collection_types/index.html.erb +1 -1
- data/app/views/hyrax/base/_attribute_rows.html.erb +15 -14
- data/app/views/hyrax/base/_form.html.erb +1 -0
- data/app/views/hyrax/base/_form_collections_error.html.erb +1 -0
- data/app/views/hyrax/base/_items.html.erb +3 -2
- data/app/views/hyrax/base/_metadata.html.erb +5 -7
- data/app/views/hyrax/base/_relationships.html.erb +3 -5
- data/app/views/hyrax/base/_relationships_parent_row.html.erb +4 -5
- data/app/views/hyrax/base/_relationships_parent_rows.html.erb +2 -1
- data/app/views/hyrax/base/_show_actions.html.erb +11 -1
- data/app/views/hyrax/batch_edits/edit.html.erb +57 -17
- data/app/views/hyrax/collections/_list_collections.html.erb +1 -1
- data/app/views/hyrax/collections/show.html.erb +1 -1
- data/app/views/hyrax/content_blocks/_form.html.erb +8 -7
- data/app/views/hyrax/dashboard/_index_partials/_current_proxy_rights.html.erb +17 -0
- data/app/views/hyrax/dashboard/collections/_collection_title.html.erb +1 -3
- data/app/views/hyrax/dashboard/collections/_default_group.html.erb +30 -0
- data/app/views/hyrax/dashboard/collections/_form_branding.html.erb +2 -2
- data/app/views/hyrax/dashboard/collections/_form_for_select_collection.html.erb +1 -1
- data/app/views/hyrax/dashboard/collections/_form_share.html.erb +2 -2
- data/app/views/hyrax/dashboard/collections/_list_collections.html.erb +13 -2
- data/app/views/hyrax/dashboard/show_user.html.erb +10 -9
- data/app/views/hyrax/my/collections/_list_collections.html.erb +10 -3
- data/app/views/hyrax/my/collections/_modal_add_subcollection.html.erb +1 -1
- data/app/views/hyrax/my/collections/_modal_add_to_collection.html.erb +1 -1
- data/app/views/hyrax/my/collections/_modal_delete_collections_deny.html.erb +14 -0
- data/app/views/hyrax/my/collections/index.html.erb +1 -0
- data/app/views/shared/_nav_safety_modal.html.erb +12 -0
- data/config/features.rb +4 -0
- data/config/initializers/samvera-nesting_indexer_initializer.rb +1 -0
- data/config/locales/hyrax.de.yml +26 -11
- data/config/locales/hyrax.en.yml +21 -6
- data/config/locales/hyrax.es.yml +17 -2
- data/config/locales/hyrax.fr.yml +17 -2
- data/config/locales/hyrax.it.yml +17 -2
- data/config/locales/hyrax.pt-BR.yml +17 -2
- data/config/locales/hyrax.zh.yml +17 -2
- data/config/locales/simple_form.en.yml +6 -27
- data/hyrax.gemspec +2 -2
- data/lib/generators/hyrax/assets_generator.rb +4 -0
- data/lib/generators/hyrax/install_generator.rb +10 -0
- data/lib/generators/hyrax/templates/app/assets/images/unauthorized.png +0 -0
- data/lib/generators/hyrax/templates/config/locales/hyrax.en.yml +6 -5
- data/lib/generators/hyrax/templates/config/tinymce.yml +12 -7
- data/lib/generators/hyrax/templates/db/migrate/20180406202557_add_badge_color_to_collection_types.rb.erb +5 -0
- data/lib/hyrax/configuration.rb +1 -1
- data/lib/hyrax/version.rb +1 -1
- data/spec/actors/hyrax/actors/collections_membership_actor_spec.rb +24 -0
- data/spec/actors/hyrax/actors/create_with_remote_files_actor_spec.rb +19 -1
- data/spec/actors/hyrax/actors/default_admin_set_actor_spec.rb +41 -8
- data/spec/actors/hyrax/actors/file_set_actor_spec.rb +4 -12
- data/spec/actors/hyrax/actors/generic_work_actor_spec.rb +3 -7
- data/spec/controllers/hyrax/admin/strategies_controller_spec.rb +13 -2
- data/spec/controllers/hyrax/batch_edits_controller_spec.rb +83 -8
- data/spec/controllers/hyrax/dashboard/collections_controller_spec.rb +3 -0
- data/spec/controllers/hyrax/downloads_controller_spec.rb +26 -5
- data/spec/controllers/hyrax/file_sets_controller_spec.rb +3 -6
- data/spec/controllers/hyrax/generic_works_controller_json_spec.rb +4 -4
- data/spec/controllers/hyrax/generic_works_controller_spec.rb +3 -23
- data/spec/controllers/hyrax/transfers_controller_spec.rb +1 -1
- data/spec/factories/admin_sets_lw.rb +215 -0
- data/spec/factories/collections.rb +10 -10
- data/spec/factory_tests/adminsets_factory_spec.rb +132 -0
- data/spec/factory_tests/collections_factory_spec.rb +3 -3
- data/spec/features/batch_create_spec.rb +5 -8
- data/spec/features/batch_edit_spec.rb +49 -2
- data/spec/features/collection_multi_membership_spec.rb +29 -14
- data/spec/features/collection_type_spec.rb +9 -2
- data/spec/features/create_work_admin_spec.rb +1 -1
- data/spec/features/create_work_spec.rb +1 -1
- data/spec/features/dashboard/collection_spec.rb +16 -12
- data/spec/features/edit_content_block_admin_spec.rb +29 -12
- data/spec/features/embargo_spec.rb +55 -0
- data/spec/features/proxy_spec.rb +3 -1
- data/spec/features/work_show_spec.rb +20 -4
- data/spec/forms/hyrax/forms/admin/collection_type_form_spec.rb +1 -0
- data/spec/indexers/hyrax/repository_reindexer_spec.rb +1 -1
- data/spec/jobs/attach_files_to_work_job_spec.rb +15 -3
- data/spec/jobs/batch_create_job_spec.rb +6 -6
- data/spec/jobs/create_work_job_spec.rb +1 -1
- data/spec/models/admin_set_spec.rb +10 -8
- data/spec/models/collection_spec.rb +1 -1
- data/spec/models/concerns/hyrax/collection_nesting_spec.rb +6 -3
- data/spec/models/flipflop_spec.rb +8 -0
- data/spec/models/hyrax/work_behavior_spec.rb +1 -1
- data/spec/presenters/hyrax/admin_set_presenter_spec.rb +70 -0
- data/spec/presenters/hyrax/collection_presenter_spec.rb +66 -0
- data/spec/renderers/hyrax/renderers/attribute_renderer_spec.rb +19 -0
- data/spec/services/hyrax/adapters/nesting_index_adapter_spec.rb +31 -21
- data/spec/services/hyrax/collection_types/create_service_spec.rb +7 -4
- data/spec/services/hyrax/collections/migration_service_spec.rb +204 -17
- data/spec/services/hyrax/collections/nested_collection_persistence_service_spec.rb +1 -1
- data/spec/services/hyrax/collections/permissions_create_service_spec.rb +1 -1
- data/spec/services/hyrax/collections/permissions_service_spec.rb +4 -0
- data/spec/services/hyrax/default_middleware_stack_spec.rb +1 -1
- data/spec/services/hyrax/multiple_membership_checker_spec.rb +4 -4
- data/spec/services/hyrax/workflow/grant_edit_to_depositor_spec.rb +1 -1
- data/spec/services/hyrax/workflow/grant_read_to_depositor_spec.rb +1 -1
- data/spec/services/hyrax/workflow/revoke_edit_from_depositor_spec.rb +1 -1
- data/spec/spec_helper.rb +35 -2
- data/spec/support/features/batch_edit_actions.rb +1 -1
- data/spec/support/selectors.rb +15 -0
- data/spec/views/hyrax/admin/admin_sets/_show_actions.html.erb_spec.rb +66 -0
- data/spec/views/hyrax/admin/admin_sets/show.html.erb_spec.rb +5 -34
- data/spec/views/hyrax/admin/collection_types/_form.html.erb_spec.rb +3 -1
- data/spec/views/hyrax/admin/collection_types/_form_appearance.html.erb_spec.rb +22 -0
- data/spec/views/hyrax/admin/collection_types/_form_participants.html.erb_spec.rb +11 -3
- data/spec/views/hyrax/base/_items.html.erb_spec.rb +46 -0
- data/spec/views/hyrax/base/_relationships.html.erb_spec.rb +1 -1
- data/spec/views/hyrax/base/_show_actions.html.erb_spec.rb +4 -2
- data/spec/views/hyrax/dashboard/collections/_default_group.html.erb_spec.rb +43 -0
- data/spec/views/hyrax/dashboard/collections/_list_collections.html.erb_spec.rb +51 -0
- data/spec/views/hyrax/dashboard/collections/show.html.erb_spec.rb +1 -0
- data/spec/views/hyrax/dashboard/show_user_spec.rb +5 -2
- data/spec/views/hyrax/my/collections/_list_collections.html.erb_spec.rb +2 -0
- data/template.rb +1 -1
- metadata +30 -13
- data/app/views/hyrax/content_blocks/_modal_content_block.html.erb +0 -15
@@ -73,6 +73,25 @@ RSpec.describe Hyrax::Renderers::AttributeRenderer do
|
|
73
73
|
end
|
74
74
|
end
|
75
75
|
|
76
|
+
describe "#render_dl_row" do
|
77
|
+
subject { Nokogiri::HTML(renderer.render_dl_row) }
|
78
|
+
|
79
|
+
let(:expected) { Nokogiri::HTML(dl_content) }
|
80
|
+
let(:dl_content) do
|
81
|
+
"<dt>Name</dt>\n" \
|
82
|
+
"<dd><ul class='tabular'><li class=\"attribute attribute-name\">Bob</li>\n" \
|
83
|
+
"<li class=\"attribute attribute-name\">Jessica</li>\n" \
|
84
|
+
"</ul></dd>"
|
85
|
+
end
|
86
|
+
|
87
|
+
before do
|
88
|
+
allow(Hyrax.config).to receive(:display_microdata?).and_return(false)
|
89
|
+
end
|
90
|
+
|
91
|
+
it { expect(renderer).not_to be_microdata(field) }
|
92
|
+
it { expect(subject).to be_equivalent_to(expected) }
|
93
|
+
end
|
94
|
+
|
76
95
|
describe "#label" do
|
77
96
|
subject { renderer }
|
78
97
|
|
@@ -80,13 +80,15 @@ RSpec.describe Hyrax::Adapters::NestingIndexAdapter do
|
|
80
80
|
|
81
81
|
describe '.each_child_document_of', clean_repo: true do
|
82
82
|
let(:ancestors_key) { described_class.solr_field_name_for_storing_ancestors }
|
83
|
+
let(:pathnames_key) { described_class.solr_field_name_for_storing_pathnames }
|
83
84
|
let(:index_document_class) { Samvera::NestingIndexer::Documents::IndexDocument }
|
84
85
|
let(:parent) { { id: document.id } }
|
85
86
|
let(:document) { index_document_class.new(id: 'parent-1', pathnames: ['parent-1'], parent_ids: [], ancestors: []) }
|
86
87
|
let(:children) do
|
87
88
|
[{ id: 'child-1',
|
88
89
|
member_of_collection_ids_ssim: [document.id],
|
89
|
-
ancestors_key => [document.id]
|
90
|
+
ancestors_key => [document.id],
|
91
|
+
pathnames_key => ['child-1'] },
|
90
92
|
{ id: 'child-2',
|
91
93
|
member_of_collection_ids_ssim: [document.id],
|
92
94
|
ancestors_key => [document.id] }]
|
@@ -94,10 +96,12 @@ RSpec.describe Hyrax::Adapters::NestingIndexAdapter do
|
|
94
96
|
let(:not_my_children) do
|
95
97
|
[{ id: 'youre-not-my-dad-1',
|
96
98
|
member_of_collection_ids_ssim: ['parent-2'],
|
97
|
-
ancestors_key => ['parent-2']
|
99
|
+
ancestors_key => ['parent-2'],
|
100
|
+
pathnames_key => ['youre-not-my-dad-1'] },
|
98
101
|
{ id: 'i-am-your-grandchild',
|
99
102
|
member_of_collection_ids_ssim: ['parent-3'],
|
100
|
-
ancestors_key => ['parent-1/parent-3']
|
103
|
+
ancestors_key => ['parent-1/parent-3'],
|
104
|
+
pathnames_key => ['i-am-your-grandchild'] }]
|
101
105
|
end
|
102
106
|
|
103
107
|
before do
|
@@ -106,15 +110,31 @@ RSpec.describe Hyrax::Adapters::NestingIndexAdapter do
|
|
106
110
|
end
|
107
111
|
end
|
108
112
|
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
+
context 'with full reindexing extent' do
|
114
|
+
it 'yields all of the child solr-documents of the given document' do
|
115
|
+
child_index_documents = []
|
116
|
+
described_class.each_child_document_of(document: document, extent: Hyrax::Adapters::NestingIndexAdapter::FULL_REINDEX) do |doc|
|
117
|
+
child_index_documents << doc
|
118
|
+
end
|
119
|
+
expect(child_index_documents.count).to eq(2)
|
120
|
+
child_index_documents.each do |child|
|
121
|
+
expect(child).to be_a(index_document_class)
|
122
|
+
expect(child.ancestors).to eq([document.id])
|
123
|
+
end
|
113
124
|
end
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
125
|
+
end
|
126
|
+
|
127
|
+
context 'with limited reindexing extent' do
|
128
|
+
it 'yields only child documents without pathnames' do
|
129
|
+
child_index_documents = []
|
130
|
+
described_class.each_child_document_of(document: document, extent: Hyrax::Adapters::NestingIndexAdapter::LIMITED_REINDEX) do |doc|
|
131
|
+
child_index_documents << doc
|
132
|
+
end
|
133
|
+
expect(child_index_documents.count).to eq(1)
|
134
|
+
child_index_documents.each do |child|
|
135
|
+
expect(child).to be_a(index_document_class)
|
136
|
+
expect(child.ancestors).to eq([document.id])
|
137
|
+
end
|
118
138
|
end
|
119
139
|
end
|
120
140
|
end
|
@@ -159,16 +179,6 @@ RSpec.describe Hyrax::Adapters::NestingIndexAdapter do
|
|
159
179
|
# rubocop:enable RSpec/ExampleLength
|
160
180
|
end
|
161
181
|
|
162
|
-
describe '.write_document_attributes_to_index_layer' do
|
163
|
-
it 'is not implemented and deprecated' do
|
164
|
-
expect do
|
165
|
-
described_class.write_document_attributes_to_index_layer(
|
166
|
-
id: 1, parent_ids: 2, ancestors: 3, pathnames: 4, deepest_nested_depth: 5
|
167
|
-
)
|
168
|
-
end.to raise_error(NotImplementedError)
|
169
|
-
end
|
170
|
-
end
|
171
|
-
|
172
182
|
describe '.solr_field_name_for_storing_ancestors' do
|
173
183
|
subject { described_class.solr_field_name_for_storing_ancestors }
|
174
184
|
|
@@ -6,6 +6,7 @@ RSpec.describe Hyrax::CollectionTypes::CreateService do
|
|
6
6
|
expect(ct.machine_id).to eq('custom_type')
|
7
7
|
expect(ct.title).to eq('Custom Type')
|
8
8
|
expect(ct.description).to eq('')
|
9
|
+
expect(ct.badge_color).to eq('#663333')
|
9
10
|
expect(ct).to be_nestable
|
10
11
|
expect(ct).to be_discoverable
|
11
12
|
expect(ct).to be_brandable
|
@@ -18,13 +19,13 @@ RSpec.describe Hyrax::CollectionTypes::CreateService do
|
|
18
19
|
end
|
19
20
|
|
20
21
|
it 'creates a collection type for the options received' do
|
21
|
-
options = {
|
22
|
-
|
23
|
-
|
24
|
-
}
|
22
|
+
options = { description: 'A collection type with options.',
|
23
|
+
badge_color: '#ffa510',
|
24
|
+
discoverable: false }
|
25
25
|
described_class.create_collection_type(machine_id: 'custom_type', title: 'Custom Type', options: options)
|
26
26
|
ct = Hyrax::CollectionType.find_by_machine_id('custom_type')
|
27
27
|
expect(ct.description).to include('with options')
|
28
|
+
expect(ct.badge_color).to include('#ffa510')
|
28
29
|
expect(ct).not_to be_discoverable
|
29
30
|
end
|
30
31
|
|
@@ -42,6 +43,7 @@ RSpec.describe Hyrax::CollectionTypes::CreateService do
|
|
42
43
|
expect(ct.machine_id).to eq(Hyrax::CollectionType::ADMIN_SET_MACHINE_ID)
|
43
44
|
expect(ct.title).to eq(Hyrax::CollectionType::ADMIN_SET_DEFAULT_TITLE)
|
44
45
|
expect(ct.description).to eq('An aggregation of works that is intended to help with administrative control. Admin Sets provide a way of defining behaviors and policies around a set of works.')
|
46
|
+
expect(ct.badge_color).to eq('#663333')
|
45
47
|
expect(ct).not_to be_nestable
|
46
48
|
expect(ct).not_to be_brandable
|
47
49
|
expect(ct).not_to be_discoverable
|
@@ -61,6 +63,7 @@ RSpec.describe Hyrax::CollectionTypes::CreateService do
|
|
61
63
|
expect(ct.machine_id).to eq(Hyrax::CollectionType::USER_COLLECTION_MACHINE_ID)
|
62
64
|
expect(ct.title).to eq(Hyrax::CollectionType::USER_COLLECTION_DEFAULT_TITLE)
|
63
65
|
expect(ct.description).to eq('A User Collection can be created by any user to organize their works.')
|
66
|
+
expect(ct.badge_color).to eq('#663333')
|
64
67
|
expect(ct).to be_nestable
|
65
68
|
expect(ct).to be_brandable
|
66
69
|
expect(ct).to be_discoverable
|
@@ -4,15 +4,21 @@ RSpec.describe Hyrax::Collections::MigrationService, clean_repo: true do
|
|
4
4
|
let(:editor2) { create(:user) }
|
5
5
|
let(:reader1) { create(:user) }
|
6
6
|
let(:reader2) { create(:user) }
|
7
|
+
let(:manager1) { create(:user) }
|
8
|
+
let(:manager2) { create(:user) }
|
9
|
+
let(:depositor1) { create(:user) }
|
10
|
+
let(:depositor2) { create(:user) }
|
11
|
+
let(:viewer1) { create(:user) }
|
12
|
+
let(:viewer2) { create(:user) }
|
7
13
|
let(:default_gid) { create(:user_collection_type).gid }
|
8
14
|
|
9
15
|
describe ".migrate_all_collections" do
|
10
16
|
context 'when legacy collections are found (e.g. collections created before Hyrax 2.1.0)' do
|
11
17
|
let!(:col_none) { build(:typeless_collection, id: 'col_none', user: user, edit_users: [user.user_key], do_save: true) }
|
12
18
|
let!(:col_vu) { build(:typeless_collection, id: 'col_vu', user: user, edit_users: [user.user_key], read_users: [reader1.user_key, reader2.user_key], do_save: true) }
|
13
|
-
let!(:col_vg) { build(:typeless_collection, id: 'col_vg', user: user, edit_users: [user.user_key], read_groups: ['
|
19
|
+
let!(:col_vg) { build(:typeless_collection, id: 'col_vg', user: user, edit_users: [user.user_key], read_groups: ['read_group_1', 'read_group_2'], do_save: true) }
|
14
20
|
let!(:col_mu) { build(:typeless_collection, id: 'col_mu', user: user, edit_users: [user.user_key, editor1.user_key, editor2.user_key], do_save: true) }
|
15
|
-
let!(:col_mg) { build(:typeless_collection, id: 'col_mg', user: user, edit_users: [user.user_key], edit_groups: ['
|
21
|
+
let!(:col_mg) { build(:typeless_collection, id: 'col_mg', user: user, edit_users: [user.user_key], edit_groups: ['edit_group_1', 'edit_group_2'], do_save: true) }
|
16
22
|
|
17
23
|
it 'sets gid and adds permissions' do # rubocop:disable RSpec/ExampleLength
|
18
24
|
Collection.all.each do |col|
|
@@ -28,6 +34,8 @@ RSpec.describe Hyrax::Collections::MigrationService, clean_repo: true do
|
|
28
34
|
expect(pt_id).not_to be_nil
|
29
35
|
expect_access(pt_id, 'user', :manage, col.edit_users)
|
30
36
|
expect_access(pt_id, 'group', :manage, col.edit_groups)
|
37
|
+
expect_access(pt_id, 'user', :deposit, [])
|
38
|
+
expect_access(pt_id, 'group', :deposit, [])
|
31
39
|
expect_access(pt_id, 'user', :view, col.read_users)
|
32
40
|
expect_access(pt_id, 'group', :view, col.read_groups)
|
33
41
|
end
|
@@ -36,24 +44,107 @@ RSpec.describe Hyrax::Collections::MigrationService, clean_repo: true do
|
|
36
44
|
|
37
45
|
context 'when newer collections are found (e.g. collections created at or after Hyrax 2.1.0)' do
|
38
46
|
let!(:collection) do
|
39
|
-
|
40
|
-
|
41
|
-
|
47
|
+
build(:collection_lw,
|
48
|
+
id: 'col_newer', user: user,
|
49
|
+
with_permission_template: { manage_users: [manager1.user_key] },
|
50
|
+
with_solr_document: true)
|
42
51
|
end
|
43
52
|
let!(:permission_template) { collection.permission_template }
|
44
53
|
let!(:collection_type_gid) { collection.collection_type_gid }
|
45
54
|
let!(:edit_users) { collection.edit_users }
|
46
55
|
|
56
|
+
before do
|
57
|
+
allow(Collection).to receive(:all).and_return([collection])
|
58
|
+
end
|
59
|
+
|
47
60
|
it "doesn't change the collection" do
|
48
61
|
expect(collection.collection_type_gid).to eq collection_type_gid
|
49
62
|
expect(Hyrax::PermissionTemplate.find_by!(source_id: collection.id).id).to eq permission_template.id
|
50
|
-
expect_access(permission_template.id, 'user', :manage,
|
63
|
+
expect_access(permission_template.id, 'user', :manage, [user.user_key, manager1.user_key])
|
51
64
|
|
52
65
|
Hyrax::Collections::MigrationService.migrate_all_collections
|
53
66
|
|
54
67
|
expect(collection.collection_type_gid).to eq collection_type_gid
|
55
68
|
expect(Hyrax::PermissionTemplate.find_by!(source_id: collection.id).id).to eq permission_template.id
|
56
|
-
expect_access(permission_template.id, 'user', :manage,
|
69
|
+
expect_access(permission_template.id, 'user', :manage, [user.user_key, manager1.user_key])
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
context 'when legacy adminsets are found (e.g. adminsets created before Hyrax 2.1.0)' do
|
74
|
+
let!(:as_none) { build(:no_solr_grants_adminset, id: 'as_none', user: user) }
|
75
|
+
let!(:as_vu) { build(:no_solr_grants_adminset, id: 'as_vu', user: user, with_permission_template: { view_users: [reader1.user_key, reader2.user_key] }) }
|
76
|
+
let!(:as_vg) { build(:no_solr_grants_adminset, id: 'as_vg', user: user, with_permission_template: { view_groups: ['read_group_1', 'read_group_2'] }) }
|
77
|
+
let!(:as_du) { build(:no_solr_grants_adminset, id: 'as_du', user: user, with_permission_template: { deposit_users: [depositor1.user_key, depositor2.user_key] }) }
|
78
|
+
let!(:as_dg) { build(:no_solr_grants_adminset, id: 'as_dg', user: user, with_permission_template: { deposit_groups: ['deposit_group_1', 'deposit_group_2'] }) }
|
79
|
+
let!(:as_mu) { build(:no_solr_grants_adminset, id: 'as_mu', user: user, with_permission_template: { manage_users: [editor1.user_key, editor2.user_key] }) }
|
80
|
+
let!(:as_mg) { build(:no_solr_grants_adminset, id: 'as_mg', user: user, with_permission_template: { manage_groups: ['edit_group_1', 'edit_group_2'] }) }
|
81
|
+
|
82
|
+
before do
|
83
|
+
allow(AdminSet).to receive(:all).and_return([as_none, as_vu, as_vg, as_du, as_dg, as_mu, as_mg])
|
84
|
+
end
|
85
|
+
|
86
|
+
it 'sets read and edit access in solr doc' do # rubocop:disable RSpec/ExampleLength
|
87
|
+
AdminSet.all.each do |adminset|
|
88
|
+
expect(adminset.edit_users).to include(user.user_key)
|
89
|
+
expect(adminset.read_users).to eq []
|
90
|
+
end
|
91
|
+
|
92
|
+
Hyrax::Collections::MigrationService.migrate_all_collections
|
93
|
+
|
94
|
+
AdminSet.all.each do |adminset|
|
95
|
+
pt_id = Hyrax::PermissionTemplate.find_by!(source_id: adminset.id)
|
96
|
+
expect(pt_id).not_to be_nil
|
97
|
+
expect_solr_access(pt_id, 'user', :manage, adminset.edit_users)
|
98
|
+
expect_solr_access(pt_id, 'group', :manage, adminset.edit_groups)
|
99
|
+
expect_solr_access(pt_id, 'user', :deposit, adminset.read_users)
|
100
|
+
expect_solr_access(pt_id, 'group', :deposit, adminset.read_groups)
|
101
|
+
expect_solr_access(pt_id, 'user', :view, adminset.read_users)
|
102
|
+
expect_solr_access(pt_id, 'group', :view, adminset.read_groups)
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
context 'when newer adminsets are found (e.g. adminsets created at or after Hyrax 2.1.0)' do
|
108
|
+
let!(:adminset) do
|
109
|
+
build(:adminset_lw,
|
110
|
+
id: 'as_newer', user: user,
|
111
|
+
with_permission_template: {
|
112
|
+
manage_users: [editor1.user_key, editor2.user_key],
|
113
|
+
deposit_users: [depositor1.user_key, depositor2.user_key],
|
114
|
+
view_users: [viewer1.user_key, viewer2.user_key],
|
115
|
+
manage_groups: ['manage_group_1', 'manage_group_2'],
|
116
|
+
deposit_groups: ['deposit_group_1', 'deposit_group_2'],
|
117
|
+
view_groups: ['view_group_1', 'view_group_2']
|
118
|
+
},
|
119
|
+
with_solr_document: true)
|
120
|
+
end
|
121
|
+
let!(:permission_template) { adminset.permission_template }
|
122
|
+
let!(:edit_users) { adminset.edit_users }
|
123
|
+
|
124
|
+
before do
|
125
|
+
allow(AdminSet).to receive(:all).and_return([adminset])
|
126
|
+
end
|
127
|
+
|
128
|
+
it "doesn't change the adminset" do # rubocop:disable RSpec/ExampleLength
|
129
|
+
pt_id = Hyrax::PermissionTemplate.find_by!(source_id: adminset.id).id
|
130
|
+
expect(pt_id).to eq permission_template.id
|
131
|
+
expect_solr_access(pt_id, 'user', :manage, adminset.edit_users)
|
132
|
+
expect_solr_access(pt_id, 'group', :manage, adminset.edit_groups)
|
133
|
+
expect_solr_access(pt_id, 'user', :deposit, adminset.read_users)
|
134
|
+
expect_solr_access(pt_id, 'group', :deposit, adminset.read_groups)
|
135
|
+
expect_solr_access(pt_id, 'user', :view, adminset.read_users)
|
136
|
+
expect_solr_access(pt_id, 'group', :view, adminset.read_groups)
|
137
|
+
|
138
|
+
Hyrax::Collections::MigrationService.migrate_all_collections
|
139
|
+
|
140
|
+
pt_id = Hyrax::PermissionTemplate.find_by!(source_id: adminset.id).id
|
141
|
+
expect(pt_id).to eq permission_template.id
|
142
|
+
expect_solr_access(pt_id, 'user', :manage, adminset.edit_users)
|
143
|
+
expect_solr_access(pt_id, 'group', :manage, adminset.edit_groups)
|
144
|
+
expect_solr_access(pt_id, 'user', :deposit, adminset.read_users)
|
145
|
+
expect_solr_access(pt_id, 'group', :deposit, adminset.read_groups)
|
146
|
+
expect_solr_access(pt_id, 'user', :view, adminset.read_users)
|
147
|
+
expect_solr_access(pt_id, 'group', :view, adminset.read_groups)
|
57
148
|
end
|
58
149
|
end
|
59
150
|
end
|
@@ -62,16 +153,16 @@ RSpec.describe Hyrax::Collections::MigrationService, clean_repo: true do
|
|
62
153
|
context 'when legacy collections are found (e.g. collections created before Hyrax 2.1.0)' do
|
63
154
|
let!(:col_none) { build(:typeless_collection, id: 'col_none', user: user, edit_users: [user.user_key], do_save: true) }
|
64
155
|
let!(:col_vu) { build(:typeless_collection, id: 'col_vu', user: user, edit_users: [user.user_key], read_users: [reader1.user_key, reader2.user_key], do_save: true) }
|
65
|
-
let!(:col_vg) { build(:typeless_collection, id: 'col_vg', user: user, edit_users: [user.user_key], read_groups: ['
|
156
|
+
let!(:col_vg) { build(:typeless_collection, id: 'col_vg', user: user, edit_users: [user.user_key], read_groups: ['read_group_1', 'read_group_2'], do_save: true) }
|
66
157
|
let!(:col_mu) { build(:typeless_collection, id: 'col_mu', user: user, edit_users: [user.user_key, editor1.user_key, editor2.user_key], do_save: true) }
|
67
|
-
let!(:col_mg) { build(:typeless_collection, id: 'col_mg', user: user, edit_users: [user.user_key], edit_groups: ['
|
158
|
+
let!(:col_mg) { build(:typeless_collection, id: 'col_mg', user: user, edit_users: [user.user_key], edit_groups: ['edit_group_1', 'edit_group_2'], do_save: true) }
|
68
159
|
|
69
160
|
context "and collection wasn't migrated at all" do
|
70
161
|
let!(:col_none) { build(:typeless_collection, id: 'col_none', user: user, edit_users: [user.user_key], do_save: true) }
|
71
162
|
let!(:col_vu) { build(:typeless_collection, id: 'col_vu', user: user, edit_users: [user.user_key], read_users: [reader1.user_key, reader2.user_key], do_save: true) }
|
72
|
-
let!(:col_vg) { build(:typeless_collection, id: 'col_vg', user: user, edit_users: [user.user_key], read_groups: ['
|
163
|
+
let!(:col_vg) { build(:typeless_collection, id: 'col_vg', user: user, edit_users: [user.user_key], read_groups: ['read_group_1', 'read_group_2'], do_save: true) }
|
73
164
|
let!(:col_mu) { build(:typeless_collection, id: 'col_mu', user: user, edit_users: [user.user_key, editor1.user_key, editor2.user_key], do_save: true) }
|
74
|
-
let!(:col_mg) { build(:typeless_collection, id: 'col_mg', user: user, edit_users: [user.user_key], edit_groups: ['
|
165
|
+
let!(:col_mg) { build(:typeless_collection, id: 'col_mg', user: user, edit_users: [user.user_key], edit_groups: ['edit_group_1', 'edit_group_2'], do_save: true) }
|
75
166
|
|
76
167
|
it 'sets gid and adds permissions' do # rubocop:disable RSpec/ExampleLength
|
77
168
|
Collection.all.each do |col|
|
@@ -96,9 +187,9 @@ RSpec.describe Hyrax::Collections::MigrationService, clean_repo: true do
|
|
96
187
|
context "and collection type gid is set but permission template doesn't exist" do
|
97
188
|
let!(:col_none) { create(:user_collection, id: 'col_none', user: user, edit_users: [user.user_key], collection_type_gid: default_gid) }
|
98
189
|
let!(:col_vu) { create(:user_collection, id: 'col_vu', user: user, edit_users: [user.user_key], read_users: [reader1.user_key, reader2.user_key], collection_type_gid: default_gid) }
|
99
|
-
let!(:col_vg) { create(:user_collection, id: 'col_vg', user: user, edit_users: [user.user_key], read_groups: ['
|
190
|
+
let!(:col_vg) { create(:user_collection, id: 'col_vg', user: user, edit_users: [user.user_key], read_groups: ['read_group_1', 'read_group_2'], collection_type_gid: default_gid) }
|
100
191
|
let!(:col_mu) { create(:user_collection, id: 'col_mu', user: user, edit_users: [user.user_key, editor1.user_key, editor2.user_key], collection_type_gid: default_gid) }
|
101
|
-
let!(:col_mg) { create(:user_collection, id: 'col_mg', user: user, edit_users: [user.user_key], edit_groups: ['
|
192
|
+
let!(:col_mg) { create(:user_collection, id: 'col_mg', user: user, edit_users: [user.user_key], edit_groups: ['edit_group_1', 'edit_group_2'], collection_type_gid: default_gid) }
|
102
193
|
|
103
194
|
it 'sets gid and adds permissions' do # rubocop:disable RSpec/ExampleLength
|
104
195
|
Collection.all.each do |col|
|
@@ -127,7 +218,7 @@ RSpec.describe Hyrax::Collections::MigrationService, clean_repo: true do
|
|
127
218
|
do_save: true, with_permission_template: true)
|
128
219
|
end
|
129
220
|
let!(:col_vg) do
|
130
|
-
build(:typeless_collection, id: 'col_vg', user: user, edit_users: [user.user_key], read_groups: ['
|
221
|
+
build(:typeless_collection, id: 'col_vg', user: user, edit_users: [user.user_key], read_groups: ['read_group_1', 'read_group_2'],
|
131
222
|
do_save: true, with_permission_template: true)
|
132
223
|
end
|
133
224
|
let!(:col_mu) do
|
@@ -135,7 +226,7 @@ RSpec.describe Hyrax::Collections::MigrationService, clean_repo: true do
|
|
135
226
|
do_save: true, with_permission_template: true)
|
136
227
|
end
|
137
228
|
let!(:col_mg) do
|
138
|
-
build(:typeless_collection, id: 'col_mg', user: user, edit_users: [user.user_key], edit_groups: ['
|
229
|
+
build(:typeless_collection, id: 'col_mg', user: user, edit_users: [user.user_key], edit_groups: ['edit_group_1', 'edit_group_2'],
|
139
230
|
do_save: true, with_permission_template: true)
|
140
231
|
end
|
141
232
|
|
@@ -191,7 +282,7 @@ RSpec.describe Hyrax::Collections::MigrationService, clean_repo: true do
|
|
191
282
|
do_save: true, with_permission_template: true)
|
192
283
|
end
|
193
284
|
let!(:col_vg) do
|
194
|
-
build(:typeless_collection, id: 'col_vg', user: user, edit_users: [user.user_key], read_groups: ['
|
285
|
+
build(:typeless_collection, id: 'col_vg', user: user, edit_users: [user.user_key], read_groups: ['read_group_1', 'read_group_2'],
|
195
286
|
do_save: true, with_permission_template: true)
|
196
287
|
end
|
197
288
|
let!(:col_mu) do
|
@@ -199,7 +290,7 @@ RSpec.describe Hyrax::Collections::MigrationService, clean_repo: true do
|
|
199
290
|
do_save: true, with_permission_template: true)
|
200
291
|
end
|
201
292
|
let!(:col_mg) do
|
202
|
-
build(:typeless_collection, id: 'col_mg', user: user, edit_users: [user.user_key], edit_groups: ['
|
293
|
+
build(:typeless_collection, id: 'col_mg', user: user, edit_users: [user.user_key], edit_groups: ['edit_group_1', 'edit_group_2'],
|
203
294
|
do_save: true, with_permission_template: true)
|
204
295
|
end
|
205
296
|
|
@@ -250,6 +341,84 @@ RSpec.describe Hyrax::Collections::MigrationService, clean_repo: true do
|
|
250
341
|
expect_access(permission_template.id, 'user', :manage, edit_users)
|
251
342
|
end
|
252
343
|
end
|
344
|
+
|
345
|
+
context 'when legacy adminsets are found (e.g. adminsets created before Hyrax 2.1.0)' do
|
346
|
+
let!(:as_none) { build(:no_solr_grants_adminset, id: 'as_none', user: user) }
|
347
|
+
let!(:as_vu) { build(:no_solr_grants_adminset, id: 'as_vu', user: user, with_permission_template: { view_users: [reader1.user_key, reader2.user_key] }) }
|
348
|
+
let!(:as_vg) { build(:no_solr_grants_adminset, id: 'as_vg', user: user, with_permission_template: { view_groups: ['read_group_1', 'read_group_2'] }) }
|
349
|
+
let!(:as_du) { build(:no_solr_grants_adminset, id: 'as_du', user: user, with_permission_template: { deposit_users: [depositor1.user_key, depositor2.user_key] }) }
|
350
|
+
let!(:as_dg) { build(:no_solr_grants_adminset, id: 'as_dg', user: user, with_permission_template: { deposit_groups: ['deposit_group_1', 'deposit_group_2'] }) }
|
351
|
+
let!(:as_mu) { build(:no_solr_grants_adminset, id: 'as_mu', user: user, with_permission_template: { manage_users: [editor1.user_key, editor2.user_key] }) }
|
352
|
+
let!(:as_mg) { build(:no_solr_grants_adminset, id: 'as_mg', user: user, with_permission_template: { manage_groups: ['edit_group_1', 'edit_group_2'] }) }
|
353
|
+
|
354
|
+
before do
|
355
|
+
allow(AdminSet).to receive(:all).and_return([as_none, as_vu, as_vg, as_du, as_dg, as_mu, as_mg])
|
356
|
+
end
|
357
|
+
|
358
|
+
it 'sets read and edit access in solr doc' do # rubocop:disable RSpec/ExampleLength
|
359
|
+
AdminSet.all.each do |adminset|
|
360
|
+
expect(adminset.edit_users).to include(user.user_key)
|
361
|
+
expect(adminset.read_users).to eq []
|
362
|
+
end
|
363
|
+
|
364
|
+
Hyrax::Collections::MigrationService.repair_migrated_collections
|
365
|
+
|
366
|
+
AdminSet.all.each do |adminset|
|
367
|
+
pt_id = Hyrax::PermissionTemplate.find_by!(source_id: adminset.id)
|
368
|
+
expect(pt_id).not_to be_nil
|
369
|
+
expect_solr_access(pt_id, 'user', :manage, adminset.edit_users)
|
370
|
+
expect_solr_access(pt_id, 'group', :manage, adminset.edit_groups)
|
371
|
+
expect_solr_access(pt_id, 'user', :deposit, adminset.read_users)
|
372
|
+
expect_solr_access(pt_id, 'group', :deposit, adminset.read_groups)
|
373
|
+
expect_solr_access(pt_id, 'user', :view, adminset.read_users)
|
374
|
+
expect_solr_access(pt_id, 'group', :view, adminset.read_groups)
|
375
|
+
end
|
376
|
+
end
|
377
|
+
end
|
378
|
+
|
379
|
+
context 'when newer adminsets are found (e.g. adminsets created at or after Hyrax 2.1.0)' do
|
380
|
+
let!(:adminset) do
|
381
|
+
build(:adminset_lw,
|
382
|
+
id: 'as_newer', user: user,
|
383
|
+
with_permission_template: {
|
384
|
+
manage_users: [editor1.user_key, editor2.user_key],
|
385
|
+
deposit_users: [depositor1.user_key, depositor2.user_key],
|
386
|
+
view_users: [viewer1.user_key, viewer2.user_key],
|
387
|
+
manage_groups: ['manage_group_1', 'manage_group_2'],
|
388
|
+
deposit_groups: ['deposit_group_1', 'deposit_group_2'],
|
389
|
+
view_groups: ['view_group_1', 'view_group_2']
|
390
|
+
},
|
391
|
+
with_solr_document: true)
|
392
|
+
end
|
393
|
+
let!(:permission_template) { adminset.permission_template }
|
394
|
+
let!(:edit_users) { adminset.edit_users }
|
395
|
+
|
396
|
+
before do
|
397
|
+
allow(AdminSet).to receive(:all).and_return([adminset])
|
398
|
+
end
|
399
|
+
|
400
|
+
it "doesn't change the adminset" do # rubocop:disable RSpec/ExampleLength
|
401
|
+
pt_id = Hyrax::PermissionTemplate.find_by!(source_id: adminset.id).id
|
402
|
+
expect(pt_id).to eq permission_template.id
|
403
|
+
expect_solr_access(pt_id, 'user', :manage, adminset.edit_users)
|
404
|
+
expect_solr_access(pt_id, 'group', :manage, adminset.edit_groups)
|
405
|
+
expect_solr_access(pt_id, 'user', :deposit, adminset.read_users)
|
406
|
+
expect_solr_access(pt_id, 'group', :deposit, adminset.read_groups)
|
407
|
+
expect_solr_access(pt_id, 'user', :view, adminset.read_users)
|
408
|
+
expect_solr_access(pt_id, 'group', :view, adminset.read_groups)
|
409
|
+
|
410
|
+
Hyrax::Collections::MigrationService.repair_migrated_collections
|
411
|
+
|
412
|
+
pt_id = Hyrax::PermissionTemplate.find_by!(source_id: adminset.id).id
|
413
|
+
expect(pt_id).to eq permission_template.id
|
414
|
+
expect_solr_access(pt_id, 'user', :manage, adminset.edit_users)
|
415
|
+
expect_solr_access(pt_id, 'group', :manage, adminset.edit_groups)
|
416
|
+
expect_solr_access(pt_id, 'user', :deposit, adminset.read_users)
|
417
|
+
expect_solr_access(pt_id, 'group', :deposit, adminset.read_groups)
|
418
|
+
expect_solr_access(pt_id, 'user', :view, adminset.read_users)
|
419
|
+
expect_solr_access(pt_id, 'group', :view, adminset.read_groups)
|
420
|
+
end
|
421
|
+
end
|
253
422
|
end
|
254
423
|
|
255
424
|
def create_access(permission_template_id, agent_type, access, agent_ids)
|
@@ -277,4 +446,22 @@ RSpec.describe Hyrax::Collections::MigrationService, clean_repo: true do
|
|
277
446
|
expect(pta).to be_empty
|
278
447
|
end
|
279
448
|
end
|
449
|
+
|
450
|
+
def expect_solr_access(permission_template_id, pt_agent_type, pt_access, solrdoc_access)
|
451
|
+
ptas = Hyrax::PermissionTemplateAccess.where(permission_template_id: permission_template_id, agent_type: pt_agent_type, access: pt_access)
|
452
|
+
expect_solr_group_access(ptas, solrdoc_access) if pt_agent_type == 'group'
|
453
|
+
expect_solr_user_access(ptas, solrdoc_access) if pt_agent_type == 'user'
|
454
|
+
end
|
455
|
+
|
456
|
+
def expect_solr_group_access(permission_templates, solrdoc_access)
|
457
|
+
permission_templates.each do |pta|
|
458
|
+
expect(solrdoc_access).to include pta.agent_id
|
459
|
+
end
|
460
|
+
end
|
461
|
+
|
462
|
+
def expect_solr_user_access(permission_templates, solrdoc_access)
|
463
|
+
permission_templates.each do |pta|
|
464
|
+
expect(solrdoc_access).to include pta.agent_id
|
465
|
+
end
|
466
|
+
end
|
280
467
|
end
|