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
5ffb848e
Commit
5ffb848e
authored
Jul 01, 2016
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tests for MergeRequest#reload_diff
parent
3dff2867
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
0 deletions
+40
-0
spec/models/merge_request_spec.rb
spec/models/merge_request_spec.rb
+40
-0
No files found.
spec/models/merge_request_spec.rb
View file @
5ffb848e
require
'spec_helper'
require
'spec_helper'
describe
MergeRequest
,
models:
true
do
describe
MergeRequest
,
models:
true
do
include
RepoHelpers
subject
{
create
(
:merge_request
)
}
subject
{
create
(
:merge_request
)
}
describe
'associations'
do
describe
'associations'
do
...
@@ -609,4 +611,42 @@ describe MergeRequest, models: true do
...
@@ -609,4 +611,42 @@ describe MergeRequest, models: true do
end
end
end
end
end
end
describe
"#reload_diff"
do
let
(
:note
)
{
create
(
:diff_note_on_merge_request
,
project:
subject
.
project
,
noteable:
subject
)
}
let
(
:commit
)
{
subject
.
project
.
commit
(
sample_commit
.
id
)
}
it
"reloads the diff content"
do
expect
(
subject
.
merge_request_diff
).
to
receive
(
:reload_content
)
subject
.
reload_diff
end
it
"updates diff note positions"
do
old_diff_refs
=
subject
.
diff_refs
merge_request_diff
=
subject
.
merge_request_diff
# Update merge_request_diff so that #diff_refs will return commit.diff_refs
allow
(
merge_request_diff
).
to
receive
(
:reload_content
)
do
merge_request_diff
.
base_commit_sha
=
commit
.
parent_id
merge_request_diff
.
start_commit_sha
=
commit
.
parent_id
merge_request_diff
.
head_commit_sha
=
commit
.
sha
end
expect
(
Notes
::
DiffPositionUpdateService
).
to
receive
(
:new
).
with
(
subject
.
project
,
nil
,
old_diff_refs:
old_diff_refs
,
new_diff_refs:
commit
.
diff_refs
,
paths:
note
.
position
.
paths
).
and_call_original
expect_any_instance_of
(
Notes
::
DiffPositionUpdateService
).
to
receive
(
:execute
).
with
(
note
)
expect_any_instance_of
(
DiffNote
).
to
receive
(
:save
).
once
subject
.
reload_diff
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