summaryrefslogtreecommitdiff
path: root/spec/support/shared_examples/quick_actions/merge_request/wip_quick_action_shared_examples.rb
blob: 60d6e53e74f121138c1430b3226b476cbbe96b7a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
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