Commit 8d7fb292 authored by Oswaldo Ferreira's avatar Oswaldo Ferreira

Avoid encoding errors for MergeToRefService

parent 50063f4a
---
title: Handle encoding errors for MergeToRefService
merge_request: 29440
author:
type: fixed
......@@ -107,7 +107,7 @@ module Gitlab
branch: encode_binary(branch),
target_ref: encode_binary(target_ref),
user: Gitlab::Git::User.from_gitlab(user).to_gitaly,
message: message
message: encode_binary(message)
)
response = GitalyClient.call(@repository.storage, :operation_service, :user_merge_to_ref, request)
......
......@@ -78,6 +78,24 @@ describe Gitlab::GitalyClient::OperationService do
subject
end
describe '#user_merge_to_ref' do
let(:branch) { 'my-branch' }
let(:source_sha) { 'cfe32cf61b73a0d5e9f13e774abde7ff789b1660' }
let(:ref) { 'refs/merge-requests/x/merge' }
let(:message) { 'validación' }
let(:response) { Gitaly::UserMergeToRefResponse.new(commit_id: 'new-commit-id') }
subject { client.user_merge_to_ref(user, source_sha, branch, ref, message) }
it 'sends a user_merge_to_ref message' do
expect_any_instance_of(Gitaly::OperationService::Stub)
.to receive(:user_merge_to_ref).with(kind_of(Gitaly::UserMergeToRefRequest), kind_of(Hash))
.and_return(response)
subject
end
end
context "when pre_receive_error is present" do
let(:response) do
Gitaly::UserUpdateBranchResponse.new(pre_receive_error: "GitLab: something failed")
......
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