Commit 2b82f907 authored by Jarka Kadlecova's avatar Jarka Kadlecova

Check the discussion lock only for issuables & clean style

parent 3d2917bf
......@@ -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])
......
......@@ -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
......
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment