Commit bb43a021 authored by Dmytro Zaporozhets's avatar Dmytro Zaporozhets

Merge branch 'ld-image-formatter-eql-for-width-and-height' into 'master'

Allow ImageFormatter#== to factor width and height

See merge request gitlab-org/gitlab!24126
parents a6fae82d 73c9dee8
......@@ -37,7 +37,9 @@ module Gitlab
def ==(other)
other.is_a?(self.class) &&
x == other.x &&
y == other.y
y == other.y &&
width == other.width &&
height == other.height
end
end
end
......
......@@ -3,20 +3,34 @@
require 'spec_helper'
describe Gitlab::Diff::Formatters::ImageFormatter do
it_behaves_like "position formatter" do
let(:base_attrs) do
{
base_sha: 123,
start_sha: 456,
head_sha: 789,
old_path: 'old_image.png',
new_path: 'new_image.png',
position_type: 'image'
}
end
let(:base_attrs) do
{
base_sha: 123,
start_sha: 456,
head_sha: 789,
old_path: 'old_image.png',
new_path: 'new_image.png',
position_type: 'image'
}
end
let(:attrs) do
base_attrs.merge(width: 100, height: 100, x: 1, y: 2)
end
it_behaves_like 'position formatter'
describe '#==' do
subject { described_class.new(attrs) }
it { is_expected.to eq(subject) }
[:width, :height, :x, :y].each do |attr|
let(:other_formatter) do
described_class.new(attrs.merge(attr => 9))
end
let(:attrs) do
base_attrs.merge(width: 100, height: 100, x: 1, y: 2)
it { is_expected.not_to eq(other_formatter) }
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