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
76e8cd5c
Commit
76e8cd5c
authored
Feb 26, 2019
by
Oswaldo Ferreira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add EE tests for draft publishing
parent
172bd567
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
76 additions
and
0 deletions
+76
-0
ee/spec/services/draft_notes/publish_service_spec.rb
ee/spec/services/draft_notes/publish_service_spec.rb
+76
-0
No files found.
ee/spec/services/draft_notes/publish_service_spec.rb
View file @
76e8cd5c
...
@@ -74,6 +74,82 @@ describe DraftNotes::PublishService do
...
@@ -74,6 +74,82 @@ describe DraftNotes::PublishService do
end
end
end
end
context
'draft notes with suggestions'
do
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:merge_request
)
{
create
(
:merge_request
,
source_project:
project
,
target_project:
project
)
}
let
(
:suggestion_note
)
do
<<-
MARKDOWN
.
strip_heredoc
```suggestion
foo
```
MARKDOWN
end
let!
(
:draft
)
{
create
(
:draft_note_on_text_diff
,
note:
suggestion_note
,
merge_request:
merge_request
,
author:
user
)
}
it
'creates a suggestion with correct content'
do
expect
{
publish
(
draft:
draft
)
}.
to
change
{
Suggestion
.
count
}.
by
(
1
)
.
and
change
{
DiffNote
.
count
}.
from
(
0
).
to
(
1
)
suggestion
=
Suggestion
.
last
expect
(
suggestion
.
from_line
).
to
eq
(
14
)
expect
(
suggestion
.
to_line
).
to
eq
(
14
)
expect
(
suggestion
.
from_content
).
to
eq
(
" vars = {
\n
"
)
expect
(
suggestion
.
to_content
).
to
eq
(
" foo
\n
"
)
end
context
'when the diff is changed'
do
let
(
:file_path
)
{
'files/ruby/popen.rb'
}
let
(
:branch_name
)
{
project
.
default_branch
}
let
(
:commit
)
{
project
.
repository
.
commit
}
def
update_file
(
file_path
,
new_content
)
params
=
{
file_path:
file_path
,
commit_message:
"Update File"
,
file_content:
new_content
,
start_project:
project
,
start_branch:
project
.
default_branch
,
branch_name:
branch_name
}
Files
::
UpdateService
.
new
(
project
,
user
,
params
).
execute
end
before
do
project
.
add_developer
(
user
)
end
it
'creates a suggestion based on the latest diff content and positions'
do
diff_file
=
merge_request
.
diffs
(
paths:
[
file_path
]).
diff_files
.
first
raw_data
=
diff_file
.
new_blob
.
data
# Add a line break to the beginning of the file
result
=
update_file
(
file_path
,
raw_data
.
prepend
(
"
\n
"
))
oldrev
=
merge_request
.
diff_head_sha
newrev
=
result
[
:result
]
expect
(
newrev
).
to
be_present
# Generates new MR revision at DB level
refresh
=
MergeRequests
::
RefreshService
.
new
(
project
,
user
)
refresh
.
execute
(
oldrev
,
newrev
,
merge_request
.
source_branch_ref
)
expect
{
publish
(
draft:
draft
)
}.
to
change
{
Suggestion
.
count
}.
by
(
1
)
.
and
change
{
DiffNote
.
count
}.
from
(
0
).
to
(
1
)
suggestion
=
Suggestion
.
last
expect
(
suggestion
.
from_line
).
to
eq
(
15
)
expect
(
suggestion
.
to_line
).
to
eq
(
15
)
expect
(
suggestion
.
from_content
).
to
eq
(
" vars = {
\n
"
)
expect
(
suggestion
.
to_content
).
to
eq
(
" foo
\n
"
)
end
end
end
it
'only publishes the draft notes belonging to the current user'
do
it
'only publishes the draft notes belonging to the current user'
do
other_user
=
create
(
:user
)
other_user
=
create
(
:user
)
project
.
add_maintainer
(
other_user
)
project
.
add_maintainer
(
other_user
)
...
...
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