summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2018-01-05 05:54:01 +0000
committerStan Hu <stanhu@gmail.com>2018-01-05 05:54:01 +0000
commitf7afb14c1150d686e53cb71da182ef014eba2a61 (patch)
tree6359048f642afd75c7f20119d8b93e98aa88e32b /spec
parentde3491cfc59187aa5550d9aad8b98556cc39e561 (diff)
parent5152cc3bfb8d60814063e86c3776030aa8891e0b (diff)
downloadgitlab-ce-f7afb14c1150d686e53cb71da182ef014eba2a61.tar.gz
Merge branch '41677-branch-name-omitted-due-to-bad-utf-8-conversion-by-gitaly-ref-handler' into 'master'
Resolve "Branch name omitted due to bad UTF-8 conversion by Gitaly ref handler" Closes #41677 See merge request gitlab-org/gitlab-ce!16243
Diffstat (limited to 'spec')
-rw-r--r--spec/lib/gitlab/encoding_helper_spec.rb18
1 files changed, 18 insertions, 0 deletions
diff --git a/spec/lib/gitlab/encoding_helper_spec.rb b/spec/lib/gitlab/encoding_helper_spec.rb
index 87ec2698fc1..4e9367323cb 100644
--- a/spec/lib/gitlab/encoding_helper_spec.rb
+++ b/spec/lib/gitlab/encoding_helper_spec.rb
@@ -120,6 +120,24 @@ describe Gitlab::EncodingHelper do
it 'returns empty string on conversion errors' do
expect { ext_class.encode_utf8('') }.not_to raise_error(ArgumentError)
end
+
+ context 'with strings that can be forcefully encoded into utf8' do
+ let(:test_string) do
+ "refs/heads/FixSymbolsTitleDropdown".encode("ASCII-8BIT")
+ end
+ let(:expected_string) do
+ "refs/heads/FixSymbolsTitleDropdown".encode("UTF-8")
+ end
+
+ subject { ext_class.encode_utf8(test_string) }
+
+ it "doesn't use CharlockHolmes if the encoding can be forced into utf_8" do
+ expect(CharlockHolmes::EncodingDetector).not_to receive(:detect)
+
+ expect(subject).to eq(expected_string)
+ expect(subject.encoding.name).to eq('UTF-8')
+ end
+ end
end
describe '#clean' do