Commit 443d20a4 authored by Rajendra Kadam's avatar Rajendra Kadam Committed by Peter Leitzen

Use applogger in project import state

parent 9ed1e151
......@@ -84,7 +84,7 @@ class ProjectImportState < ApplicationRecord
update_column(:last_error, sanitized_message)
rescue ActiveRecord::ActiveRecordError => e
Rails.logger.error("Error setting import status to failed: #{e.message}. Original error: #{sanitized_message}") # rubocop:disable Gitlab/RailsLogger
Gitlab::AppLogger.error("Error setting import status to failed: #{e.message}. Original error: #{sanitized_message}")
ensure
@errors = original_errors
end
......
---
title: Use applogger in project import state file
merge_request: 32182
author: Rajendra Kadam
type: fixed
......@@ -57,6 +57,25 @@ describe ProjectImportState, type: :model do
end
end
describe '#mark_as_failed' do
let(:error_message) { 'some message' }
it 'logs error when update column fails' do
allow(import_state).to receive(:update_column).and_raise(ActiveRecord::ActiveRecordError)
allow(Gitlab::AppLogger).to receive(:error)
import_state.mark_as_failed(error_message)
expect(Gitlab::AppLogger).to have_received(:error)
end
it 'updates last_error with error message' do
import_state.mark_as_failed(error_message)
expect(import_state.last_error).to eq(error_message)
end
end
describe '#human_status_name' do
context 'when import_state exists' do
it 'returns the humanized status name' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment