Skip to content

Commit

Permalink
IsaiahB/APPEALS-53208 (#22410)
Browse files Browse the repository at this point in the history
* update mail_task.rb

* added method override for verifying user in correspondence mail task model

* fix spec tests

---------

Co-authored-by: cacevesva <109166981+cacevesva@users.noreply.github.com>
Co-authored-by: HunJerBAH <Jeremy.Hunton@va.gov>
  • Loading branch information
3 people committed Aug 13, 2024
1 parent 36acc96 commit c1542c5
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
3 changes: 0 additions & 3 deletions app/models/task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,6 @@ def cannot_have_children
end

def verify_user_can_create!(user, parent)
# guard clause to allow InboundOpsTeam members to create mail/appeal tasks within Correspondence Intake
return true if parent.appeal_type == Correspondence.name && InboundOpsTeam.singleton.user_has_access?(user)

can_create = parent&.available_actions(user)&.map do |action|
parent.build_action_hash(action, user)
end&.any? do |action|
Expand Down
6 changes: 6 additions & 0 deletions app/models/tasks/mail_task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ def parent_if_blocking_task(parent_task)
parent_task
end

def verify_user_can_create!(user, parent)
return true if InboundOpsTeam.singleton.user_has_access?(user)

super(user, parent)
end

def create_from_params(params, user)
parent_task = Task.find(params[:parent_id])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@

# Abstract base class for "tasks not related to an appeal" added to a correspondence during Correspondence Intake.
class CorrespondenceMailTask < CorrespondenceTask
class << self
# allows inbound ops team users to create tasks in intake
def verify_user_can_create!(user, parent)
return true if InboundOpsTeam.singleton.user_has_access?(user)

super(user, parent)
end
end

self.abstract_class = true

def self.create_child_task(parent, current_user, params)
Expand Down

0 comments on commit c1542c5

Please sign in to comment.