diff options
author | Sean McGivern <sean@mcgivern.me.uk> | 2017-09-06 15:55:35 +0000 |
---|---|---|
committer | Sean McGivern <sean@mcgivern.me.uk> | 2017-09-06 15:55:35 +0000 |
commit | ba39b26cc2f1ace540177c3b73d64d40b06bc902 (patch) | |
tree | 74691ce0b45a6b2d35efc58cdbfa460dc0ddef22 /spec | |
parent | 93e1d4dd285c657a3abb09dff7f86e552b0097f2 (diff) | |
parent | 46f6092a6d4dd39bfa193d0a6ccbd5688df7eebe (diff) | |
download | gitlab-ce-ba39b26cc2f1ace540177c3b73d64d40b06bc902.tar.gz |
Merge branch '35942_api_binary_encoding' into 'master'
API fix for non UTF-8 data
Closes #35942
See merge request !14038
Diffstat (limited to 'spec')
-rw-r--r-- | spec/lib/gitlab/git/diff_spec.rb | 19 | ||||
-rw-r--r-- | spec/requests/api/commits_spec.rb | 6 |
2 files changed, 25 insertions, 0 deletions
diff --git a/spec/lib/gitlab/git/diff_spec.rb b/spec/lib/gitlab/git/diff_spec.rb index dfbdbee48f7..d39b33a0c05 100644 --- a/spec/lib/gitlab/git/diff_spec.rb +++ b/spec/lib/gitlab/git/diff_spec.rb @@ -273,6 +273,25 @@ EOT end end + describe '#json_safe_diff' do + let(:project) { create(:project, :repository) } + + it 'fake binary message when it detects binary' do + # Rugged will not detect this as binary, but we can fake it + diff_message = "Binary files files/images/icn-time-tracking.pdf and files/images/icn-time-tracking.pdf differ\n" + binary_diff = described_class.between(project.repository, 'add-pdf-text-binary', 'add-pdf-text-binary^').first + + expect(binary_diff.diff).not_to be_empty + expect(binary_diff.json_safe_diff).to eq(diff_message) + end + + it 'leave non-binary diffs as-is' do + diff = described_class.new(@rugged_diff) + + expect(diff.json_safe_diff).to eq(diff.diff) + end + end + describe '#submodule?' do before do commit = repository.lookup('5937ac0a7beb003549fc5fd26fc247adbce4a52e') diff --git a/spec/requests/api/commits_spec.rb b/spec/requests/api/commits_spec.rb index edbfaf510c5..f663719d28c 100644 --- a/spec/requests/api/commits_spec.rb +++ b/spec/requests/api/commits_spec.rb @@ -673,6 +673,12 @@ describe API::Commits do it_behaves_like 'ref diff' end end + + context 'when binary diff are treated as text' do + let(:commit_id) { TestEnv::BRANCH_SHA['add-pdf-text-binary'] } + + it_behaves_like 'ref diff' + end end end |