2021-04-17 20:07:23 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
RSpec.describe Ci::CreatePipelineService do
|
|
|
|
let_it_be(:project) { create(:project, :repository) }
|
|
|
|
let_it_be(:developer) { create(:user) }
|
2021-06-08 01:23:25 +05:30
|
|
|
|
2021-04-17 20:07:23 +05:30
|
|
|
let(:service) { described_class.new(project, user, ref: 'master') }
|
|
|
|
let(:user) { developer }
|
|
|
|
|
|
|
|
before_all do
|
|
|
|
project.add_developer(developer)
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '#execute' do
|
2021-10-27 15:23:28 +05:30
|
|
|
subject { service.execute(:push).payload }
|
2021-04-17 20:07:23 +05:30
|
|
|
|
|
|
|
context 'with deployment tier' do
|
|
|
|
before do
|
|
|
|
config = YAML.dump(
|
|
|
|
deploy: {
|
|
|
|
script: 'ls',
|
|
|
|
environment: { name: "review/$CI_COMMIT_REF_NAME", deployment_tier: tier }
|
|
|
|
})
|
|
|
|
|
|
|
|
stub_ci_pipeline_yaml_file(config)
|
|
|
|
end
|
|
|
|
|
|
|
|
let(:tier) { 'development' }
|
|
|
|
|
|
|
|
it 'creates the environment with the expected tier' do
|
|
|
|
is_expected.to be_created_successfully
|
|
|
|
|
|
|
|
expect(Environment.find_by_name("review/master")).to be_development
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when tier is testing' do
|
|
|
|
let(:tier) { 'testing' }
|
|
|
|
|
|
|
|
it 'creates the environment with the expected tier' do
|
|
|
|
is_expected.to be_created_successfully
|
|
|
|
|
|
|
|
expect(Environment.find_by_name("review/master")).to be_testing
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|