diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-20 21:38:24 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-20 21:38:24 +0300 |
commit | 983a0bba5d2a042c4a3bbb22432ec192c7501d82 (patch) | |
tree | b153cd387c14ba23bd5a07514c7c01fddf6a78a0 /spec/lib/api/entities/project_import_status_spec.rb | |
parent | a2bddee2cdb38673df0e004d5b32d9f77797de64 (diff) |
Add latest changes from gitlab-org/gitlab@12-10-stable-ee
Diffstat (limited to 'spec/lib/api/entities/project_import_status_spec.rb')
-rw-r--r-- | spec/lib/api/entities/project_import_status_spec.rb | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/spec/lib/api/entities/project_import_status_spec.rb b/spec/lib/api/entities/project_import_status_spec.rb new file mode 100644 index 00000000000..650f9c156a3 --- /dev/null +++ b/spec/lib/api/entities/project_import_status_spec.rb @@ -0,0 +1,49 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe API::Entities::ProjectImportStatus do + describe '#as_json' do + subject { entity.as_json } + + let(:correlation_id) { 'cid' } + + context 'when import has not finished yet' do + let(:project) { create(:project, :import_scheduled, import_correlation_id: correlation_id) } + let(:entity) { described_class.new(project) } + + it 'includes basic fields and no failures', :aggregate_failures do + expect(subject[:import_status]).to eq('scheduled') + expect(subject[:correlation_id]).to eq(correlation_id) + expect(subject[:import_error]).to be_nil + expect(subject[:failed_relations]).to eq([]) + end + end + + context 'when import has finished with failed relations' do + let(:project) { create(:project, :import_finished, import_correlation_id: correlation_id) } + let(:entity) { described_class.new(project) } + + it 'includes basic fields with failed relations', :aggregate_failures do + create(:import_failure, :hard_failure, project: project, correlation_id_value: correlation_id) + + expect(subject[:import_status]).to eq('finished') + expect(subject[:correlation_id]).to eq(correlation_id) + expect(subject[:import_error]).to be_nil + expect(subject[:failed_relations]).not_to be_empty + end + end + + context 'when import has failed' do + let(:project) { create(:project, :import_failed, import_correlation_id: correlation_id, import_last_error: 'error') } + let(:entity) { described_class.new(project) } + + it 'includes basic fields with import error', :aggregate_failures do + expect(subject[:import_status]).to eq('failed') + expect(subject[:correlation_id]).to eq(correlation_id) + expect(subject[:import_error]).to eq('error') + expect(subject[:failed_relations]).to eq([]) + end + end + end +end |