2018-08-11 16:33:15 -04:00
|
|
|
describe Gitlab::Diff::Line do
|
2018-08-28 09:39:17 -04:00
|
|
|
describe '.init_from_hash' do
|
|
|
|
it 'round-trips correctly with to_hash' do
|
|
|
|
line = described_class.new('<input>', 'match', 0, 0, 1,
|
|
|
|
parent_file: double(:file),
|
|
|
|
line_code: double(:line_code),
|
|
|
|
rich_text: '<input>')
|
|
|
|
|
|
|
|
expect(described_class.init_from_hash(line.to_hash).to_hash)
|
|
|
|
.to eq(line.to_hash)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-08-11 16:33:15 -04:00
|
|
|
context "when setting rich text" do
|
|
|
|
it 'escapes any HTML special characters in the diff chunk header' do
|
|
|
|
subject = described_class.new("<input>", "", 0, 0, 0)
|
|
|
|
line = subject.as_json
|
|
|
|
|
|
|
|
expect(line[:rich_text]).to eq("<input>")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|