Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean McGivern <sean@gitlab.com>2017-07-25 19:57:02 +0300
committerSean McGivern <sean@gitlab.com>2017-07-26 17:34:57 +0300
commit396b8f91ec47ffb5a02ebf6d713ef4cbf04f1f94 (patch)
treec27074b1608622faa29efb8275be983a9331b2db /spec/models/merge_request_diff_spec.rb
parent0c563225b663742b4f26731dc7bc822a38f7289b (diff)
Fix saving diffs that are not valid UTF-8
Previously, we used Psych, which would: 1. Check if a string was encoded as binary, and not ASCII-compatible. 2. Add the !binary tag in that case. 3. Convert to base64. We need to do the same thing, using a new column in place of the tag.
Diffstat (limited to 'spec/models/merge_request_diff_spec.rb')
-rw-r--r--spec/models/merge_request_diff_spec.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/spec/models/merge_request_diff_spec.rb b/spec/models/merge_request_diff_spec.rb
index edc2f4bb9f0..0e77752bccc 100644
--- a/spec/models/merge_request_diff_spec.rb
+++ b/spec/models/merge_request_diff_spec.rb
@@ -105,6 +105,15 @@ describe MergeRequestDiff, models: true do
expect(mr_diff.empty?).to be_truthy
end
+
+ it 'saves binary diffs correctly' do
+ path = 'files/images/icn-time-tracking.pdf'
+ mr_diff = create(:merge_request, source_branch: 'add-pdf-text-binary', target_branch: 'master').merge_request_diff
+ diff_file = mr_diff.merge_request_diff_files.find_by(new_path: path)
+
+ expect(diff_file).to be_binary
+ expect(diff_file.diff).to eq(mr_diff.compare.diffs(paths: [path]).to_a.first.diff)
+ end
end
describe '#commit_shas' do