BigW Consortium Gitlab

wip_message_spec.rb 1.46 KB
Newer Older
1 2
require 'spec_helper'

3
feature 'Work In Progress help message' do
4
  let!(:project) { create(:project, :public, :repository) }
5 6 7 8
  let!(:user)    { create(:user) }

  before do
    project.team << [user, :master]
9
    sign_in(user)
10 11 12 13
  end

  context 'with WIP commits' do
    it 'shows a specific WIP hint' do
14
      visit project_new_merge_request_path(
15 16 17 18 19 20
        project,
        merge_request: {
          source_project_id: project.id,
          target_project_id: project.id,
          source_branch: 'wip',
          target_branch: 'master'
21
        })
22 23 24 25 26 27 28 29 30 31 32

      within_wip_explanation do
        expect(page).to have_text(
          'It looks like you have some WIP commits in this branch'
        )
      end
    end
  end

  context 'without WIP commits' do
    it 'shows the regular WIP message' do
33
      visit project_new_merge_request_path(
34 35 36 37 38 39
        project,
        merge_request: {
          source_project_id: project.id,
          target_project_id: project.id,
          source_branch: 'fix',
          target_branch: 'master'
40
        })
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59

      within_wip_explanation do
        expect(page).not_to have_text(
          'It looks like you have some WIP commits in this branch'
        )
        expect(page).to have_text(
          "Start the title with WIP: to prevent a Work In Progress merge \
request from being merged before it's ready"
        )
      end
    end
  end

  def within_wip_explanation(&block)
    page.within '.js-no-wip-explanation' do
      yield
    end
  end
end