diff options
author | Douwe Maan <douwe@selenight.nl> | 2017-11-16 12:23:50 +0100 |
---|---|---|
committer | Douwe Maan <douwe@selenight.nl> | 2017-11-16 15:12:23 +0100 |
commit | f691010d5c66b543c05ed4d53d663986b05dc90f (patch) | |
tree | 7ae8c49381f97f7be9ccce60d24a6bf695b9b63f /app/controllers | |
parent | a4072db0198896242886d22c644ed91c1016aa8d (diff) | |
download | gitlab-ce-f691010d5c66b543c05ed4d53d663986b05dc90f.tar.gz |
Make sure NotesActions#noteable returns a Noteable in the update actiondm-notes-actions-noteable-for-update
Diffstat (limited to 'app/controllers')
-rw-r--r-- | app/controllers/concerns/notes_actions.rb | 10 | ||||
-rw-r--r-- | app/controllers/snippets/notes_controller.rb | 1 |
2 files changed, 8 insertions, 3 deletions
diff --git a/app/controllers/concerns/notes_actions.rb b/app/controllers/concerns/notes_actions.rb index 3c64fd964ff..be2e1b47feb 100644 --- a/app/controllers/concerns/notes_actions.rb +++ b/app/controllers/concerns/notes_actions.rb @@ -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 diff --git a/app/controllers/snippets/notes_controller.rb b/app/controllers/snippets/notes_controller.rb index f9496787b15..c8b4682e6dc 100644 --- a/app/controllers/snippets/notes_controller.rb +++ b/app/controllers/snippets/notes_controller.rb @@ -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]) |