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
Jérome Perrin
gitlab-ce
Commits
d78037c2
Commit
d78037c2
authored
Aug 11, 2017
by
Jarka Kadlecova
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use UserNoteEntity instead of UserEntity for notes
parent
345df208
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
78 additions
and
4 deletions
+78
-4
app/serializers/note_entity.rb
app/serializers/note_entity.rb
+2
-2
app/serializers/user_entity.rb
app/serializers/user_entity.rb
+0
-2
app/serializers/user_note_entity.rb
app/serializers/user_note_entity.rb
+9
-0
spec/controllers/projects/issues_controller_spec.rb
spec/controllers/projects/issues_controller_spec.rb
+16
-0
spec/serializers/note_entity_spec.rb
spec/serializers/note_entity_spec.rb
+51
-0
No files found.
app/serializers/note_entity.rb
View file @
d78037c2
...
...
@@ -3,7 +3,7 @@ class NoteEntity < API::Entities::Note
expose
:type
expose
:author
,
using:
UserEntity
expose
:author
,
using:
User
Note
Entity
expose
:human_access
do
|
note
|
note
.
project
.
team
.
human_max_access
(
note
.
author_id
)
...
...
@@ -15,7 +15,7 @@ class NoteEntity < API::Entities::Note
expose
:redacted_note_html
,
as: :note_html
expose
:last_edited_at
,
if:
->
(
note
,
_
)
{
note
.
is_edited?
}
expose
:last_edited_by
,
using:
UserEntity
,
if:
->
(
note
,
_
)
{
note
.
is_edited?
}
expose
:last_edited_by
,
using:
User
Note
Entity
,
if:
->
(
note
,
_
)
{
note
.
is_edited?
}
expose
:current_user
do
expose
:can_edit
do
|
note
|
...
...
app/serializers/user_entity.rb
View file @
d78037c2
class
UserEntity
<
API
::
Entities
::
UserBasic
include
RequestAwareEntity
unexpose
:web_url
expose
:path
do
|
user
|
user_path
(
user
)
end
...
...
app/serializers/user_note_entity.rb
0 → 100644
View file @
d78037c2
class
UserNoteEntity
<
API
::
Entities
::
UserBasic
include
RequestAwareEntity
unexpose
:web_url
expose
:path
do
|
user
|
user_path
(
user
)
end
end
spec/controllers/projects/issues_controller_spec.rb
View file @
d78037c2
...
...
@@ -877,4 +877,20 @@ describe Projects::IssuesController do
format: :json
end
end
describe
'GET #discussions'
do
let!
(
:discussion
)
{
create
(
:discussion_note_on_issue
,
noteable:
issue
,
project:
issue
.
project
)
}
before
do
project
.
add_developer
(
user
)
sign_in
(
user
)
end
it
'returns discussion json'
do
get
:discussions
,
namespace_id:
project
.
namespace
,
project_id:
project
,
id:
issue
.
iid
expect
(
JSON
.
parse
(
response
.
body
).
first
.
keys
).
to
match_array
(
[
'id'
,
'reply_id'
,
'expanded'
,
'notes'
,
'individual_note'
])
end
end
end
spec/serializers/note_entity_spec.rb
0 → 100644
View file @
d78037c2
require
'spec_helper'
describe
NoteEntity
do
include
Gitlab
::
Routing
let
(
:request
)
{
double
(
'request'
,
current_user:
user
,
noteable:
note
.
noteable
)
}
let
(
:entity
)
{
described_class
.
new
(
note
,
request:
request
)
}
let
(
:note
)
{
create
(
:note
)
}
let
(
:user
)
{
create
(
:user
)
}
subject
{
entity
.
as_json
}
context
'basic note'
do
it
'exposes correct elements'
do
expect
(
subject
).
to
include
(
:type
,
:author
,
:human_access
,
:note
,
:note_html
,
:current_user
,
:discussion_id
,
:emoji_awardable
,
:award_emoji
,
:toggle_award_path
,
:report_abuse_path
,
:path
,
:attachment
)
end
it
'does not expose elements for specific notes cases'
do
expect
(
subject
).
not_to
include
(
:last_edited_by
,
:last_edited_at
,
:system_note_icon_name
)
end
it
'exposes author correctly'
do
expect
(
subject
[
:author
]).
to
include
(
:id
,
:name
,
:username
,
:state
,
:avatar_url
,
:path
)
end
it
'does not expose web_url for author'
do
expect
(
subject
[
:author
]).
not_to
include
(
:web_url
)
end
end
context
'when note was edited'
do
before
do
note
.
update
(
updated_at:
1
.
minute
.
from_now
,
updated_by:
user
)
end
it
'exposes last_edited_at and last_edited_by elements'
do
expect
(
subject
).
to
include
(
:last_edited_at
,
:last_edited_by
)
end
end
context
'when note is a system note'
do
before
do
note
.
update
(
system:
true
)
end
it
'exposes system_note_icon_name element'
do
expect
(
subject
).
to
include
(
:system_note_icon_name
)
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