BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
a540f55c
Commit
a540f55c
authored
Aug 30, 2017
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix specs
parent
b181d312
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
16 additions
and
9 deletions
+16
-9
notes_actions.rb
app/controllers/concerns/notes_actions.rb
+1
-1
note.rb
app/models/note.rb
+1
-1
note_entity.rb
app/serializers/note_entity.rb
+2
-2
notes_controller_spec.rb
spec/controllers/projects/notes_controller_spec.rb
+12
-5
No files found.
app/controllers/concerns/notes_actions.rb
View file @
a540f55c
...
...
@@ -89,7 +89,7 @@ module NotesActions
if
note
.
persisted?
attrs
[
:valid
]
=
true
if
noteable
.
discussions_rendered_on_frontend?
if
noteable
.
nil?
||
noteable
.
discussions_rendered_on_frontend?
attrs
.
merge!
(
note_serializer
.
represent
(
note
))
else
attrs
.
merge!
(
...
...
app/models/note.rb
View file @
a540f55c
...
...
@@ -300,7 +300,7 @@ class Note < ActiveRecord::Base
end
def
expire_etag_cache
return
unless
noteable
.
discussions_rendered_on_frontend?
return
unless
noteable
&
.
discussions_rendered_on_frontend?
key
=
Gitlab
::
Routing
.
url_helpers
.
project_noteable_notes_path
(
project
,
...
...
app/serializers/note_entity.rb
View file @
a540f55c
...
...
@@ -14,8 +14,8 @@ 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:
NoteUserEntity
,
if:
->
(
note
,
_
)
{
note
.
is_
edited?
}
expose
:last_edited_at
,
if:
->
(
note
,
_
)
{
note
.
edited?
}
expose
:last_edited_by
,
using:
NoteUserEntity
,
if:
->
(
note
,
_
)
{
note
.
edited?
}
expose
:current_user
do
expose
:can_edit
do
|
note
|
...
...
spec/controllers/projects/notes_controller_spec.rb
View file @
a540f55c
...
...
@@ -46,10 +46,13 @@ describe Projects::NotesController do
end
context
'for a discussion note'
do
let!
(
:note
)
{
create
(
:discussion_note_on_issue
,
noteable:
issue
,
project:
project
)
}
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let!
(
:note
)
{
create
(
:discussion_note_on_merge_request
,
project:
project
)
}
let
(
:params
)
{
request_params
.
merge
(
target_type:
'merge_request'
,
target_id:
note
.
noteable_id
)
}
it
'responds with the expected attributes'
do
get
:index
,
request_
params
get
:index
,
params
expect
(
note_json
[
:id
]).
to
eq
(
note
.
id
)
expect
(
note_json
[
:discussion_html
]).
not_to
be_nil
...
...
@@ -104,10 +107,12 @@ describe Projects::NotesController do
end
context
'for a regular note'
do
let!
(
:note
)
{
create
(
:note
,
noteable:
issue
,
project:
project
)
}
let!
(
:note
)
{
create
(
:note_on_merge_request
,
project:
project
)
}
let
(
:params
)
{
request_params
.
merge
(
target_type:
'merge_request'
,
target_id:
note
.
noteable_id
)
}
it
'responds with the expected attributes'
do
get
:index
,
request_
params
get
:index
,
params
expect
(
note_json
[
:id
]).
to
eq
(
note
.
id
)
expect
(
note_json
[
:html
]).
not_to
be_nil
...
...
@@ -125,7 +130,9 @@ describe Projects::NotesController do
note:
{
note:
'some note'
,
noteable_id:
merge_request
.
id
,
noteable_type:
'MergeRequest'
},
namespace_id:
project
.
namespace
,
project_id:
project
,
merge_request_diff_head_sha:
'sha'
merge_request_diff_head_sha:
'sha'
,
target_type:
'merge_request'
,
target_id:
merge_request
.
id
}
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