hyrax 2.1.0 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (153) hide show
  1. checksums.yaml +5 -5
  2. data/.github/ISSUE_TEMPLATE.md +1 -1
  3. data/.github/PULL_REQUEST_TEMPLATE.md +5 -0
  4. data/.rubocop.yml +8 -1
  5. data/README.md +3 -11
  6. data/app/actors/hyrax/actors/file_set_actor.rb +6 -1
  7. data/app/assets/javascripts/hyrax.js +1 -1
  8. data/app/assets/javascripts/hyrax/editor.es6 +8 -0
  9. data/app/assets/javascripts/hyrax/save_work/save_work_control.es6 +20 -1
  10. data/app/assets/javascripts/hyrax/save_work/uploaded_files.es6 +1 -0
  11. data/app/assets/stylesheets/hyrax/_breadcrumbs.scss +25 -0
  12. data/app/assets/stylesheets/hyrax/_collections.scss +6 -0
  13. data/app/assets/stylesheets/hyrax/_file-listing.scss +5 -0
  14. data/app/assets/stylesheets/hyrax/_file_upload.scss +14 -0
  15. data/app/assets/stylesheets/hyrax/_form-progress.scss +6 -0
  16. data/app/assets/stylesheets/hyrax/_hyrax.scss +1 -1
  17. data/app/assets/stylesheets/hyrax/_styles.scss +6 -0
  18. data/app/assets/stylesheets/hyrax/dashboard.scss +4 -5
  19. data/app/builders/hyrax/bootstrap_breadcrumbs_builder.rb +10 -4
  20. data/app/controllers/concerns/hyrax/admin/stats_behavior.rb +25 -1
  21. data/app/controllers/concerns/hyrax/breadcrumbs_for_collections.rb +6 -2
  22. data/app/controllers/concerns/hyrax/controller.rb +1 -1
  23. data/app/controllers/concerns/hyrax/deny_access_override_behavior.rb +1 -1
  24. data/app/controllers/concerns/hyrax/works_controller_behavior.rb +1 -1
  25. data/app/controllers/hyrax/admin/admin_sets_controller.rb +1 -1
  26. data/app/controllers/hyrax/dashboard/collections_controller.rb +2 -2
  27. data/app/controllers/hyrax/downloads_controller.rb +1 -1
  28. data/app/controllers/hyrax/featured_works_controller.rb +1 -5
  29. data/app/controllers/hyrax/homepage_controller.rb +1 -1
  30. data/app/controllers/hyrax/single_use_links_controller.rb +1 -1
  31. data/app/controllers/hyrax/transfers_controller.rb +1 -1
  32. data/app/controllers/hyrax/users_controller.rb +1 -0
  33. data/app/helpers/hyrax/citations_behaviors/publication_behavior.rb +2 -2
  34. data/app/helpers/hyrax/collections_helper.rb +1 -1
  35. data/app/helpers/hyrax/hyrax_helper_behavior.rb +2 -2
  36. data/app/jobs/characterize_job.rb +1 -1
  37. data/app/jobs/fixity_check_job.rb +1 -1
  38. data/app/jobs/import_url_job.rb +12 -1
  39. data/app/models/checksum_audit_log.rb +1 -1
  40. data/app/models/concerns/hyrax/ability.rb +1 -1
  41. data/app/models/hyrax/collection_type.rb +1 -1
  42. data/app/models/hyrax/operation.rb +4 -6
  43. data/app/models/hyrax/permission_template_access.rb +5 -5
  44. data/app/models/sipity/entity.rb +1 -1
  45. data/app/presenters/hyrax/admin_set_presenter.rb +9 -2
  46. data/app/presenters/hyrax/admin_stats_presenter.rb +52 -6
  47. data/app/presenters/hyrax/inspect_work_presenter.rb +1 -1
  48. data/app/presenters/hyrax/workflow_presenter.rb +1 -1
  49. data/app/search_builders/hyrax/dashboard/nested_collections_search_builder.rb +3 -5
  50. data/app/search_builders/hyrax/filter_suppressed_with_roles.rb +5 -1
  51. data/app/search_builders/hyrax/my/works_search_builder.rb +2 -1
  52. data/app/services/hyrax/collection_size_service.rb +12 -0
  53. data/app/services/hyrax/collections/nested_collection_query_service.rb +2 -2
  54. data/app/services/hyrax/graph_exporter.rb +6 -1
  55. data/app/services/hyrax/license_service.rb +1 -9
  56. data/app/services/hyrax/qa_select_service.rb +28 -0
  57. data/app/services/hyrax/rights_statement_service.rb +1 -1
  58. data/app/services/hyrax/tolerant_select_service.rb +23 -0
  59. data/app/services/hyrax/workflow/permission_query.rb +1 -1
  60. data/app/services/hyrax/workflow/sipity_actions_generator.rb +1 -1
  61. data/app/strategies/hyrax/strategies/yaml_strategy.rb +1 -1
  62. data/app/views/_logo.html.erb +1 -1
  63. data/app/views/catalog/_search_form.html.erb +1 -1
  64. data/app/views/hyrax/admin/collection_types/index.html.erb +1 -1
  65. data/app/views/hyrax/admin/workflow_roles/index.html.erb +4 -2
  66. data/app/views/hyrax/admin/workflows/index.html.erb +1 -1
  67. data/app/views/hyrax/base/_form_files.html.erb +7 -7
  68. data/app/views/hyrax/base/_form_progress.html.erb +10 -5
  69. data/app/views/hyrax/base/_share_with.html.erb +3 -11
  70. data/app/views/hyrax/base/_show_actions.html.erb +1 -3
  71. data/app/views/hyrax/batch_edits/_check_all.html.erb +15 -7
  72. data/app/views/hyrax/collections/_list_collections.html.erb +1 -1
  73. data/app/views/hyrax/dashboard/_index_partials/_transfers.html.erb +1 -1
  74. data/app/views/hyrax/dashboard/collections/_default_group.html.erb +7 -2
  75. data/app/views/hyrax/dashboard/collections/_edit_actions.html.erb +1 -2
  76. data/app/views/hyrax/dashboard/collections/_form.html.erb +1 -1
  77. data/app/views/hyrax/dashboard/collections/_form_branding.html.erb +6 -6
  78. data/app/views/hyrax/dashboard/collections/_list_collections.html.erb +1 -1
  79. data/app/views/hyrax/dashboard/collections/_show_actions.html.erb +1 -2
  80. data/app/views/hyrax/dashboard/collections/_show_add_items_actions.html.erb +1 -2
  81. data/app/views/hyrax/dashboard/sidebar/_repository_content.html.erb +1 -2
  82. data/app/views/hyrax/dashboard/works/_default_group.html.erb +1 -1
  83. data/app/views/hyrax/file_sets/_actions.html.erb +1 -1
  84. data/app/views/hyrax/file_sets/_form.html.erb +3 -3
  85. data/app/views/hyrax/file_sets/_permission.html.erb +2 -2
  86. data/app/views/hyrax/file_sets/_permission_form.html.erb +10 -10
  87. data/app/views/hyrax/file_sets/_show_actions.html.erb +1 -4
  88. data/app/views/hyrax/file_sets/_single_use_links.html.erb +5 -0
  89. data/app/views/hyrax/file_sets/_versioning.html.erb +9 -7
  90. data/app/views/hyrax/file_sets/edit.html.erb +6 -6
  91. data/app/views/hyrax/file_sets/media_display/_audio.html.erb +1 -1
  92. data/app/views/hyrax/file_sets/media_display/_image.html.erb +1 -1
  93. data/app/views/hyrax/file_sets/media_display/_office_document.html.erb +0 -1
  94. data/app/views/hyrax/file_sets/media_display/_pdf.html.erb +0 -1
  95. data/app/views/hyrax/file_sets/media_display/_video.html.erb +1 -1
  96. data/app/views/hyrax/my/collections/_default_group.html.erb +8 -3
  97. data/app/views/hyrax/my/collections/_list_collections.html.erb +1 -1
  98. data/app/views/hyrax/my/works/_batch_actions.html.erb +1 -1
  99. data/app/views/hyrax/my/works/_tabs.html.erb +3 -3
  100. data/app/views/hyrax/single_use_links_viewer/show.html.erb +1 -1
  101. data/app/views/hyrax/uploads/_js_templates.html.erb +11 -11
  102. data/app/views/hyrax/uploads/_js_templates_branding.html.erb +2 -2
  103. data/app/views/layouts/_head_tag_content.html.erb +1 -1
  104. data/app/views/layouts/hyrax.html.erb +1 -1
  105. data/app/views/layouts/hyrax/dashboard.html.erb +1 -1
  106. data/app/views/records/edit_fields/_license.html.erb +1 -1
  107. data/app/views/records/edit_fields/_rights_statement.html.erb +2 -1
  108. data/config/features.rb +4 -0
  109. data/config/locales/hyrax.de.yml +1 -0
  110. data/config/locales/hyrax.en.yml +39 -1
  111. data/config/locales/hyrax.es.yml +1 -0
  112. data/config/locales/hyrax.fr.yml +1 -0
  113. data/config/locales/hyrax.it.yml +1 -0
  114. data/config/locales/hyrax.pt-BR.yml +1 -0
  115. data/config/locales/hyrax.zh.yml +1 -0
  116. data/hyrax.gemspec +5 -2
  117. data/lib/generators/hyrax/templates/mediated_deposit_workflow.json.erb +1 -0
  118. data/lib/hyrax.rb +7 -1
  119. data/lib/hyrax/arkivo/create_subscription_job.rb +1 -1
  120. data/lib/hyrax/redis_event_store.rb +1 -1
  121. data/lib/hyrax/resource_sync/change_list_writer.rb +2 -2
  122. data/lib/hyrax/version.rb +1 -1
  123. data/spec/actors/hyrax/actors/file_set_actor_spec.rb +1 -1
  124. data/spec/controllers/hyrax/admin/stats_controller_spec.rb +31 -1
  125. data/spec/controllers/hyrax/collections_controller_spec.rb +2 -2
  126. data/spec/controllers/hyrax/dashboard/collections_controller_spec.rb +2 -2
  127. data/spec/controllers/hyrax/generic_works_controller_spec.rb +19 -3
  128. data/spec/controllers/hyrax/homepage_controller_spec.rb +1 -1
  129. data/spec/controllers/hyrax/users_controller_spec.rb +58 -0
  130. data/spec/features/batch_create_spec.rb +1 -1
  131. data/spec/features/create_work_spec.rb +22 -2
  132. data/spec/features/dashboard/collection_spec.rb +3 -3
  133. data/spec/features/homepage_spec.rb +20 -4
  134. data/spec/javascripts/save_work_spec.js +50 -0
  135. data/spec/jobs/import_url_job_spec.rb +10 -8
  136. data/spec/lib/hyrax_spec.rb +9 -0
  137. data/spec/models/flipflop_spec.rb +8 -0
  138. data/spec/models/solr_document_spec.rb +2 -2
  139. data/spec/presenters/hyrax/admin_stats_presenter_spec.rb +73 -0
  140. data/spec/search_builders/hyrax/my/works_search_builder_spec.rb +0 -2
  141. data/spec/services/hyrax/graph_exporter_spec.rb +18 -0
  142. data/spec/services/hyrax/qa_select_service_spec.rb +40 -17
  143. data/spec/services/hyrax/tolerant_select_service_spec.rb +80 -0
  144. data/spec/support/fakes/fake_authority.rb +13 -0
  145. data/spec/support/logging_formatter.rb +1 -1
  146. data/spec/support/matchers/collection_type_property_matchers.rb +5 -5
  147. data/spec/views/hyrax/base/_form_progress.html.erb_spec.rb +11 -1
  148. data/spec/views/hyrax/file_sets/_show_actions.html.erb_spec.rb +0 -1
  149. data/spec/views/hyrax/file_sets/_single_use_links.html.erb_spec.rb +4 -0
  150. data/spec/views/hyrax/single_use_links_viewer/show.html.erb_spec.rb +0 -4
  151. data/template.rb +1 -1
  152. metadata +24 -11
  153. data/app/views/kaminari/blacklight_compact/_paginator.html.erb +0 -22
@@ -7,7 +7,7 @@ signed in %>
7
7
  <%= tag :meta, name: 'current-user', data: { user_key: current_user.user_key } %>
8
8
  <% end %>
9
9
  <!-- added for use on small devices like phones -->
10
- <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
10
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
11
11
  <link rel="resourcesync" href="<%= hyrax.capability_list_url %>" />
12
12
 
13
13
  <!-- Twitter card metadata -->
@@ -7,7 +7,7 @@
7
7
 
8
8
  <body>
9
9
  <div class="skip-to-content">
10
- <%= link_to "Skip to Content", "#skip-to-content", data: { turbolinks: false } %>
10
+ <%= link_to "Skip to Content", "#skip-to-content" %>
11
11
  </div>
12
12
  <%= render '/masthead' %>
13
13
  <%= content_for(:navbar) %>
@@ -7,7 +7,7 @@
7
7
 
8
8
  <body class="dashboard">
9
9
  <div class="skip-to-content">
10
- <%= link_to "Skip to Content", "#skip-to-content", data: { turbolinks: false } %>
10
+ <%= link_to "Skip to Content", "#skip-to-content" %>
11
11
  </div>
12
12
  <%= render '/masthead' %>
13
13
  <%= content_for(:navbar) %>
@@ -1,4 +1,4 @@
1
- <% license_service = Hyrax::LicenseService.new %>
1
+ <% license_service = Hyrax.config.license_service_class.new %>
2
2
  <%= f.input :license, as: :multi_value_select,
3
3
  collection: license_service.select_active_options,
4
4
  include_blank: true,
@@ -1,5 +1,6 @@
1
- <% rights_statements = Hyrax::RightsStatementService.new %>
1
+ <% rights_statements = Hyrax.config.rights_statement_service_class.new %>
2
2
  <%= f.input :rights_statement,
3
3
  collection: rights_statements.select_active_options,
4
4
  include_blank: true,
5
+ item_helper: rights_statements.method(:include_current_value),
5
6
  input_html: { class: 'form-control' } %>
@@ -38,4 +38,8 @@ Flipflop.configure do
38
38
  feature :hide_private_items,
39
39
  default: false,
40
40
  description: "Do not show the private items."
41
+
42
+ feature :hide_users_list,
43
+ default: true,
44
+ description: "Do not show users list unless user has authenticated."
41
45
  end
@@ -314,6 +314,7 @@ de:
314
314
  delete:
315
315
  confirm: Sind Sie sich sicher?
316
316
  header:
317
+ name: Name
317
318
  roles: Rollen
318
319
  user: Benutzer
319
320
  new_role: Rolle zuweisen
@@ -314,6 +314,7 @@ en:
314
314
  delete:
315
315
  confirm: Are you sure?
316
316
  header:
317
+ name: Name
317
318
  roles: Roles
318
319
  user: User
319
320
  new_role: Assign Role
@@ -420,6 +421,11 @@ en:
420
421
  header: Relationships
421
422
  relationships_parent_row:
422
423
  label: 'In %{type}:'
424
+ share_with:
425
+ definitions_html: "<strong>View/Download:</strong> this file (both contents and metadata) is accessible from within %{application_name}.<br />
426
+ <strong>Edit:</strong> this file (both contents and metadata) can be edited. You may only grant this permission to %{institution_name} users and/or groups."
427
+ definition_heading: "Permission Definitions"
428
+ share_with_html: "You may grant &quot;View/Download&quot; or &quot;Edit&quot; access for specific users and/or groups to files. Enter a valid %{account_name}, one at a time, select the access level for that user, and click +Add."
423
429
  show:
424
430
  last_modified: Last modified
425
431
  social_media:
@@ -842,8 +848,39 @@ en:
842
848
  header: Select an action
843
849
  versions: Versions
844
850
  versions_title: Display previous versions
851
+ edit:
852
+ header: "Edit %{file_set}"
853
+ descriptions: "Descriptions"
854
+ versions: "Versions"
855
+ permissions: "Permissions"
856
+ form:
857
+ attach_to: "Attach to %{parent}"
858
+ cancel: "Cancel"
859
+ save: "Save"
860
+ title: "Title"
845
861
  groups_description:
846
862
  description_html: The list of groups in the drop-down marked "Select a group" is a list of User Managed Groups that you are a member of. You may select a specific group and assign an access level for a file within %{application_name}, similarly to adding user access levels.
863
+ permission_form:
864
+ applied_to: "(applied to all files just uploaded)"
865
+ depositor: "Depositor"
866
+ enter: "Enter %{account_label} (one at a time)"
867
+ header: "Permissions"
868
+ optional: "(optional)"
869
+ save_note_html: "Permissions are <strong>not</strong> saved until the &quot;Save&quot; button is pressed at the bottom of the page."
870
+ select_group: "Select a group"
871
+ share_with: "Share With"
872
+ table_title_access: "Access Level"
873
+ table_title_user: "Person/Group"
874
+ user_search: "Search for a user"
875
+ permission:
876
+ save: "Save"
877
+ versioning:
878
+ current: "Current Version"
879
+ header: "Versions"
880
+ upload: "Upload New Version"
881
+ restore: "Restore Previous Version"
882
+ restore_from: "Restore From"
883
+ save: "Save Revision"
847
884
  help:
848
885
  header: User Support
849
886
  override_text: Use app/views/static/help.html.erb to override this file.
@@ -984,7 +1021,7 @@ en:
984
1021
  name: Work
985
1022
  share_button: Share Your Work
986
1023
  single_use_links:
987
- button: Single-Use Link to File
1024
+ button: Create Single-Use Link
988
1025
  copy:
989
1026
  button: Copy
990
1027
  tooltip: Copied!
@@ -1199,6 +1236,7 @@ en:
1199
1236
  transfer_to: User
1200
1237
  placeholders:
1201
1238
  defaults:
1239
+ file: 'xxx'
1202
1240
  find_child_work: Search for a work…
1203
1241
  member_of_collection_ids: Select a collection…
1204
1242
  required:
@@ -314,6 +314,7 @@ es:
314
314
  delete:
315
315
  confirm: "¿Estás seguro?"
316
316
  header:
317
+ name: Nombre
317
318
  roles: Roles
318
319
  user: Usuario
319
320
  new_role: Asignar Rol
@@ -314,6 +314,7 @@ fr:
314
314
  delete:
315
315
  confirm: Êtes-vous sûr?
316
316
  header:
317
+ name: Nom
317
318
  roles: Les rôles
318
319
  user: Utilisateur
319
320
  new_role: Attribuer un rôle
@@ -314,6 +314,7 @@ it:
314
314
  delete:
315
315
  confirm: Sei sicuro?
316
316
  header:
317
+ name: Nome
317
318
  roles: ruoli
318
319
  user: Utente
319
320
  new_role: Assegna ruolo
@@ -314,6 +314,7 @@ pt-BR:
314
314
  delete:
315
315
  confirm: Você tem certeza?
316
316
  header:
317
+ name: Nome
317
318
  roles: Roles
318
319
  user: Do utilizador
319
320
  new_role: Atribuir papel
@@ -314,6 +314,7 @@ zh:
314
314
  delete:
315
315
  confirm: 您肯定要删除?
316
316
  header:
317
+ name: 名称
317
318
  roles: 角色
318
319
  user: 用户
319
320
  new_role: '授予角色:'
@@ -24,6 +24,8 @@ SUMMARY
24
24
  spec.version = Hyrax::VERSION
25
25
  spec.license = 'Apache-2.0'
26
26
 
27
+ spec.required_ruby_version = '>= 2.3'
28
+
27
29
  # Note: rails does not follow sem-ver conventions, it's
28
30
  # minor version releases can include breaking changes; see
29
31
  # http://guides.rubyonrails.org/maintenance_policy.html
@@ -35,7 +37,8 @@ SUMMARY
35
37
  spec.add_dependency 'blacklight', '~> 6.14'
36
38
  spec.add_dependency 'blacklight-gallery', '~> 0.7'
37
39
  spec.add_dependency 'breadcrumbs_on_rails', '~> 3.0'
38
- spec.add_dependency 'browse-everything', '>= 0.10.5'
40
+ # Pin browse-everything to stable version
41
+ spec.add_dependency 'browse-everything', '< 0.16'
39
42
  spec.add_dependency 'carrierwave', '~> 1.0'
40
43
  spec.add_dependency 'clipboard-rails', '~> 1.5'
41
44
  spec.add_dependency 'dry-equalizer', '~> 0.2'
@@ -92,7 +95,7 @@ SUMMARY
92
95
  spec.add_development_dependency 'rspec-its', '~> 1.1'
93
96
  spec.add_development_dependency 'rspec-rails', '~> 3.1'
94
97
  spec.add_development_dependency "selenium-webdriver"
95
- spec.add_development_dependency 'solr_wrapper', '~> 1.1'
98
+ spec.add_development_dependency 'solr_wrapper', '>= 1.1', '< 3.0'
96
99
  spec.add_development_dependency 'i18n-debug' if ENV['I18N_DEBUG']
97
100
  spec.add_development_dependency 'i18n_yaml_sorter' unless ENV['TRAVIS']
98
101
  spec.add_development_dependency 'rails-controller-testing', '~> 1'
@@ -18,6 +18,7 @@
18
18
  }
19
19
  ],
20
20
  "methods": [
21
+ "Hyrax::Workflow::GrantReadToDepositor",
21
22
  "Hyrax::Workflow::DeactivateObject"
22
23
  ]
23
24
  }, {
@@ -46,7 +46,13 @@ module Hyrax
46
46
  @config
47
47
  end
48
48
 
49
+ ##
50
+ # @return [Logger]
51
+ def self.logger
52
+ @logger ||= ActiveFedora::Base.logger
53
+ end
54
+
49
55
  def self.primary_work_type
50
- Hyrax::WorkRelation::DummyModel.primary_concern
56
+ config.curation_concerns.first
51
57
  end
52
58
  end
@@ -22,7 +22,7 @@ module Hyrax
22
22
  private
23
23
 
24
24
  def logger
25
- ActiveFedora::Base.logger
25
+ Hyrax.logger
26
26
  end
27
27
 
28
28
  def validate_user!
@@ -15,7 +15,7 @@ module Hyrax
15
15
  nil
16
16
  end
17
17
 
18
- delegate :logger, to: ActiveFedora::Base
18
+ delegate :logger, to: Hyrax
19
19
 
20
20
  def instance
21
21
  if Redis.current.is_a? Redis::Namespace
@@ -8,8 +8,8 @@ module Hyrax
8
8
  # lists and add a Change List Index to point to all of them.
9
9
  class ChangeListWriter
10
10
  attr_reader :resource_host, :capability_list_url
11
- MODIFIED_DATE_FIELD = 'system_modified_dtsi'.freeze
12
- BEGINNING_OF_TIME = '1970-01-01T00:00:00Z'.freeze
11
+ MODIFIED_DATE_FIELD = 'system_modified_dtsi'
12
+ BEGINNING_OF_TIME = '1970-01-01T00:00:00Z'
13
13
 
14
14
  def initialize(resource_host:, capability_list_url:)
15
15
  @resource_host = resource_host
@@ -1,3 +1,3 @@
1
1
  module Hyrax
2
- VERSION = '2.1.0'.freeze
2
+ VERSION = '2.2.0'.freeze
3
3
  end
@@ -275,7 +275,7 @@ RSpec.describe Hyrax::Actors::FileSetActor do
275
275
  actor.attach_to_work(work)
276
276
  expect(work.representative).to eq(file_set)
277
277
  expect(work.thumbnail).to eq(file_set)
278
- expect { work.reload }.not_to change { [work.representative, work.thumbnail] }
278
+ expect { work.reload }.not_to change { [work.representative.id, work.thumbnail.id] }
279
279
  end
280
280
  end
281
281
 
@@ -21,10 +21,40 @@ RSpec.describe Hyrax::Admin::StatsController, type: :controller do
21
21
  end
22
22
 
23
23
  it 'allows an authorized user to view the page' do
24
- expect(Hyrax::AdminStatsPresenter).to receive(:new).with(expected_params, 5).and_call_original
25
24
  get :show
25
+
26
26
  expect(response).to be_success
27
27
  expect(assigns[:presenter]).to be_kind_of Hyrax::AdminStatsPresenter
28
+ expect(assigns[:presenter])
29
+ .to have_attributes(limit: 5, stats_filters: {})
30
+ end
31
+
32
+ context 'with a custom presenter' do
33
+ let(:presenter_class) { Class.new(Hyrax::AdminStatsPresenter) }
34
+
35
+ before { described_class.admin_stats_presenter = presenter_class }
36
+
37
+ it 'allows an authorized user to view the page' do
38
+ get :show
39
+
40
+ expect(assigns[:presenter]).to be_kind_of presenter_class
41
+ expect(assigns[:presenter])
42
+ .to have_attributes(limit: 5, stats_filters: {})
43
+ end
44
+ end
45
+
46
+ context 'with custom stats services' do
47
+ let(:by_depositor_class) { Class.new(Hyrax::Statistics::Works::ByDepositor) }
48
+ let(:service_config) { { by_depositor: by_depositor_class } }
49
+
50
+ before { described_class.admin_stats_services = service_config }
51
+
52
+ it 'allows an authorized user to view the page' do
53
+ get :show
54
+
55
+ expect(assigns[:presenter])
56
+ .to have_attributes(by_depositor: by_depositor_class)
57
+ end
28
58
  end
29
59
  end
30
60
  end
@@ -83,7 +83,7 @@ RSpec.describe Hyrax::CollectionsController do
83
83
  expect(controller).to receive(:add_breadcrumb).with('Home', Hyrax::Engine.routes.url_helpers.root_path(locale: 'en'))
84
84
  expect(controller).to receive(:add_breadcrumb).with('Dashboard', Hyrax::Engine.routes.url_helpers.dashboard_path(locale: 'en'))
85
85
  expect(controller).to receive(:add_breadcrumb).with('Collections', Hyrax::Engine.routes.url_helpers.my_collections_path(locale: 'en'))
86
- expect(controller).to receive(:add_breadcrumb).with('My collection', collection_path(collection.id, locale: 'en'))
86
+ expect(controller).to receive(:add_breadcrumb).with('My collection', collection_path(collection.id, locale: 'en'), "aria-current" => "page")
87
87
  get :show, params: { id: collection }
88
88
  expect(response).to be_successful
89
89
  end
@@ -117,7 +117,7 @@ RSpec.describe Hyrax::CollectionsController do
117
117
  it "sets breadcrumbs" do
118
118
  expect(controller).not_to receive(:add_breadcrumb).with(I18n.t('hyrax.dashboard.title'), Hyrax::Engine.routes.url_helpers.dashboard_path(locale: 'en'))
119
119
  expect(controller).not_to receive(:add_breadcrumb).with('Your Collections', Hyrax::Engine.routes.url_helpers.my_collections_path(locale: 'en'))
120
- expect(controller).to receive(:add_breadcrumb).with('My collection', collection_path(collection.id, locale: 'en'))
120
+ expect(controller).to receive(:add_breadcrumb).with('My collection', collection_path(collection.id, locale: 'en'), "aria-current" => "page")
121
121
  get :show, params: { id: collection }
122
122
  expect(response).to be_successful
123
123
  end
@@ -359,7 +359,7 @@ RSpec.describe Hyrax::Dashboard::CollectionsController, :clean_repo do
359
359
  expect(controller).to receive(:add_breadcrumb).with('Home', Hyrax::Engine.routes.url_helpers.root_path(locale: 'en'))
360
360
  expect(controller).to receive(:add_breadcrumb).with('Dashboard', Hyrax::Engine.routes.url_helpers.dashboard_path(locale: 'en'))
361
361
  expect(controller).to receive(:add_breadcrumb).with('Collections', Hyrax::Engine.routes.url_helpers.my_collections_path(locale: 'en'))
362
- expect(controller).to receive(:add_breadcrumb).with('My collection', collection_path(collection.id, locale: 'en'))
362
+ expect(controller).to receive(:add_breadcrumb).with('My collection', collection_path(collection.id, locale: 'en'), "aria-current" => "page")
363
363
  get :show, params: { id: collection }
364
364
  expect(response).to be_successful
365
365
  end
@@ -457,7 +457,7 @@ RSpec.describe Hyrax::Dashboard::CollectionsController, :clean_repo do
457
457
  expect(controller).to receive(:add_breadcrumb).with('Home', Hyrax::Engine.routes.url_helpers.root_path(locale: 'en'))
458
458
  expect(controller).to receive(:add_breadcrumb).with('Dashboard', Hyrax::Engine.routes.url_helpers.dashboard_path(locale: 'en'))
459
459
  expect(controller).to receive(:add_breadcrumb).with('Collections', Hyrax::Engine.routes.url_helpers.my_collections_path(locale: 'en'))
460
- expect(controller).to receive(:add_breadcrumb).with(I18n.t("hyrax.collection.browse_view"), collection_path(collection.id, locale: 'en'))
460
+ expect(controller).to receive(:add_breadcrumb).with(I18n.t("hyrax.collection.browse_view"), collection_path(collection.id, locale: 'en'), "aria-current" => "page")
461
461
  get :edit, params: { id: collection }
462
462
  expect(response).to be_successful
463
463
  end
@@ -199,9 +199,10 @@ RSpec.describe Hyrax::GenericWorksController do
199
199
  end
200
200
  let(:work) { instance_double(GenericWork, id: '99999', to_global_id: '99999') }
201
201
 
202
- context 'with a user lacking workflow permission' do
202
+ context 'with a user lacking both workflow permission and read access' do
203
203
  before do
204
204
  allow(SolrDocument).to receive(:find).and_return(document)
205
+ allow(controller.current_ability).to receive(:can?).with(:read, document).and_return(false)
205
206
  end
206
207
  let(:document_list) { [] }
207
208
  let(:document) { instance_double(SolrDocument, suppressed?: true) }
@@ -209,8 +210,23 @@ RSpec.describe Hyrax::GenericWorksController do
209
210
  it 'shows the unauthorized message' do
210
211
  get :show, params: { id: work.id }
211
212
  expect(response.code).to eq '401'
212
- expect(response).to render_template(:unavailable)
213
- expect(flash[:notice]).to eq 'The work is not currently available because it has not yet completed the approval process'
213
+ expect(response).to render_template(:unauthorized)
214
+ end
215
+
216
+ context 'with a user who lacks workflow permission but has read access' do
217
+ before do
218
+ allow(SolrDocument).to receive(:find).and_return(document)
219
+ allow(controller.current_ability).to receive(:can?).with(:read, document).and_return(true)
220
+ end
221
+ let(:document_list) { [] }
222
+ let(:document) { instance_double(SolrDocument, suppressed?: true) }
223
+
224
+ it 'shows the unavailable message' do
225
+ get :show, params: { id: work.id }
226
+ expect(response.code).to eq '401'
227
+ expect(response).to render_template(:unavailable)
228
+ expect(flash[:notice]).to eq 'The work is not currently available because it has not yet completed the approval process'
229
+ end
214
230
  end
215
231
  end
216
232
 
@@ -70,7 +70,7 @@ RSpec.describe Hyrax::HomepageController, type: :controller do
70
70
  get :index
71
71
  expect(response).to be_success
72
72
  expect(assigns(:recent_documents).length).to be <= 4
73
- create_times = assigns(:recent_documents).map { |d| d['system_create_dtsi'] }
73
+ create_times = assigns(:recent_documents).map { |d| d['date_uploaded_dtsi'] }
74
74
  expect(create_times).to eq create_times.sort.reverse
75
75
  end
76
76
  end
@@ -21,6 +21,10 @@ RSpec.describe Hyrax::UsersController, type: :controller do
21
21
  let!(:u1) { create(:user) }
22
22
  let!(:u2) { create(:user) }
23
23
 
24
+ before do
25
+ allow(Flipflop).to receive(:hide_users_list?).and_return(false)
26
+ end
27
+
24
28
  describe "requesting html" do
25
29
  before do
26
30
  # These user types are excluded:
@@ -90,4 +94,58 @@ RSpec.describe Hyrax::UsersController, type: :controller do
90
94
  end
91
95
  end
92
96
  end
97
+
98
+ describe 'user list access' do
99
+ context 'with hide_users_list?=enabled' do
100
+ before do
101
+ allow(Flipflop).to receive(:hide_users_list?).and_return(true)
102
+ end
103
+
104
+ describe 'with registered user' do
105
+ it 'renders the user list' do
106
+ get :index
107
+ expect(response.code).to eq '200'
108
+ expect(response).to render_template(:index)
109
+ end
110
+
111
+ it 'does return .json results' do
112
+ get :index, params: { format: :json }
113
+ expect(response).to be_successful
114
+ end
115
+ end
116
+
117
+ describe 'with unauthenticated user' do
118
+ before do
119
+ sign_out user
120
+ end
121
+
122
+ it 'does not render the user list' do
123
+ get :index
124
+ expect(flash[:alert]).to eq 'You need to sign in or sign up before continuing.'
125
+ expect(response).to have_http_status(302)
126
+ expect(response).to redirect_to('/users/sign_in')
127
+ end
128
+
129
+ it 'does not return .json results' do
130
+ get :index, params: { format: :json }
131
+ expect(response).not_to be_successful
132
+ end
133
+ end
134
+ end
135
+
136
+ context 'with hide_users_list?=disabled' do
137
+ before do
138
+ sign_out user
139
+ allow(Flipflop).to receive(:hide_users_list?).and_return(false)
140
+ end
141
+
142
+ describe 'with unauthenticated user' do
143
+ it 'renders the user list' do
144
+ get :index
145
+ expect(response.code).to eq '200'
146
+ expect(response).to render_template(:index)
147
+ end
148
+ end
149
+ end
150
+ end
93
151
  end