Skip to content

Commit

Permalink
Merge pull request #3222 from DFE-Digital/LUPEYALPHA-1096/fix-claim-s…
Browse files Browse the repository at this point in the history
…tarted-date-2

LUPEYALPHA 1096/fix claim started date 2
  • Loading branch information
rjlynch authored Sep 25, 2024
2 parents ea35048 + bb99389 commit 5451ece
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 2 deletions.
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
2 changes: 1 addition & 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_24_091408) do
ActiveRecord::Schema[7.0].define(version: 2024_09_24_095435) do
# These are extensions that must be enabled in order to support this database
enable_extension "citext"
enable_extension "pg_trgm"
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 @@ -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

0 comments on commit 5451ece

Please sign in to comment.