Commit e22417f7 authored by Imre Farkas's avatar Imre Farkas

Merge branch 'kassio/github-importer-fix-ghost-merger-user' into 'master'

GithubImporter: Fixes merged_by importer when merger user is nil

See merge request gitlab-org/gitlab!65152
parents 6afdd714 fa0ff124
......@@ -43,7 +43,7 @@ module Gitlab
def missing_author_note
s_("GitHubImporter|*Merged by: %{author} at %{timestamp}*") % {
author: pull_request.merged_by.login,
author: pull_request.merged_by&.login || 'ghost',
timestamp: pull_request.merged_at
}
end
......
......@@ -8,13 +8,14 @@ RSpec.describe Gitlab::GithubImport::Importer::PullRequestMergedByImporter, :cle
let(:project) { merge_request.project }
let(:merged_at) { Time.new(2017, 1, 1, 12, 00).utc }
let(:client_double) { double(user: double(id: 999, login: 'merger', email: 'merger@email.com')) }
let(:merger_user) { double(id: 999, login: 'merger') }
let(:pull_request) do
instance_double(
Gitlab::GithubImport::Representation::PullRequest,
iid: merge_request.iid,
merged_at: merged_at,
merged_by: double(id: 999, login: 'merger')
merged_by: merger_user
)
end
......@@ -48,4 +49,23 @@ RSpec.describe Gitlab::GithubImport::Importer::PullRequestMergedByImporter, :cle
expect(last_note.author).to eq(project.creator)
end
end
context 'when the merger user is not provided' do
let(:merger_user) { nil }
it 'adds a note referencing the merger user' do
expect { subject.execute }
.to change(Note, :count).by(1)
.and not_change(merge_request, :updated_at)
metrics = merge_request.metrics.reload
expect(metrics.merged_by).to be_nil
expect(metrics.merged_at).to eq(merged_at)
last_note = merge_request.notes.last
expect(last_note.note).to eq("*Merged by: ghost at 2017-01-01 12:00:00 UTC*")
expect(last_note.created_at).to eq(merged_at)
expect(last_note.author).to eq(project.creator)
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