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
3d471c0d
Commit
3d471c0d
authored
Feb 07, 2020
by
Gary Holtz
Committed by
Douglas Barbosa Alexandre
Feb 13, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding a basic fix and a resulting spec
parent
57acb8eb
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
1 deletion
+22
-1
lib/gitlab/diff/suggestion_diff.rb
lib/gitlab/diff/suggestion_diff.rb
+5
-1
spec/lib/gitlab/diff/suggestion_diff_spec.rb
spec/lib/gitlab/diff/suggestion_diff_spec.rb
+17
-0
No files found.
lib/gitlab/diff/suggestion_diff.rb
View file @
3d471c0d
...
...
@@ -18,13 +18,17 @@ module Gitlab
private
def
raw_diff
"
#{
diff_header
}
\n
#{
from_content_as_diff
}#{
to_content_as_diff
}
"
"
#{
diff_header
}
\n
#{
from_content_as_diff
}#{
spacer
}#{
to_content_as_diff
}
"
end
def
diff_header
"@@ -
#{
from_line
}
+
#{
from_line
}
"
end
def
spacer
"
\n
"
unless
from_content_as_diff
[
-
1
,
3
]
==
"
\n
"
end
def
from_content_as_diff
from_content
.
lines
.
map
{
|
line
|
line
.
prepend
(
'-'
)
}.
join
end
...
...
spec/lib/gitlab/diff/suggestion_diff_spec.rb
View file @
3d471c0d
...
...
@@ -51,5 +51,22 @@ describe Gitlab::Diff::SuggestionDiff do
expect
(
diff_lines
[
index
].
to_hash
).
to
include
(
expected_line
)
end
end
describe
'when the suggestion is for the last line of a file'
do
it
'returns a correct value if there is no newline at the end of the file'
do
from_content
=
"One line test"
to_content
=
"Successful test!"
suggestion
=
instance_double
(
Suggestion
,
from_line:
1
,
from_content:
from_content
,
to_content:
to_content
)
diff_lines
=
described_class
.
new
(
suggestion
).
diff_lines
bad_string
=
"-One line test+Successful test!"
diff_lines
.
each
do
|
diff_line
|
expect
(
diff_line
.
to_hash
).
not_to
include
(
bad_string
)
end
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