-
-
Notifications
You must be signed in to change notification settings - Fork 487
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[#1741] Generate past court reports from past court date #2095
Merged
compwron
merged 5 commits into
rubyforgood:main
from
rhian-cs:1741-generate-past-court-report-from-past-court-date
Jun 3, 2021
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
7b92680
Add a template file for past court dates
73b13c2
Fix issue when displaying nil implementation status in past court dat…
3952bbb
Add a way to generate and download .docx reports of past court dates
0c3e8ae
Add spec for PastCourtDate model
05b6d69
Fix erb lint mistake
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
@@ -1,23 +1,32 @@ | ||
class PastCourtDatesController < ApplicationController | ||
before_action :set_casa_case, only: %i[show] | ||
before_action :set_past_court_date, only: %i[show] | ||
before_action :set_past_court_date, only: %i[show generate] | ||
before_action :require_organization! | ||
|
||
rescue_from ActiveRecord::RecordNotFound, with: -> { head :not_found } | ||
|
||
def show | ||
authorize @casa_case | ||
|
||
respond_to do |format| | ||
format.html {} | ||
format.docx do | ||
send_data @past_court_date.generate_report, | ||
type: :docx, | ||
filename: "#{@past_court_date.display_name}.docx", | ||
disposition: "attachment", | ||
status: :ok | ||
end | ||
end | ||
end | ||
|
||
private | ||
|
||
def set_casa_case | ||
@casa_case = current_organization.casa_cases.find(params[:casa_case_id]) | ||
rescue ActiveRecord::RecordNotFound | ||
head :not_found | ||
end | ||
|
||
def set_past_court_date | ||
@past_court_date = @casa_case.past_court_dates.find(params[:id]) | ||
rescue ActiveRecord::RecordNotFound | ||
head :not_found | ||
end | ||
end |
Binary file not shown.
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,67 @@ | ||
require "rails_helper" | ||
|
||
RSpec.describe PastCourtDate, type: :model do | ||
describe "validations" do | ||
it { is_expected.to belong_to(:casa_case) } | ||
it { is_expected.to belong_to(:hearing_type).optional(true) } | ||
it { is_expected.to belong_to(:judge).optional(true) } | ||
end | ||
|
||
describe "methods" do | ||
let(:past_court_date) { build_stubbed(:past_court_date) } | ||
|
||
pending "#associated_reports" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please implement the pending tests also |
||
pending "#latest_associated_report" | ||
|
||
describe "#additional_info?" do | ||
subject(:additional_info?) { past_court_date.additional_info? } | ||
|
||
context "without court details" do | ||
it { is_expected.to be_falsy } | ||
end | ||
|
||
context "with court details" do | ||
context "with judge" do | ||
before { past_court_date.judge = build_stubbed(:judge) } | ||
|
||
it { is_expected.to be_truthy } | ||
end | ||
|
||
context "with hearing type" do | ||
before { past_court_date.hearing_type = build_stubbed(:hearing_type) } | ||
|
||
it { is_expected.to be_truthy } | ||
end | ||
|
||
context "with both judge and hearing type" do | ||
before do | ||
past_court_date.judge = build_stubbed(:judge) | ||
past_court_date.hearing_type = build_stubbed(:hearing_type) | ||
end | ||
|
||
it { is_expected.to be_truthy } | ||
end | ||
end | ||
end | ||
|
||
describe "#generate_report" do | ||
subject(:generate_report) { past_court_date.generate_report } | ||
|
||
it { is_expected.not_to be_nil } | ||
end | ||
|
||
describe "#display_name" do | ||
subject(:display_name) { past_court_date.display_name } | ||
|
||
let(:casa_case) { build_stubbed(:casa_case, case_number: "CINA-000") } | ||
let(:past_court_date) { build_stubbed(:past_court_date, casa_case: casa_case, date: Time.zone.local(2020, 5, 3)) } | ||
|
||
it { is_expected.to eq "CINA-000 - Past Court Date - 2020-05-03" } | ||
end | ||
end | ||
|
||
it "has a valid factory" do | ||
past_court_date = build(:past_court_date) | ||
expect(past_court_date.valid?).to be_truthy | ||
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style note: prefer to use
Rails.root.join