summaryrefslogtreecommitdiff
path: root/spec/features/auto_deploy_spec.rb
blob: ea7a97d1d4fde10f29b239c665c38756112b7461 (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
require 'spec_helper'

describe 'Auto deploy' do
  include WaitForAjax

  let(:user) { create(:user) }
  let(:project) { create(:project) }

  before do
    project.create_kubernetes_service(
      active: true,
      properties: {
        namespace: project.path,
        api_url: 'https://kubernetes.example.com',
        token: 'a' * 40,
      }
    )
    project.team << [user, :master]
    login_as user
  end

  context 'when no deployment service is active' do
    before do
      project.kubernetes_service.update!(active: false)
    end

    it 'does not show a button to set up auto deploy' do
      visit namespace_project_path(project.namespace, project)
      expect(page).to have_no_content('Set up auto deploy')
    end
  end

  context 'when a deployment service is active' do
    before do
      project.kubernetes_service.update!(active: true)
      visit namespace_project_path(project.namespace, project)
    end

    it 'shows a button to set up auto deploy' do
      expect(page).to have_link('Set up auto deploy')
    end

    it 'includes OpenShift as an available template', js: true do
      click_link 'Set up auto deploy'
      click_button 'Choose a GitLab CI Yaml template'

      within '.gitlab-ci-yml-selector' do
        expect(page).to have_content('OpenShift')
      end
    end

    it 'creates a merge request using "auto-deploy" branch', js: true do
      click_link 'Set up auto deploy'
      click_button 'Choose a GitLab CI Yaml template'
      within '.gitlab-ci-yml-selector' do
        click_on 'OpenShift'
      end
      wait_for_ajax
      click_button 'Commit Changes'

      expect(page).to have_content('New Merge Request From auto-deploy into master')
    end
  end
end