auto_deploy_spec.rb 1.68 KB
Newer Older
1 2 3 4 5 6
require 'spec_helper'

describe 'Auto deploy' do
  include WaitForAjax

  let(:user) { create(:user) }
7
  let(:project) { create(:project) }
8 9

  before do
10 11 12 13 14 15 16 17
    project.create_kubernetes_service(
      active: true,
      properties: {
        namespace: project.path,
        api_url: 'https://kubernetes.example.com',
        token: 'a' * 40,
      }
    )
18 19 20 21 22 23 24 25 26 27 28
    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)
29
      expect(page).to have_no_content('Set up auto deploy')
30 31 32 33 34 35 36 37 38 39
    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
40
      expect(page).to have_link('Set up auto deploy')
41 42
    end

43 44
    it 'includes OpenShift as an available template', js: true do
      click_link 'Set up auto deploy'
45
      click_button 'Apply a GitLab CI Yaml template'
46 47

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

52 53
    it 'creates a merge request using "auto-deploy" branch', js: true do
      click_link 'Set up auto deploy'
54
      click_button 'Apply a GitLab CI Yaml template'
55
      within '.gitlab-ci-yml-selector' do
56
        click_on 'OpenShift'
57 58
      end
      wait_for_ajax
59
      click_button 'Commit changes'
60

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