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
@@ -0,0 +1,132 @@
1
+ RSpec.describe 'AdminSets Factory' do # rubocop:disable RSpec/DescribeClass
2
+ let(:user) { build(:user, email: 'user@example.com') }
3
+ let(:user_mgr) { build(:user, email: 'user_mgr@example.com') }
4
+ let(:user_dep) { build(:user, email: 'user_dep@example.com') }
5
+ let(:user_vw) { build(:user, email: 'user_vw@example.com') }
6
+
7
+ describe 'build' do
8
+ context 'with_permission_template' do
9
+ it 'will not create a permission template or access when it is the default value of false' do
10
+ expect { build(:adminset_lw) }.not_to change { Hyrax::PermissionTemplate.count }
11
+ expect { build(:adminset_lw) }.not_to change { Hyrax::PermissionTemplateAccess.count }
12
+ end
13
+
14
+ it 'will create a permission template and one access for the creating user when set to true' do
15
+ expect { build(:adminset_lw, with_permission_template: true) }.to change { Hyrax::PermissionTemplate.count }.by(1)
16
+ expect { build(:adminset_lw, with_permission_template: true) }.to change { Hyrax::PermissionTemplateAccess.count }.by(1)
17
+ end
18
+
19
+ it 'will create a permission template and access for each user specified when it is set to attributes identifying access' do
20
+ expect { build(:adminset_lw, with_permission_template: { manage_users: [user_mgr] }) }.to change { Hyrax::PermissionTemplate.count }.by(1)
21
+ expect { build(:adminset_lw, with_permission_template: { manage_users: [user_mgr] }) }.to change { Hyrax::PermissionTemplateAccess.count }.by(2)
22
+ expect { build(:adminset_lw, with_permission_template: { manage_users: [user_mgr], deposit_users: [user_dep], view_users: [user_vw] }) }
23
+ .to change { Hyrax::PermissionTemplate.count }.by(1)
24
+ expect { build(:adminset_lw, with_permission_template: { manage_users: [user_mgr], deposit_users: [user_dep], view_users: [user_vw] }) }
25
+ .to change { Hyrax::PermissionTemplateAccess.count }.by(4)
26
+ end
27
+ end
28
+
29
+ context 'with_solr_document' do
30
+ it 'will not create a solr document by default' do
31
+ adminset = build(:adminset_lw)
32
+ expect(adminset.id).to eq nil # no real way to confirm a solr document wasn't created if the admin set doesn't have an id
33
+ end
34
+
35
+ context 'true' do
36
+ let(:adminset) { build(:adminset_lw, with_solr_document: true) }
37
+
38
+ subject { ActiveFedora::SolrService.get("id:#{adminset.id}")["response"]["docs"].first }
39
+
40
+ it 'will create a solr document' do
41
+ expect(subject["id"]).to eq adminset.id
42
+ expect(subject["has_model_ssim"].first).to eq "AdminSet"
43
+ expect(subject["edit_access_person_ssim"]).not_to be_blank
44
+ end
45
+ end
46
+
47
+ context 'true and with_permission_template defines additional access' do
48
+ let(:adminset) do
49
+ build(:adminset_lw, user: user,
50
+ with_solr_document: true,
51
+ with_permission_template: { manage_users: [user_mgr],
52
+ deposit_users: [user_dep],
53
+ view_users: [user_vw] })
54
+ end
55
+
56
+ subject { ActiveFedora::SolrService.get("id:#{adminset.id}")["response"]["docs"].first }
57
+
58
+ it 'will created a solr document' do
59
+ expect(subject["id"]).to eq adminset.id
60
+ expect(subject["has_model_ssim"].first).to eq "AdminSet"
61
+ expect(subject["edit_access_person_ssim"]).to include(user.user_key, user_mgr.user_key)
62
+ expect(subject["read_access_person_ssim"]).to include(user_dep.user_key, user_vw.user_key)
63
+ end
64
+ end
65
+ end
66
+ end
67
+
68
+ describe 'create' do
69
+ # with_solr_document is tested by build
70
+ # with_permission_template is tested by build except that the permission template is always created for `create`
71
+
72
+ context 'with_permission_template: false' do
73
+ it 'will create a permission template and access even when it is the default value of false' do
74
+ expect { create(:adminset_lw) }.to change { Hyrax::PermissionTemplate.count }.by(1)
75
+ expect { create(:adminset_lw) }.to change { Hyrax::PermissionTemplateAccess.count }.by(1)
76
+ end
77
+ end
78
+ end
79
+
80
+ describe 'default_adminset' do
81
+ let(:default_adminset) { build(:default_adminset) }
82
+ let(:solrdoc) { ActiveFedora::SolrService.get("id:#{default_adminset.id}")["response"]["docs"].first }
83
+ let(:permission_template) { default_adminset.permission_template }
84
+
85
+ it 'will create the default adminset with expected metadata' do
86
+ expect(default_adminset.id).to eq AdminSet::DEFAULT_ID
87
+ expect(default_adminset.title).to eq AdminSet::DEFAULT_TITLE
88
+ end
89
+
90
+ it 'will create solr doc with no access' do
91
+ expect(solrdoc["id"]).to eq default_adminset.id
92
+ expect(solrdoc["has_model_ssim"].first).to eq "AdminSet"
93
+ expect(solrdoc["edit_access_person_ssim"].count).to eq 1 # creator automatically assigned by factory
94
+ expect(solrdoc["read_access_person_ssim"]).to eq nil
95
+ expect(solrdoc["edit_access_group_ssim"]).to include(::Ability.admin_group_name)
96
+ expect(solrdoc["read_access_group_ssim"]).to eq nil
97
+ end
98
+
99
+ it 'will create permission template with registered users as depositors' do
100
+ expect(permission_template.agent_ids_for(access: 'deposit', agent_type: 'group'))
101
+ .to include(::Ability.registered_group_name)
102
+ expect(permission_template.agent_ids_for(access: 'manage', agent_type: 'group'))
103
+ .to include(::Ability.admin_group_name)
104
+ end
105
+ end
106
+
107
+ describe 'build no_solr_grants_adminset' do
108
+ let(:permissions) do
109
+ { manage_users: [user_mgr],
110
+ deposit_users: [user_dep],
111
+ view_users: [user_vw] }
112
+ end
113
+ let(:legacy_adminset) { build(:no_solr_grants_adminset, user: user, with_permission_template: permissions) }
114
+ let(:solrdoc) { ActiveFedora::SolrService.get("id:#{legacy_adminset.id}")["response"]["docs"].first }
115
+
116
+ it 'will create a permission template with all access' do
117
+ expect { build(:no_solr_grants_adminset, user: user, with_permission_template: permissions) }
118
+ .to change { Hyrax::PermissionTemplate.count }.by(1)
119
+ expect { build(:no_solr_grants_adminset, user: user, with_permission_template: permissions) }
120
+ .to change { Hyrax::PermissionTemplateAccess.count }.by(4)
121
+ end
122
+
123
+ it 'will create solr doc with creator access only' do
124
+ expect(solrdoc["id"]).to eq legacy_adminset.id
125
+ expect(solrdoc["has_model_ssim"].first).to eq "AdminSet"
126
+ expect(solrdoc["edit_access_person_ssim"]).to eq [user.user_key]
127
+ expect(solrdoc["read_access_person_ssim"]).to eq nil
128
+ expect(solrdoc["edit_access_group_ssim"]).to eq nil
129
+ expect(solrdoc["read_access_group_ssim"]).to eq nil
130
+ end
131
+ end
132
+ end
@@ -59,7 +59,7 @@ RSpec.describe 'Collections Factory' do # rubocop:disable RSpec/DescribeClass
59
59
  end
60
60
 
61
61
  context 'with_solr_document' do
62
- it 'will not created a solr document by default' do
62
+ it 'will not create a solr document by default' do
63
63
  col = build(:collection_lw)
64
64
  expect(col.id).to eq nil # no real way to confirm a solr document wasn't created if the collection doesn't have an id
65
65
  end
@@ -69,7 +69,7 @@ RSpec.describe 'Collections Factory' do # rubocop:disable RSpec/DescribeClass
69
69
 
70
70
  subject { ActiveFedora::SolrService.get("id:#{col.id}")["response"]["docs"].first }
71
71
 
72
- it 'will created a solr document' do
72
+ it 'will create a solr document' do
73
73
  expect(subject["id"]).to eq col.id
74
74
  expect(subject["has_model_ssim"].first).to eq "Collection"
75
75
  expect(subject["edit_access_person_ssim"]).not_to be_blank
@@ -87,7 +87,7 @@ RSpec.describe 'Collections Factory' do # rubocop:disable RSpec/DescribeClass
87
87
 
88
88
  subject { ActiveFedora::SolrService.get("id:#{col.id}")["response"]["docs"].first }
89
89
 
90
- it 'will created a solr document' do
90
+ it 'will create a solr document' do
91
91
  expect(subject["id"]).to eq col.id
92
92
  expect(subject["has_model_ssim"].first).to eq "Collection"
93
93
  expect(subject["edit_access_person_ssim"]).to include(user.user_key, user_mgr.user_key)
@@ -10,13 +10,7 @@ RSpec.describe 'Batch creation of works', type: :feature do
10
10
  with_permission_template: { deposit_groups: [::Ability.registered_group_name] })
11
11
  end
12
12
 
13
- before do
14
- # stub out characterization and derivatives. Travis doesn't have fits installed, and it's not relevant to the test.
15
- allow(CharacterizeJob).to receive(:perform_later)
16
- allow(CreateDerivativesJob).to receive(:perform_later)
17
-
18
- sign_in user
19
- end
13
+ before { sign_in user }
20
14
 
21
15
  it "renders the batch create form" do
22
16
  visit hyrax.new_batch_upload_path
@@ -27,10 +21,13 @@ RSpec.describe 'Batch creation of works', type: :feature do
27
21
  expect(page).to have_content("Each file will be uploaded to a separate new work resulting in one work per uploaded file.")
28
22
  end
29
23
 
30
- context 'when the user is a proxy', :js, :workflow do
24
+ context 'when the user is a proxy', :js, :workflow, :perform_enqueued do
31
25
  let(:second_user) { create(:user) }
32
26
 
33
27
  before do
28
+ allow(CharacterizeJob).to receive(:perform_later).and_return(true)
29
+ allow(CreateDerivativesJob).to receive(:perform_later).and_return(true)
30
+
34
31
  ProxyDepositRights.create!(grantor: second_user, grantee: user)
35
32
  sign_in user
36
33
  click_link 'Works'
@@ -2,10 +2,16 @@
2
2
 
3
3
  RSpec.describe 'batch', type: :feature, clean_repo: true, js: true do
4
4
  let(:current_user) { create(:user) }
5
- let!(:work1) { create(:public_work, user: current_user) }
6
- let!(:work2) { create(:public_work, user: current_user) }
5
+ let(:admin_set) { create(:admin_set) }
6
+ let(:permission_template) { create(:permission_template, source_id: admin_set.id) }
7
+ let!(:workflow) { create(:workflow, allows_access_grant: true, active: true, permission_template_id: permission_template.id) }
8
+
9
+ let!(:work1) { create(:public_work, admin_set_id: admin_set.id, user: current_user, members: [file_set]) }
10
+ let!(:work2) { create(:public_work, admin_set_id: admin_set.id, user: current_user) }
11
+ let!(:file_set) { create(:file_set) }
7
12
 
8
13
  before do
14
+ RoleMapper.byname[current_user.user_key] << 'donor'
9
15
  sign_in current_user
10
16
  visit '/dashboard/my/works'
11
17
  check 'check_all'
@@ -60,6 +66,47 @@ RSpec.describe 'batch', type: :feature, clean_repo: true, js: true do
60
66
  page.find("input#generic_work_related_url[value='NEW related_url']")
61
67
  end
62
68
  end
69
+
70
+ it 'updates permissions and roles' do
71
+ click_on 'batch-edit'
72
+ find('#edit_permissions_link').click
73
+ expect(page).to have_content('Batch Edit Descriptions')
74
+
75
+ # Set visibility to private
76
+ within "#form_permissions_visibility" do
77
+ batch_edit_expand('permissions_visibility')
78
+ find('#generic_work_visibility_authenticated').click
79
+ find('#permissions_visibility_save').click
80
+ # This was `expect(page).to have_content 'Changes Saved'`, however in debugging,
81
+ # the `have_content` check was ignoring the `within` scoping and finding
82
+ # "Changes Saved" for other field areas
83
+ find('.status', text: 'Changes Saved', wait: 5)
84
+ end
85
+
86
+ within "#form_permissions" do
87
+ batch_edit_expand('permissions_sharing')
88
+ page.select('donor', from: 'new_group_name_skel')
89
+ page.select('View/Download', from: 'new_group_permission_skel')
90
+ page.find('#add_new_group_skel').click
91
+ find('#collapse_permissions_sharing table', text: 'View/Download')
92
+ find('#collapse_permissions_sharing table', text: 'donor')
93
+ find('#permissions_sharing_save').click
94
+ # This was `expect(page).to have_content 'Changes Saved'`, however in debugging,
95
+ # the `have_content` check was ignoring the `within` scoping and finding
96
+ # "Changes Saved" for other field areas
97
+ find('.status', text: 'Changes Saved', wait: 5)
98
+ end
99
+
100
+ # Visit work permissions and verify
101
+ visit "/concern/generic_works/#{work1.id}/edit#share"
102
+ page.find('#generic_work_visibility_authenticated:checked')
103
+ page.find('#share table', text: 'donor')
104
+
105
+ # Visit file permissions and verify
106
+ visit "concern/file_sets/#{work1.file_sets.first.id}/edit#permissions_display"
107
+ page.find('#file_set_visibility_authenticated:checked')
108
+ page.find('#permissions_display table', text: 'donor')
109
+ end
63
110
  end
64
111
 
65
112
  describe 'deleting' do
@@ -1,4 +1,5 @@
1
1
  RSpec.describe 'Adding a work to multiple collections', type: :feature, clean_repo: true, js: true do
2
+ include Selectors::Dashboard
2
3
  let(:admin_user) { create(:admin, email: 'admin@example.com') }
3
4
  let(:single_membership_type_1) { create(:collection_type, :not_allow_multiple_membership, title: 'Single-membership 1') }
4
5
  let(:single_membership_type_2) { create(:collection_type, :not_allow_multiple_membership, title: 'Single-membership 2') }
@@ -58,7 +59,14 @@ RSpec.describe 'Adding a work to multiple collections', type: :feature, clean_re
58
59
 
59
60
  describe 'when both collections require single membership' do
60
61
  let(:old_collection) { create(:collection_lw, user: admin_user, collection_type_gid: single_membership_type_1.gid) }
61
- let!(:work) { create(:generic_work, user: admin_user, member_of_collections: [old_collection], title: ['The highly valued work that everyone wants in their collection']) }
62
+ let!(:work) do
63
+ create(:generic_work,
64
+ user: admin_user,
65
+ member_of_collections: [old_collection],
66
+ title: ['The highly valued work that everyone wants in their collection'],
67
+ creator: ["Fred"],
68
+ keyword: ['test'], rights_statement: ['http://rightsstatements.org/vocab/InC/1.0/'])
69
+ end
62
70
 
63
71
  context 'and are of different types' do
64
72
  let!(:new_collection) { create(:collection_lw, user: admin_user, collection_type_gid: single_membership_type_2.gid) }
@@ -99,25 +107,31 @@ RSpec.describe 'Adding a work to multiple collections', type: :feature, clean_re
99
107
  expect(page).to have_link 'Your Collections'
100
108
  end
101
109
 
102
- err_message = "Error: You have specified more than one of the same single-membership collection types: " \
103
- "Single-membership 1 (#{new_collection.title.first} and #{old_collection.title.first})"
110
+ err_message = "Error: You have specified more than one of the same single-membership collection type " \
111
+ "(type: Single-membership 1, collections: #{new_collection.title.first} and #{old_collection.title.first})"
104
112
  expect(page).to have_selector '.alert', text: err_message
105
113
  end
106
114
 
107
- it "from the work's edit form Relationships tab" do
108
- skip 'Needs additional work to find and select the second collection'
115
+ it "from the work's edit form Relationships tab", js: true do
109
116
  # Attempt to add to second single-membership collection of the same type
110
117
  visit edit_hyrax_generic_work_path(work)
111
118
  click_link "Relationships"
112
- # TODO: not sure how to find and select the correct collection
113
119
 
114
- # forwards to work index page and shows flash message
115
- expect(page).to have_link 'All Works'
116
- expect(page).to have_link 'Your Works'
120
+ select_collection(new_collection)
121
+ check('agreement')
122
+ sleep 3
123
+ choose('generic_work_visibility_open')
124
+ sleep 3
117
125
 
118
- err_message = "Error: You have specified more than one of the same single-membership collection types: " \
119
- "Single-membership 1 (Collection 1 for SM1)"
120
- expect(page).to have_selector '.alert', text: err_message
126
+ within('div#savewidget') do
127
+ element = nil
128
+ all('input').each { |i| element = i if i.value == 'Save changes' }
129
+ element.click
130
+ end
131
+
132
+ err_message = "Error: You have specified more than one of the same single-membership collection type " \
133
+ "(type: Single-membership 1, collections: #{old_collection.title.first} and #{new_collection.title.first})"
134
+ expect(page).to have_selector '.help-block', text: err_message
121
135
  end
122
136
 
123
137
  it "from the collection's show page Add to collection" do
@@ -135,8 +149,9 @@ RSpec.describe 'Adding a work to multiple collections', type: :feature, clean_re
135
149
  expect(page).to have_link 'All Collections'
136
150
  expect(page).to have_link 'Your Collections'
137
151
  end
138
- err_message = "Error: You have specified more than one of the same single-membership collection types: " \
139
- "Single-membership 1 (#{new_collection.title.first} and #{old_collection.title.first})"
152
+
153
+ err_message = "Error: You have specified more than one of the same single-membership collection type " \
154
+ "(type: Single-membership 1, collections: #{new_collection.title.first} and #{old_collection.title.first})"
140
155
  expect(page).to have_selector '.alert', text: err_message
141
156
  end
142
157
  end
@@ -323,13 +323,14 @@ RSpec.describe 'collection_type', type: :feature, clean_repo: true do
323
323
  context 'when there are no collections of this type' do
324
324
  let!(:empty_collection_type) { create(:collection_type, title: 'Empty Type', creator_user: admin_user) }
325
325
  let!(:delete_modal_text) { 'Deleting this collection type will permanently remove the type and its settings from the repository. Are you sure you want to delete this collection type?' }
326
+ let!(:deleted_flash_text) { "The collection type #{empty_collection_type.title} has been deleted." }
326
327
 
327
328
  before do
328
329
  sign_in admin_user
329
330
  visit '/admin/collection_types'
330
331
  end
331
332
 
332
- it 'shows warning and deletes collection type', :js do
333
+ it 'shows warning, deletes collection type, and shows flash message on success', :js do
333
334
  expect(page).to have_content(empty_collection_type.title)
334
335
 
335
336
  find(:xpath, "//tr[td[contains(.,'#{empty_collection_type.title}')]]/td/button", text: 'Delete').click
@@ -339,7 +340,13 @@ RSpec.describe 'collection_type', type: :feature, clean_repo: true do
339
340
  click_button('Delete')
340
341
  end
341
342
 
342
- expect(page).not_to have_content(empty_collection_type.title)
343
+ within('.alert-success') do
344
+ expect(page).to have_content(deleted_flash_text)
345
+ end
346
+
347
+ within('.collection-types-table') do
348
+ expect(page).not_to have_content(empty_collection_type.title)
349
+ end
343
350
  end
344
351
  end
345
352
 
@@ -1,4 +1,4 @@
1
- RSpec.describe 'Creating a new Work as admin', :js, :workflow do
1
+ RSpec.describe 'Creating a new Work as admin', :js, :workflow, perform_enqueued: [AttachFilesToWorkJob, IngestJob] do
2
2
  let(:user) { create(:admin) }
3
3
  let(:admin_set_1) do
4
4
  create(:admin_set, id: AdminSet::DEFAULT_ID,
@@ -56,7 +56,7 @@ RSpec.describe 'Creating a new Work', :js, :workflow do
56
56
  end
57
57
  end
58
58
 
59
- context 'when the user is a proxy' do
59
+ context 'when the user is a proxy', perform_enqueued: [ContentDepositorChangeEventJob, AttachFilesToWorkJob, IngestJob] do
60
60
  let(:second_user) { create(:user) }
61
61
 
62
62
  before do
@@ -424,7 +424,7 @@ RSpec.describe 'collection', type: :feature, clean_repo: true do
424
424
  end
425
425
  end
426
426
 
427
- context 'when user without permissions selects delete' do
427
+ context 'when user does not have permission to delete a collection' do
428
428
  let(:user2) { create(:user) }
429
429
 
430
430
  before do
@@ -437,18 +437,22 @@ RSpec.describe 'collection', type: :feature, clean_repo: true do
437
437
  visit '/dashboard/collections' # Managed Collections tab
438
438
  end
439
439
 
440
- it 'does not allow delete collection' do
441
- expect(page).to have_content(collection.title.first)
442
- check_tr_data_attributes(collection.id, 'collection')
443
- within("#document_#{collection.id}") do
444
- first('button.dropdown-toggle').click
445
- first('.itemtrash').click
446
- end
447
- expect(page).to have_selector('div#collection-to-delete-deny-modal', visible: true)
448
- within('div#collection-to-delete-deny-modal') do
449
- click_button('Close')
440
+ context 'and selects Delete from drop down within table' do
441
+ it 'does not allow delete collection', js: true do
442
+ expect(page).to have_content(collection.title.first)
443
+ check_tr_data_attributes(collection.id, 'collection')
444
+ within("#document_#{collection.id}") do
445
+ first('button.dropdown-toggle').click
446
+ first('.itemtrash').click
447
+ end
448
+
449
+ # Exepct the modal to be shown that explains why the user can't delete the collection.
450
+ expect(page).to have_selector('div#collection-to-delete-deny-modal', visible: true)
451
+ within('div#collection-to-delete-deny-modal') do
452
+ click_button('Close')
453
+ end
454
+ expect(page).to have_content(collection.title.first)
450
455
  end
451
- expect(page).to have_content(collection.title.first)
452
456
  end
453
457
  end
454
458
 
@@ -11,35 +11,52 @@ RSpec.describe 'Editing content blocks as admin', :js do
11
11
  click_link 'Content Blocks'
12
12
  end
13
13
 
14
- it "gives a confirmation message" do
14
+ it "does not display a confirmation message when form data has not changed" do
15
15
  expect(page).to have_content('Content Blocks')
16
16
  expect(page).to have_content('Announcement')
17
17
  click_link 'Marketing Text'
18
- within('#change-tab-content-block') do
18
+ expect(page).not_to have_content(confirm_modal_text)
19
+ end
20
+
21
+ it "displays a confirmation message when form data has changed" do
22
+ expect(page).to have_content('Content Blocks')
23
+ expect(page).to have_content('Announcement')
24
+ expect(page).to have_selector('#content_block_announcement_ifr')
25
+ within_frame('content_block_announcement_ifr') do
26
+ find('body').set('Updated text.')
27
+ end
28
+ click_link 'Marketing Text'
29
+ within('#nav-safety-modal') do
19
30
  expect(page).to have_content(confirm_modal_text)
20
31
  end
21
32
  end
22
33
 
23
- it "changes tab when user accept the changing tab confirmation" do
34
+ it "does not change tab when user dismisses the confirmation" do
24
35
  expect(page).to have_selector('#announcement_text', class: 'active')
25
36
  expect(page).not_to have_selector('#marketing', class: 'active')
37
+ within_frame('content_block_announcement_ifr') do
38
+ find('body').set('Updated text.')
39
+ end
26
40
  click_link 'Marketing Text'
27
- within('#change-tab-content-block') do
28
- click_link('OK')
41
+ within('#nav-safety-modal') do
42
+ click_button('OK')
29
43
  end
30
- expect(page).to have_selector('#marketing', class: 'active')
31
- expect(page).not_to have_selector('#announcement_text', class: 'active')
44
+ expect(page).not_to have_selector('#marketing', class: 'active')
45
+ expect(page).to have_selector('#announcement_text', class: 'active')
32
46
  end
33
47
 
34
- it "does not change tab when user cancel the changing tab confirmation" do
48
+ it "does not redisplay the confirmation unless form data is changed" do
35
49
  expect(page).to have_selector('#announcement_text', class: 'active')
36
50
  expect(page).not_to have_selector('#marketing', class: 'active')
51
+ within_frame('content_block_announcement_ifr') do
52
+ find('body').set('Updated text.')
53
+ end
37
54
  click_link 'Marketing Text'
38
- within('#change-tab-content-block') do
39
- click_button('Cancel')
55
+ within('#nav-safety-modal') do
56
+ click_button('OK')
40
57
  end
41
- expect(page).not_to have_selector('#marketing', class: 'active')
42
- expect(page).to have_selector('#announcement_text', class: 'active')
58
+ click_link 'Marketing Text'
59
+ expect(page).not_to have_content(confirm_modal_text)
43
60
  end
44
61
  end
45
62
  end