2016-12-21 10:21:55 -05:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe 'Auto deploy' do
|
|
|
|
let(:user) { create(:user) }
|
2017-03-28 17:13:16 -04:00
|
|
|
let(:project) { create(:project, :repository) }
|
2016-12-21 10:21:55 -05:00
|
|
|
|
2017-11-27 09:19:16 -05:00
|
|
|
shared_examples 'same behavior between KubernetesService and Platform::Kubernetes' do
|
2017-11-22 04:31:07 -05:00
|
|
|
context 'when no deployment service is active' do
|
|
|
|
before do
|
2017-11-27 13:06:38 -05:00
|
|
|
trun_off
|
2017-11-22 04:31:07 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not show a button to set up auto deploy' do
|
|
|
|
visit project_path(project)
|
|
|
|
expect(page).to have_no_content('Set up auto deploy')
|
|
|
|
end
|
2016-12-21 10:21:55 -05:00
|
|
|
end
|
|
|
|
|
2017-11-22 04:31:07 -05:00
|
|
|
context 'when a deployment service is active' do
|
|
|
|
before do
|
2017-11-27 13:06:38 -05:00
|
|
|
trun_on
|
2017-11-22 04:31:07 -05:00
|
|
|
visit project_path(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 do
|
|
|
|
click_link 'Set up auto deploy'
|
|
|
|
click_button 'Apply 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 do
|
|
|
|
click_link 'Set up auto deploy'
|
|
|
|
click_button 'Apply a GitLab CI Yaml template'
|
|
|
|
within '.gitlab-ci-yml-selector' do
|
|
|
|
click_on 'OpenShift'
|
|
|
|
end
|
|
|
|
wait_for_requests
|
|
|
|
click_button 'Commit changes'
|
|
|
|
|
|
|
|
expect(page).to have_content('New Merge Request From auto-deploy into master')
|
|
|
|
end
|
2016-12-21 10:21:55 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-11-27 08:35:16 -05:00
|
|
|
context 'when user configured kubernetes from Integration > Kubernetes' do
|
2016-12-21 10:21:55 -05:00
|
|
|
before do
|
2017-11-27 08:35:16 -05:00
|
|
|
create :kubernetes_service, project: project
|
2017-12-22 03:18:28 -05:00
|
|
|
project.add_master(user)
|
2017-11-22 04:31:07 -05:00
|
|
|
sign_in user
|
2016-12-21 10:21:55 -05:00
|
|
|
end
|
|
|
|
|
2017-11-27 13:06:38 -05:00
|
|
|
let(:trun_on) { project.deployment_platform.update!(active: true) }
|
|
|
|
let(:trun_off) { project.deployment_platform.update!(active: false) }
|
|
|
|
|
2017-11-27 09:19:16 -05:00
|
|
|
it_behaves_like 'same behavior between KubernetesService and Platform::Kubernetes'
|
2017-11-27 08:35:16 -05:00
|
|
|
end
|
2017-11-22 04:31:07 -05:00
|
|
|
|
2017-11-27 08:35:16 -05:00
|
|
|
context 'when user configured kubernetes from CI/CD > Clusters' do
|
|
|
|
before do
|
|
|
|
create(:cluster, :provided_by_gcp, projects: [project])
|
2017-12-22 03:18:28 -05:00
|
|
|
project.add_master(user)
|
2017-11-27 08:35:16 -05:00
|
|
|
sign_in user
|
2016-12-21 10:21:55 -05:00
|
|
|
end
|
|
|
|
|
2017-11-27 13:06:38 -05:00
|
|
|
let(:trun_on) { project.deployment_platform.cluster.update!(enabled: true) }
|
|
|
|
let(:trun_off) { project.deployment_platform.cluster.update!(enabled: false) }
|
|
|
|
|
2017-11-27 09:19:16 -05:00
|
|
|
it_behaves_like 'same behavior between KubernetesService and Platform::Kubernetes'
|
2016-12-21 10:21:55 -05:00
|
|
|
end
|
|
|
|
end
|