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

fix task and add test #1160

Merged
merged 2 commits into from
Sep 9, 2024
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
4 changes: 2 additions & 2 deletions lib/tasks/fixes.rake
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ namespace :fixes do
]

records.each do |record|
id = record['submission_id']
new_reference = record['laa_reference']
id = record[:submission_id]
new_reference = record[:laa_reference]
fix_laa_reference(id, new_reference)
end
end
Expand Down
26 changes: 26 additions & 0 deletions spec/lib/tasks/fix_mismatched_references_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
require 'rails_helper'

describe 'fixes:mismatched_references:fix', type: :task do
let(:unmatched_application) do
create(:prior_authority_application, id: '8db79c28-35fd-42ae-aef8-156fbe28631a', state: 'sent_back',
laa_reference: 'LAA-ABCDEF')
end
let(:records) do
[{ submission_id: unmatched_application.id, laa_reference: 'LAA-Xcoqqz' }]
end

before do
Rails.application.load_tasks if Rake::Task.tasks.empty?
end

after do
Rake::Task['fixes:mismatched_references:fix'].reenable
end

it 'prints out the correct information' do
# rubocop:disable Layout/LineLength
expected_output = "Fixed LAA Reference for Submission: #{unmatched_application.id}. Old Reference: #{unmatched_application.laa_reference}, New Reference: #{records.first[:laa_reference]}\n"
# rubocop:enable Layout/LineLength
expect { Rake::Task['fixes:mismatched_references:fix'].execute }.to output(expected_output).to_stdout
end
end