BigW Consortium Gitlab

Commit 1d7e3ef1 by Shinya Maeda

Duplicate spec for Platform::Kubernetes with kubernetes_project

parent 5324383d
...@@ -113,40 +113,44 @@ describe Projects::BranchesController do ...@@ -113,40 +113,44 @@ describe Projects::BranchesController do
expect(response).to redirect_to project_tree_path(project, branch) expect(response).to redirect_to project_tree_path(project, branch)
end end
it 'redirects to autodeploy setup page' do context 'when user configured kubernetes from Integration > Kubernetes' do
result = { status: :success, branch: double(name: branch) } it 'redirects to autodeploy setup page' do
result = { status: :success, branch: double(name: branch) }
project.services << build(:kubernetes_service) project.services << build(:kubernetes_service)
expect_any_instance_of(CreateBranchService).to receive(:execute).and_return(result) expect_any_instance_of(CreateBranchService).to receive(:execute).and_return(result)
expect(SystemNoteService).to receive(:new_issue_branch).and_return(true) expect(SystemNoteService).to receive(:new_issue_branch).and_return(true)
post :create, post :create,
namespace_id: project.namespace.to_param, namespace_id: project.namespace.to_param,
project_id: project.to_param, project_id: project.to_param,
branch_name: branch, branch_name: branch,
issue_iid: issue.iid issue_iid: issue.iid
expect(response.location).to include(project_new_blob_path(project, branch)) expect(response.location).to include(project_new_blob_path(project, branch))
expect(response).to have_gitlab_http_status(302) expect(response).to have_gitlab_http_status(302)
end
end end
it 'redirects to autodeploy setup page' do context 'when user configured kubernetes from CI/CD > Clusters' do
result = { status: :success, branch: double(name: branch) } it 'redirects to autodeploy setup page' do
result = { status: :success, branch: double(name: branch) }
create(:cluster, :provided_by_gcp, projects: [project]) create(:cluster, :provided_by_gcp, projects: [project])
expect_any_instance_of(CreateBranchService).to receive(:execute).and_return(result) expect_any_instance_of(CreateBranchService).to receive(:execute).and_return(result)
expect(SystemNoteService).to receive(:new_issue_branch).and_return(true) expect(SystemNoteService).to receive(:new_issue_branch).and_return(true)
post :create, post :create,
namespace_id: project.namespace.to_param, namespace_id: project.namespace.to_param,
project_id: project.to_param, project_id: project.to_param,
branch_name: branch, branch_name: branch,
issue_iid: issue.iid issue_iid: issue.iid
expect(response.location).to include(project_new_blob_path(project, branch)) expect(response.location).to include(project_new_blob_path(project, branch))
expect(response).to have_gitlab_http_status(302) expect(response).to have_gitlab_http_status(302)
end
end end
end end
......
...@@ -178,15 +178,29 @@ module Gitlab ...@@ -178,15 +178,29 @@ module Gitlab
end end
context 'when kubernetes is active' do context 'when kubernetes is active' do
let(:project) { create(:kubernetes_project) } shared_examples 'correct behavior for kubernetes policy' do
let(:pipeline) { create(:ci_empty_pipeline, project: project) } it 'returns seeds for kubernetes dependent job' do
seeds = subject.stage_seeds(pipeline)
it 'returns seeds for kubernetes dependent job' do expect(seeds.size).to eq 2
seeds = subject.stage_seeds(pipeline) expect(seeds.first.builds.dig(0, :name)).to eq 'spinach'
expect(seeds.second.builds.dig(0, :name)).to eq 'production'
end
end
expect(seeds.size).to eq 2 context 'when user configured kubernetes from Integration > Kubernetes' do
expect(seeds.first.builds.dig(0, :name)).to eq 'spinach' let(:project) { create(:kubernetes_project) }
expect(seeds.second.builds.dig(0, :name)).to eq 'production' let(:pipeline) { create(:ci_empty_pipeline, project: project) }
it_behaves_like 'correct behavior for kubernetes policy'
end
context 'when user configured kubernetes from CI/CD > Clusters' do
let!(:cluster) { create(:cluster, :project, :provided_by_gcp) }
let(:project) { cluster.project }
let(:pipeline) { create(:ci_empty_pipeline, project: project) }
it_behaves_like 'correct behavior for kubernetes policy'
end end
end end
......
...@@ -557,10 +557,23 @@ describe Ci::Pipeline, :mailer do ...@@ -557,10 +557,23 @@ describe Ci::Pipeline, :mailer do
describe '#has_kubernetes_active?' do describe '#has_kubernetes_active?' do
context 'when kubernetes is active' do context 'when kubernetes is active' do
let(:project) { create(:kubernetes_project) } shared_examples 'correct behavior with has_kubernetes_active?' do
it 'returns true' do
expect(pipeline).to have_kubernetes_active
end
end
it 'returns true' do context 'when user configured kubernetes from Integration > Kubernetes' do
expect(pipeline).to have_kubernetes_active let(:project) { create(:kubernetes_project) }
it_behaves_like 'correct behavior with has_kubernetes_active?'
end
context 'when user configured kubernetes from CI/CD > Clusters' do
let!(:cluster) { create(:cluster, :project, :provided_by_gcp) }
let(:project) { cluster.project }
it_behaves_like 'correct behavior with has_kubernetes_active?'
end end
end end
......
...@@ -327,15 +327,28 @@ describe Environment do ...@@ -327,15 +327,28 @@ describe Environment do
context 'when the enviroment is available' do context 'when the enviroment is available' do
context 'with a deployment service' do context 'with a deployment service' do
let(:project) { create(:kubernetes_project) } shared_examples 'correct behavior for has_terminals?' do
context 'and a deployment' do
let!(:deployment) { create(:deployment, environment: environment) }
it { is_expected.to be_truthy }
end
context 'and a deployment' do context 'but no deployments' do
let!(:deployment) { create(:deployment, environment: environment) } it { is_expected.to be_falsy }
it { is_expected.to be_truthy } end
end end
context 'but no deployments' do context 'when user configured kubernetes from Integration > Kubernetes' do
it { is_expected.to be_falsy } let(:project) { create(:kubernetes_project) }
it_behaves_like 'correct behavior for has_terminals?'
end
context 'when user configured kubernetes from CI/CD > Clusters' do
let!(:cluster) { create(:cluster, :project, :provided_by_gcp) }
let(:project) { cluster.project }
it_behaves_like 'correct behavior for has_terminals?'
end end
end end
......
require 'spec_helper' require 'spec_helper'
describe ReactiveCachingWorker do describe ReactiveCachingWorker do
let(:project) { create(:kubernetes_project) }
let(:service) { project.deployment_service } let(:service) { project.deployment_service }
subject { described_class.new.perform("KubernetesService", service.id) } subject { described_class.new.perform("KubernetesService", service.id) }
describe '#perform' do describe '#perform' do
it 'calls #exclusively_update_reactive_cache!' do shared_examples 'correct behavior with perform' do
expect_any_instance_of(KubernetesService).to receive(:exclusively_update_reactive_cache!) it 'calls #exclusively_update_reactive_cache!' do
expect_any_instance_of(KubernetesService).to receive(:exclusively_update_reactive_cache!)
subject subject
end
end
context 'when user configured kubernetes from Integration > Kubernetes' do
let(:project) { create(:kubernetes_project) }
it_behaves_like 'correct behavior with perform'
end
context 'when user configured kubernetes from CI/CD > Clusters' do
let!(:cluster) { create(:cluster, :project, :provided_by_gcp) }
let(:project) { cluster.project }
it_behaves_like 'correct behavior with perform'
end end
end end
end end
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