Skip to content

Commit

Permalink
remove now-obsolete JudgeTask action references
Browse files Browse the repository at this point in the history
Connects #8033

Co-authored-by: Lowell Wood <lowell@navahq.com>
  • Loading branch information
Tomas Apodaca and lowellrex committed Dec 5, 2018
1 parent b6936e3 commit 73e837a
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 31 deletions.
2 changes: 1 addition & 1 deletion app/controllers/idt/api/v1/appeals_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def tasks_assigned_to_user
if feature_enabled?(:idt_ama_appeals)
tasks += Task.where(assigned_to: user).where.not(status: [:completed, :on_hold])
end
tasks.reject { |task| task.action == "assign" || task.is_a?(JudgeAssignTask) }
tasks.reject { |task| task.is_a?(JudgeAssignTask) }
end

def role
Expand Down
1 change: 0 additions & 1 deletion app/controllers/tasks_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ class TasksController < ApplicationController
AttorneyTask: AttorneyTask,
GenericTask: GenericTask,
QualityReviewTask: QualityReviewTask,
JudgeTask: JudgeAssignTask,
JudgeAssignTask: JudgeAssignTask,
ScheduleHearingTask: ScheduleHearingTask,
MailTask: MailTask,
Expand Down
2 changes: 1 addition & 1 deletion app/models/distribution.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def validate_judge_has_no_pending_distributions
def judge_has_no_unassigned_cases
pending_statuses = [Constants.TASK_STATUSES.assigned, Constants.TASK_STATUSES.in_progress]
assigned_tasks = judge.tasks.select do |t|
((t.is_a?(JudgeTask) && t.action == "assign") || t.is_a?(JudgeAssignTask)) && pending_statuses.include?(t.status)
t.is_a?(JudgeAssignTask) && pending_statuses.include?(t.status)
end
return false if assigned_tasks.any?

Expand Down
9 changes: 0 additions & 9 deletions app/models/tasks/judge_task.rb
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
class JudgeTask < Task
include RoundRobinAssigner

def available_actions(_user)
actions = [{ label: COPY::JUDGE_CHECKOUT_DISPATCH_LABEL, value: "dispatch_decision/special_issues" }]
actions = [Constants.TASK_ACTIONS.ASSIGN_TO_ATTORNEY.to_h] if action.eql? "assign"

actions << Constants.TASK_ACTIONS.MARK_COMPLETE.to_h if parent && parent.is_a?(QualityReviewTask)

actions
end

def no_actions_available?(user)
assigned_to != user
end
Expand Down
27 changes: 8 additions & 19 deletions spec/models/tasks/judge_task_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,29 @@
end

context ".available_actions" do
let(:action) { nil }
let(:user) { judge }
let(:task) { JudgeTask.create!(assigned_to: judge, appeal: FactoryBot.create(:appeal), action: action) }
subject { task.available_actions_unwrapper(user) }
let(:assign_task) { JudgeAssignTask.create!(assigned_to: judge, appeal: FactoryBot.create(:appeal)) }
let(:review_task) { JudgeReviewTask.create!(assigned_to: judge, appeal: FactoryBot.create(:appeal)) }

subject { assign_task.available_actions_unwrapper(user) }

context "when the task is assigned to the current user" do
context "and we are in the assign phase" do
let(:action) { "assign" }
it "should return the assignment action" do
expect(subject).to eq([task.build_action_hash(Constants.TASK_ACTIONS.ASSIGN_TO_ATTORNEY.to_h)])
expect(subject).to eq([assign_task.build_action_hash(Constants.TASK_ACTIONS.ASSIGN_TO_ATTORNEY.to_h)])
end
end

context "and we are in the review phase" do
let(:action) { "review" }
subject { review_task.available_actions_unwrapper(user) }
it "should return the dispatch action" do
expect(subject).to eq([task.build_action_hash(Constants.TASK_ACTIONS.JUDGE_CHECKOUT.to_h)])
expect(subject).to eq([review_task.build_action_hash(Constants.TASK_ACTIONS.JUDGE_CHECKOUT.to_h)])
end
end
end

context "when the task is not assigned to the current user" do
let(:user) { judge2 }
let(:action) { "review" }
it "should return an empty array" do
expect(subject).to eq([])
end
Expand All @@ -42,17 +41,7 @@

context ".create_from_params" do
let(:params) { { assigned_to: judge, appeal: FactoryBot.create(:appeal) } }
subject { JudgeTask.create_from_params(params, attorney) }

it "should set the action" do
expect(subject.action).to eq(nil)
expect(subject.type).to eq JudgeAssignTask.name
end

it "should set the action" do
expect(subject.action).to eq nil
expect(subject.type).to eq JudgeAssignTask.name
end
subject { JudgeAssignTask.create_from_params(params, attorney) }

context "when creating a JudgeTask from a QualityReviewTask" do
let(:qr_task) { FactoryBot.create(:qr_task) }
Expand Down

0 comments on commit 73e837a

Please sign in to comment.