summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorNick Thomas <nick@gitlab.com>2016-12-08 15:37:41 +0000
committerNick Thomas <nick@gitlab.com>2016-12-15 13:57:04 +0000
commit58486918fc12bbcc5139b6ca32461ad5e037497b (patch)
tree45f046807b9c15612acd66f0790662178b1e8fed /spec
parent93a03cd92f6418fbeaf126c30c161ab40d377e94 (diff)
downloadgitlab-ce-58486918fc12bbcc5139b6ca32461ad5e037497b.tar.gz
Create environments when the build referencing them is created
Diffstat (limited to 'spec')
-rw-r--r--spec/models/environment_spec.rb2
-rw-r--r--spec/services/ci/create_pipeline_service_spec.rb17
2 files changed, 18 insertions, 1 deletions
diff --git a/spec/models/environment_spec.rb b/spec/models/environment_spec.rb
index 706f1a5cd1c..97cbb093ed2 100644
--- a/spec/models/environment_spec.rb
+++ b/spec/models/environment_spec.rb
@@ -223,7 +223,7 @@ describe Environment, models: true do
"foo-" => "foo" + SUFFIX,
}.each do |name, matcher|
it "returns a slug matching #{matcher}, given #{name}" do
- slug = described_class.new(name: name).generate_clean_name
+ slug = described_class.new(name: name).generate_slug
expect(slug).to match(/\A#{matcher}\z/)
end
diff --git a/spec/services/ci/create_pipeline_service_spec.rb b/spec/services/ci/create_pipeline_service_spec.rb
index 4aadd009f3e..ceaca96e25b 100644
--- a/spec/services/ci/create_pipeline_service_spec.rb
+++ b/spec/services/ci/create_pipeline_service_spec.rb
@@ -210,5 +210,22 @@ describe Ci::CreatePipelineService, services: true do
expect(result.manual_actions).not_to be_empty
end
end
+
+ context 'with environment' do
+ before do
+ config = YAML.dump(deploy: { environment: { name: "review/$CI_BUILD_REF_NAME" }, script: 'ls' })
+ stub_ci_pipeline_yaml_file(config)
+ end
+
+ it 'creates the environment' do
+ result = execute(ref: 'refs/heads/master',
+ before: '00000000',
+ after: project.commit.id,
+ commits: [{ message: 'some msg' }])
+
+ expect(result).to be_persisted
+ expect(Environment.find_by(name: "review/master")).not_to be_nil
+ end
+ end
end
end