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
213f646f
Commit
213f646f
authored
Jul 01, 2016
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tests for DiffPositionUpdateService
parent
e0ecfe5b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
71 additions
and
0 deletions
+71
-0
spec/services/notes/diff_position_update_service_spec.rb
spec/services/notes/diff_position_update_service_spec.rb
+71
-0
No files found.
spec/services/notes/diff_position_update_service_spec.rb
0 → 100644
View file @
213f646f
require
'spec_helper'
describe
Notes
::
DiffPositionUpdateService
,
services:
true
do
let
(
:project
)
{
create
(
:project
)
}
let
(
:create_commit
)
{
project
.
commit
(
"913c66a37b4a45b9769037c55c2d238bd0942d2e"
)
}
let
(
:modify_commit
)
{
project
.
commit
(
"874797c3a73b60d2187ed6e2fcabd289ff75171e"
)
}
let
(
:edit_commit
)
{
project
.
commit
(
"570e7b2abdd848b95f2f578043fc23bd6f6fd24d"
)
}
let
(
:path
)
{
"files/ruby/popen.rb"
}
let
(
:old_diff_refs
)
do
Gitlab
::
Diff
::
DiffRefs
.
new
(
base_sha:
create_commit
.
parent_id
,
head_sha:
modify_commit
.
sha
)
end
let
(
:new_diff_refs
)
do
Gitlab
::
Diff
::
DiffRefs
.
new
(
base_sha:
create_commit
.
parent_id
,
head_sha:
edit_commit
.
sha
)
end
subject
do
described_class
.
new
(
project
,
nil
,
old_diff_refs:
old_diff_refs
,
new_diff_refs:
new_diff_refs
,
paths:
[
path
]
)
end
describe
"#execute"
do
let
(
:note
)
{
create
(
:diff_note_on_merge_request
,
project:
project
,
position:
old_position
)
}
let
(
:old_position
)
do
Gitlab
::
Diff
::
Position
.
new
(
old_path:
path
,
new_path:
path
,
old_line:
nil
,
new_line:
line
,
diff_refs:
old_diff_refs
)
end
context
"when the diff line is the same"
do
let
(
:line
)
{
16
}
it
"updates the position"
do
subject
.
execute
(
note
)
expect
(
note
.
original_position
).
to
eq
(
old_position
)
expect
(
note
.
position
).
not_to
eq
(
old_position
)
expect
(
note
.
position
.
new_line
).
to
eq
(
22
)
end
end
context
"when the diff line has changed"
do
let
(
:line
)
{
9
}
it
"doesn't update the position"
do
subject
.
execute
(
note
)
expect
(
note
.
original_position
).
to
eq
(
old_position
)
expect
(
note
.
position
).
to
eq
(
old_position
)
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