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
0
Merge Requests
0
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
Boxiang Sun
gitlab-ce
Commits
047b7e50
Commit
047b7e50
authored
Dec 20, 2018
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow truncated_diff_lines to be called on image diff discussion
parent
f6dd6e56
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
2 deletions
+9
-2
app/models/concerns/discussion_on_diff.rb
app/models/concerns/discussion_on_diff.rb
+1
-0
spec/models/concerns/discussion_on_diff_spec.rb
spec/models/concerns/discussion_on_diff_spec.rb
+8
-2
No files found.
app/models/concerns/discussion_on_diff.rb
View file @
047b7e50
...
@@ -39,6 +39,7 @@ module DiscussionOnDiff
...
@@ -39,6 +39,7 @@ module DiscussionOnDiff
# Returns an array of at most 16 highlighted lines above a diff note
# Returns an array of at most 16 highlighted lines above a diff note
def
truncated_diff_lines
(
highlight:
true
,
diff_limit:
nil
)
def
truncated_diff_lines
(
highlight:
true
,
diff_limit:
nil
)
return
[]
unless
on_text?
return
[]
if
diff_line
.
nil?
&&
first_note
.
is_a?
(
LegacyDiffNote
)
return
[]
if
diff_line
.
nil?
&&
first_note
.
is_a?
(
LegacyDiffNote
)
diff_limit
=
[
diff_limit
,
NUMBER_OF_TRUNCATED_DIFF_LINES
].
compact
.
min
diff_limit
=
[
diff_limit
,
NUMBER_OF_TRUNCATED_DIFF_LINES
].
compact
.
min
...
...
spec/models/concerns/discussion_on_diff_spec.rb
View file @
047b7e50
...
@@ -50,11 +50,17 @@ describe DiscussionOnDiff do
...
@@ -50,11 +50,17 @@ describe DiscussionOnDiff do
end
end
context
"when the diff line does not exist on a legacy diff note"
do
context
"when the diff line does not exist on a legacy diff note"
do
subject
{
create
(
:legacy_diff_note_on_merge_request
).
to_discussion
}
it
"returns an empty array"
do
it
"returns an empty array"
do
legacy_note
=
LegacyDiffNote
.
new
expect
(
truncated_lines
).
to
eq
([])
end
end
allow
(
subject
).
to
receive
(
:first_note
).
and_return
(
legacy_note
)
context
'when the discussion is on an image'
do
subject
{
create
(
:image_diff_note_on_merge_request
).
to_discussion
}
it
'returns an empty array'
do
expect
(
truncated_lines
).
to
eq
([])
expect
(
truncated_lines
).
to
eq
([])
end
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