Commit 766e1b27 authored by Robert May's avatar Robert May

Fix for diff text formatter equality testing

Ensures that changes in the `line_range` attr are detected.
parent ddd741b2
......@@ -45,7 +45,8 @@ module Gitlab
def ==(other)
other.is_a?(self.class) &&
new_line == other.new_line &&
old_line == other.old_line
old_line == other.old_line &&
line_range == other.line_range
end
end
end
......
......@@ -26,6 +26,7 @@ describe Gitlab::Diff::Formatters::TextFormatter do
# Specific text formatter examples
let!(:formatter) { described_class.new(attrs) }
let(:attrs) { base }
describe '#line_age' do
subject { formatter.line_age }
......@@ -42,4 +43,21 @@ describe Gitlab::Diff::Formatters::TextFormatter do
it { is_expected.to eq('old') }
end
end
describe "#==" do
it "is false when the line_range changes" do
formatter_1 = described_class.new(base.merge(line_range: { start_line_code: "foo", end_line_code: "bar" }))
formatter_2 = described_class.new(base.merge(line_range: { start_line_code: "foo", end_line_code: "baz" }))
expect(formatter_1).not_to eq(formatter_2)
end
it "is true when the line_range doesn't change" do
attrs = base.merge({ line_range: { start_line_code: "foo", end_line_code: "baz" } })
formatter_1 = described_class.new(attrs)
formatter_2 = described_class.new(attrs)
expect(formatter_1).to eq(formatter_2)
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment