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
Boxiang Sun
gitlab-ce
Commits
f691010d
Commit
f691010d
authored
Nov 16, 2017
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make sure NotesActions#noteable returns a Noteable in the update action
parent
a4072db0
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
36 additions
and
3 deletions
+36
-3
app/controllers/concerns/notes_actions.rb
app/controllers/concerns/notes_actions.rb
+7
-3
app/controllers/snippets/notes_controller.rb
app/controllers/snippets/notes_controller.rb
+1
-0
changelogs/unreleased/dm-notes-actions-noteable-for-update.yml
...elogs/unreleased/dm-notes-actions-noteable-for-update.yml
+5
-0
spec/controllers/projects/notes_controller_spec.rb
spec/controllers/projects/notes_controller_spec.rb
+23
-0
No files found.
app/controllers/concerns/notes_actions.rb
View file @
f691010d
...
...
@@ -4,7 +4,7 @@ module NotesActions
included
do
before_action
:set_polling_interval_header
,
only:
[
:index
]
before_action
:
noteable
,
only: :index
before_action
:
require_noteable!
,
only:
[
:index
,
:create
]
before_action
:authorize_admin_note!
,
only:
[
:update
,
:destroy
]
before_action
:note_project
,
only:
[
:create
]
end
...
...
@@ -90,7 +90,7 @@ module NotesActions
if
note
.
persisted?
attrs
[
:valid
]
=
true
if
noteable
.
nil?
||
noteable
.
discussions_rendered_on_frontend?
if
noteable
.
discussions_rendered_on_frontend?
attrs
.
merge!
(
note_serializer
.
represent
(
note
))
else
attrs
.
merge!
(
...
...
@@ -191,7 +191,11 @@ module NotesActions
end
def
noteable
@noteable
||=
notes_finder
.
target
||
render_404
@noteable
||=
notes_finder
.
target
||
@note
&
.
noteable
end
def
require_noteable!
render_404
unless
noteable
end
def
last_fetched_at
...
...
app/controllers/snippets/notes_controller.rb
View file @
f691010d
...
...
@@ -20,6 +20,7 @@ class Snippets::NotesController < ApplicationController
def
snippet
PersonalSnippet
.
find_by
(
id:
params
[
:snippet_id
])
end
alias_method
:noteable
,
:snippet
def
note_params
super
.
merge
(
noteable_id:
params
[
:snippet_id
])
...
...
changelogs/unreleased/dm-notes-actions-noteable-for-update.yml
0 → 100644
View file @
f691010d
---
title
:
Make sure NotesActions#noteable returns a Noteable in the update action
merge_request
:
author
:
type
:
fixed
spec/controllers/projects/notes_controller_spec.rb
View file @
f691010d
...
...
@@ -336,6 +336,29 @@ describe Projects::NotesController do
end
end
describe
'PUT update'
do
let
(
:request_params
)
do
{
namespace_id:
project
.
namespace
,
project_id:
project
,
id:
note
,
format: :json
,
note:
{
note:
"New comment"
}
}
end
before
do
sign_in
(
note
.
author
)
project
.
team
<<
[
note
.
author
,
:developer
]
end
it
"updates the note"
do
expect
{
put
:update
,
request_params
}.
to
change
{
note
.
reload
.
note
}
end
end
describe
'DELETE destroy'
do
let
(
:request_params
)
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