BigW Consortium Gitlab

cherry_pick_spec.rb 3.09 KB
Newer Older
1 2 3
require 'spec_helper'

describe 'Cherry-pick Commits' do
4
  let(:user) { create(:user) }
5
  let(:group) { create(:group) }
6
  let(:project) { create(:project, :repository, namespace: group) }
7 8 9 10
  let(:master_pickable_commit)  { project.commit('7d3b0f7cff5f37573aea97cebfd5692ea1689924') }
  let(:master_pickable_merge)  { project.commit('e56497bb5f03a90a51293fc6d516788730953899') }

  before do
11 12
    sign_in(user)
    project.team << [user, :master]
13
    visit project_commit_path(project, master_pickable_commit.id)
14 15 16 17 18
  end

  context "I cherry-pick a commit" do
    it do
      find("a[href='#modal-cherry-pick-commit']").click
19
      expect(page).not_to have_content('v1.0.0') # Only branches, not tags
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
      page.within('#modal-cherry-pick-commit') do
        uncheck 'create_merge_request'
        click_button 'Cherry-pick'
      end
      expect(page).to have_content('The commit has been successfully cherry-picked.')
    end
  end

  context "I cherry-pick a merge commit" do
    it do
      find("a[href='#modal-cherry-pick-commit']").click
      page.within('#modal-cherry-pick-commit') do
        uncheck 'create_merge_request'
        click_button 'Cherry-pick'
      end
      expect(page).to have_content('The commit has been successfully cherry-picked.')
    end
  end

  context "I cherry-pick a commit that was previously cherry-picked" do
    it do
      find("a[href='#modal-cherry-pick-commit']").click
      page.within('#modal-cherry-pick-commit') do
        uncheck 'create_merge_request'
        click_button 'Cherry-pick'
      end
46
      visit project_commit_path(project, master_pickable_commit.id)
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
      find("a[href='#modal-cherry-pick-commit']").click
      page.within('#modal-cherry-pick-commit') do
        uncheck 'create_merge_request'
        click_button 'Cherry-pick'
      end
      expect(page).to have_content('Sorry, we cannot cherry-pick this commit automatically.')
    end
  end

  context "I cherry-pick a commit in a new merge request" do
    it do
      find("a[href='#modal-cherry-pick-commit']").click
      page.within('#modal-cherry-pick-commit') do
        click_button 'Cherry-pick'
      end
      expect(page).to have_content('The commit has been successfully cherry-picked. You can now submit a merge request to get this change into the original branch.')
63
      expect(page).to have_content("From cherry-pick-#{master_pickable_commit.short_id} into master")
64 65
    end
  end
66

67
  context "I cherry-pick a commit from a different branch", :js do
68
    it do
69
      find('.header-action-buttons a.dropdown-toggle').click
70 71 72 73 74 75
      find(:css, "a[href='#modal-cherry-pick-commit']").click

      page.within('#modal-cherry-pick-commit') do
        click_button 'master'
      end

76
      wait_for_requests
77

Sam Rose committed
78 79
      page.within('#modal-cherry-pick-commit .dropdown-menu') do
        find('.dropdown-input input').set('feature')
80
        wait_for_requests
Sam Rose committed
81
        click_link "feature"
82 83 84 85 86 87 88 89 90 91
      end

      page.within('#modal-cherry-pick-commit') do
        uncheck 'create_merge_request'
        click_button 'Cherry-pick'
      end

      expect(page).to have_content('The commit has been successfully cherry-picked.')
    end
  end
92
end