Skip to content

Commit

Permalink
remove now-obsolete JudgeTask action references (#8116)
Browse files Browse the repository at this point in the history
Resolves #8033

### Description
This is the last step in #8033
  • Loading branch information
tomas-nava authored and va-bot committed Dec 7, 2018
1 parent 67b0905 commit eae4d78
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 43 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?(JudgeLegacyTask) && task.action == "assign") || 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
12 changes: 8 additions & 4 deletions app/models/distribution.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,20 @@ def validate_judge_has_no_pending_distributions
end

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)
end
return false if assigned_tasks.any?

legacy_tasks = QueueRepository.tasks_for_user(judge.css_id)
legacy_tasks.none? { |task| task.assigned_to_attorney_date.nil? }
end

def assigned_tasks
pending_statuses = [Constants.TASK_STATUSES.assigned, Constants.TASK_STATUSES.in_progress]
judge.tasks.select do |t|
assigned_legacy_task = t.is_a?(JudgeLegacyTask) && t.action == "assign"
(assigned_legacy_task || t.is_a?(JudgeAssignTask)) && pending_statuses.include?(t.status)
end
end

def batch_size
Constants::AttorneyJudgeTeams::JUDGES[Rails.current_env][judge.css_id]
.try(:[], :attorneys)
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
11 changes: 2 additions & 9 deletions spec/controllers/idt/api/appeals_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,11 @@
end

context "when request header contains valid token" do
context "and user is not an attorney" do
before do
create(:user, css_id: "ANOTHER_TEST_ID")
key, t = Idt::Token.generate_one_time_key_and_proposed_token
Idt::Token.activate_proposed_token(key, "ANOTHER_TEST_ID")
request.headers["TOKEN"] = t
end
end

context "and user is a judge" do
let(:role) { :judge_role }

before do
create(:staff, role, sdomainid: user.css_id)
request.headers["TOKEN"] = token
end

Expand Down Expand Up @@ -107,6 +99,7 @@
let(:role) { :attorney_role }

before do
create(:staff, role, sdomainid: user.css_id)
request.headers["TOKEN"] = token
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 eae4d78

Please sign in to comment.