Commit ab2b2108 authored by Mayra Cabrera's avatar Mayra Cabrera

Merge branch 'multi-line-equality-fix' into 'master'

Fix for diff text formatter equality testing

See merge request gitlab-org/gitlab!31748
parents 9fbd9326 766e1b27
...@@ -45,7 +45,8 @@ module Gitlab ...@@ -45,7 +45,8 @@ module Gitlab
def ==(other) def ==(other)
other.is_a?(self.class) && other.is_a?(self.class) &&
new_line == other.new_line && new_line == other.new_line &&
old_line == other.old_line old_line == other.old_line &&
line_range == other.line_range
end end
end end
end end
......
...@@ -26,6 +26,7 @@ describe Gitlab::Diff::Formatters::TextFormatter do ...@@ -26,6 +26,7 @@ describe Gitlab::Diff::Formatters::TextFormatter do
# Specific text formatter examples # Specific text formatter examples
let!(:formatter) { described_class.new(attrs) } let!(:formatter) { described_class.new(attrs) }
let(:attrs) { base }
describe '#line_age' do describe '#line_age' do
subject { formatter.line_age } subject { formatter.line_age }
...@@ -42,4 +43,21 @@ describe Gitlab::Diff::Formatters::TextFormatter do ...@@ -42,4 +43,21 @@ describe Gitlab::Diff::Formatters::TextFormatter do
it { is_expected.to eq('old') } it { is_expected.to eq('old') }
end end
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 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