396b8f91ec
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.
36 lines
796 B
Ruby
36 lines
796 B
Ruby
require 'rails_helper'
|
|
|
|
describe MergeRequestDiffFile, type: :model do
|
|
describe '#diff' do
|
|
let(:unpacked) { 'unpacked' }
|
|
let(:packed) { [unpacked].pack('m0') }
|
|
|
|
before do
|
|
subject.diff = packed
|
|
end
|
|
|
|
context 'when the diff is marked as binary' do
|
|
before do
|
|
subject.binary = true
|
|
end
|
|
|
|
it 'unpacks from base 64' do
|
|
expect(subject.diff).to eq(unpacked)
|
|
end
|
|
end
|
|
|
|
context 'when the diff is not marked as binary' do
|
|
it 'returns the raw diff' do
|
|
expect(subject.diff).to eq(packed)
|
|
end
|
|
end
|
|
end
|
|
|
|
describe '#utf8_diff' do
|
|
it 'does not raise error when the diff is binary' do
|
|
subject.diff = "\x05\x00\x68\x65\x6c\x6c\x6f"
|
|
|
|
expect { subject.utf8_diff }.not_to raise_error
|
|
end
|
|
end
|
|
end
|