diff options
author | Stan Hu <stanhu@gmail.com> | 2019-06-11 01:50:23 +0300 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2019-06-11 01:54:14 +0300 |
commit | 1edf1807c570d74ee0039f5f58ef607ee797187a (patch) | |
tree | 172ff4fd62d291c2edc322d332b83b5efa6a24da /spec/lib/gitlab/gitaly_client | |
parent | 3017d2a52a3da5dc8e701f442b6d7c65c19cc054 (diff) |
Fix UTF-8 conversion issues when resolving conflicts
Similar to https://gitlab.com/gitlab-org/gitlab-ce/issues/63030,
when the commit message in the /resolve_conflicts endpoint contains a
UTF-8 character, the conversion to the Gitaly ASCII-8BIT value may flag
an error. To fix this, we run `force_encoding` on the commit message.
Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/63062
Diffstat (limited to 'spec/lib/gitlab/gitaly_client')
-rw-r--r-- | spec/lib/gitlab/gitaly_client/conflicts_service_spec.rb | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/spec/lib/gitlab/gitaly_client/conflicts_service_spec.rb b/spec/lib/gitlab/gitaly_client/conflicts_service_spec.rb index e4fe01a671f..a8a6830ee2d 100644 --- a/spec/lib/gitlab/gitaly_client/conflicts_service_spec.rb +++ b/spec/lib/gitlab/gitaly_client/conflicts_service_spec.rb @@ -35,7 +35,7 @@ describe Gitlab::GitalyClient::ConflictsService do end let(:source_branch) { 'master' } let(:target_branch) { 'feature' } - let(:commit_message) { 'Solving conflicts' } + let(:commit_message) { 'Solving conflicts\n\nTést' } let(:resolution) do Gitlab::Git::Conflict::Resolution.new(user, files, commit_message) end @@ -51,6 +51,18 @@ describe Gitlab::GitalyClient::ConflictsService do subject end + it 'handles commit messages with UTF-8 characters' do + allow(::Gitlab::GitalyClient).to receive(:call).and_call_original + expect(::Gitlab::GitalyClient).to receive(:call).with(anything, :conflicts_service, :resolve_conflicts, any_args) do |*args| + # Force the generation of request messages by iterating through the enumerator + args[3].to_a + + double(resolution_error: nil) + end + + subject + end + it 'raises a relevant exception if resolution_error is present' do expect_any_instance_of(Gitaly::ConflictsService::Stub).to receive(:resolve_conflicts) .with(kind_of(Enumerator), kind_of(Hash)).and_return(double(resolution_error: "something happened")) |