diff options
Diffstat (limited to 'spec/lib/gitlab/bitbucket_import/importer_spec.rb')
-rw-r--r-- | spec/lib/gitlab/bitbucket_import/importer_spec.rb | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/spec/lib/gitlab/bitbucket_import/importer_spec.rb b/spec/lib/gitlab/bitbucket_import/importer_spec.rb index 9786e7a364e..517d557d665 100644 --- a/spec/lib/gitlab/bitbucket_import/importer_spec.rb +++ b/spec/lib/gitlab/bitbucket_import/importer_spec.rb @@ -112,6 +112,7 @@ RSpec.describe Gitlab::BitbucketImport::Importer, :clean_gitlab_redis_cache, fea end let(:pull_request_author) { 'other' } + let(:comments) { [@inline_note, @reply] } let(:author_line) { "*Created by: someuser*\n\n" } @@ -145,8 +146,6 @@ RSpec.describe Gitlab::BitbucketImport::Importer, :clean_gitlab_redis_cache, fea has_parent?: true, parent_id: 2) - comments = [@inline_note, @reply] - allow(subject.client).to receive(:repo) allow(subject.client).to receive(:pull_requests).and_return([pull_request]) allow(subject.client).to receive(:pull_request_comments).with(anything, pull_request.iid).and_return(comments) @@ -202,6 +201,12 @@ RSpec.describe Gitlab::BitbucketImport::Importer, :clean_gitlab_redis_cache, fea end end + it 'calls RefConverter to convert Bitbucket refs to Gitlab refs' do + expect(subject.instance_values['ref_converter']).to receive(:convert_note).twice + + subject.execute + end + context 'when importing a pull request throws an exception' do before do allow(pull_request).to receive(:raw).and_return({ error: "broken" }) @@ -384,6 +389,12 @@ RSpec.describe Gitlab::BitbucketImport::Importer, :clean_gitlab_redis_cache, fea expect(label_after_import.attributes).to eq(existing_label.attributes) end end + + it 'raises an error if a label is not valid' do + stub_const("#{described_class}::LABELS", [{ title: nil, color: nil }]) + + expect { importer.create_labels }.to raise_error(StandardError, /Failed to create label/) + end end it 'maps statuses to open or closed' do @@ -444,26 +455,33 @@ RSpec.describe Gitlab::BitbucketImport::Importer, :clean_gitlab_redis_cache, fea end context 'with issue comments' do + let(:note) { 'Hello world' } let(:inline_note) do - instance_double(Bitbucket::Representation::Comment, note: 'Hello world', author: 'someuser', created_at: Time.now, updated_at: Time.now) + instance_double(Bitbucket::Representation::Comment, note: note, author: 'someuser', created_at: Time.now, updated_at: Time.now) end before do allow_next_instance_of(Bitbucket::Client) do |instance| allow(instance).to receive(:issue_comments).and_return([inline_note]) end + allow(importer).to receive(:import_wiki) end it 'imports issue comments' do - allow(importer).to receive(:import_wiki) importer.execute comment = project.notes.first expect(project.notes.size).to eq(7) - expect(comment.note).to include(inline_note.note) + expect(comment.note).to include(note) expect(comment.note).to include(inline_note.author) expect(importer.errors).to be_empty end + + it 'calls RefConverter to convert Bitbucket refs to Gitlab refs' do + expect(importer.instance_values['ref_converter']).to receive(:convert_note).exactly(7).times + + importer.execute + end end context 'when issue was already imported' do |