summaryrefslogtreecommitdiff
path: root/spec/features/projects/branches_spec.rb
blob: 7ac58b4dd02b5aa8607a79cde21168d2f5a67af7 (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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
require 'rails_helper'

feature 'Branches', feature: true, js: true do
  let(:project) { create(:project) }
  let(:user) { create(:user) }

  before do
    project.team << [user, :master]
    login_as user

    visit namespace_project_branches_path(project.namespace, project)
  end

  it 'should show list of branches' do
    page.within '.all-branches' do
      expect(page).to have_content project.repository.branches.first.name
    end
  end

  it 'should protect a branch' do
    branch_el = first('.all-branches li')
    first('.js-branch-settings-toggle').click

    page.within branch_el do
      click_button 'Protected'
    end

    expect(page).to have_content 'protected'
  end

  it 'should unprotect branch' do
    branch_el = first('.all-branches li')
    first('.js-branch-settings-toggle').click

    page.within branch_el do
      click_button 'Protected'
    end

    expect(page).to have_content 'protected'

    first('.js-branch-settings-toggle').click
    click_link 'Unprotected'

    expect(page).to have_no_content 'protected'
  end

  it 'should allow developers to push' do
    branch_el = first('.all-branches li')
    first('.js-branch-settings-toggle').click
    page.within branch_el do
      click_button 'Protected'
    end
    expect(page).to have_content 'protected'

    first('.js-branch-settings-toggle').click

    branch_el = first('.all-branches li')
    page.within branch_el do
      click_link 'Developers can push'
    end

    expect(page).to have_selector('.js-branch-dev-push.is-active', visible: false)
  end

  it 'should allow branch to be deleted' do
    branch_el = first('.all-branches li')
    branch_name = project.repository.branches.first.name
    first('.js-branch-settings-toggle').click

    page.within branch_el do
      click_link 'Delete branch'
    end
    expect(page).to have_no_content branch_name
  end
end