summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexandru Croitor <acroitor@gitlab.com>2019-04-03 14:56:08 +0300
committerAlexandru Croitor <acroitor@gitlab.com>2019-04-05 23:10:31 +0300
commit42fe7e91b3d306596a92b9103ccbdf900493a50a (patch)
tree119c2018c39ad13fcfaf42a174a0e89ab895c03d
parentd793d4a7c30c7e16e43b8f4d393c393fe9e7ab3f (diff)
downloadgitlab-ce-59570-wip-quick-action.tar.gz
Extract wip quick action to a shared example59570-wip-quick-action
-rw-r--r--spec/features/merge_request/user_uses_quick_actions_spec.rb48
-rw-r--r--spec/support/shared_examples/quick_actions/merge_request/wip_quick_action_shared_examples.rb43
2 files changed, 44 insertions, 47 deletions
diff --git a/spec/features/merge_request/user_uses_quick_actions_spec.rb b/spec/features/merge_request/user_uses_quick_actions_spec.rb
index 5e466fb41d0..8d308729f62 100644
--- a/spec/features/merge_request/user_uses_quick_actions_spec.rb
+++ b/spec/features/merge_request/user_uses_quick_actions_spec.rb
@@ -58,52 +58,6 @@ describe 'Merge request > User uses quick actions', :js do
it_behaves_like 'merge quick action'
it_behaves_like 'target_branch quick action'
-
- describe 'toggling the WIP prefix in the title from note' do
- context 'when the current user can toggle the WIP prefix' do
- before do
- sign_in(user)
- visit project_merge_request_path(project, merge_request)
- wait_for_requests
- end
-
- it 'adds the WIP: prefix to the title' do
- add_note("/wip")
-
- expect(page).not_to have_content '/wip'
- expect(page).to have_content 'Commands applied'
-
- expect(merge_request.reload.work_in_progress?).to eq true
- end
-
- it 'removes the WIP: prefix from the title' do
- merge_request.title = merge_request.wip_title
- merge_request.save
- add_note("/wip")
-
- expect(page).not_to have_content '/wip'
- expect(page).to have_content 'Commands applied'
-
- expect(merge_request.reload.work_in_progress?).to eq false
- end
- end
-
- context 'when the current user cannot toggle the WIP prefix' do
- before do
- project.add_guest(guest)
- sign_in(guest)
- visit project_merge_request_path(project, merge_request)
- end
-
- it 'does not change the WIP prefix' do
- add_note("/wip")
-
- expect(page).not_to have_content '/wip'
- expect(page).not_to have_content 'Commands applied'
-
- expect(merge_request.reload.work_in_progress?).to eq false
- end
- end
- end
+ it_behaves_like 'wip quick action'
end
end
diff --git a/spec/support/shared_examples/quick_actions/merge_request/wip_quick_action_shared_examples.rb b/spec/support/shared_examples/quick_actions/merge_request/wip_quick_action_shared_examples.rb
index 6abb12b41b2..60d6e53e74f 100644
--- a/spec/support/shared_examples/quick_actions/merge_request/wip_quick_action_shared_examples.rb
+++ b/spec/support/shared_examples/quick_actions/merge_request/wip_quick_action_shared_examples.rb
@@ -1,4 +1,47 @@
# frozen_string_literal: true
shared_examples 'wip quick action' do
+ context 'when the current user can toggle the WIP prefix' do
+ before do
+ sign_in(user)
+ visit project_merge_request_path(project, merge_request)
+ wait_for_requests
+ end
+
+ it 'adds the WIP: prefix to the title' do
+ add_note('/wip')
+
+ expect(page).not_to have_content '/wip'
+ expect(page).to have_content 'Commands applied'
+
+ expect(merge_request.reload.work_in_progress?).to eq true
+ end
+
+ it 'removes the WIP: prefix from the title' do
+ merge_request.update!(title: merge_request.wip_title)
+ add_note('/wip')
+
+ expect(page).not_to have_content '/wip'
+ expect(page).to have_content 'Commands applied'
+
+ expect(merge_request.reload.work_in_progress?).to eq false
+ end
+ end
+
+ context 'when the current user cannot toggle the WIP prefix' do
+ before do
+ project.add_guest(guest)
+ sign_in(guest)
+ visit project_merge_request_path(project, merge_request)
+ end
+
+ it 'does not change the WIP prefix' do
+ add_note('/wip')
+
+ expect(page).not_to have_content '/wip'
+ expect(page).not_to have_content 'Commands applied'
+
+ expect(merge_request.reload.work_in_progress?).to eq false
+ end
+ end
end