summaryrefslogtreecommitdiff
path: root/spec/features/projects/branches/user_views_branches_spec.rb
blob: b6b6dcb5cf1a7985f49b488d6655a42b95306ba1 (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
# frozen_string_literal: true

require "spec_helper"

RSpec.describe "User views branches", :js do
  let_it_be(:project) { create(:project, :repository) }
  let_it_be(:user) { project.first_owner }

  before do
    sign_in(user)
  end

  context "all branches", :js do
    before do
      visit(project_branches_path(project))
      branch_search = find('input[data-testid="branch-search"]')
      branch_search.set('master')
      branch_search.native.send_keys(:enter)
    end

    it "shows branches" do
      expect(page).to have_content("Branches").and have_content("master")

      expect(page.all(".graph-side")).to all( have_content(/\d+/) )
    end

    it "displays a disabled button with a tooltip for the default branch that cannot be deleted", :js do
      expect(page).to have_button('The default branch cannot be deleted', disabled: true)
    end
  end

  context "protected branches" do
    let_it_be(:protected_branch) { create(:protected_branch, project: project) }

    before do
      visit(project_protected_branches_path(project))
    end

    it "shows branches" do
      page.within(".protected-branches-list") do
        expect(page).to have_content(protected_branch.name).and have_no_content("master")
      end
    end
  end
end