BigW Consortium Gitlab

branches.rb 2.35 KB
Newer Older
1
class Spinach::Features::ProjectCommitsBranches < Spinach::FeatureSteps
Nihad Abbasov committed
2 3 4 5
  include SharedAuthentication
  include SharedProject
  include SharedPaths

6
  step 'I click link "All"' do
7 8 9
    click_link "All"
  end

10
  step 'I should see "Shop" all branches list' do
11 12
    expect(page).to have_content "Branches"
    expect(page).to have_content "master"
13 14
  end

15
  step 'I click link "Protected"' do
16 17 18
    click_link "Protected"
  end

19
  step 'I should see "Shop" protected branches list' do
20
    page.within ".protected-branches-list" do
21 22
      expect(page).to have_content "stable"
      expect(page).not_to have_content "master"
23 24 25
    end
  end

26
  step 'project "Shop" has protected branches' do
skv committed
27
    project = Project.find_by(name: "Shop")
28
    create(:protected_branch, project: project, name: "stable")
29
  end
30 31 32 33 34 35 36

  step 'I click new branch link' do
    click_link "New branch"
  end

  step 'I submit new branch form' do
    fill_in 'branch_name', with: 'deploy_keys'
37
    select_branch('master')
38 39 40
    click_button 'Create branch'
  end

41 42
  step 'I submit new branch form with invalid name' do
    fill_in 'branch_name', with: '1.0 stable'
43
    select_branch('master')
44 45 46 47 48
    click_button 'Create branch'
  end

  step 'I submit new branch form with branch that already exists' do
    fill_in 'branch_name', with: 'master'
49
    select_branch('master')
50 51 52
    click_button 'Create branch'
  end

53
  step 'I should see new branch created' do
54
    expect(page).to have_content 'deploy_keys'
55 56 57
  end

  step 'I should see new an error that branch is invalid' do
58
    expect(page).to have_content 'Branch name is invalid'
59
    expect(page).to have_content "can't contain spaces"
60 61 62
  end

  step 'I should see new an error that branch already exists' do
63
    expect(page).to have_content 'Branch already exists'
64
  end
65

66 67 68 69 70
  step 'I filter for branch improve/awesome' do
    fill_in 'branch-search', with: 'improve/awesome'
    find('#branch-search').native.send_keys(:enter)
  end

71
  step "I click branch 'improve/awesome' delete link" do
72
    page.within '.js-branch-improve\/awesome' do
73 74 75 76 77 78
      find('.btn-remove').click
      sleep 0.05
    end
  end

  step "I should not see branch 'improve/awesome'" do
79
    expect(page.all(visible: true)).not_to have_content 'improve/awesome'
80
  end
81 82 83 84 85 86 87 88

  def select_branch(branch_name)
    click_button 'master'

    page.within '#new-branch-form .dropdown-menu' do
      click_link branch_name
    end
  end
89
end