-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HunJerBAH/APPEALS-17522: Create IssuesUpdate Task Model (#18465)
* Created Issues Update task model and methods for formatting instructions * jHoang/APPEALS-17511 (#18444) * migration to add mst and pact status to request_issues * schema update * typo in migration * typo in schema * set default status * Revert "schema update" This reverts commit 0d5df1a. * Revert "typo in schema" This reverts commit 9a74e6e. * +1 --------- Co-authored-by: Jonathan Hoang <trinhjoanthan.hoang@va.gov> Co-authored-by: youfoundmanesh <maneshreddy.kommidi@va.gov> * Justin/appeals 17512 (#18443) * feature toggle mst_pact_identification * toggle added to queue, intake, and hearings erb * replaced bracket that was accidentally removed * hearings feature toggle to camelCase to match * removing merge problems * APPEALS-17506: MST & PACT Components (#18451) * APPEALS-17506: MST & PACT Components * +1 * updated storybook test args for rendering badges --------- Co-authored-by: HunJerBAH <Jeremy.Hunton@va.gov> * added issueUpdateTask bool check * refactored format_instructions method to store in nested array * refactored instruction logic and updated rendering/styling of task instructions * updated css styling to match wireframes * refactored special issue format and created tests --------- Co-authored-by: jonathanh-va <111081469+jonathanh-va@users.noreply.github.com> Co-authored-by: Jonathan Hoang <trinhjoanthan.hoang@va.gov> Co-authored-by: youfoundmanesh <maneshreddy.kommidi@va.gov> Co-authored-by: sulak-j <95875751+sulak-j@users.noreply.github.com> Co-authored-by: youfoundmanesh <129548081+youfoundmanesh@users.noreply.github.com>
- Loading branch information
1 parent
3bd8416
commit 528a0df
Showing
3 changed files
with
251 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# frozen_string_literal: true | ||
|
||
class IssuesUpdateTask < Task | ||
validates :parent, presence: true | ||
|
||
def label | ||
"Issues Update Task" | ||
end | ||
|
||
def format_instructions(issue_category, original_mst, original_pact, edit_mst, edit_pact, edit_reason) | ||
# format the instructions by loading an array and adding it to the instructions | ||
edit_issue_format = [] | ||
edit_issue_format << issue_category | ||
original_comment = "#{format_special_issues_text(original_mst, original_pact)}" | ||
edit_issue_format << original_comment | ||
|
||
# format edit | ||
edit_issue_format << issue_category | ||
updated_comment = "#{format_special_issues_text(edit_mst, edit_pact)}" | ||
edit_issue_format << updated_comment | ||
|
||
# add edit reason on the end | ||
edit_issue_format << edit_reason | ||
|
||
# add edit_issue_format into the instructions array for the task | ||
instructions << edit_issue_format | ||
save! | ||
end | ||
|
||
private | ||
|
||
def format_special_issues_text(mst_status, pact_status) | ||
# format the special issues comment to display the change in the special issues status(es) | ||
s = "Special Issues:" | ||
|
||
return s + " None" if !mst_status && !pact_status | ||
return s + " MST, PACT" if mst_status && pact_status | ||
return s + " MST" if mst_status | ||
return s + " PACT" if pact_status | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,178 @@ | ||
# frozen_string_literal: true | ||
|
||
describe IssuesUpdateTask do | ||
let(:user) { create(:user) } | ||
let(:bva_intake) { BvaIntake.singleton } | ||
let(:root_task) { create(:root_task) } | ||
let(:distribution_task) { create(:distribution_task, parent: root_task) } | ||
let(:task_class) { IssuesUpdateTask } | ||
|
||
before do | ||
bva_intake.add_user(user) | ||
User.authenticate!(user: user) | ||
FeatureToggle.enable!(:mst_pact_identification) | ||
end | ||
|
||
describe ".verify_user_can_create" do | ||
let(:params) { { appeal: root_task.appeal, parent_id: distribution_task&.id, type: task_class.name } } | ||
|
||
context "when no root task exists for appeal" do | ||
let(:distribution_task) { nil } | ||
|
||
it "throws an error" do | ||
expect { task_class.create!( | ||
appeal: root_task.appeal, | ||
parent_id: distribution_task&.id, | ||
type: task_class.name, | ||
assigned_to: bva_intake, | ||
assigned_by: user) }.to raise_error(ActiveRecord::RecordInvalid) | ||
end | ||
end | ||
|
||
context "proper params are sent" do | ||
it "creates the new task" do | ||
expect { task_class.create!( | ||
appeal: root_task.appeal, | ||
parent_id: distribution_task&.id, | ||
type: task_class.name, | ||
assigned_to: bva_intake, | ||
assigned_by: user) }.to change{IssuesUpdateTask.count}.by(1) | ||
end | ||
end | ||
|
||
# test contexts for successfully creating task when an appeal has a CC will go here once other tasks are made | ||
end | ||
|
||
describe ".format_instructions" do | ||
let(:issues_update_task) do | ||
task_class.create!( | ||
appeal: root_task.appeal, | ||
parent_id: distribution_task&.id, | ||
type: task_class.name, | ||
assigned_to: bva_intake, | ||
assigned_by: user) | ||
end | ||
|
||
# clear the instructions after each run | ||
after do | ||
issues_update_task.instructions.clear | ||
issues_update_task.save! | ||
end | ||
|
||
context "changes occur to the MST status on an issue" do | ||
let(:params) do | ||
{ | ||
issue_category: "test category", | ||
original_mst: false, | ||
original_pact: false, | ||
edit_mst: true, | ||
edit_pact: false, | ||
edit_reason: "reason for edit here..." | ||
} | ||
end | ||
|
||
subject { issues_update_task.format_instructions( | ||
params[:issue_category], | ||
params[:original_mst], | ||
params[:original_pact], | ||
params[:edit_mst], | ||
params[:edit_pact], | ||
params[:edit_reason]) } | ||
it "formats the instructions with MST" do | ||
expect(subject).to eql(true) | ||
expect(issues_update_task.instructions[0][0]).to eql("test category") | ||
expect(issues_update_task.instructions[0][1]).to eql("Special Issues: None") | ||
expect(issues_update_task.instructions[0][2]).to eql("test category") | ||
expect(issues_update_task.instructions[0][3]).to eql("Special Issues: MST") | ||
expect(issues_update_task.instructions[0][4]).to eql("reason for edit here...") | ||
end | ||
end | ||
|
||
context "changes occur to the PACT status on an issue" do | ||
let(:params) do | ||
{ | ||
issue_category: "test category", | ||
original_mst: false, | ||
original_pact: false, | ||
edit_mst: false, | ||
edit_pact: true, | ||
edit_reason: "reason for edit here..." | ||
} | ||
end | ||
|
||
subject { issues_update_task.format_instructions( | ||
params[:issue_category], | ||
params[:original_mst], | ||
params[:original_pact], | ||
params[:edit_mst], | ||
params[:edit_pact], | ||
params[:edit_reason]) } | ||
it "formats the instructions with PACT" do | ||
expect(subject).to eql(true) | ||
expect(issues_update_task.instructions[0][0]).to eql("test category") | ||
expect(issues_update_task.instructions[0][1]).to eql("Special Issues: None") | ||
expect(issues_update_task.instructions[0][2]).to eql("test category") | ||
expect(issues_update_task.instructions[0][3]).to eql("Special Issues: PACT") | ||
expect(issues_update_task.instructions[0][4]).to eql("reason for edit here...") | ||
end | ||
end | ||
|
||
context "changes occur to the MST and PACT status on an issue" do | ||
let(:params) do | ||
{ | ||
issue_category: "test category", | ||
original_mst: false, | ||
original_pact: false, | ||
edit_mst: true, | ||
edit_pact: true, | ||
edit_reason: "reason for edit here..." | ||
} | ||
end | ||
|
||
subject { issues_update_task.format_instructions( | ||
params[:issue_category], | ||
params[:original_mst], | ||
params[:original_pact], | ||
params[:edit_mst], | ||
params[:edit_pact], | ||
params[:edit_reason]) } | ||
it "formats the instructions with MST and PACT" do | ||
expect(subject).to eql(true) | ||
expect(issues_update_task.instructions[0][0]).to eql("test category") | ||
expect(issues_update_task.instructions[0][1]).to eql("Special Issues: None") | ||
expect(issues_update_task.instructions[0][2]).to eql("test category") | ||
expect(issues_update_task.instructions[0][3]).to eql("Special Issues: MST, PACT") | ||
expect(issues_update_task.instructions[0][4]).to eql("reason for edit here...") | ||
end | ||
end | ||
|
||
context "MST and PACT status on an issue are removed" do | ||
let(:params) do | ||
{ | ||
issue_category: "test category", | ||
original_mst: true, | ||
original_pact: true, | ||
edit_mst: false, | ||
edit_pact: false, | ||
edit_reason: "reason for edit here..." | ||
} | ||
end | ||
|
||
subject { issues_update_task.format_instructions( | ||
params[:issue_category], | ||
params[:original_mst], | ||
params[:original_pact], | ||
params[:edit_mst], | ||
params[:edit_pact], | ||
params[:edit_reason]) } | ||
it "formats the instructions from MST and PACT to None" do | ||
expect(subject).to eql(true) | ||
expect(issues_update_task.instructions[0][0]).to eql("test category") | ||
expect(issues_update_task.instructions[0][1]).to eql("Special Issues: MST, PACT") | ||
expect(issues_update_task.instructions[0][2]).to eql("test category") | ||
expect(issues_update_task.instructions[0][3]).to eql("Special Issues: None") | ||
expect(issues_update_task.instructions[0][4]).to eql("reason for edit here...") | ||
end | ||
end | ||
end | ||
end |