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

review app don't merge - don't close until 2024-09-27 #3182

Closed
wants to merge 6 commits into from
Closed
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -346,3 +346,4 @@ the user IP address as part of the payload data sent to Application Insights in
[`lib/application_insights`](lib/application_insights). See
[`config/initializers/application_insights.rb`](config/initializers/application_insights.rb)
for how to mixin this code to your Rails application.

2 changes: 2 additions & 0 deletions app/forms/claim_submission_base_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ def build_claim

claim.eligibility = main_eligibility

claim.started_at = journey_session.created_at

answers.attributes.each do |name, value|
if claim.respond_to?(:"#{name}=")
claim.public_send(:"#{name}=", value)
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/admin/claims_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def admin_student_loan_details(claim)

def admin_submission_details(claim)
[
[translate("admin.started_at"), l(claim.created_at)],
[translate("admin.started_at"), l(claim.started_at)],
[translate("admin.submitted_at"), l(claim.submitted_at)],
[translate("admin.decision_deadline"), l(claim.decision_deadline_date)],
[translate("admin.decision_overdue"), decision_deadline_warning(claim)]
Expand Down
3 changes: 2 additions & 1 deletion app/models/claim.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ class Claim < ApplicationRecord
onelogin_idv_date_of_birth: true,
paye_reference: true,
practitioner_email_address: true,
provider_contact_name: true
provider_contact_name: true,
started_at: false
}.freeze
DECISION_DEADLINE = 12.weeks
DECISION_DEADLINE_WARNING_POINT = 2.weeks
Expand Down
1 change: 1 addition & 0 deletions config/analytics.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ shared:
- logged_in_with_onelogin
- onelogin_auth_at
- onelogin_idv_at
- started_at
:decisions:
- id
- result
Expand Down
5 changes: 5 additions & 0 deletions db/migrate/20240924091408_add_started_at_to_claims.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddStartedAtToClaims < ActiveRecord::Migration[7.0]
def change
add_column :claims, :started_at, :timestamp
end
end
22 changes: 22 additions & 0 deletions db/migrate/20240924095435_back_fill_claims_started_at.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
class BackFillClaimsStartedAt < ActiveRecord::Migration[7.0]
def up
execute <<-SQL
UPDATE claims
SET started_at = journeys_sessions.created_at
FROM journeys_sessions
WHERE claims.journeys_session_id = journeys_sessions.id
AND claims.started_at IS NULL
SQL

execute <<-SQL
UPDATE claims
SET started_at = created_at
WHERE journeys_session_id IS NULL
AND claims.started_at IS NULL
SQL
end

def down
Claim.update_all(started_at: nil)
end
end
5 changes: 5 additions & 0 deletions db/migrate/20240924113642_make_claims_started_at_not_null.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class MakeClaimsStartedAtNotNull < ActiveRecord::Migration[7.0]
def change
change_column_null :claims, :started_at, false
end
end
3 changes: 2 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema[7.0].define(version: 2024_09_04_150711) do
ActiveRecord::Schema[7.0].define(version: 2024_09_24_113642) do
# These are extensions that must be enabled in order to support this database
enable_extension "citext"
enable_extension "pg_trgm"
Expand Down Expand Up @@ -111,6 +111,7 @@
t.text "onelogin_idv_first_name"
t.text "onelogin_idv_last_name"
t.date "onelogin_idv_date_of_birth"
t.datetime "started_at", precision: nil, null: false
t.index ["academic_year"], name: "index_claims_on_academic_year"
t.index ["created_at"], name: "index_claims_on_created_at"
t.index ["eligibility_type", "eligibility_id"], name: "index_claims_on_eligibility_type_and_eligibility_id"
Expand Down
2 changes: 2 additions & 0 deletions spec/factories/claims.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
sequence(:national_insurance_number, 100000) { |n| "QQ#{n}C" }

factory :claim do
started_at { Time.zone.now }

transient do
policy { Policies::StudentLoans }
eligibility_factory { :"#{policy.to_s.underscore}_eligibility" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
address_line_4: "Oregon",
postcode: "AB12 3CD",
email_address: "[email protected]",
created_at: DateTime.new(2024, 8, 1, 9, 0, 0),
started_at: DateTime.new(2024, 8, 1, 9, 0, 0),
submitted_at: DateTime.new(2024, 8, 1, 11, 0, 0),
academic_year: AcademicYear.new(2024)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,11 @@
end

let(:journey_session) do
build(:additional_payments_session, journey: journey::ROUTING_NAME, answers: answers)
create(
:additional_payments_session,
journey: journey::ROUTING_NAME,
answers: answers
)
end

let(:form) { described_class.new(journey_session: journey_session) }
Expand Down Expand Up @@ -262,6 +266,8 @@

expect(journey_session.claim).to eq(claim)

expect(claim.started_at).to eq(journey_session.created_at)

expect(ClaimMailer).to have_received(:submitted).with(claim)
expect(ClaimVerifierJob).to have_received(:perform_later).with(claim)
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,10 @@
{
details_check: true,
logged_in_with_tid: true
}.merge(attributes_for(:claim, :with_dqt_teacher_status))
}.merge(
attributes_for(:claim, :with_dqt_teacher_status)
.except(:started_at)
)
end

it "sets the induction as complete" do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
expect(claim.logged_in_with_onelogin).to eq(answers.logged_in_with_onelogin)
expect(claim.onelogin_credentials).to eq(answers.onelogin_credentials)
expect(claim.onelogin_user_info).to eq(answers.onelogin_user_info)
expect(claim.started_at).to eql(journey_session.created_at)

expect(claim.onelogin_uid).to eql(answers.onelogin_uid)
expect(claim.onelogin_auth_at).to eql(answers.onelogin_auth_at)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@

expect(claim.reference).to be_present

expect(claim.started_at).to eq(journey_session.created_at)

eligibility_answers.each do |attribute, value|
expect(eligibility.public_send(attribute)).to eq(value)
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
}
end

let(:journey_session) { build(:student_loans_session, answers: answers) }
let(:journey_session) { create(:student_loans_session, answers: answers) }

let(:form) { described_class.new(journey_session: journey_session) }

Expand Down Expand Up @@ -199,6 +199,8 @@
eq("Policies::StudentLoans::Eligibility")
)

expect(claim.started_at).to eq(journey_session.created_at)

expect(journey_session.claim).to eq(claim)

expect(ClaimMailer).to have_received(:submitted).with(claim)
Expand Down