auto_deploy_spec.rb 1.52 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
Valery Sizov's avatar
Valery Sizov committed
8
    create :kubernetes_service, project: project
9 10 11 12 13 14 15 16 17 18 19
    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)
20
      expect(page).to have_no_content('Set up auto deploy')
21 22 23 24 25 26 27 28 29 30
    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
31
      expect(page).to have_link('Set up auto deploy')
32 33
    end

34 35
    it 'includes OpenShift as an available template', js: true do
      click_link 'Set up auto deploy'
36
      click_button 'Apply a GitLab CI Yaml template'
37 38

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

43 44
    it 'creates a merge request using "auto-deploy" branch', js: true do
      click_link 'Set up auto deploy'
45
      click_button 'Apply a GitLab CI Yaml template'
46
      within '.gitlab-ci-yml-selector' do
47
        click_on 'OpenShift'
48 49
      end
      wait_for_ajax
50
      click_button 'Commit changes'
51

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