hyrax 2.0.0.rc1 → 2.0.0.rc2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (111) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -2
  3. data/app/actors/hyrax/actors/create_with_remote_files_actor.rb +5 -1
  4. data/app/assets/stylesheets/hyrax/_header.scss +6 -0
  5. data/app/controllers/concerns/hyrax/works_controller_behavior.rb +1 -1
  6. data/app/controllers/hyrax/admin/permission_template_accesses_controller.rb +4 -3
  7. data/app/controllers/hyrax/collections_controller.rb +2 -0
  8. data/app/forms/hyrax/forms/permission_template_form.rb +113 -48
  9. data/app/jobs/ingest_local_file_job.rb +0 -1
  10. data/app/renderers/hyrax/renderers/rights_statement_attribute_renderer.rb +25 -0
  11. data/app/search_builders/hyrax/deposit_search_builder.rb +6 -3
  12. data/app/search_builders/hyrax/stats/work_status_search_builder.rb +4 -5
  13. data/app/services/hyrax/default_middleware_stack.rb +0 -1
  14. data/app/services/hyrax/file_set_derivatives_service.rb +13 -4
  15. data/app/services/hyrax/statistics/depositors/summary.rb +1 -1
  16. data/app/services/hyrax/workflow/abstract_notification.rb +3 -2
  17. data/app/services/hyrax/workflow/notification_service.rb +3 -12
  18. data/app/services/hyrax/workflow/permission_query.rb +3 -3
  19. data/app/services/hyrax/workflow/status_list_service.rb +1 -1
  20. data/app/views/hyrax/admin/admin_sets/_form_participants.html.erb +1 -0
  21. data/app/views/hyrax/admin/admin_sets/_form_visibility.html.erb +1 -1
  22. data/app/views/hyrax/base/_attribute_rows.html.erb +1 -1
  23. data/app/views/hyrax/collections/show.html.erb +3 -0
  24. data/app/views/hyrax/dashboard/_index_partials/_proxy_rights.html.erb +1 -0
  25. data/app/views/hyrax/notifications/_notifications.html.erb +1 -0
  26. data/config/locales/hyrax.de.yml +7 -3
  27. data/config/locales/hyrax.en.yml +16 -12
  28. data/config/locales/hyrax.es.yml +4 -0
  29. data/config/locales/hyrax.fr.yml +4 -0
  30. data/config/locales/hyrax.it.yml +4 -0
  31. data/config/locales/hyrax.pt-BR.yml +4 -0
  32. data/config/locales/hyrax.zh.yml +4 -0
  33. data/hyrax.gemspec +2 -2
  34. data/lib/generators/hyrax/templates/config/locales/hyrax.de.yml +1 -1
  35. data/lib/generators/hyrax/templates/config/locales/hyrax.en.yml +1 -1
  36. data/lib/generators/hyrax/templates/config/locales/hyrax.es.yml +1 -1
  37. data/lib/generators/hyrax/templates/config/locales/hyrax.fr.yml +1 -1
  38. data/lib/generators/hyrax/templates/config/locales/hyrax.it.yml +1 -1
  39. data/lib/generators/hyrax/templates/config/locales/hyrax.pt-BR.yml +1 -1
  40. data/lib/generators/hyrax/templates/config/locales/hyrax.zh.yml +1 -1
  41. data/lib/hyrax/configuration.rb +11 -0
  42. data/lib/hyrax/version.rb +1 -1
  43. data/spec/abilities/file_set_abilities_spec.rb +3 -3
  44. data/spec/abilities/generic_work_abilities_spec.rb +5 -5
  45. data/spec/actors/hyrax/actors/generic_work_actor_spec.rb +12 -12
  46. data/spec/actors/hyrax/actors/transactional_request_spec.rb +1 -1
  47. data/spec/controllers/hyrax/api/items_controller_spec.rb +6 -6
  48. data/spec/controllers/hyrax/citations_controller_spec.rb +2 -2
  49. data/spec/controllers/hyrax/collections_controller_spec.rb +1 -0
  50. data/spec/controllers/hyrax/content_blocks_controller_spec.rb +5 -5
  51. data/spec/controllers/hyrax/dashboard/profiles_controller_spec.rb +2 -2
  52. data/spec/controllers/hyrax/downloads_controller_spec.rb +3 -3
  53. data/spec/controllers/hyrax/featured_work_lists_controller_spec.rb +2 -2
  54. data/spec/controllers/hyrax/generic_works_controller_spec.rb +1 -1
  55. data/spec/controllers/hyrax/homepage_controller_spec.rb +1 -1
  56. data/spec/controllers/hyrax/pages_controller_spec.rb +6 -6
  57. data/spec/controllers/hyrax/users_controller_spec.rb +1 -1
  58. data/spec/controllers/hyrax/workflow_actions_controller_spec.rb +1 -1
  59. data/spec/conversions/power_converters/polymorphic_type_spec.rb +1 -1
  60. data/spec/factories/admin_sets.rb +1 -1
  61. data/spec/factories/api_items.rb +1 -1
  62. data/spec/factories/collections_factory.rb +2 -2
  63. data/spec/factories/content_blocks.rb +1 -1
  64. data/spec/factories/featured_works.rb +1 -1
  65. data/spec/factories/file_sets.rb +3 -3
  66. data/spec/factories/generic_works.rb +15 -15
  67. data/spec/factories/operations.rb +1 -1
  68. data/spec/factories/permission_template_accesses.rb +1 -1
  69. data/spec/factories/permission_templates.rb +1 -1
  70. data/spec/factories/proxy_deposit_requests.rb +2 -2
  71. data/spec/factories/single_use_links.rb +1 -1
  72. data/spec/factories/sipity_entities.rb +1 -1
  73. data/spec/factories/uploaded_files.rb +1 -1
  74. data/spec/factories/users.rb +2 -2
  75. data/spec/factories/workflow_actions.rb +1 -1
  76. data/spec/factories/workflow_states.rb +1 -1
  77. data/spec/factories/workflows.rb +1 -1
  78. data/spec/features/notifications_spec.rb +1 -1
  79. data/spec/forms/hyrax/forms/permission_template_form_spec.rb +113 -2
  80. data/spec/helpers/hyrax/collections_helper_spec.rb +2 -2
  81. data/spec/helpers/hyrax/content_block_helper_spec.rb +1 -1
  82. data/spec/helpers/hyrax/trophy_helper_spec.rb +1 -1
  83. data/spec/jobs/create_derivatives_job_spec.rb +3 -4
  84. data/spec/jobs/ingest_local_file_job_spec.rb +2 -5
  85. data/spec/lib/hyrax/arkivo/actor_spec.rb +2 -2
  86. data/spec/lib/hyrax/arkivo/metadata_munger_spec.rb +1 -1
  87. data/spec/lib/hyrax/arkivo/schema_validator_spec.rb +1 -1
  88. data/spec/lib/hyrax/configuration_spec.rb +4 -0
  89. data/spec/models/file_set_spec.rb +1 -1
  90. data/spec/models/generic_work_spec.rb +1 -1
  91. data/spec/models/hyrax/user_usage_stats_spec.rb +1 -1
  92. data/spec/models/sipity/entity_spec.rb +1 -1
  93. data/spec/models/user_spec.rb +7 -7
  94. data/spec/presenters/hyrax/admin/users_presenter_spec.rb +2 -2
  95. data/spec/renderers/hyrax/renderers/rights_statement_attribute_renderer_spec.rb +20 -0
  96. data/spec/search_builders/hyrax/stats/work_status_search_builder_spec.rb +12 -12
  97. data/spec/services/hyrax/default_middleware_stack_spec.rb +0 -1
  98. data/spec/services/hyrax/embargo_service_spec.rb +4 -4
  99. data/spec/services/hyrax/workflow/notification_service_spec.rb +0 -35
  100. data/spec/services/hyrax/workflow/permission_generator_spec.rb +1 -1
  101. data/spec/services/hyrax/workflow/status_list_service_spec.rb +12 -0
  102. data/spec/spec_helper.rb +6 -6
  103. data/spec/support/features/session_helpers.rb +1 -1
  104. data/spec/views/hyrax/admin/users/index.html.erb_spec.rb +1 -1
  105. data/spec/views/hyrax/base/_attribute_rows.html.erb_spec.rb +1 -1
  106. data/spec/views/hyrax/base/file_manager.html.erb_spec.rb +1 -1
  107. data/spec/views/hyrax/collections/show.html.erb_spec.rb +23 -5
  108. data/spec/views/pages/show.html.erb_spec.rb +1 -1
  109. data/template.rb +1 -1
  110. metadata +8 -6
  111. data/app/actors/hyrax/actors/assign_representative_actor.rb +0 -22
@@ -58,7 +58,7 @@ RSpec.describe Hyrax::GenericWorksController do
58
58
  expect(controller).to receive(:add_breadcrumb).with('test title', main_app.hyrax_generic_work_path(work.id, locale: 'en'))
59
59
  get :show, params: { id: work }
60
60
  expect(response).to be_successful
61
- expect(response).to render_template("layouts/hyrax")
61
+ expect(response).to render_template("layouts/hyrax/1_column")
62
62
  end
63
63
  end
64
64
 
@@ -98,7 +98,7 @@ RSpec.describe Hyrax::HomepageController, type: :controller do
98
98
  end
99
99
 
100
100
  context "with featured works" do
101
- let!(:my_work) { FactoryGirl.create(:work, user: user) }
101
+ let!(:my_work) { FactoryBot.create(:work, user: user) }
102
102
 
103
103
  before do
104
104
  FeaturedWork.create!(work_id: my_work.id)
@@ -1,5 +1,5 @@
1
1
  RSpec.describe Hyrax::PagesController, type: :controller do
2
- let(:user) { FactoryGirl.create(:user) }
2
+ let(:user) { FactoryBot.create(:user) }
3
3
 
4
4
  before do
5
5
  sign_in user
@@ -34,16 +34,16 @@ RSpec.describe Hyrax::PagesController, type: :controller do
34
34
  end
35
35
  context 'when editing pages' do
36
36
  let!(:about_page) do
37
- FactoryGirl.create(:content_block, name: 'about_page')
37
+ FactoryBot.create(:content_block, name: 'about_page')
38
38
  end
39
39
  let!(:help_page) do
40
- FactoryGirl.create(:content_block, name: 'help_page')
40
+ FactoryBot.create(:content_block, name: 'help_page')
41
41
  end
42
42
  let!(:agreement_page) do
43
- FactoryGirl.create(:content_block, name: 'agreement_page')
43
+ FactoryBot.create(:content_block, name: 'agreement_page')
44
44
  end
45
45
  let!(:terms_page) do
46
- FactoryGirl.create(:content_block, name: 'terms_page')
46
+ FactoryBot.create(:content_block, name: 'terms_page')
47
47
  end
48
48
 
49
49
  context 'with an unprivileged user' do
@@ -63,7 +63,7 @@ RSpec.describe Hyrax::PagesController, type: :controller do
63
63
  end
64
64
 
65
65
  context 'with an administrator' do
66
- let(:user) { FactoryGirl.create(:admin) }
66
+ let(:user) { FactoryBot.create(:admin) }
67
67
 
68
68
  describe "GET #edit" do
69
69
  it "renders breadcrumbs and dashboard layout" do
@@ -81,7 +81,7 @@ RSpec.describe Hyrax::UsersController, type: :controller do
81
81
  end
82
82
 
83
83
  it "uses the base query" do
84
- u3 = FactoryGirl.create(:user)
84
+ u3 = FactoryBot.create(:user)
85
85
  allow(controller).to receive(:base_query).and_return(["email == \"#{u3.email}\""])
86
86
  get :index
87
87
  expect(assigns[:users]).to include(u3)
@@ -1,5 +1,5 @@
1
1
  RSpec.describe Hyrax::WorkflowActionsController, type: :controller do
2
- let(:user) { FactoryGirl.create(:user) }
2
+ let(:user) { FactoryBot.create(:user) }
3
3
  let(:generic_work) { stub_model(GenericWork, id: '123') }
4
4
  let(:form) { instance_double(Hyrax::Forms::WorkflowActionForm) }
5
5
 
@@ -7,7 +7,7 @@ RSpec.describe 'PowerConverter', no_clean: true do
7
7
  expect(PowerConverter.convert_to_polymorphic_type(object)).to eq(:symbol)
8
8
  end
9
9
  it 'will convert an ActiveRecord::Base object' do
10
- user = FactoryGirl.build(:user)
10
+ user = FactoryBot.build(:user)
11
11
  expect(PowerConverter.convert_to_polymorphic_type(user)).to eq(user.class)
12
12
  end
13
13
  it 'will convert an object that responds to #base_class' do
@@ -1,4 +1,4 @@
1
- FactoryGirl.define do
1
+ FactoryBot.define do
2
2
  factory :admin_set do
3
3
  sequence(:title) { |n| ["Title #{n}"] }
4
4
 
@@ -1,4 +1,4 @@
1
- FactoryGirl.define do
1
+ FactoryBot.define do
2
2
  factory :post_item, class: Hash do
3
3
  skip_create
4
4
 
@@ -1,7 +1,7 @@
1
- FactoryGirl.define do
1
+ FactoryBot.define do
2
2
  factory :collection do
3
3
  transient do
4
- user { FactoryGirl.create(:user) }
4
+ user { FactoryBot.create(:user) }
5
5
  end
6
6
  sequence(:title) { |n| ["Title #{n}"] }
7
7
 
@@ -1,4 +1,4 @@
1
- FactoryGirl.define do
1
+ FactoryBot.define do
2
2
  factory :content_block do |_cb|
3
3
  end
4
4
  end
@@ -1,4 +1,4 @@
1
- FactoryGirl.define do
1
+ FactoryBot.define do
2
2
  factory :featured_work do |_u|
3
3
  end
4
4
  end
@@ -1,7 +1,7 @@
1
- FactoryGirl.define do
1
+ FactoryBot.define do
2
2
  factory :file_set do
3
3
  transient do
4
- user { FactoryGirl.create(:user) }
4
+ user { FactoryBot.create(:user) }
5
5
  content nil
6
6
  end
7
7
  after(:build) do |fs, evaluator|
@@ -30,7 +30,7 @@ FactoryGirl.define do
30
30
  if evaluator.content
31
31
  Hydra::Works::UploadFileToFileSet.call(file, evaluator.content)
32
32
  end
33
- FactoryGirl.create(:generic_work, user: evaluator.user).members << file
33
+ FactoryBot.create(:generic_work, user: evaluator.user).members << file
34
34
  end
35
35
  end
36
36
  end
@@ -1,7 +1,7 @@
1
- FactoryGirl.define do
1
+ FactoryBot.define do
2
2
  factory :work, aliases: [:generic_work, :private_generic_work], class: GenericWork do
3
3
  transient do
4
- user { FactoryGirl.create(:user) }
4
+ user { FactoryBot.create(:user) }
5
5
  # Set to true (or a hash) if you want to create an admin set
6
6
  with_admin_set false
7
7
  end
@@ -37,45 +37,45 @@ FactoryGirl.define do
37
37
 
38
38
  factory :work_with_one_file do
39
39
  before(:create) do |work, evaluator|
40
- work.ordered_members << FactoryGirl.create(:file_set, user: evaluator.user, title: ['A Contained FileSet'], label: 'filename.pdf')
40
+ work.ordered_members << FactoryBot.create(:file_set, user: evaluator.user, title: ['A Contained FileSet'], label: 'filename.pdf')
41
41
  end
42
42
  end
43
43
 
44
44
  factory :work_with_files do
45
- before(:create) { |work, evaluator| 2.times { work.ordered_members << FactoryGirl.create(:file_set, user: evaluator.user) } }
45
+ before(:create) { |work, evaluator| 2.times { work.ordered_members << FactoryBot.create(:file_set, user: evaluator.user) } }
46
46
  end
47
47
 
48
48
  factory :work_with_ordered_files do
49
49
  before(:create) do |work, evaluator|
50
- work.ordered_members << FactoryGirl.create(:file_set, user: evaluator.user)
51
- work.ordered_member_proxies.insert_target_at(0, FactoryGirl.create(:file_set, user: evaluator.user))
50
+ work.ordered_members << FactoryBot.create(:file_set, user: evaluator.user)
51
+ work.ordered_member_proxies.insert_target_at(0, FactoryBot.create(:file_set, user: evaluator.user))
52
52
  end
53
53
  end
54
54
 
55
55
  factory :work_with_one_child do
56
56
  before(:create) do |work, evaluator|
57
- work.ordered_members << FactoryGirl.create(:generic_work, user: evaluator.user, title: ['A Contained Work'])
57
+ work.ordered_members << FactoryBot.create(:generic_work, user: evaluator.user, title: ['A Contained Work'])
58
58
  end
59
59
  end
60
60
 
61
61
  factory :work_with_two_children do
62
62
  before(:create) do |work, evaluator|
63
- work.ordered_members << FactoryGirl.create(:generic_work, user: evaluator.user, title: ['A Contained Work'], id: "BlahBlah1")
64
- work.ordered_members << FactoryGirl.create(:generic_work, user: evaluator.user, title: ['Another Contained Work'], id: "BlahBlah2")
63
+ work.ordered_members << FactoryBot.create(:generic_work, user: evaluator.user, title: ['A Contained Work'], id: "BlahBlah1")
64
+ work.ordered_members << FactoryBot.create(:generic_work, user: evaluator.user, title: ['Another Contained Work'], id: "BlahBlah2")
65
65
  end
66
66
  end
67
67
 
68
68
  factory :work_with_representative_file do
69
69
  before(:create) do |work, evaluator|
70
- work.ordered_members << FactoryGirl.create(:file_set, user: evaluator.user, title: ['A Contained FileSet'])
70
+ work.ordered_members << FactoryBot.create(:file_set, user: evaluator.user, title: ['A Contained FileSet'])
71
71
  work.representative_id = work.members[0].id
72
72
  end
73
73
  end
74
74
 
75
75
  factory :work_with_file_and_work do
76
76
  before(:create) do |work, evaluator|
77
- work.ordered_members << FactoryGirl.create(:file_set, user: evaluator.user)
78
- work.ordered_members << FactoryGirl.create(:generic_work, user: evaluator.user)
77
+ work.ordered_members << FactoryBot.create(:file_set, user: evaluator.user)
78
+ work.ordered_members << FactoryBot.create(:generic_work, user: evaluator.user)
79
79
  end
80
80
  end
81
81
 
@@ -90,7 +90,7 @@ FactoryGirl.define do
90
90
  end
91
91
  factory :embargoed_work_with_files do
92
92
  after(:build) { |work, evaluator| work.apply_embargo(evaluator.embargo_date, evaluator.current_state, evaluator.future_state) }
93
- after(:create) { |work, evaluator| 2.times { work.ordered_members << FactoryGirl.create(:file_set, user: evaluator.user) } }
93
+ after(:create) { |work, evaluator| 2.times { work.ordered_members << FactoryBot.create(:file_set, user: evaluator.user) } }
94
94
  end
95
95
  end
96
96
 
@@ -105,7 +105,7 @@ FactoryGirl.define do
105
105
  end
106
106
  factory :leased_work_with_files do
107
107
  after(:build) { |work, evaluator| work.apply_lease(evaluator.lease_date, evaluator.current_state, evaluator.future_state) }
108
- after(:create) { |work, evaluator| 2.times { work.ordered_members << FactoryGirl.create(:file_set, user: evaluator.user) } }
108
+ after(:create) { |work, evaluator| 2.times { work.ordered_members << FactoryBot.create(:file_set, user: evaluator.user) } }
109
109
  end
110
110
  end
111
111
  end
@@ -113,6 +113,6 @@ FactoryGirl.define do
113
113
  # Doesn't set up any edit_users
114
114
  factory :work_without_access, class: GenericWork do
115
115
  title ['Test title']
116
- depositor { FactoryGirl.create(:user).user_key }
116
+ depositor { FactoryBot.create(:user).user_key }
117
117
  end
118
118
  end
@@ -1,4 +1,4 @@
1
- FactoryGirl.define do
1
+ FactoryBot.define do
2
2
  factory :operation, class: Hyrax::Operation do
3
3
  operation_type "Test operation"
4
4
 
@@ -1,4 +1,4 @@
1
- FactoryGirl.define do
1
+ FactoryBot.define do
2
2
  factory :permission_template_access, class: Hyrax::PermissionTemplateAccess do
3
3
  permission_template
4
4
  trait :manage do
@@ -1,4 +1,4 @@
1
- FactoryGirl.define do
1
+ FactoryBot.define do
2
2
  factory :permission_template, class: Hyrax::PermissionTemplate do
3
3
  # Given that there is a one to one strong relation between permission_template and admin_set,
4
4
  # with a unique index on the admin_set_id, I don't want to have duplication in admin_set_id
@@ -1,6 +1,6 @@
1
- # Read about factories at https://github.com/thoughtbot/factory_girl
1
+ # Read about factories at https://github.com/thoughtbot/factory_bot
2
2
 
3
- FactoryGirl.define do
3
+ FactoryBot.define do
4
4
  factory :proxy_deposit_request do
5
5
  end
6
6
  end
@@ -1,4 +1,4 @@
1
- FactoryGirl.define do
1
+ FactoryBot.define do
2
2
  factory :single_use_link do
3
3
  factory :show_link do
4
4
  itemId 'fs-id'
@@ -1,4 +1,4 @@
1
- FactoryGirl.define do
1
+ FactoryBot.define do
2
2
  factory :sipity_entity, class: Sipity::Entity do
3
3
  proxy_for_global_id 'gid://internal/Mock/1'
4
4
  workflow { workflow_state.workflow }
@@ -1,4 +1,4 @@
1
- FactoryGirl.define do
1
+ FactoryBot.define do
2
2
  factory :uploaded_file, class: Hyrax::UploadedFile do
3
3
  user
4
4
  end
@@ -1,11 +1,11 @@
1
- FactoryGirl.define do
1
+ FactoryBot.define do
2
2
  factory :user do
3
3
  sequence(:email) { |n| "user#{n}@example.com" }
4
4
  password 'password'
5
5
 
6
6
  transient do
7
7
  # Allow for custom groups when a user is instantiated.
8
- # @example FactoryGirl.create(:user, groups: 'avacado')
8
+ # @example FactoryBot.create(:user, groups: 'avacado')
9
9
  groups []
10
10
  end
11
11
 
@@ -1,4 +1,4 @@
1
- FactoryGirl.define do
1
+ FactoryBot.define do
2
2
  factory :workflow_action, class: Sipity::WorkflowAction do
3
3
  workflow
4
4
  name 'submit'
@@ -1,4 +1,4 @@
1
- FactoryGirl.define do
1
+ FactoryBot.define do
2
2
  factory :workflow_state, class: Sipity::WorkflowState do
3
3
  workflow
4
4
  name 'initial'
@@ -1,4 +1,4 @@
1
- FactoryGirl.define do
1
+ FactoryBot.define do
2
2
  factory :workflow, class: Sipity::Workflow do
3
3
  sequence(:name) { |n| "generic_work-#{n}" }
4
4
  permission_template
@@ -1,6 +1,6 @@
1
1
  RSpec.feature "Notifications page", type: :feature do
2
2
  before do
3
- sign_in FactoryGirl.create(:user_with_mail)
3
+ sign_in FactoryBot.create(:user_with_mail)
4
4
  visit "/notifications"
5
5
  end
6
6
 
@@ -17,6 +17,111 @@ RSpec.describe Hyrax::Forms::PermissionTemplateForm do
17
17
  expect(form.workflow_id).to eq(workflow.id)
18
18
  end
19
19
 
20
+ describe 'integration tests' do
21
+ let(:permission_template) { create(:permission_template, with_admin_set: true, with_workflows: true) }
22
+
23
+ subject do
24
+ form.update(
25
+ ActionController::Parameters.new(
26
+ access_grants_attributes: [
27
+ ActionController::Parameters.new(agent_type: "user",
28
+ agent_id: user.user_key,
29
+ access: access_level).permit!
30
+ ]
31
+ ).permit!
32
+ )
33
+ end
34
+
35
+ before do
36
+ # Create MANAGING role manually
37
+ Sipity::Role[Hyrax::RoleRegistry::MANAGING]
38
+ end
39
+
40
+ def count_template_accesses_for(user, access_level)
41
+ Hyrax::PermissionTemplateAccess.where(
42
+ agent_id: user.user_key,
43
+ access: access_level
44
+ ).count
45
+ end
46
+
47
+ def count_workflow_responsibilities_for(user)
48
+ Sipity::WorkflowResponsibility.where(agent: user.to_sipity_agent).count
49
+ end
50
+
51
+ it 'starts with no PTAs' do
52
+ expect(permission_template.access_grants).to be_empty
53
+ end
54
+
55
+ context 'with manager users' do
56
+ let(:user) { create(:user) }
57
+ let(:access_level) { 'manage' }
58
+
59
+ it 'adds the expected permission template accesses and workflow responsibilities' do
60
+ expect { subject }.to change {
61
+ count_template_accesses_for(user, access_level)
62
+ }.from(0).to(1).and change {
63
+ count_workflow_responsibilities_for(user)
64
+ }.from(0).to(6)
65
+ end
66
+
67
+ it 'removes workflow responsibilities' do
68
+ subject
69
+ expect do
70
+ form.remove_access!(
71
+ permission_template.access_grants.find_by(agent_id: user.user_key, access: access_level)
72
+ )
73
+ end.to change { count_workflow_responsibilities_for(user) }
74
+ .from(6).to(0)
75
+ end
76
+ end
77
+
78
+ context 'with depositor users' do
79
+ let(:user) { create(:user) }
80
+ let(:access_level) { 'deposit' }
81
+
82
+ it 'adds the expected permission template accesses and workflow responsibilities' do
83
+ expect { subject }.to change {
84
+ count_template_accesses_for(user, access_level)
85
+ }.from(0).to(1).and change {
86
+ count_workflow_responsibilities_for(user)
87
+ }.from(0).to(2)
88
+ end
89
+
90
+ it 'removes workflow responsibilities' do
91
+ subject
92
+ expect do
93
+ form.remove_access!(
94
+ permission_template.access_grants.find_by(agent_id: user.user_key, access: access_level)
95
+ )
96
+ end.to change { count_workflow_responsibilities_for(user) }
97
+ .from(2).to(0)
98
+ end
99
+ end
100
+
101
+ context 'with viewer users' do
102
+ let(:user) { create(:user) }
103
+ let(:access_level) { 'view' }
104
+
105
+ it 'adds the expected permission template accesses and workflow responsibilities' do
106
+ expect { subject }.to change {
107
+ count_template_accesses_for(user, access_level)
108
+ }.from(0).to(1).and change {
109
+ count_workflow_responsibilities_for(user)
110
+ }.by(0)
111
+ end
112
+
113
+ it 'does nothing (yet)' do
114
+ subject
115
+ expect do
116
+ form.remove_access!(
117
+ permission_template.access_grants.find_by(agent_id: user.user_key, access: access_level)
118
+ )
119
+ end.to change { count_workflow_responsibilities_for(user) }
120
+ .by(0)
121
+ end
122
+ end
123
+ end
124
+
20
125
  describe "#update" do
21
126
  subject { form.update(input_params) }
22
127
 
@@ -234,7 +339,10 @@ RSpec.describe Hyrax::Forms::PermissionTemplateForm do
234
339
  end
235
340
 
236
341
  describe "#grant_workflow_roles" do
237
- subject { form.send(:grant_workflow_roles, attributes) }
342
+ subject do
343
+ form.attributes = attributes
344
+ form.send(:grant_workflow_roles)
345
+ end
238
346
 
239
347
  let(:attributes) { { workflow_id: workflow.id } }
240
348
  let(:workflow) { create(:workflow, permission_template: permission_template, active: true) }
@@ -428,7 +536,10 @@ RSpec.describe Hyrax::Forms::PermissionTemplateForm do
428
536
  describe "#permission_template_update_params" do
429
537
  let(:permission_template) { create(:permission_template, admin_set_id: admin_set.id) }
430
538
 
431
- subject { form.send(:permission_template_update_params, input_params) }
539
+ subject do
540
+ form.attributes = input_params
541
+ form.send(:permission_template_update_params)
542
+ end
432
543
 
433
544
  context "with release varies by date selected" do
434
545
  let(:input_params) do