diff options
Diffstat (limited to 'spec')
-rw-r--r-- | spec/factories/projects.rb | 26 | ||||
-rw-r--r-- | spec/features/auto_deploy_spec.rb | 56 | ||||
-rw-r--r-- | spec/features/environment_spec.rb | 2 | ||||
-rw-r--r-- | spec/features/environments_spec.rb | 2 | ||||
-rw-r--r-- | spec/models/environment_spec.rb | 6 | ||||
-rw-r--r-- | spec/models/project_services/kubernetes_service_spec.rb | 2 | ||||
-rw-r--r-- | spec/models/project_spec.rb | 2 | ||||
-rw-r--r-- | spec/workers/reactive_caching_worker_spec.rb | 2 |
8 files changed, 77 insertions, 21 deletions
diff --git a/spec/factories/projects.rb b/spec/factories/projects.rb index f7fa834d7a2..f4ab732caa4 100644 --- a/spec/factories/projects.rb +++ b/spec/factories/projects.rb @@ -48,6 +48,19 @@ FactoryGirl.define do end end + trait :kubernetes do + after :create do |project| + project.create_kubernetes_service( + active: true, + properties: { + namespace: project.path, + api_url: 'https://kubernetes.example.com/api', + token: 'a' * 40, + } + ) + end + end + # Nest Project Feature attributes transient do wiki_access_level ProjectFeature::ENABLED @@ -137,17 +150,4 @@ FactoryGirl.define do ) end end - - factory :kubernetes_project, parent: :empty_project do - after :create do |project| - project.create_kubernetes_service( - active: true, - properties: { - namespace: project.path, - api_url: 'https://kubernetes.example.com', - token: 'a' * 40, - } - ) - end - end end diff --git a/spec/features/auto_deploy_spec.rb b/spec/features/auto_deploy_spec.rb new file mode 100644 index 00000000000..92c5b1cbb3b --- /dev/null +++ b/spec/features/auto_deploy_spec.rb @@ -0,0 +1,56 @@ +require 'spec_helper' + +describe 'Auto deploy' do + include WaitForAjax + + let(:user) { create(:user) } + let(:project) { create(:project, :kubernetes) } + + before do + 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 autodeploy') + 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 autodeploy') + end + + it 'includes Kubernetes as an available template', js: true do + click_link 'Set up autodeploy' + click_button 'Choose a GitLab CI Yaml template' + + within '.gitlab-ci-yml-selector' do + expect(page).to have_content('Kubernetes') + end + end + + it 'creates a merge request using "autodeploy" branch', js: true do + click_link 'Set up autodeploy' + click_button 'Choose a GitLab CI Yaml template' + within '.gitlab-ci-yml-selector' do + click_on 'Kubernetes' + end + wait_for_ajax + click_button 'Commit Changes' + + expect(page).to have_content('New Merge Request From autodeploy into master') + end + end +end diff --git a/spec/features/environment_spec.rb b/spec/features/environment_spec.rb index 56f6cd2e095..c7411f1f4ac 100644 --- a/spec/features/environment_spec.rb +++ b/spec/features/environment_spec.rb @@ -93,7 +93,7 @@ feature 'Environment', :feature do end context 'with terminal' do - let(:project) { create(:kubernetes_project, :test_repo) } + let(:project) { create(:empty_project, :kubernetes, :test_repo) } context 'for project master' do let(:role) { :master } diff --git a/spec/features/environments_spec.rb b/spec/features/environments_spec.rb index 72b984cfab8..e1387e44be8 100644 --- a/spec/features/environments_spec.rb +++ b/spec/features/environments_spec.rb @@ -151,7 +151,7 @@ feature 'Environments page', :feature, :js do end context 'with terminal' do - let(:project) { create(:kubernetes_project, :test_repo) } + let(:project) { create(:empty_project, :kubernetes, :test_repo) } context 'for project master' do let(:role) { :master } diff --git a/spec/models/environment_spec.rb b/spec/models/environment_spec.rb index 93eb402e060..2aa63d7bcc3 100644 --- a/spec/models/environment_spec.rb +++ b/spec/models/environment_spec.rb @@ -200,7 +200,7 @@ describe Environment, models: true do context 'when the enviroment is available' do context 'with a deployment service' do - let(:project) { create(:kubernetes_project) } + let(:project) { create(:empty_project, :kubernetes) } context 'and a deployment' do let!(:deployment) { create(:deployment, environment: environment) } @@ -218,14 +218,14 @@ describe Environment, models: true do end context 'when the environment is unavailable' do - let(:project) { create(:kubernetes_project) } + let(:project) { create(:empty_project, :kubernetes) } before { environment.stop } it { is_expected.to be_falsy } end end describe '#terminals' do - let(:project) { create(:kubernetes_project) } + let(:project) { create(:empty_project, :kubernetes) } subject { environment.terminals } context 'when the environment has terminals' do diff --git a/spec/models/project_services/kubernetes_service_spec.rb b/spec/models/project_services/kubernetes_service_spec.rb index 4f3cd14e941..0b20f4d3154 100644 --- a/spec/models/project_services/kubernetes_service_spec.rb +++ b/spec/models/project_services/kubernetes_service_spec.rb @@ -4,7 +4,7 @@ describe KubernetesService, models: true, caching: true do include KubernetesHelpers include ReactiveCachingHelpers - let(:project) { create(:kubernetes_project) } + let(:project) { create(:empty_project, :kubernetes) } let(:service) { project.kubernetes_service } # We use Kubeclient to interactive with the Kubernetes API. It will diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb index 88d5d14f855..8be99bbf3ee 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -1719,7 +1719,7 @@ describe Project, models: true do end context 'when project has a deployment service' do - let(:project) { create(:kubernetes_project) } + let(:project) { create(:empty_project, :kubernetes) } it 'returns variables from this service' do expect(project.deployment_variables).to include( diff --git a/spec/workers/reactive_caching_worker_spec.rb b/spec/workers/reactive_caching_worker_spec.rb index 5f4453c15d6..c6009e25713 100644 --- a/spec/workers/reactive_caching_worker_spec.rb +++ b/spec/workers/reactive_caching_worker_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' describe ReactiveCachingWorker do - let(:project) { create(:kubernetes_project) } + let(:project) { create(:empty_project, :kubernetes) } let(:service) { project.deployment_service } subject { described_class.new.perform("KubernetesService", service.id) } |