BigW Consortium Gitlab

auto_deploy_spec.rb 1.67 KB
Newer Older
1 2 3 4
require 'spec_helper'

describe 'Auto deploy' do
  let(:user) { create(:user) }
5
  let(:project) { create(:project, :repository) }
6 7

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

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

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

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

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