Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
766e1b27
Commit
766e1b27
authored
May 12, 2020
by
Robert May
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix for diff text formatter equality testing
Ensures that changes in the `line_range` attr are detected.
parent
ddd741b2
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
1 deletion
+20
-1
lib/gitlab/diff/formatters/text_formatter.rb
lib/gitlab/diff/formatters/text_formatter.rb
+2
-1
spec/lib/gitlab/diff/formatters/text_formatter_spec.rb
spec/lib/gitlab/diff/formatters/text_formatter_spec.rb
+18
-0
No files found.
lib/gitlab/diff/formatters/text_formatter.rb
View file @
766e1b27
...
...
@@ -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
...
...
spec/lib/gitlab/diff/formatters/text_formatter_spec.rb
View file @
766e1b27
...
...
@@ -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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment