BigW Consortium Gitlab

user_accepts_merge_request_spec.rb 1.88 KB
Newer Older
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 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
require 'spec_helper'

describe 'User accepts a merge request', :js do
  let(:merge_request) { create(:merge_request, :with_diffs, :simple, source_project: project) }
  let(:project) { create(:project, :public, :repository) }
  let(:user) { create(:user) }

  before do
    project.add_developer(user)
    sign_in(user)
  end

  context 'with removing the source branch' do
    before do
      visit(merge_request_path(merge_request))
    end

    it 'accepts a merge request' do
      check('Remove source branch')
      click_button('Merge')

      expect(page).to have_content('The changes were merged into')
      expect(page).not_to have_selector('.js-remove-branch-button')

      # Wait for View Resource requests to complete so they don't blow up if they are
      # only handled after `DatabaseCleaner` has already run.
      wait_for_requests
    end
  end

  context 'without removing the source branch' do
    before do
      visit(merge_request_path(merge_request))
    end

    it 'accepts a merge request' do
      click_button('Merge')

      expect(page).to have_content('The changes were merged into')
      expect(page).to have_selector('.js-remove-branch-button')

      # Wait for View Resource requests to complete so they don't blow up if they are
      # only handled after `DatabaseCleaner` has already run
      wait_for_requests
    end
  end

  context 'when a URL has an anchor' do
    before do
      visit(merge_request_path(merge_request, anchor: 'note_123'))
    end

    it 'accepts a merge request' do
      check('Remove source branch')
      click_button('Merge')

      expect(page).to have_content('The changes were merged into')
      expect(page).not_to have_selector('.js-remove-branch-button')

      # Wait for View Resource requests to complete so they don't blow up if they are
      # only handled after `DatabaseCleaner` has already run
      wait_for_requests
    end
  end
end