Commit 1fd5f16c authored by Aleksei Lipniagov's avatar Aleksei Lipniagov

Define explicit :subject on restorer spec

parent d6db5727
......@@ -635,43 +635,39 @@ describe Gitlab::ImportExport::ProjectTreeRestorer do
end
context 'JSON with invalid records' do
subject(:restored_project_json) { project_tree_restorer.restore }
let(:user) { create(:user) }
let!(:project) { create(:project, :builds_disabled, :issues_disabled, name: 'project', path: 'project') }
let(:project_tree_restorer) { described_class.new(user: user, shared: shared, project: project) }
let(:restored_project_json) { project_tree_restorer.restore }
context 'when some failures occur' do
context 'because a relation fails to be processed' do
let(:correlation_id) { 'my-correlation-id' }
let(:correlation_id) { 'my-correlation-id' }
before do
setup_import_export_config('with_invalid_records')
before do
setup_import_export_config('with_invalid_records')
Labkit::Correlation::CorrelationId.use_id(correlation_id) do
expect(restored_project_json).to eq(true)
end
end
Labkit::Correlation::CorrelationId.use_id(correlation_id) { subject }
end
it_behaves_like 'restores project successfully',
issues: 0,
labels: 0,
label_with_priorities: nil,
milestones: 1,
first_issue_labels: 0,
services: 0,
import_failures: 1
it 'records the failures in the database' do
import_failure = ImportFailure.last
expect(import_failure.project_id).to eq(project.id)
expect(import_failure.relation_key).to eq('milestones')
expect(import_failure.relation_index).to be_present
expect(import_failure.exception_class).to eq('ActiveRecord::RecordInvalid')
expect(import_failure.exception_message).to be_present
expect(import_failure.correlation_id_value).to eq('my-correlation-id')
expect(import_failure.created_at).to be_present
end
context 'when failures occur because a relation fails to be processed' do
it_behaves_like 'restores project successfully',
issues: 0,
labels: 0,
label_with_priorities: nil,
milestones: 1,
first_issue_labels: 0,
services: 0,
import_failures: 1
it 'records the failures in the database' do
import_failure = ImportFailure.last
expect(import_failure.project_id).to eq(project.id)
expect(import_failure.relation_key).to eq('milestones')
expect(import_failure.relation_index).to be_present
expect(import_failure.exception_class).to eq('ActiveRecord::RecordInvalid')
expect(import_failure.exception_message).to be_present
expect(import_failure.correlation_id_value).to eq('my-correlation-id')
expect(import_failure.created_at).to be_present
end
end
end
......
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