Commit a2cd8492 authored by Nick Thomas's avatar Nick Thomas

Merge branch '28154-remove-batch-comments-license-requirement' into 'master'

Remove license requirement for batch comments

See merge request gitlab-org/gitlab!32625
parents 11271ac4 a20c3919
......@@ -5,7 +5,6 @@ class Projects::MergeRequests::DraftsController < Projects::MergeRequests::Appli
respond_to :json
before_action :check_draft_notes_available!, except: [:index]
before_action :authorize_create_note!, only: [:create, :publish]
before_action :authorize_admin_draft!, only: [:update, :destroy]
before_action :authorize_admin_draft!, if: -> { action_name == 'publish' && params[:id].present? }
......@@ -68,7 +67,7 @@ class Projects::MergeRequests::DraftsController < Projects::MergeRequests::Appli
end
def draft_notes
return unless current_user && draft_notes_available?
return unless current_user
strong_memoize(:draft_notes) do
merge_request.draft_notes.authored_by(current_user)
......@@ -120,10 +119,6 @@ class Projects::MergeRequests::DraftsController < Projects::MergeRequests::Appli
note
end
def draft_notes_available?
@project.feature_available?(:batch_comments, current_user)
end
def authorize_admin_draft!
access_denied! unless can?(current_user, :admin_note, draft_note)
end
......@@ -131,10 +126,4 @@ class Projects::MergeRequests::DraftsController < Projects::MergeRequests::Appli
def authorize_create_note!
access_denied! unless can?(current_user, :create_note, merge_request)
end
def check_draft_notes_available!
return if draft_notes_available?
access_denied!('Draft Notes are not available with your current License')
end
end
......@@ -25,7 +25,7 @@ module EE
explanation _('Submit the current review.')
types MergeRequest
condition do
quick_action_target.persisted? && quick_action_target.project.feature_available?(:batch_comments, current_user)
quick_action_target.persisted?
end
command :submit_review do
next if params[:review_id]
......
......@@ -19,7 +19,7 @@ describe Projects::MergeRequests::DraftsController do
before do
sign_in(user)
stub_licensed_features(batch_comments: true, multiple_merge_request_assignees: true)
stub_licensed_features(multiple_merge_request_assignees: true)
stub_commonmark_sourcepos_disabled
end
......@@ -451,91 +451,4 @@ describe Projects::MergeRequests::DraftsController do
end
end
end
shared_examples_for 'batch comments feature disabled' do
context 'GET #index' do
it 'does not return existing drafts' do
create_list(:draft_note, 4, merge_request: merge_request, author: user)
get :index, params: params
expect(json_response).to eq([])
end
end
context 'POST #create' do
it 'errors out' do
expect do
post :create, params: params.merge(draft_note: { note: 'comment' })
end.to change { DraftNote.count }.by(0)
expect(response).to have_gitlab_http_status(:forbidden)
end
end
context 'PUT #update' do
it 'errors out' do
draft = create(:draft_note, merge_request: merge_request, author: user)
expect do
put :update, params: params.merge(id: draft.id, draft_note: { note: 'comment' })
end.to change { DraftNote.count }.by(0)
expect(response).to have_gitlab_http_status(:forbidden)
end
end
context 'DELETE #destroy' do
it 'errors out' do
draft = create(:draft_note, merge_request: merge_request, author: user)
expect { delete :destroy, params: params.merge(id: draft.id) }.to change { DraftNote.count }.by(0)
expect(response).to have_gitlab_http_status(:forbidden)
end
end
context 'collection endpoints' do
before do
create_list(:draft_note, 5, merge_request: merge_request, author: user)
end
context 'POST #publish' do
it 'errors out' do
expect do
post :publish, params: params
end.to change { DraftNote.count }.by(0).and change { Note.count }.by(0)
expect(response).to have_gitlab_http_status(:forbidden)
expect(DraftNote.count).to eq(5)
end
end
context 'DELETE #discard' do
it 'errors out' do
expect do
delete :discard, params: params
end.to change { DraftNote.count }.by(0)
expect(response).to have_gitlab_http_status(:forbidden)
expect(DraftNote.count).to eq(5)
end
end
end
end
context 'disabled due to license' do
before do
stub_licensed_features(batch_comments: false)
end
it_behaves_like 'batch comments feature disabled'
end
context 'disabled via feature flag' do
before do
stub_feature_flags(batch_comments: false)
end
it_behaves_like 'batch comments feature disabled'
end
end
......@@ -676,10 +676,6 @@ describe QuickActions::InterpretService do
let(:content) { '/submit_review' }
let!(:draft_note) { create(:draft_note, note: note, merge_request: merge_request, author: current_user) }
before do
stub_licensed_features(batch_comments: true)
end
it 'submits the users current review' do
_, _, message = service.execute(content, merge_request)
......
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