Commit 7277b3b3 authored by Shinya Maeda's avatar Shinya Maeda

Fix feature spec

parent b4c4e1bd
...@@ -903,7 +903,6 @@ class Project < ActiveRecord::Base ...@@ -903,7 +903,6 @@ class Project < ActiveRecord::Base
end end
# TODO: This will be extended for multiple enviroment clusters # TODO: This will be extended for multiple enviroment clusters
# TODO: Add super nice tests to check this interchangeability
def deployment_platform def deployment_platform
@deployment_platform ||= clusters.find_by(enabled: true)&.platform_kubernetes @deployment_platform ||= clusters.find_by(enabled: true)&.platform_kubernetes
@deployment_platform ||= services.where(category: :deployment).reorder(nil).find_by(active: true) @deployment_platform ||= services.where(category: :deployment).reorder(nil).find_by(active: true)
......
...@@ -7,7 +7,7 @@ describe 'Auto deploy' do ...@@ -7,7 +7,7 @@ describe 'Auto deploy' do
shared_examples 'same behavior between KubernetesService and Platform::Kubernetes' do shared_examples 'same behavior between KubernetesService and Platform::Kubernetes' do
context 'when no deployment service is active' do context 'when no deployment service is active' do
before do before do
project.kubernetes_service.update!(active: false) trun_off
end end
it 'does not show a button to set up auto deploy' do it 'does not show a button to set up auto deploy' do
...@@ -18,7 +18,7 @@ describe 'Auto deploy' do ...@@ -18,7 +18,7 @@ describe 'Auto deploy' do
context 'when a deployment service is active' do context 'when a deployment service is active' do
before do before do
project.kubernetes_service.update!(active: true) trun_on
visit project_path(project) visit project_path(project)
end end
...@@ -56,6 +56,9 @@ describe 'Auto deploy' do ...@@ -56,6 +56,9 @@ describe 'Auto deploy' do
sign_in user sign_in user
end end
let(:trun_on) { project.deployment_platform.update!(active: true) }
let(:trun_off) { project.deployment_platform.update!(active: false) }
it_behaves_like 'same behavior between KubernetesService and Platform::Kubernetes' it_behaves_like 'same behavior between KubernetesService and Platform::Kubernetes'
end end
...@@ -66,6 +69,9 @@ describe 'Auto deploy' do ...@@ -66,6 +69,9 @@ describe 'Auto deploy' do
sign_in user sign_in user
end end
let(:trun_on) { project.deployment_platform.cluster.update!(enabled: true) }
let(:trun_off) { project.deployment_platform.cluster.update!(enabled: false) }
it_behaves_like 'same behavior between KubernetesService and Platform::Kubernetes' it_behaves_like 'same behavior between KubernetesService and Platform::Kubernetes'
end end
end end
...@@ -233,7 +233,7 @@ feature 'Environments page', :js do ...@@ -233,7 +233,7 @@ feature 'Environments page', :js do
end end
context 'when user configured kubernetes from CI/CD > Clusters' do context 'when user configured kubernetes from CI/CD > Clusters' do
let!(:cluster) { create(:cluster, :project, :provided_by_gcp) } let(:cluster) { create(:cluster, :provided_by_gcp, projects: [create(:project, :repository)]) }
let(:project) { cluster.project } let(:project) { cluster.project }
it_behaves_like 'same behavior between KubernetesService and Platform::Kubernetes' it_behaves_like 'same behavior between KubernetesService and Platform::Kubernetes'
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment