user_mass_updates_spec.rb 3.28 KB
Newer Older
1 2
require 'rails_helper'

3 4 5
describe 'Merge requests > User mass updates', :js do
  let(:project) { create(:project, :repository) }
  let(:user)    { project.creator }
6 7 8
  let!(:merge_request) { create(:merge_request, source_project: project, target_project: project) }

  before do
9
    project.add_master(user)
10
    sign_in(user)
11 12
  end

13
  context 'status' do
14 15
    describe 'close merge request' do
      before do
16
        visit project_merge_requests_path(project)
17
      end
18

19 20 21 22 23
      it 'closes merge request' do
        change_status('Closed')

        expect(page).to have_selector('.merge-request', count: 0)
      end
24 25
    end

26 27 28
    describe 'reopen merge request' do
      before do
        merge_request.close
29
        visit project_merge_requests_path(project, state: 'closed')
30 31 32 33
      end

      it 'reopens merge request' do
        change_status('Open')
34

35 36
        expect(page).to have_selector('.merge-request', count: 0)
      end
37 38 39
    end
  end

40
  context 'assignee' do
41
    describe 'set assignee' do
42
      before do
43
        visit project_merge_requests_path(project)
44
      end
45

46
      it 'updates merge request with assignee' do
47
        change_assignee(user.name)
48

49 50 51
        page.within('.merge-request .controls') do
          expect(find('.author_link')["title"]).to have_content(user.name)
        end
52 53 54
      end
    end

55
    describe 'remove assignee' do
56 57 58
      before do
        merge_request.assignee = user
        merge_request.save
59
        visit project_merge_requests_path(project)
60
      end
61

62
      it 'removes assignee from the merge request' do
63
        change_assignee('Unassigned')
64

65 66
        expect(find('.merge-request .controls')).not_to have_css('.author_link')
      end
67 68 69
    end
  end

70
  context 'milestone' do
71 72
    let(:milestone)  { create(:milestone, project: project) }

73
    describe 'set milestone' do
74
      before do
75
        visit project_merge_requests_path(project)
76
      end
77

78
      it 'updates merge request with milestone' do
79
        change_milestone(milestone.title)
80

81 82
        expect(find('.merge-request')).to have_content milestone.title
      end
83 84
    end

85
    describe 'unset milestone' do
86 87 88
      before do
        merge_request.milestone = milestone
        merge_request.save
89
        visit project_merge_requests_path(project)
90
      end
91

92
      it 'removes milestone from the merge request' do
93
        change_milestone("No Milestone")
94

95 96 97 98
        expect(find('.merge-request')).not_to have_content milestone.title
      end
    end
  end
99

100
  def change_status(text)
101
    click_button 'Edit merge requests'
102
    find('#check-all-issues').click
103 104 105 106
    find('.js-issue-status').click
    find('.dropdown-menu-status a', text: text).click
    click_update_merge_requests_button
  end
107

108
  def change_assignee(text)
109
    click_button 'Edit merge requests'
110
    find('#check-all-issues').click
111
    find('.js-update-assignee').click
112
    wait_for_requests
113

114 115
    page.within '.dropdown-menu-user' do
      click_link text
116
    end
117 118

    click_update_merge_requests_button
119 120
  end

121
  def change_milestone(text)
122
    click_button 'Edit merge requests'
123 124
    find('#check-all-issues').click
    find('.issues-bulk-update .js-milestone-select').click
125 126
    find('.dropdown-menu-milestone a', text: text).click
    click_update_merge_requests_button
127 128 129
  end

  def click_update_merge_requests_button
130
    find('.update-selected-issues').click
131
    wait_for_requests
132 133
  end
end