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.
Files changed (180) hide show
  1. checksums.yaml +4 -4
  2. data/.github/CODE_OF_CONDUCT.md +5 -5
  3. data/.github/CONTRIBUTING.md +2 -2
  4. data/.rubocop.yml +1 -0
  5. data/.rubocop_fixme.yml +2 -0
  6. data/Gemfile +1 -0
  7. data/README.md +3 -2
  8. data/app/actors/hyrax/actors/collections_membership_actor.rb +3 -0
  9. data/app/actors/hyrax/actors/create_with_remote_files_actor.rb +4 -3
  10. data/app/actors/hyrax/actors/default_admin_set_actor.rb +9 -6
  11. data/app/assets/javascripts/hyrax.js +3 -0
  12. data/app/assets/javascripts/hyrax/app.js.erb +14 -0
  13. data/app/assets/javascripts/hyrax/batch_edit.js +2 -1
  14. data/app/assets/javascripts/hyrax/collection_types.es6 +97 -36
  15. data/app/assets/javascripts/hyrax/collections.js +15 -49
  16. data/app/assets/javascripts/hyrax/collections_utils.es6 +116 -0
  17. data/app/assets/javascripts/hyrax/collections_v2.es6 +57 -0
  18. data/app/assets/javascripts/hyrax/content_blocks.js +1 -13
  19. data/app/assets/javascripts/hyrax/nav_safety.js +41 -0
  20. data/app/assets/javascripts/hyrax/turbolinks_events.js +3 -0
  21. data/app/assets/stylesheets/hyrax/_collection_types.scss +46 -2
  22. data/app/assets/stylesheets/hyrax/_work-show.scss +6 -9
  23. data/app/assets/stylesheets/hyrax/dashboard.scss +2 -0
  24. data/app/assets/stylesheets/hyrax/sidebar.scss +4 -0
  25. data/app/controllers/concerns/hyrax/works_controller_behavior.rb +10 -2
  26. data/app/controllers/hyrax/admin/admin_sets_controller.rb +2 -9
  27. data/app/controllers/hyrax/admin/collection_types_controller.rb +1 -1
  28. data/app/controllers/hyrax/batch_edits_controller.rb +30 -4
  29. data/app/controllers/hyrax/dashboard/collection_members_controller.rb +1 -0
  30. data/app/controllers/hyrax/dashboard/collections_controller.rb +4 -1
  31. data/app/controllers/hyrax/downloads_controller.rb +7 -1
  32. data/app/forms/hyrax/forms/admin/collection_type_form.rb +1 -1
  33. data/app/indexers/hyrax/repository_reindexer.rb +1 -1
  34. data/app/jobs/attach_files_to_work_job.rb +8 -4
  35. data/app/jobs/import_url_job.rb +11 -5
  36. data/app/models/admin_set.rb +25 -3
  37. data/app/models/concerns/hyrax/collection_behavior.rb +23 -11
  38. data/app/models/concerns/hyrax/collection_nesting.rb +22 -3
  39. data/app/models/hyrax/permission_template_access.rb +7 -4
  40. data/app/presenters/hyrax/admin_set_presenter.rb +21 -0
  41. data/app/presenters/hyrax/collection_presenter.rb +23 -1
  42. data/app/presenters/hyrax/dashboard/user_presenter.rb +4 -0
  43. data/app/presenters/hyrax/presents_attributes.rb +6 -2
  44. data/app/presenters/hyrax/work_show_presenter.rb +4 -0
  45. data/app/renderers/hyrax/renderers/attribute_renderer.rb +14 -0
  46. data/app/services/hyrax/adapters/nesting_index_adapter.rb +19 -39
  47. data/app/services/hyrax/admin_set_create_service.rb +1 -1
  48. data/app/services/hyrax/collection_types/create_service.rb +4 -0
  49. data/app/services/hyrax/collections/migration_service.rb +25 -2
  50. data/app/services/hyrax/collections/nested_collection_persistence_service.rb +8 -3
  51. data/app/services/hyrax/collections/nested_collection_query_service.rb +3 -3
  52. data/app/services/hyrax/default_middleware_stack.rb +3 -3
  53. data/app/services/hyrax/multiple_membership_checker.rb +4 -2
  54. data/app/views/catalog/_index_header_list_collection.html.erb +1 -1
  55. data/app/views/catalog/_search_form.html.erb +0 -4
  56. data/app/views/hyrax/admin/admin_sets/_show_actions.html.erb +27 -0
  57. data/app/views/hyrax/admin/admin_sets/show.html.erb +1 -25
  58. data/app/views/hyrax/admin/collection_types/_form.html.erb +17 -6
  59. data/app/views/hyrax/admin/collection_types/_form_appearance.html.erb +5 -0
  60. data/app/views/hyrax/admin/collection_types/_form_participant_table.html.erb +1 -1
  61. data/app/views/hyrax/admin/collection_types/_form_participants.html.erb +56 -52
  62. data/app/views/hyrax/admin/collection_types/edit.html.erb +9 -7
  63. data/app/views/hyrax/admin/collection_types/index.html.erb +1 -1
  64. data/app/views/hyrax/base/_attribute_rows.html.erb +15 -14
  65. data/app/views/hyrax/base/_form.html.erb +1 -0
  66. data/app/views/hyrax/base/_form_collections_error.html.erb +1 -0
  67. data/app/views/hyrax/base/_items.html.erb +3 -2
  68. data/app/views/hyrax/base/_metadata.html.erb +5 -7
  69. data/app/views/hyrax/base/_relationships.html.erb +3 -5
  70. data/app/views/hyrax/base/_relationships_parent_row.html.erb +4 -5
  71. data/app/views/hyrax/base/_relationships_parent_rows.html.erb +2 -1
  72. data/app/views/hyrax/base/_show_actions.html.erb +11 -1
  73. data/app/views/hyrax/batch_edits/edit.html.erb +57 -17
  74. data/app/views/hyrax/collections/_list_collections.html.erb +1 -1
  75. data/app/views/hyrax/collections/show.html.erb +1 -1
  76. data/app/views/hyrax/content_blocks/_form.html.erb +8 -7
  77. data/app/views/hyrax/dashboard/_index_partials/_current_proxy_rights.html.erb +17 -0
  78. data/app/views/hyrax/dashboard/collections/_collection_title.html.erb +1 -3
  79. data/app/views/hyrax/dashboard/collections/_default_group.html.erb +30 -0
  80. data/app/views/hyrax/dashboard/collections/_form_branding.html.erb +2 -2
  81. data/app/views/hyrax/dashboard/collections/_form_for_select_collection.html.erb +1 -1
  82. data/app/views/hyrax/dashboard/collections/_form_share.html.erb +2 -2
  83. data/app/views/hyrax/dashboard/collections/_list_collections.html.erb +13 -2
  84. data/app/views/hyrax/dashboard/show_user.html.erb +10 -9
  85. data/app/views/hyrax/my/collections/_list_collections.html.erb +10 -3
  86. data/app/views/hyrax/my/collections/_modal_add_subcollection.html.erb +1 -1
  87. data/app/views/hyrax/my/collections/_modal_add_to_collection.html.erb +1 -1
  88. data/app/views/hyrax/my/collections/_modal_delete_collections_deny.html.erb +14 -0
  89. data/app/views/hyrax/my/collections/index.html.erb +1 -0
  90. data/app/views/shared/_nav_safety_modal.html.erb +12 -0
  91. data/config/features.rb +4 -0
  92. data/config/initializers/samvera-nesting_indexer_initializer.rb +1 -0
  93. data/config/locales/hyrax.de.yml +26 -11
  94. data/config/locales/hyrax.en.yml +21 -6
  95. data/config/locales/hyrax.es.yml +17 -2
  96. data/config/locales/hyrax.fr.yml +17 -2
  97. data/config/locales/hyrax.it.yml +17 -2
  98. data/config/locales/hyrax.pt-BR.yml +17 -2
  99. data/config/locales/hyrax.zh.yml +17 -2
  100. data/config/locales/simple_form.en.yml +6 -27
  101. data/hyrax.gemspec +2 -2
  102. data/lib/generators/hyrax/assets_generator.rb +4 -0
  103. data/lib/generators/hyrax/install_generator.rb +10 -0
  104. data/lib/generators/hyrax/templates/app/assets/images/unauthorized.png +0 -0
  105. data/lib/generators/hyrax/templates/config/locales/hyrax.en.yml +6 -5
  106. data/lib/generators/hyrax/templates/config/tinymce.yml +12 -7
  107. data/lib/generators/hyrax/templates/db/migrate/20180406202557_add_badge_color_to_collection_types.rb.erb +5 -0
  108. data/lib/hyrax/configuration.rb +1 -1
  109. data/lib/hyrax/version.rb +1 -1
  110. data/spec/actors/hyrax/actors/collections_membership_actor_spec.rb +24 -0
  111. data/spec/actors/hyrax/actors/create_with_remote_files_actor_spec.rb +19 -1
  112. data/spec/actors/hyrax/actors/default_admin_set_actor_spec.rb +41 -8
  113. data/spec/actors/hyrax/actors/file_set_actor_spec.rb +4 -12
  114. data/spec/actors/hyrax/actors/generic_work_actor_spec.rb +3 -7
  115. data/spec/controllers/hyrax/admin/strategies_controller_spec.rb +13 -2
  116. data/spec/controllers/hyrax/batch_edits_controller_spec.rb +83 -8
  117. data/spec/controllers/hyrax/dashboard/collections_controller_spec.rb +3 -0
  118. data/spec/controllers/hyrax/downloads_controller_spec.rb +26 -5
  119. data/spec/controllers/hyrax/file_sets_controller_spec.rb +3 -6
  120. data/spec/controllers/hyrax/generic_works_controller_json_spec.rb +4 -4
  121. data/spec/controllers/hyrax/generic_works_controller_spec.rb +3 -23
  122. data/spec/controllers/hyrax/transfers_controller_spec.rb +1 -1
  123. data/spec/factories/admin_sets_lw.rb +215 -0
  124. data/spec/factories/collections.rb +10 -10
  125. data/spec/factory_tests/adminsets_factory_spec.rb +132 -0
  126. data/spec/factory_tests/collections_factory_spec.rb +3 -3
  127. data/spec/features/batch_create_spec.rb +5 -8
  128. data/spec/features/batch_edit_spec.rb +49 -2
  129. data/spec/features/collection_multi_membership_spec.rb +29 -14
  130. data/spec/features/collection_type_spec.rb +9 -2
  131. data/spec/features/create_work_admin_spec.rb +1 -1
  132. data/spec/features/create_work_spec.rb +1 -1
  133. data/spec/features/dashboard/collection_spec.rb +16 -12
  134. data/spec/features/edit_content_block_admin_spec.rb +29 -12
  135. data/spec/features/embargo_spec.rb +55 -0
  136. data/spec/features/proxy_spec.rb +3 -1
  137. data/spec/features/work_show_spec.rb +20 -4
  138. data/spec/forms/hyrax/forms/admin/collection_type_form_spec.rb +1 -0
  139. data/spec/indexers/hyrax/repository_reindexer_spec.rb +1 -1
  140. data/spec/jobs/attach_files_to_work_job_spec.rb +15 -3
  141. data/spec/jobs/batch_create_job_spec.rb +6 -6
  142. data/spec/jobs/create_work_job_spec.rb +1 -1
  143. data/spec/models/admin_set_spec.rb +10 -8
  144. data/spec/models/collection_spec.rb +1 -1
  145. data/spec/models/concerns/hyrax/collection_nesting_spec.rb +6 -3
  146. data/spec/models/flipflop_spec.rb +8 -0
  147. data/spec/models/hyrax/work_behavior_spec.rb +1 -1
  148. data/spec/presenters/hyrax/admin_set_presenter_spec.rb +70 -0
  149. data/spec/presenters/hyrax/collection_presenter_spec.rb +66 -0
  150. data/spec/renderers/hyrax/renderers/attribute_renderer_spec.rb +19 -0
  151. data/spec/services/hyrax/adapters/nesting_index_adapter_spec.rb +31 -21
  152. data/spec/services/hyrax/collection_types/create_service_spec.rb +7 -4
  153. data/spec/services/hyrax/collections/migration_service_spec.rb +204 -17
  154. data/spec/services/hyrax/collections/nested_collection_persistence_service_spec.rb +1 -1
  155. data/spec/services/hyrax/collections/permissions_create_service_spec.rb +1 -1
  156. data/spec/services/hyrax/collections/permissions_service_spec.rb +4 -0
  157. data/spec/services/hyrax/default_middleware_stack_spec.rb +1 -1
  158. data/spec/services/hyrax/multiple_membership_checker_spec.rb +4 -4
  159. data/spec/services/hyrax/workflow/grant_edit_to_depositor_spec.rb +1 -1
  160. data/spec/services/hyrax/workflow/grant_read_to_depositor_spec.rb +1 -1
  161. data/spec/services/hyrax/workflow/revoke_edit_from_depositor_spec.rb +1 -1
  162. data/spec/spec_helper.rb +35 -2
  163. data/spec/support/features/batch_edit_actions.rb +1 -1
  164. data/spec/support/selectors.rb +15 -0
  165. data/spec/views/hyrax/admin/admin_sets/_show_actions.html.erb_spec.rb +66 -0
  166. data/spec/views/hyrax/admin/admin_sets/show.html.erb_spec.rb +5 -34
  167. data/spec/views/hyrax/admin/collection_types/_form.html.erb_spec.rb +3 -1
  168. data/spec/views/hyrax/admin/collection_types/_form_appearance.html.erb_spec.rb +22 -0
  169. data/spec/views/hyrax/admin/collection_types/_form_participants.html.erb_spec.rb +11 -3
  170. data/spec/views/hyrax/base/_items.html.erb_spec.rb +46 -0
  171. data/spec/views/hyrax/base/_relationships.html.erb_spec.rb +1 -1
  172. data/spec/views/hyrax/base/_show_actions.html.erb_spec.rb +4 -2
  173. data/spec/views/hyrax/dashboard/collections/_default_group.html.erb_spec.rb +43 -0
  174. data/spec/views/hyrax/dashboard/collections/_list_collections.html.erb_spec.rb +51 -0
  175. data/spec/views/hyrax/dashboard/collections/show.html.erb_spec.rb +1 -0
  176. data/spec/views/hyrax/dashboard/show_user_spec.rb +5 -2
  177. data/spec/views/hyrax/my/collections/_list_collections.html.erb_spec.rb +2 -0
  178. data/template.rb +1 -1
  179. metadata +30 -13
  180. data/app/views/hyrax/content_blocks/_modal_content_block.html.erb +0 -15
@@ -32,4 +32,59 @@ RSpec.describe 'embargo' do
32
32
  expect(page).to have_content(later_future_date.to_date.to_formatted_s(:standard))
33
33
  end
34
34
  end
35
+
36
+ describe 'updating embargoed object' do
37
+ let(:my_admin_set) do
38
+ create(:admin_set,
39
+ title: ['admin set with embargo range'],
40
+ with_permission_template: { release_period: "6mos", with_active_workflow: true })
41
+ end
42
+ let(:default_admin_set) do
43
+ create(:admin_set, id: AdminSet::DEFAULT_ID,
44
+ title: ["Default Admin Set"],
45
+ description: ["A description"],
46
+ with_permission_template: {})
47
+ end
48
+ let(:future_date) { 5.days.from_now }
49
+ let(:later_future_date) { 10.days.from_now }
50
+ let(:invalid_future_date) { 185.days.from_now } # More than 6 months
51
+ let(:admin) { create(:admin) }
52
+ let(:work) do
53
+ create(:work, title: ['embargoed work1'],
54
+ embargo_release_date: future_date.to_datetime.iso8601,
55
+ admin_set_id: my_admin_set.id,
56
+ edit_users: [user])
57
+ end
58
+
59
+ it 'can be updated with a valid date' do
60
+ visit "/concern/generic_works/#{work.id}"
61
+
62
+ click_link 'Edit'
63
+ click_link 'Embargo Management Page'
64
+
65
+ expect(page).to have_content('This Generic Work is under embargo.')
66
+ expect(page).to have_xpath("//input[@name='generic_work[embargo_release_date]' and @value='#{future_date.to_datetime.iso8601}']") # current embargo date is pre-populated in edit field
67
+
68
+ fill_in 'until', with: later_future_date.to_s
69
+
70
+ click_button 'Update Embargo'
71
+ expect(page).to have_content(later_future_date.to_date.to_formatted_s(:standard))
72
+ expect(page).to have_content(my_admin_set.title.first)
73
+ end
74
+
75
+ it 'cannot be updated with an invalid date' do
76
+ visit "/concern/generic_works/#{work.id}"
77
+
78
+ click_link 'Edit'
79
+ click_link 'Embargo Management Page'
80
+
81
+ expect(page).to have_content('This Generic Work is under embargo.')
82
+ expect(page).to have_xpath("//input[@name='generic_work[embargo_release_date]' and @value='#{future_date.to_datetime.iso8601}']") # current embargo date is pre-populated in edit field
83
+
84
+ fill_in 'until', with: invalid_future_date.to_s
85
+
86
+ click_button 'Update Embargo'
87
+ expect(page).to have_content('Release date specified does not match permission template release requirements for selected AdminSet.')
88
+ end
89
+ end
35
90
  end
@@ -6,7 +6,9 @@ RSpec.describe 'proxy', type: :feature do
6
6
  it "creates a proxy" do
7
7
  sign_in user
8
8
  click_link "Your activity"
9
- click_link "Manage Proxies"
9
+ within 'div#proxy_management' do
10
+ click_link "Manage Proxies"
11
+ end
10
12
  expect(first("td.depositor-name")).to be_nil
11
13
 
12
14
  # BEGIN create_proxy_using_partial
@@ -19,6 +19,8 @@ RSpec.describe "display a work as its owner" do
19
19
  let(:user) { create(:user) }
20
20
  let(:file_set) { create(:file_set, user: user, title: ['A Contained FileSet'], content: file) }
21
21
  let(:file) { File.open(fixture_path + '/world.png') }
22
+ let(:multi_membership_type_1) { create(:collection_type, :allow_multiple_membership, title: 'Multi-membership 1') }
23
+ let!(:collection) { create(:collection_lw, user: user, collection_type_gid: multi_membership_type_1.gid) }
22
24
 
23
25
  before do
24
26
  sign_in user
@@ -29,8 +31,8 @@ RSpec.describe "display a work as its owner" do
29
31
  expect(page).to have_selector 'h2', text: 'Magnificent splendor'
30
32
  expect(page).to have_selector 'h2', text: 'Happy little trees'
31
33
  expect(page).to have_selector 'li', text: 'The Internet'
32
- expect(page).to have_selector 'th', text: 'Location'
33
- expect(page).not_to have_selector 'th', text: 'Based near'
34
+ expect(page).to have_selector 'dt', text: 'Location'
35
+ expect(page).not_to have_selector 'dt', text: 'Based near'
34
36
  expect(page).to have_selector 'button', text: 'Attach Child', count: 1
35
37
 
36
38
  # Displays FileSets already attached to this work
@@ -41,6 +43,20 @@ RSpec.describe "display a work as its owner" do
41
43
  # IIIF manifest does not include locale query param
42
44
  expect(find('div.viewer:first')['data-uri']).to eq "/concern/generic_works/#{work.id}/manifest"
43
45
  end
46
+
47
+ it "add work to a collection", js: true do
48
+ click_button "Add to collection" # opens the modal
49
+ # since there is only one collection, it's not necessary to choose a radio button
50
+ within('div#collection-list-container') do
51
+ choose collection.title.first # selects the collection
52
+ click_button 'Save changes'
53
+ end
54
+
55
+ # forwards to collection show page
56
+ expect(page).to have_content collection.title.first
57
+ expect(page).to have_content work.title.first
58
+ expect(page).to have_selector '.alert-success', text: 'Collection was successfully updated.'
59
+ end
44
60
  end
45
61
 
46
62
  context "as a user who is not logged in" do
@@ -54,8 +70,8 @@ RSpec.describe "display a work as its owner" do
54
70
  it "shows a work" do
55
71
  expect(page).to have_selector 'h2', text: 'Magnificent splendor'
56
72
  expect(page).to have_selector 'li', text: 'The Internet'
57
- expect(page).to have_selector 'th', text: 'Location'
58
- expect(page).not_to have_selector 'th', text: 'Based near'
73
+ expect(page).to have_selector 'dt', text: 'Location'
74
+ expect(page).not_to have_selector 'dt', text: 'Based near'
59
75
 
60
76
  # Doesn't have the upload form for uploading more files
61
77
  expect(page).not_to have_selector "form#fileupload"
@@ -19,6 +19,7 @@ RSpec.describe Hyrax::Forms::Admin::CollectionTypeForm do
19
19
  it { is_expected.to delegate_method(:collections?).to(:collection_type) }
20
20
  it { is_expected.to delegate_method(:admin_set?).to(:collection_type) }
21
21
  it { is_expected.to delegate_method(:user_collection?).to(:collection_type) }
22
+ it { is_expected.to delegate_method(:badge_color).to(:collection_type) }
22
23
 
23
24
  describe '#all_settings_disabled?' do
24
25
  before do
@@ -2,7 +2,7 @@ RSpec.describe Hyrax::RepositoryReindexer do
2
2
  let(:subject) { Samvera::NestingIndexer }
3
3
 
4
4
  it 'overrides ActiveFedora#reindex_everything' do
5
- expect(subject).to receive(:reindex_all!)
5
+ expect(subject).to receive(:reindex_all!).with(extent: Hyrax::Adapters::NestingIndexAdapter::FULL_REINDEX)
6
6
  ActiveFedora::Base.reindex_everything
7
7
  end
8
8
  end
@@ -1,4 +1,4 @@
1
- RSpec.describe AttachFilesToWorkJob do
1
+ RSpec.describe AttachFilesToWorkJob, perform_enqueued: [AttachFilesToWorkJob] do
2
2
  context "happy path" do
3
3
  let(:file1) { File.open(fixture_path + '/world.png') }
4
4
  let(:file2) { File.open(fixture_path + '/image.jp2') }
@@ -7,15 +7,15 @@ RSpec.describe AttachFilesToWorkJob do
7
7
  let(:generic_work) { create(:public_generic_work) }
8
8
  let(:user) { create(:user) }
9
9
 
10
- shared_examples 'a file attacher' do
10
+ shared_examples 'a file attacher', perform_enqueued: [AttachFilesToWorkJob, IngestJob] do
11
11
  it 'attaches files, copies visibility and permissions and updates the uploaded files' do
12
- expect(ImportUrlJob).not_to receive(:perform_later)
13
12
  expect(CharacterizeJob).to receive(:perform_later).twice
14
13
  described_class.perform_now(generic_work, [uploaded_file1, uploaded_file2])
15
14
  generic_work.reload
16
15
  expect(generic_work.file_sets.count).to eq 2
17
16
  expect(generic_work.file_sets.map(&:visibility)).to all(eq 'open')
18
17
  expect(uploaded_file1.reload.file_set_uri).not_to be_nil
18
+ expect(ImportUrlJob).not_to have_been_enqueued
19
19
  end
20
20
  end
21
21
 
@@ -56,5 +56,17 @@ RSpec.describe AttachFilesToWorkJob do
56
56
  end
57
57
  end
58
58
  end
59
+
60
+ context "deposited as 'Yourself' selected in on behalf of list" do
61
+ before do
62
+ generic_work.on_behalf_of = ''
63
+ generic_work.save
64
+ end
65
+ it_behaves_like 'a file attacher' do
66
+ it 'records the depositor(s) in edit_users' do
67
+ expect(generic_work.file_sets.map(&:edit_users)).to all(match_array([generic_work.depositor]))
68
+ end
69
+ end
70
+ end
59
71
  end
60
72
  end
@@ -14,12 +14,12 @@ RSpec.describe BatchCreateJob do
14
14
  let(:uploaded_files) { [upload1.id.to_s, upload2.id.to_s] }
15
15
 
16
16
  subject do
17
- described_class.perform_later(user,
18
- title,
19
- resource_types,
20
- uploaded_files,
21
- metadata,
22
- operation)
17
+ described_class.perform_now(user,
18
+ title,
19
+ resource_types,
20
+ uploaded_files,
21
+ metadata,
22
+ operation)
23
23
  end
24
24
 
25
25
  before do
@@ -5,7 +5,7 @@ RSpec.describe CreateWorkJob do
5
5
  operation_type: "Create Work")
6
6
  end
7
7
 
8
- describe "#perform" do
8
+ describe "#perform", perform_enqueued: [described_class] do
9
9
  let(:file1) { File.open(fixture_path + '/world.png') }
10
10
  let(:upload1) { Hyrax::UploadedFile.create(user: user, file: file1) }
11
11
  let(:metadata) do
@@ -198,15 +198,17 @@ RSpec.describe AdminSet, type: :model do
198
198
 
199
199
  before do
200
200
  allow(admin_set).to receive(:permission_template).and_return(permission_template)
201
- allow(permission_template).to receive(:agent_ids_for).with(access: 'manage', agent_type: 'user').and_return(['mgr1.ex.com', 'mgr2.ex.com', user.user_key])
201
+ allow(permission_template).to receive(:agent_ids_for).with(access: 'manage', agent_type: 'user').and_return(['mgr1@ex.com', 'mgr2@ex.com', user.user_key])
202
202
  allow(permission_template).to receive(:agent_ids_for).with(access: 'manage', agent_type: 'group').and_return(['managers', ::Ability.admin_group_name])
203
- allow(permission_template).to receive(:agent_ids_for).with(access: 'view', agent_type: 'user').and_return(['vw1.ex.com', 'vw2.ex.com'])
204
- allow(permission_template).to receive(:agent_ids_for).with(access: 'view', agent_type: 'group').and_return(['viewers'])
203
+ allow(permission_template).to receive(:agent_ids_for).with(access: 'deposit', agent_type: 'user').and_return(['dep1@ex.com', 'dep2@ex.com'])
204
+ allow(permission_template).to receive(:agent_ids_for).with(access: 'deposit', agent_type: 'group').and_return(['depositors', 'registered'])
205
+ allow(permission_template).to receive(:agent_ids_for).with(access: 'view', agent_type: 'user').and_return(['vw1@ex.com', 'vw2@ex.com'])
206
+ allow(permission_template).to receive(:agent_ids_for).with(access: 'view', agent_type: 'group').and_return(['viewers', 'public'])
205
207
  end
206
208
 
207
209
  it 'resets user edit access' do
208
210
  admin_set.reset_access_controls!
209
- expect(admin_set.edit_users).to match_array([user.user_key, 'mgr1.ex.com', 'mgr2.ex.com'])
211
+ expect(admin_set.edit_users).to match_array([user.user_key, 'mgr1@ex.com', 'mgr2@ex.com'])
210
212
  end
211
213
 
212
214
  it 'resets group edit access' do
@@ -214,14 +216,14 @@ RSpec.describe AdminSet, type: :model do
214
216
  expect(admin_set.edit_groups).to match_array(['managers', ::Ability.admin_group_name])
215
217
  end
216
218
 
217
- it "doesn't reset user read access" do
219
+ it 'resets user read access' do
218
220
  admin_set.reset_access_controls!
219
- expect(admin_set.read_users).to match_array([]) # different behavior from Collections which grants participant Viewers to have read_access in the solr doc
221
+ expect(admin_set.read_users).to match_array(['dep1@ex.com', 'dep2@ex.com', 'vw1@ex.com', 'vw2@ex.com'])
220
222
  end
221
223
 
222
- it "doesn't reset group read access" do
224
+ it 'resets group read access' do
223
225
  admin_set.reset_access_controls!
224
- expect(admin_set.read_groups).to match_array(['public']) # different behavior from Collections which grants participant Viewers to have read_access in the solr doc
226
+ expect(admin_set.read_groups).to match_array(['depositors', 'viewers'])
225
227
  end
226
228
  end
227
229
  end
@@ -319,7 +319,7 @@ RSpec.describe Collection, type: :model do
319
319
 
320
320
  describe '#update_nested_collection_relationship_indices', :with_nested_reindexing do
321
321
  it 'will be called after save' do
322
- expect(Samvera::NestingIndexer).to receive(:reindex_relationships).with(id: kind_of(String))
322
+ expect(Samvera::NestingIndexer).to receive(:reindex_relationships).with(id: kind_of(String), extent: kind_of(String))
323
323
  collection.save!
324
324
  end
325
325
  end
@@ -33,6 +33,7 @@ RSpec.describe Hyrax::CollectionNesting do
33
33
  let(:user) { create(:user) }
34
34
  let!(:collection) { create(:collection, collection_type_settings: [:nestable]) }
35
35
  let!(:child_collection) { create(:collection, collection_type_settings: [:nestable]) }
36
+ let(:extent) { Hyrax::Adapters::NestingIndexAdapter::FULL_REINDEX }
36
37
 
37
38
  before do
38
39
  Hyrax::Collections::NestedCollectionPersistenceService.persist_nested_collection_for(parent: collection, child: child_collection)
@@ -47,11 +48,13 @@ RSpec.describe Hyrax::CollectionNesting do
47
48
  it { is_expected.to respond_to(:update_nested_collection_relationship_indices) }
48
49
  it { is_expected.to respond_to(:update_child_nested_collection_relationship_indices) }
49
50
  it { is_expected.to respond_to(:use_nested_reindexing?) }
51
+ it { is_expected.to respond_to(:reindex_extent) }
52
+ it { is_expected.to respond_to(:reindex_extent=) }
50
53
 
51
54
  context 'after_update_index callback' do
52
55
  describe '#update_nested_collection_relationship_indices' do
53
56
  it 'will call Hyrax.config.nested_relationship_reindexer' do
54
- expect(Hyrax.config.nested_relationship_reindexer).to receive(:call).with(id: subject.id).and_call_original
57
+ expect(Hyrax.config.nested_relationship_reindexer).to receive(:call).with(id: subject.id, extent: extent).and_call_original
55
58
  subject.update_nested_collection_relationship_indices
56
59
  end
57
60
 
@@ -62,10 +65,10 @@ RSpec.describe Hyrax::CollectionNesting do
62
65
  end
63
66
  end
64
67
 
65
- context 'after_destroy callback' do
68
+ context 'after_destroy callback', with_nested_reindexing: true do
66
69
  describe '#update_child_nested_collection_relationship_indices' do
67
70
  it 'will call Hyrax.config.nested_relationship_reindexer' do
68
- expect(Hyrax.config.nested_relationship_reindexer).to receive(:call).with(id: child_collection.id).and_call_original
71
+ expect(Hyrax.config.nested_relationship_reindexer).to receive(:call).with(id: child_collection.id, extent: extent).and_call_original
69
72
  subject.update_child_nested_collection_relationship_indices
70
73
  end
71
74
  end
@@ -30,4 +30,12 @@ RSpec.describe Flipflop do
30
30
  is_expected.to be true
31
31
  end
32
32
  end
33
+
34
+ describe "hide_private_files?" do
35
+ subject { described_class.hide_private_files? }
36
+
37
+ it "defaults to false" do
38
+ is_expected.to be false
39
+ end
40
+ end
33
41
  end
@@ -57,7 +57,7 @@ RSpec.describe Hyrax::WorkBehavior do
57
57
 
58
58
  describe '#update_nested_collection_relationship_indices', :with_nested_reindexing do
59
59
  it 'will be called after save' do
60
- expect(Samvera::NestingIndexer).to receive(:reindex_relationships).with(id: kind_of(String))
60
+ expect(Samvera::NestingIndexer).to receive(:reindex_relationships).with(id: kind_of(String), extent: kind_of(String))
61
61
  subject.save!
62
62
  end
63
63
  end
@@ -70,4 +70,74 @@ RSpec.describe Hyrax::AdminSetPresenter do
70
70
 
71
71
  it { is_expected.to eq "/admin/admin_sets/#{admin_set.id}" }
72
72
  end
73
+
74
+ describe '#managed_access' do
75
+ let(:admin_set) { create(:admin_set, members: [work]) }
76
+
77
+ context 'when manager' do
78
+ before do
79
+ allow(ability).to receive(:can?).with(:edit, solr_document).and_return(true)
80
+ end
81
+ it 'returns Manage label' do
82
+ expect(presenter.managed_access).to eq 'Manage'
83
+ end
84
+ end
85
+
86
+ context 'when depositor' do
87
+ before do
88
+ allow(ability).to receive(:can?).with(:edit, solr_document).and_return(false)
89
+ allow(ability).to receive(:can?).with(:deposit, solr_document).and_return(true)
90
+ end
91
+ it 'returns Deposit label' do
92
+ expect(presenter.managed_access).to eq 'Deposit'
93
+ end
94
+ end
95
+
96
+ context 'when viewer' do
97
+ before do
98
+ allow(ability).to receive(:can?).with(:edit, solr_document).and_return(false)
99
+ allow(ability).to receive(:can?).with(:deposit, solr_document).and_return(false)
100
+ allow(ability).to receive(:can?).with(:read, solr_document).and_return(true)
101
+ end
102
+ it 'returns View label' do
103
+ expect(presenter.managed_access).to eq 'View'
104
+ end
105
+ end
106
+ end
107
+
108
+ describe '#allow_batch?' do
109
+ let(:admin_set) { create(:admin_set, members: [work]) }
110
+
111
+ context 'when user cannot edit' do
112
+ before do
113
+ allow(ability).to receive(:can?).with(:edit, solr_document).and_return(false)
114
+ end
115
+
116
+ it 'returns false' do
117
+ expect(presenter.allow_batch?).to be false
118
+ end
119
+ end
120
+
121
+ context 'when user can edit' do
122
+ before do
123
+ allow(ability).to receive(:can?).with(:edit, solr_document).and_return(true)
124
+ end
125
+
126
+ context 'and there are works in the admin set' do
127
+ it 'returns false' do
128
+ expect(presenter.allow_batch?).to be false
129
+ end
130
+ end
131
+
132
+ context 'and there are no works in the admin set' do
133
+ before do
134
+ allow(presenter).to receive(:total_items).and_return(0)
135
+ end
136
+
137
+ it 'returns true' do
138
+ expect(presenter.allow_batch?).to be true
139
+ end
140
+ end
141
+ end
142
+ end
73
143
  end
@@ -322,6 +322,18 @@ RSpec.describe Hyrax::CollectionPresenter do
322
322
  end
323
323
  end
324
324
 
325
+ describe "#collection_type_badge" do
326
+ let(:collection_type) { create(:collection_type) }
327
+ before do
328
+ allow(collection_type).to receive(:badge_color).and_return("#ffa510")
329
+ allow(presenter).to receive(:collection_type).and_return(collection_type)
330
+ end
331
+
332
+ subject { presenter.collection_type_badge }
333
+
334
+ it { is_expected.to eq "<span class=\"label\" style=\"background-color: #ffa510;\">" + collection_type.title + "</span>" }
335
+ end
336
+
325
337
  describe "#user_can_nest_collection?" do
326
338
  before do
327
339
  allow(ability).to receive(:can?).with(:deposit, solr_doc).and_return(true)
@@ -392,4 +404,58 @@ RSpec.describe Hyrax::CollectionPresenter do
392
404
  it { is_expected.to delegate_method(:related_url).to(:solr_document) }
393
405
  it { is_expected.to delegate_method(:identifier).to(:solr_document) }
394
406
  it { is_expected.to delegate_method(:date_created).to(:solr_document) }
407
+
408
+ describe '#managed_access' do
409
+ context 'when manager' do
410
+ before do
411
+ allow(ability).to receive(:can?).with(:edit, solr_doc).and_return(true)
412
+ end
413
+ it 'returns Manage label' do
414
+ expect(presenter.managed_access).to eq 'Manage'
415
+ end
416
+ end
417
+
418
+ context 'when depositor' do
419
+ before do
420
+ allow(ability).to receive(:can?).with(:edit, solr_doc).and_return(false)
421
+ allow(ability).to receive(:can?).with(:deposit, solr_doc).and_return(true)
422
+ end
423
+ it 'returns Deposit label' do
424
+ expect(presenter.managed_access).to eq 'Deposit'
425
+ end
426
+ end
427
+
428
+ context 'when manager' do
429
+ before do
430
+ allow(ability).to receive(:can?).with(:edit, solr_doc).and_return(false)
431
+ allow(ability).to receive(:can?).with(:deposit, solr_doc).and_return(false)
432
+ allow(ability).to receive(:can?).with(:read, solr_doc).and_return(true)
433
+ end
434
+ it 'returns View label' do
435
+ expect(presenter.managed_access).to eq 'View'
436
+ end
437
+ end
438
+ end
439
+
440
+ describe '#allow_batch?' do
441
+ context 'when user cannot edit' do
442
+ before do
443
+ allow(ability).to receive(:can?).with(:edit, solr_doc).and_return(false)
444
+ end
445
+
446
+ it 'returns false' do
447
+ expect(presenter.allow_batch?).to be false
448
+ end
449
+ end
450
+
451
+ context 'when user can edit' do
452
+ before do
453
+ allow(ability).to receive(:can?).with(:edit, solr_doc).and_return(true)
454
+ end
455
+
456
+ it 'returns false' do
457
+ expect(presenter.allow_batch?).to be true
458
+ end
459
+ end
460
+ end
395
461
  end