Skip to content
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

Implement pending past court date model specs #2132

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/models/past_court_date.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class PastCourtDate < ApplicationRecord
belongs_to :hearing_type, optional: true
belongs_to :judge, optional: true

DOCX_TEMPLATE_PATH = "app/documents/templates/default_past_court_date_template.docx"
DOCX_TEMPLATE_PATH = Rails.root.join("app", "documents", "templates", "default_past_court_date_template.docx")

# get reports associated with the case this belongs to before this court date but after the court date before this one
def associated_reports
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,49 @@
describe "methods" do
let(:past_court_date) { build_stubbed(:past_court_date) }

pending "#associated_reports"
pending "#latest_associated_report"
describe "reports methods" do
let(:past_court_date) { create(:past_court_date, casa_case: casa_case) }

let(:volunteer) { create(:volunteer) }
let(:casa_case) { create(:casa_case, casa_org: volunteer.casa_org) }
let!(:case_assignment) { create(:case_assignment, volunteer: volunteer, casa_case: casa_case) }

let!(:reports) do
[10, 30, 60].map do |n|
report = CaseCourtReport.new(
volunteer_id: volunteer.id,
case_id: casa_case.id,
path_to_template: "app/documents/templates/default_report_template.docx"
)
casa_case.court_reports.attach(io: StringIO.new(report.generate_to_string), filename: "report#{n}.docx")
attached_report = casa_case.latest_court_report
attached_report.created_at = n.days.ago

attached_report.save!
attached_report
end
end

describe "#associated_reports" do
subject(:associated_reports) { past_court_date.associated_reports }

context "without other court dates" do
it { is_expected.to eq reports }
end

context "with a previous court date" do
let!(:other_past_court_date) { create(:past_court_date, casa_case: casa_case, date: 40.days.ago) }

it { is_expected.to eq [reports[0], reports[1]] }
end
end

describe "#latest_associated_report" do
subject(:latest_associated_report) { past_court_date.latest_associated_report }

it { is_expected.to eq past_court_date.associated_reports.order(:created_at).last }
end
end

describe "#additional_info?" do
subject(:additional_info?) { past_court_date.additional_info? }
Expand Down