diff options
-rw-r--r-- | app/controllers/projects/notes_controller.rb | 2 | ||||
-rw-r--r-- | app/policies/note_policy.rb | 2 | ||||
-rw-r--r-- | spec/controllers/projects/notes_controller_spec.rb | 4 |
3 files changed, 4 insertions, 4 deletions
diff --git a/app/controllers/projects/notes_controller.rb b/app/controllers/projects/notes_controller.rb index dd3dc71c004..bb0c1869955 100644 --- a/app/controllers/projects/notes_controller.rb +++ b/app/controllers/projects/notes_controller.rb @@ -77,7 +77,7 @@ class Projects::NotesController < Projects::ApplicationController def authorize_create_note! noteable_type = note_params[:noteable_type] - return unless ['MergeRequest', 'Issue'].include?(noteable_type) + return unless %w[MergeRequest Issue].include?(noteable_type) return access_denied! unless can?(current_user, :create_note, project) noteable = noteable_type.constantize.find(note_params[:noteable_id]) diff --git a/app/policies/note_policy.rb b/app/policies/note_policy.rb index 5d51fbf4f4a..307c514a74b 100644 --- a/app/policies/note_policy.rb +++ b/app/policies/note_policy.rb @@ -7,7 +7,7 @@ class NotePolicy < BasePolicy condition(:is_noteable_author) { @user && @subject.noteable.author_id == @user.id } condition(:editable, scope: :subject) { @subject.editable? } - condition(:locked) { @subject.noteable.discussion_locked? } + condition(:locked) { [MergeRequest, Issue].include?(@subject.noteable.class) && @subject.noteable.discussion_locked? } rule { ~editable | anonymous }.prevent :edit_note diff --git a/spec/controllers/projects/notes_controller_spec.rb b/spec/controllers/projects/notes_controller_spec.rb index 26429b57bd5..10edad462c1 100644 --- a/spec/controllers/projects/notes_controller_spec.rb +++ b/spec/controllers/projects/notes_controller_spec.rb @@ -253,7 +253,7 @@ describe Projects::NotesController do end it 'creates a new note' do - expect{ post :create, request_params }.to change { Note.count }.by(1) + expect { post :create, request_params }.to change { Note.count }.by(1) end end @@ -269,7 +269,7 @@ describe Projects::NotesController do end it 'does not create a new note' do - expect{ post :create, request_params }.not_to change { Note.count } + expect { post :create, request_params }.not_to change { Note.count } end end end |