summaryrefslogtreecommitdiff
path: root/spec/controllers/projects/notes_controller_spec.rb
diff options
context:
space:
mode:
authorHeinrich Lee Yu <heinrich@gitlab.com>2019-03-15 08:07:52 +0800
committerBrett Walker <bwalker@gitlab.com>2019-03-18 13:28:35 -0500
commit3d85406734fc31bb9c9fb95ce26898b65b60b3ea (patch)
treeb7f51a67e2f6b4fc01c6e7b75b381f205102136f /spec/controllers/projects/notes_controller_spec.rb
parent45a4bc300c52a6cf17049626ea682d039efa9fc7 (diff)
downloadgitlab-ce-3d85406734fc31bb9c9fb95ce26898b65b60b3ea.tar.gz
Only return `commands_changes` used in frontend
When executing quick actions, this limits the `commands_changes` response to only those used by the frontend
Diffstat (limited to 'spec/controllers/projects/notes_controller_spec.rb')
-rw-r--r--spec/controllers/projects/notes_controller_spec.rb31
1 files changed, 31 insertions, 0 deletions
diff --git a/spec/controllers/projects/notes_controller_spec.rb b/spec/controllers/projects/notes_controller_spec.rb
index 0b0f5117784..deecb7fefe9 100644
--- a/spec/controllers/projects/notes_controller_spec.rb
+++ b/spec/controllers/projects/notes_controller_spec.rb
@@ -413,6 +413,37 @@ describe Projects::NotesController do
end
end
end
+
+ context 'when creating a note with quick actions' do
+ context 'with commands that return changes' do
+ let(:note_text) { "/award :thumbsup:\n/estimate 1d\n/spend 3h" }
+
+ it 'includes changes in commands_changes ' do
+ post :create, params: request_params.merge(note: { note: note_text }, format: :json)
+
+ expect(response).to have_gitlab_http_status(200)
+ expect(json_response['commands_changes']).to include('emoji_award', 'time_estimate', 'spend_time')
+ expect(json_response['commands_changes']).not_to include('target_project', 'title')
+ end
+ end
+
+ context 'with commands that do not return changes' do
+ let(:issue) { create(:issue, project: project) }
+ let(:other_project) { create(:project) }
+ let(:note_text) { "/move #{other_project.full_path}\n/title AAA" }
+
+ before do
+ other_project.add_developer(user)
+ end
+
+ it 'does not include changes in commands_changes' do
+ post :create, params: request_params.merge(note: { note: note_text }, target_type: 'issue', target_id: issue.id, format: :json)
+
+ expect(response).to have_gitlab_http_status(200)
+ expect(json_response['commands_changes']).not_to include('target_project', 'title')
+ end
+ end
+ end
end
describe 'PUT update' do