diff options
author | Bart Libert <bart.libert@gmail.com> | 2018-04-05 13:44:18 +0200 |
---|---|---|
committer | Bart Libert <bart.libert@gmail.com> | 2018-05-24 13:28:58 +0200 |
commit | 4bfd54f3d2e303d751d49834879867f3c62156e9 (patch) | |
tree | 14bec3c9ce3fefc68a6a0664da91470880b3cbed /spec | |
parent | 942fe5fe79f512b4c801fc887a1240a963b827d0 (diff) | |
download | gitlab-ce-4bfd54f3d2e303d751d49834879867f3c62156e9.tar.gz |
Import bitbucket issues that are reported by an anonymous user
For these kind of issues, the "reporter" field is present but zero.
In such a case, "fetch" will not return the default value, but it will
return nil.
Hence, importing fails, because the "username" field of nil is referenced
Fixes issue #44381
Diffstat (limited to 'spec')
-rw-r--r-- | spec/lib/gitlab/bitbucket_import/importer_spec.rb | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/spec/lib/gitlab/bitbucket_import/importer_spec.rb b/spec/lib/gitlab/bitbucket_import/importer_spec.rb index c63120b0b29..05c232d22cf 100644 --- a/spec/lib/gitlab/bitbucket_import/importer_spec.rb +++ b/spec/lib/gitlab/bitbucket_import/importer_spec.rb @@ -19,6 +19,18 @@ describe Gitlab::BitbucketImport::Importer do ] end + let(:reporters) do + [ + nil, + { "username" => "reporter1" }, + nil, + { "username" => "reporter2" }, + { "username" => "reporter1" }, + nil, + { "username" => "reporter3" } + ] + end + let(:sample_issues_statuses) do issues = [] @@ -36,6 +48,10 @@ describe Gitlab::BitbucketImport::Importer do } end + reporters.map.with_index do |reporter, index| + issues[index]['reporter'] = reporter + end + issues end @@ -147,5 +163,19 @@ describe Gitlab::BitbucketImport::Importer do expect(importer.errors).to be_empty end end + + describe 'issue import' do + it 'maps reporters to anonymous if bitbucket reporter is nil' do + allow(importer).to receive(:import_wiki) + importer.execute + + expect(project.issues.size).to eq(7) + expect(project.issues.where("description LIKE ?", '%Anonymous%').size).to eq(3) + expect(project.issues.where("description LIKE ?", '%reporter1%').size).to eq(2) + expect(project.issues.where("description LIKE ?", '%reporter2%').size).to eq(1) + expect(project.issues.where("description LIKE ?", '%reporter3%').size).to eq(1) + expect(importer.errors).to be_empty + end + end end end |