summaryrefslogtreecommitdiff
path: root/spec/features/merge_requests/cherry_pick_spec.rb
blob: 205e38337d103f40de380162ac8966eca7df50e3 (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
require 'spec_helper'

describe 'Cherry-pick Merge Requests', :js do
  let(:user) { create(:user) }
  let(:group) { create(:group) }
  let(:project) { create(:project, :repository, namespace: group) }
  let(:merge_request) { create(:merge_request_with_diffs, source_project: project, author: user) }

  before do
    sign_in user
    project.add_master(user)
  end

  context "Viewing a merged merge request" do
    before do
      service = MergeRequests::MergeService.new(project, user)

      perform_enqueued_jobs do
        service.execute(merge_request)
      end
    end

    # Fast-forward merge, or merged before GitLab 8.5.
    context "Without a merge commit" do
      before do
        merge_request.merge_commit_sha = nil
        merge_request.save
      end

      it "doesn't show a Cherry-pick button" do
        visit project_merge_request_path(project, merge_request)

        expect(page).not_to have_link "Cherry-pick"
      end
    end

    context "With a merge commit" do
      it "shows a Cherry-pick button" do
        visit project_merge_request_path(project, merge_request)

        expect(page).to have_link "Cherry-pick"
      end
    end
  end
end