Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🧹 Fix ./spec/requests/admin_dashboard_spec.rb spec #2092

Merged
merged 1 commit into from
Dec 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading