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
ceb2db43
Commit
ceb2db43
authored
Aug 08, 2017
by
Sean McGivern
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '36169-fix-master' into 'master'
Fix a broken Events API spec See merge request !13381
parents
97f60b49
164e6604
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
13 deletions
+8
-13
spec/requests/api/events_spec.rb
spec/requests/api/events_spec.rb
+8
-13
No files found.
spec/requests/api/events_spec.rb
View file @
ceb2db43
...
@@ -140,33 +140,28 @@ describe API::Events do
...
@@ -140,33 +140,28 @@ describe API::Events do
end
end
context
'when exists some events'
do
context
'when exists some events'
do
let
(
:merge_request1
)
{
create
(
:merge_request
,
:closed
,
author:
user
,
assignee:
user
,
source_project:
private_project
,
title:
'Test'
)
}
let
(
:merge_request2
)
{
create
(
:merge_request
,
:closed
,
author:
user
,
assignee:
user
,
source_project:
private_project
,
title:
'Test'
)
}
before
do
before
do
create_event
(
note1
)
create_event
(
note2
)
create_event
(
merge_request1
)
create_event
(
merge_request1
)
end
end
let
(
:note1
)
{
create
(
:note_on_merge_request
,
project:
private_project
,
author:
user
)
}
let
(
:note2
)
{
create
(
:note_on_issue
,
project:
private_project
,
author:
user
)
}
let
(
:merge_request1
)
{
create
(
:merge_request
,
state:
'closed'
,
author:
user
,
assignee:
user
,
source_project:
private_project
,
title:
'Test'
)
}
let
(
:merge_request2
)
{
create
(
:merge_request
,
state:
'closed'
,
author:
user
,
assignee:
user
,
source_project:
private_project
,
title:
'Test'
)
}
it
'avoids N+1 queries'
do
it
'avoids N+1 queries'
do
control_count
=
ActiveRecord
::
QueryRecorder
.
new
do
control_count
=
ActiveRecord
::
QueryRecorder
.
new
do
get
api
(
"/projects/
#{
private_project
.
id
}
/events"
,
user
)
get
api
(
"/projects/
#{
private_project
.
id
}
/events"
,
user
)
,
target_type: :merge_request
end
.
count
end
.
count
create_event
(
merge_request2
)
create_event
(
merge_request2
)
expect
do
expect
do
get
api
(
"/projects/
#{
private_project
.
id
}
/events"
,
user
)
get
api
(
"/projects/
#{
private_project
.
id
}
/events"
,
user
)
,
target_type: :merge_request
end
.
not_to
exceed_query_limit
(
control_count
)
end
.
not_to
exceed_query_limit
(
control_count
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
have_
gitlab_
http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
size
).
to
eq
(
2
)
expect
(
json_response
[
0
]).
to
include
(
'target_type'
=>
'MergeRequest'
,
'target_id'
=>
merge_request2
.
id
)
expect
(
json_response
.
map
{
|
r
|
r
[
'target_id'
]
}).
to
match_array
([
merge_request1
.
id
,
merge_request2
.
id
])
expect
(
json_response
[
1
]).
to
include
(
'target_type'
=>
'MergeRequest'
,
'target_id'
=>
merge_request1
.
id
)
end
end
def
create_event
(
target
)
def
create_event
(
target
)
...
...
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