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
b7a68f79
Commit
b7a68f79
authored
Aug 23, 2019
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Automatic merge of gitlab-org/gitlab-ce master
parents
fad31946
15ea6147
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
91 additions
and
72 deletions
+91
-72
CHANGELOG.md
CHANGELOG.md
+13
-0
changelogs/unreleased/sh-eliminate-gitaly-nplus-one-notes.yml
...gelogs/unreleased/sh-eliminate-gitaly-nplus-one-notes.yml
+5
-0
changelogs/unreleased/sh-fix-issues-api-gitaly-nplusone.yml
changelogs/unreleased/sh-fix-issues-api-gitaly-nplusone.yml
+0
-5
changelogs/unreleased/sh-revert-redis-cache-store.yml
changelogs/unreleased/sh-revert-redis-cache-store.yml
+0
-5
changelogs/unreleased/tr-param-undefined-fix.yml
changelogs/unreleased/tr-param-undefined-fix.yml
+0
-5
lib/api/helpers/notes_helpers.rb
lib/api/helpers/notes_helpers.rb
+2
-0
lib/api/notes.rb
lib/api/notes.rb
+7
-6
spec/requests/api/discussions_spec.rb
spec/requests/api/discussions_spec.rb
+3
-51
spec/requests/api/notes_spec.rb
spec/requests/api/notes_spec.rb
+7
-0
spec/support/shared_examples/requests/api/discussions.rb
spec/support/shared_examples/requests/api/discussions.rb
+54
-0
No files found.
CHANGELOG.md
View file @
b7a68f79
...
...
@@ -2,6 +2,19 @@
documentation
](
doc/development/changelog.md
)
for instructions on adding your own
entry.
## 12.2.1
### Fixed (3 changes)
-
Fix for embedded metrics undefined params. !31975
-
Fix "ERR value is not an integer or out of range" errors. !32126
-
Prevent duplicated trigger action button.
### Performance (1 change)
-
Fix Gitaly N+1 calls with listing issues/MRs via API. !31938
## 12.2.0
### Security (4 changes, 1 of them is from the community)
...
...
changelogs/unreleased/sh-eliminate-gitaly-nplus-one-notes.yml
0 → 100644
View file @
b7a68f79
---
title
:
Eliminate Gitaly N+1 queries with notes API
merge_request
:
32089
author
:
type
:
performance
changelogs/unreleased/sh-fix-issues-api-gitaly-nplusone.yml
deleted
100644 → 0
View file @
fad31946
---
title
:
Fix Gitaly N+1 calls with listing issues/MRs via API
merge_request
:
31938
author
:
type
:
performance
changelogs/unreleased/sh-revert-redis-cache-store.yml
deleted
100644 → 0
View file @
fad31946
---
title
:
Fix "ERR value is not an integer or out of range" errors
merge_request
:
32126
author
:
type
:
fixed
changelogs/unreleased/tr-param-undefined-fix.yml
deleted
100644 → 0
View file @
fad31946
---
title
:
Fix for embedded metrics undefined params
merge_request
:
31975
author
:
type
:
fixed
lib/api/helpers/notes_helpers.rb
View file @
b7a68f79
...
...
@@ -3,6 +3,8 @@
module
API
module
Helpers
module
NotesHelpers
include
::
RendersNotes
def
self
.
noteable_types
# This is a method instead of a constant, allowing EE to more easily
# extend it.
...
...
lib/api/notes.rb
View file @
b7a68f79
...
...
@@ -36,12 +36,13 @@ module API
# page can have less elements than :per_page even if
# there's more than one page.
raw_notes
=
noteable
.
notes
.
with_metadata
.
reorder
(
order_options_with_tie_breaker
)
notes
=
# paginate() only works with a relation. This could lead to a
# mismatch between the pagination headers info and the actual notes
# array returned, but this is really a edge-case.
paginate
(
raw_notes
)
.
reject
{
|
n
|
n
.
cross_reference_not_visible_for?
(
current_user
)
}
notes
=
paginate
(
raw_notes
)
notes
=
prepare_notes_for_rendering
(
notes
)
notes
=
notes
.
reject
{
|
n
|
n
.
cross_reference_not_visible_for?
(
current_user
)
}
present
notes
,
with:
Entities
::
Note
end
# rubocop: enable CodeReuse/ActiveRecord
...
...
spec/requests/api/discussions_spec.rb
View file @
b7a68f79
...
...
@@ -9,59 +9,11 @@ describe API::Discussions do
project
.
add_developer
(
user
)
end
context
'with cross-reference system notes'
,
:request_store
do
let
(
:merge_request
)
{
create
(
:merge_request
)
}
let
(
:project
)
{
merge_request
.
project
}
let
(
:new_merge_request
)
{
create
(
:merge_request
)
}
let
(
:commit
)
{
new_merge_request
.
project
.
commit
}
let!
(
:note
)
{
create
(
:system_note
,
noteable:
merge_request
,
project:
project
,
note:
cross_reference
)
}
let!
(
:note_metadata
)
{
create
(
:system_note_metadata
,
note:
note
,
action:
'cross_reference'
)
}
let
(
:cross_reference
)
{
"test commit
#{
commit
.
to_reference
(
project
)
}
"
}
let
(
:pat
)
{
create
(
:personal_access_token
,
user:
user
)
}
context
'when discussions have cross-reference system notes'
do
let
(
:url
)
{
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
/discussions"
}
let
(
:notes_in_response
)
{
json_response
.
first
[
'notes'
]
}
before
do
project
.
add_developer
(
user
)
new_merge_request
.
project
.
add_developer
(
user
)
end
it
'returns only the note that the user should see'
do
hidden_merge_request
=
create
(
:merge_request
)
new_cross_reference
=
"test commit
#{
hidden_merge_request
.
project
.
commit
}
"
new_note
=
create
(
:system_note
,
noteable:
merge_request
,
project:
project
,
note:
new_cross_reference
)
create
(
:system_note_metadata
,
note:
new_note
,
action:
'cross_reference'
)
get
api
(
url
,
user
,
personal_access_token:
pat
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
json_response
.
count
).
to
eq
(
1
)
expect
(
json_response
.
first
[
'notes'
].
count
).
to
eq
(
1
)
parsed_note
=
json_response
.
first
[
'notes'
].
first
expect
(
parsed_note
[
'id'
]).
to
eq
(
note
.
id
)
expect
(
parsed_note
[
'body'
]).
to
eq
(
cross_reference
)
expect
(
parsed_note
[
'system'
]).
to
be
true
end
it
'avoids Git calls and N+1 SQL queries'
do
expect_any_instance_of
(
Repository
).
not_to
receive
(
:find_commit
).
with
(
commit
.
id
)
control
=
ActiveRecord
::
QueryRecorder
.
new
do
get
api
(
url
,
user
,
personal_access_token:
pat
)
end
expect
(
response
).
to
have_gitlab_http_status
(
200
)
RequestStore
.
clear!
new_note
=
create
(
:system_note
,
noteable:
merge_request
,
project:
project
,
note:
cross_reference
)
create
(
:system_note_metadata
,
note:
new_note
,
action:
'cross_reference'
)
RequestStore
.
clear!
expect
{
get
api
(
url
,
user
,
personal_access_token:
pat
)
}.
not_to
exceed_query_limit
(
control
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
end
it_behaves_like
'with cross-reference system notes'
end
context
'when noteable is an Issue'
do
...
...
spec/requests/api/notes_spec.rb
View file @
b7a68f79
...
...
@@ -9,6 +9,13 @@ describe API::Notes do
project
.
add_reporter
(
user
)
end
context
'when there are cross-reference system notes'
do
let
(
:url
)
{
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
/notes"
}
let
(
:notes_in_response
)
{
json_response
}
it_behaves_like
'with cross-reference system notes'
end
context
"when noteable is an Issue"
do
let!
(
:issue
)
{
create
(
:issue
,
project:
project
,
author:
user
)
}
let!
(
:issue_note
)
{
create
(
:note
,
noteable:
issue
,
project:
project
,
author:
user
)
}
...
...
spec/support/shared_examples/requests/api/discussions.rb
View file @
b7a68f79
# frozen_string_literal: true
shared_examples
'with cross-reference system notes'
do
let
(
:merge_request
)
{
create
(
:merge_request
)
}
let
(
:project
)
{
merge_request
.
project
}
let
(
:new_merge_request
)
{
create
(
:merge_request
)
}
let
(
:commit
)
{
new_merge_request
.
project
.
commit
}
let!
(
:note
)
{
create
(
:system_note
,
noteable:
merge_request
,
project:
project
,
note:
cross_reference
)
}
let!
(
:note_metadata
)
{
create
(
:system_note_metadata
,
note:
note
,
action:
'cross_reference'
)
}
let
(
:cross_reference
)
{
"test commit
#{
commit
.
to_reference
(
project
)
}
"
}
let
(
:pat
)
{
create
(
:personal_access_token
,
user:
user
)
}
before
do
project
.
add_developer
(
user
)
new_merge_request
.
project
.
add_developer
(
user
)
hidden_merge_request
=
create
(
:merge_request
)
new_cross_reference
=
"test commit
#{
hidden_merge_request
.
project
.
commit
}
"
new_note
=
create
(
:system_note
,
noteable:
merge_request
,
project:
project
,
note:
new_cross_reference
)
create
(
:system_note_metadata
,
note:
new_note
,
action:
'cross_reference'
)
end
it
'returns only the note that the user should see'
do
get
api
(
url
,
user
,
personal_access_token:
pat
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
json_response
.
count
).
to
eq
(
1
)
expect
(
notes_in_response
.
count
).
to
eq
(
1
)
parsed_note
=
notes_in_response
.
first
expect
(
parsed_note
[
'id'
]).
to
eq
(
note
.
id
)
expect
(
parsed_note
[
'body'
]).
to
eq
(
cross_reference
)
expect
(
parsed_note
[
'system'
]).
to
be
true
end
it
'avoids Git calls and N+1 SQL queries'
,
:request_store
do
expect_any_instance_of
(
Repository
).
not_to
receive
(
:find_commit
).
with
(
commit
.
id
)
control
=
ActiveRecord
::
QueryRecorder
.
new
do
get
api
(
url
,
user
,
personal_access_token:
pat
)
end
expect
(
response
).
to
have_gitlab_http_status
(
200
)
RequestStore
.
clear!
new_note
=
create
(
:system_note
,
noteable:
merge_request
,
project:
project
,
note:
cross_reference
)
create
(
:system_note_metadata
,
note:
new_note
,
action:
'cross_reference'
)
RequestStore
.
clear!
expect
{
get
api
(
url
,
user
,
personal_access_token:
pat
)
}.
not_to
exceed_query_limit
(
control
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
end
end
shared_examples
'discussions API'
do
|
parent_type
,
noteable_type
,
id_name
,
can_reply_to_individual_notes:
false
|
describe
"GET /
#{
parent_type
}
/:id/
#{
noteable_type
}
/:noteable_id/discussions"
do
it
"returns an array of discussions"
do
...
...
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