This repository has been archived by the owner on Jan 5, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adds monitoring to complaint detail timeline
- Loading branch information
Showing
8 changed files
with
214 additions
and
11 deletions.
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
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
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,27 @@ | ||
class Timeline::MonitoringEvent < Timeline::Event | ||
include ActionView::Helpers::TagHelper | ||
|
||
attr_reader :review | ||
delegate :api_error_message, :status, :review_type, to: :review | ||
|
||
def initialize(issue_monitoring_review) | ||
@name = issue_monitoring_review.review_id | ||
@date = issue_monitoring_review.start_date | ||
@review = issue_monitoring_review.monitoring_review | ||
end | ||
|
||
def api_call_succeeded? | ||
review.valid? | ||
end | ||
|
||
def review_link | ||
# using content_tag for the link will properly escape any dangerous characters that sneak into name or ttahub_url | ||
content_tag(:a, name, class: "usa-link", href: review.itams_url, target: "_blank") | ||
rescue Api::Error | ||
name | ||
end | ||
|
||
def timeline_partial | ||
"monitoring_timeline_event" | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<h3 class="usa-process-list__heading ct-timeline__two-part-container"> | ||
<span>Monitoring Activity: <%= event.review_link %></span> | ||
<span class="ct-timeline__date"><%= event.formatted_date %></span> | ||
</h3> | ||
<% if event.api_call_succeeded? %> | ||
<div> | ||
<ul class="usa-list usa-list--unstyled"> | ||
<li><strong>Status:</strong> <%= event.status %></li> | ||
<li><strong>Type:</strong> <%= event.review_type %></li> | ||
</ul> | ||
</div> | ||
<% else %> | ||
<div class="usa-alert usa-alert--error"> | ||
<div class="usa-alert__body"> | ||
<p class="usa-alert__text"><%= event.api_error_message %></p> | ||
</div> | ||
</div> | ||
<% 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,53 @@ | ||
require "rails_helper" | ||
|
||
RSpec.describe Timeline::MonitoringEvent do | ||
let(:date) { 1.day.ago.strftime("%F") } | ||
let(:review_id) { "Test-Review-ID" } | ||
let(:issue_id) { "Test-Issue-ID" } | ||
# just setting the start_date manually because we aren't triggering the before_validation callback | ||
let(:event_param) { IssueMonitoringReview.new review_id: review_id, issue_id: issue_id, start_date: date } | ||
let(:monitoring_review) { event_param.monitoring_review } | ||
subject { Timeline::MonitoringEvent.new(event_param) } | ||
|
||
describe "#init" do | ||
it "assigns attr_readers inherited from Timeline::Event" do | ||
expect(subject.name).to eq review_id | ||
expect(subject.date).to eq Date.parse(date) | ||
end | ||
end | ||
|
||
describe "#review_link" do | ||
it "returns a link that opens in a new tab" do | ||
expect(subject.review_link).to match /\A<a .*>#{review_id}<\/a>\z/ | ||
expect(subject.review_link).to include 'target="_blank"' | ||
end | ||
|
||
context "authorization error loading Monitoring API" do | ||
xit "returns just the review ID with no link" | ||
end | ||
end | ||
|
||
describe "#review_type" do | ||
it "returns the review type" do | ||
expect(subject.review_type).to be_a(String) | ||
end | ||
end | ||
|
||
describe "#status" do | ||
it "returns the review status" do | ||
expect(subject.status).to be_a(String) | ||
end | ||
end | ||
|
||
describe "#timeline_partial" do | ||
it "returns the monitoring event timeline partial" do | ||
expect(subject.timeline_partial).to eq "monitoring_timeline_event" | ||
end | ||
end | ||
|
||
describe "#formatted_date" do | ||
it "returns the date formatted '%m/%d/%Y'" do | ||
expect(subject.formatted_date).to eq Date.parse(date).strftime("%m/%d/%Y") | ||
end | ||
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