summaryrefslogtreecommitdiff
path: root/features/steps/project/deploy_keys.rb
blob: a4d6c9a1b8e625dcebb5d93d60e49a20d99075ba (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
76
77
78
79
80
81
82
83
84
85
86
87
class Spinach::Features::ProjectDeployKeys < Spinach::FeatureSteps
  include SharedAuthentication
  include SharedProject
  include SharedPaths

  step 'project has deploy key' do
    create(:deploy_keys_project, project: @project)
  end

  step 'I should see project deploy key' do
    page.within '.enabled-keys' do
      expect(page).to have_content deploy_key.title
    end
  end

  step 'I should see other project deploy key' do
    page.within '.available-keys' do
      expect(page).to have_content other_deploy_key.title
    end
  end

  step 'I should see public deploy key' do
    page.within '.available-keys' do
      expect(page).to have_content public_deploy_key.title
    end
  end

  step 'I click \'New Deploy Key\'' do
    click_link 'New Deploy Key'
  end

  step 'I submit new deploy key' do
    fill_in "deploy_key_title", with: "laptop"
    fill_in "deploy_key_key", with: "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAzrEJUIR6Y03TCE9rIJ+GqTBvgb8t1jI9h5UBzCLuK4VawOmkLornPqLDrGbm6tcwM/wBrrLvVOqi2HwmkKEIecVO0a64A4rIYScVsXIniHRS6w5twyn1MD3sIbN+socBDcaldECQa2u1dI3tnNVcs8wi77fiRe7RSxePsJceGoheRQgC8AZ510UdIlO+9rjIHUdVN7LLyz512auAfYsgx1OfablkQ/XJcdEwDNgi9imI6nAXhmoKUm1IPLT2yKajTIC64AjLOnE0YyCh6+7RFMpiMyu1qiOCpdjYwTgBRiciNRZCH8xIedyCoAmiUgkUT40XYHwLuwiPJICpkAzp7Q== user@laptop"
    click_button "Create"
  end

  step 'I should be on deploy keys page' do
    expect(current_path).to eq namespace_project_deploy_keys_path(@project.namespace, @project)
  end

  step 'I should see newly created deploy key' do
    page.within '.enabled-keys' do
      expect(page).to have_content(deploy_key.title)
    end
  end

  step 'other projects have deploy keys' do
    @second_project = create(:project, namespace: create(:group))
    @second_project.team << [current_user, :master]
    create(:deploy_keys_project, project: @second_project)

    @third_project = create(:project, namespace: create(:group))
    @third_project.team << [current_user, :master]
    create(:deploy_keys_project, project: @third_project, deploy_key: @second_project.deploy_keys.first)
  end

  step 'I should only see the same deploy key once' do
    page.within '.available-keys' do
      expect(page).to have_selector('ul li', count: 1)
    end
  end

  step 'public deploy key exists' do
    create(:deploy_key, public: true)
  end

  step 'I click attach deploy key' do
    page.within '.available-keys' do
      click_link 'Enable'
    end
  end

  protected

  def deploy_key
    @project.deploy_keys.last
  end

  def other_deploy_key
    @second_project.deploy_keys.last
  end

  def public_deploy_key
    DeployKey.are_public.last
  end
end