Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2018-07-26 10:52:39 +0300
committerDouwe Maan <douwe@gitlab.com>2018-07-26 10:52:39 +0300
commit64661425add7308ddadcc5866e082b95b208c2c3 (patch)
tree5232c75dc25c92cfdcc990cf20ef456ae7beae77 /spec/requests
parent447ccbe4060ee155407990670f72db6f577a1da8 (diff)
parent3bcb04f100f5e982379fbeae37a30a191581d1ef (diff)
Merge branch 'bvl-graphql-wip-mutation' into 'master'
toggle wip status using GraphQL mutation Closes #48719 See merge request gitlab-org/gitlab-ce!20443
Diffstat (limited to 'spec/requests')
-rw-r--r--spec/requests/api/graphql/mutations/merge_requests/set_wip_spec.rb68
1 files changed, 68 insertions, 0 deletions
diff --git a/spec/requests/api/graphql/mutations/merge_requests/set_wip_spec.rb b/spec/requests/api/graphql/mutations/merge_requests/set_wip_spec.rb
new file mode 100644
index 00000000000..8f427d71a32
--- /dev/null
+++ b/spec/requests/api/graphql/mutations/merge_requests/set_wip_spec.rb
@@ -0,0 +1,68 @@
+require 'spec_helper'
+
+describe 'Setting WIP status of a merge request' do
+ include GraphqlHelpers
+
+ let(:current_user) { create(:user) }
+ let(:merge_request) { create(:merge_request) }
+ let(:project) { merge_request.project }
+ let(:input) { { wip: true } }
+
+ let(:mutation) do
+ variables = {
+ project_path: project.full_path,
+ iid: merge_request.iid
+ }
+ graphql_mutation(:merge_request_set_wip, variables.merge(input))
+ end
+
+ def mutation_response
+ graphql_mutation_response(:merge_request_set_wip)
+ end
+
+ before do
+ project.add_developer(current_user)
+ end
+
+ it 'returns an error if the user is not allowed to update the merge request' do
+ post_graphql_mutation(mutation, current_user: create(:user))
+
+ expect(graphql_errors).not_to be_empty
+ end
+
+ it 'marks the merge request as WIP' do
+ post_graphql_mutation(mutation, current_user: current_user)
+
+ expect(response).to have_gitlab_http_status(:success)
+ expect(mutation_response['mergeRequest']['title']).to start_with('WIP:')
+ end
+
+ it 'does not do anything if the merge request was already marked `WIP`' do
+ merge_request.update!(title: 'wip: hello world')
+
+ post_graphql_mutation(mutation, current_user: current_user)
+
+ expect(response).to have_gitlab_http_status(:success)
+ expect(mutation_response['mergeRequest']['title']).to start_with('wip:')
+ end
+
+ context 'when passing WIP false as input' do
+ let(:input) { { wip: false } }
+
+ it 'does not do anything if the merge reqeust was not marked wip' do
+ post_graphql_mutation(mutation, current_user: current_user)
+
+ expect(response).to have_gitlab_http_status(:success)
+ expect(mutation_response['mergeRequest']['title']).not_to start_with(/wip\:/)
+ end
+
+ it 'unmarks the merge request as `WIP`' do
+ merge_request.update!(title: 'wip: hello world')
+
+ post_graphql_mutation(mutation, current_user: current_user)
+
+ expect(response).to have_gitlab_http_status(:success)
+ expect(mutation_response['mergeRequest']['title']).not_to start_with('/wip\:/')
+ end
+ end
+end