Skip to content

Commit

Permalink
Merge pull request #2092 from samvera/hyrax-5-upgrade-workflow-respon…
Browse files Browse the repository at this point in the history
…sibility

🧹 Fix `./spec/requests/admin_dashboard_spec.rb` spec
  • Loading branch information
jeremyf authored Dec 20, 2023
2 parents 97403ce + 338aa71 commit b4c0f5e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
16 changes: 12 additions & 4 deletions app/forms/hyrax/forms/workflow_responsibility_form_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,21 @@
module Hyrax
module Forms
module WorkflowResponsibilityFormDecorator
##
# @note We introduced this little crease in the code to allow for conditional switching; and
# thus avoid copying a very large controller
# (e.g. Hyrax::Admin::WorkflowRolesController)
# @see Hyrax::Forms::WorkflowResponsibilityGroupForm
module ClassMethods
# Determine which form it is, user or group
##
# Determine which form it is, user or group. By default, it will be a user
# (e.g. {Hyrax::Forms::WorkflowResponsibilityForm}); however when you provide a :group_id it
# will be a group form (e.g. {Hyrax::Forms::WorkflowResponsibilityGroupForm}.
def new(params = {})
if params[:user_id].present?
super
else
if params[:group_id].present?
Forms::WorkflowResponsibilityGroupForm.new(params)
else
super
end
end
end
Expand Down
5 changes: 5 additions & 0 deletions app/forms/hyrax/forms/workflow_responsibility_group_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ def initialize(params = {})
model_instance.agent = group.to_sipity_agent
end

##
# This method is necessary for the HTML form fields to have the correct name (e.g. `<input
# name="sipity_workflow_responsibility[group_id]">`).
#
# @see ActiveModel::Naming
def model_instance
@model ||= Sipity::WorkflowResponsibility.new
end
Expand Down

0 comments on commit b4c0f5e

Please sign in to comment.