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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-ce
Commits
f5240f97
Commit
f5240f97
authored
Mar 15, 2016
by
Rémy Coutable
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Expose MergeRequest#user_notes_count in the API and use the method in issues list
Signed-off-by:
Rémy Coutable
<
remy@rymai.me
>
parent
53644007
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
73 additions
and
45 deletions
+73
-45
CHANGELOG
CHANGELOG
+1
-3
app/views/projects/issues/_issue.html.haml
app/views/projects/issues/_issue.html.haml
+4
-10
app/views/projects/merge_requests/_merge_request.html.haml
app/views/projects/merge_requests/_merge_request.html.haml
+4
-10
doc/api/merge_requests.md
doc/api/merge_requests.md
+15
-7
lib/api/entities.rb
lib/api/entities.rb
+1
-1
spec/requests/api/issues_spec.rb
spec/requests/api/issues_spec.rb
+20
-14
spec/requests/api/merge_requests_spec.rb
spec/requests/api/merge_requests_spec.rb
+28
-0
No files found.
CHANGELOG
View file @
f5240f97
...
...
@@ -25,6 +25,7 @@ v 8.8.0 (unreleased)
- Added button to toggle whitespaces changes on diff view
- Backport GitHub Enterprise import support from EE
- Create tags using Rugged for performance reasons. !3745
- API: Expose Issue#user_notes_count. !3126 (Anton Popov)
- Files over 5MB can only be viewed in their raw form, files over 1MB without highlighting !3718
- Add support for supressing text diffs using .gitattributes on the default branch (Matt Oakes)
- Added multiple colors for labels in dropdowns when dups happen.
...
...
@@ -51,9 +52,6 @@ v 8.7.2
- Label titles in filters are now escaped properly
v 8.7.1
- API: Expose Issue#user_notes_count (Anton Popov)
v 8.7.1 (unreleased)
- Throttle the update of `project.last_activity_at` to 1 minute. !3848
- Fix .gitlab-ci.yml parsing issue when hidde job is a template without script definition. !3849
- Fix license detection to detect all license files, not only known licenses. !3878
...
...
app/views/projects/issues/_issue.html.haml
View file @
f5240f97
...
...
@@ -28,16 +28,10 @@
=
downvotes
-
note_count
=
issue
.
notes
.
user
.
nonawards
.
count
-
if
note_count
>
0
%li
=
link_to
issue_path
(
issue
)
+
"#notes"
do
=
icon
(
'comments'
)
=
note_count
-
else
%li
=
link_to
issue_path
(
issue
)
+
"#notes"
,
class:
"issue-no-comments"
do
=
icon
(
'comments'
)
=
note_count
%li
=
link_to
issue_path
(
issue
,
anchor:
'notes'
),
class:
(
'issue-no-comments'
if
note_count
.
zero?
)
do
=
icon
(
'comments'
)
=
note_count
.issue-info
#{
issue
.
to_reference
}
·
...
...
app/views/projects/merge_requests/_merge_request.html.haml
View file @
f5240f97
...
...
@@ -36,16 +36,10 @@
=
downvotes
-
note_count
=
merge_request
.
mr_and_commit_notes
.
user
.
nonawards
.
count
-
if
note_count
>
0
%li
=
link_to
merge_request_path
(
merge_request
)
+
"#notes"
do
=
icon
(
'comments'
)
=
note_count
-
else
%li
=
link_to
merge_request_path
(
merge_request
)
+
"#notes"
,
class:
"merge-request-no-comments"
do
=
icon
(
'comments'
)
=
note_count
%li
=
link_to
merge_request_path
(
merge_request
,
anchor:
'notes'
),
class:
(
'merge-request-no-comments'
if
note_count
.
zero?
)
do
=
icon
(
'comments'
)
=
note_count
.merge-request-info
#{
merge_request
.
to_reference
}
·
...
...
doc/api/merge_requests.md
View file @
f5240f97
...
...
@@ -67,7 +67,8 @@ Parameters:
},
"merge_when_build_succeeds"
:
true
,
"merge_status"
:
"can_be_merged"
,
"subscribed"
:
false
"subscribed"
:
false
,
"user_notes_count"
:
1
}
]
```
...
...
@@ -130,7 +131,8 @@ Parameters:
},
"merge_when_build_succeeds"
:
true
,
"merge_status"
:
"can_be_merged"
,
"subscribed"
:
true
"subscribed"
:
true
,
"user_notes_count"
:
1
}
```
...
...
@@ -230,6 +232,7 @@ Parameters:
"merge_when_build_succeeds"
:
true
,
"merge_status"
:
"can_be_merged"
,
"subscribed"
:
true
,
"user_notes_count"
:
1
,
"changes"
:
[
{
"old_path"
:
"VERSION"
,
...
...
@@ -308,7 +311,8 @@ Parameters:
},
"merge_when_build_succeeds"
:
true
,
"merge_status"
:
"can_be_merged"
,
"subscribed"
:
true
"subscribed"
:
true
,
"user_notes_count"
:
0
}
```
...
...
@@ -378,7 +382,8 @@ Parameters:
},
"merge_when_build_succeeds"
:
true
,
"merge_status"
:
"can_be_merged"
,
"subscribed"
:
true
"subscribed"
:
true
,
"user_notes_count"
:
1
}
```
...
...
@@ -472,7 +477,8 @@ Parameters:
},
"merge_when_build_succeeds"
:
true
,
"merge_status"
:
"can_be_merged"
,
"subscribed"
:
true
"subscribed"
:
true
,
"user_notes_count"
:
1
}
```
...
...
@@ -537,7 +543,8 @@ Parameters:
},
"merge_when_build_succeeds"
:
true
,
"merge_status"
:
"can_be_merged"
,
"subscribed"
:
true
"subscribed"
:
true
,
"user_notes_count"
:
1
}
```
...
...
@@ -602,7 +609,8 @@ Example response:
"title"
:
"Consequatur vero maxime deserunt laboriosam est voluptas dolorem."
,
"created_at"
:
"2016-01-04T15:31:51.081Z"
,
"iid"
:
6
,
"labels"
:
[]
"labels"
:
[],
"user_notes_count"
:
1
},
]
```
...
...
lib/api/entities.rb
View file @
f5240f97
...
...
@@ -187,10 +187,10 @@ module API
expose
:milestone
,
using:
Entities
::
Milestone
expose
:merge_when_build_succeeds
expose
:merge_status
expose
:subscribed
do
|
merge_request
,
options
|
merge_request
.
subscribed?
(
options
[
:current_user
])
end
expose
:user_notes_count
end
class
MergeRequestChanges
<
MergeRequest
...
...
spec/requests/api/issues_spec.rb
View file @
f5240f97
...
...
@@ -39,7 +39,7 @@ describe API::API, api: true do
let!
(
:empty_milestone
)
do
create
(
:milestone
,
title:
'2.0.0'
,
project:
project
)
end
let!
(
:
issue_note
)
{
create
(
:note
,
noteable:
issue
,
project:
project
,
author:
user
)
}
let!
(
:
note
)
{
create
(
:note_on_issue
,
author:
user
,
project:
project
,
noteable:
issue
)
}
before
{
project
.
team
<<
[
user
,
:reporter
]
}
...
...
@@ -129,13 +129,6 @@ describe API::API, api: true do
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
length
).
to
eq
(
0
)
end
it
'should return an count notes in issue'
do
get
api
(
"/issues"
,
user
)
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
first
[
'user_notes_count'
]).
to
eq
(
1
)
end
end
end
...
...
@@ -237,18 +230,31 @@ describe API::API, api: true do
expect
(
json_response
.
length
).
to
eq
(
1
)
expect
(
json_response
.
first
[
'id'
]).
to
eq
(
closed_issue
.
id
)
end
end
describe
"GET /projects/:id/issues/:issue_id"
do
it
'exposes known attributes'
do
get
api
(
"/projects/
#{
project
.
id
}
/issues/
#{
issue
.
id
}
"
,
user
)
it
'should return an count notes in issue'
do
get
api
(
"
#{
base_url
}
/issues"
,
user
)
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
first
[
'user_notes_count'
]).
to
eq
(
1
)
expect
(
json_response
[
'id'
]).
to
eq
(
issue
.
id
)
expect
(
json_response
[
'iid'
]).
to
eq
(
issue
.
iid
)
expect
(
json_response
[
'project_id'
]).
to
eq
(
issue
.
project
.
id
)
expect
(
json_response
[
'title'
]).
to
eq
(
issue
.
title
)
expect
(
json_response
[
'description'
]).
to
eq
(
issue
.
description
)
expect
(
json_response
[
'state'
]).
to
eq
(
issue
.
state
)
expect
(
json_response
[
'created_at'
]).
to
be_present
expect
(
json_response
[
'updated_at'
]).
to
be_present
expect
(
json_response
[
'labels'
]).
to
eq
(
issue
.
label_names
)
expect
(
json_response
[
'milestone'
]).
to
be_a
Hash
expect
(
json_response
[
'assignee'
]).
to
be_a
Hash
expect
(
json_response
[
'author'
]).
to
be_a
Hash
expect
(
json_response
[
'user_notes_count'
]).
to
be
(
1
)
end
end
describe
"GET /projects/:id/issues/:issue_id"
do
it
"should return a project issue by id"
do
get
api
(
"/projects/
#{
project
.
id
}
/issues/
#{
issue
.
id
}
"
,
user
)
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
json_response
[
'title'
]).
to
eq
(
issue
.
title
)
expect
(
json_response
[
'iid'
]).
to
eq
(
issue
.
iid
)
...
...
spec/requests/api/merge_requests_spec.rb
View file @
f5240f97
...
...
@@ -113,6 +113,34 @@ describe API::API, api: true do
end
describe
"GET /projects/:id/merge_requests/:merge_request_id"
do
it
'exposes known attributes'
do
get
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
id
}
"
,
user
)
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
json_response
[
'id'
]).
to
eq
(
merge_request
.
id
)
expect
(
json_response
[
'iid'
]).
to
eq
(
merge_request
.
iid
)
expect
(
json_response
[
'project_id'
]).
to
eq
(
merge_request
.
project
.
id
)
expect
(
json_response
[
'title'
]).
to
eq
(
merge_request
.
title
)
expect
(
json_response
[
'description'
]).
to
eq
(
merge_request
.
description
)
expect
(
json_response
[
'state'
]).
to
eq
(
merge_request
.
state
)
expect
(
json_response
[
'created_at'
]).
to
be_present
expect
(
json_response
[
'updated_at'
]).
to
be_present
expect
(
json_response
[
'labels'
]).
to
eq
(
merge_request
.
label_names
)
expect
(
json_response
[
'milestone'
]).
to
be_nil
expect
(
json_response
[
'assignee'
]).
to
be_a
Hash
expect
(
json_response
[
'author'
]).
to
be_a
Hash
expect
(
json_response
[
'target_branch'
]).
to
eq
(
merge_request
.
target_branch
)
expect
(
json_response
[
'source_branch'
]).
to
eq
(
merge_request
.
source_branch
)
expect
(
json_response
[
'upvotes'
]).
to
eq
(
0
)
expect
(
json_response
[
'downvotes'
]).
to
eq
(
0
)
expect
(
json_response
[
'source_project_id'
]).
to
eq
(
merge_request
.
source_project
.
id
)
expect
(
json_response
[
'target_project_id'
]).
to
eq
(
merge_request
.
target_project
.
id
)
expect
(
json_response
[
'work_in_progress'
]).
to
be_falsy
expect
(
json_response
[
'merge_when_build_succeeds'
]).
to
be_falsy
expect
(
json_response
[
'merge_status'
]).
to
eq
(
'can_be_merged'
)
expect
(
json_response
[
'user_notes_count'
]).
to
be
(
2
)
end
it
"should return merge_request"
do
get
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
id
}
"
,
user
)
expect
(
response
.
status
).
to
eq
(
200
)
...
...
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