summaryrefslogtreecommitdiff
path: root/spec/support
diff options
context:
space:
mode:
authorLin Jen-Shin <godfat@godfat.org>2017-06-02 02:46:34 +0800
committerLin Jen-Shin <godfat@godfat.org>2017-06-02 02:46:34 +0800
commitf62603286d72d42e5b4e87b8f7f7bd6094407f1b (patch)
treef27b97f601359a34de49ae202848c341f6535553 /spec/support
parente9a98d3d2dbf8d7d9c181a5505c5d3a3200d711b (diff)
downloadgitlab-ce-f62603286d72d42e5b4e87b8f7f7bd6094407f1b.tar.gz
Fix other use of CreateDeploymentService and make
it a bit more robust against missing options, which we did guard on for some cases.
Diffstat (limited to 'spec/support')
-rw-r--r--spec/support/cycle_analytics_helpers.rb41
1 files changed, 35 insertions, 6 deletions
diff --git a/spec/support/cycle_analytics_helpers.rb b/spec/support/cycle_analytics_helpers.rb
index 66545127a44..7317ce6b907 100644
--- a/spec/support/cycle_analytics_helpers.rb
+++ b/spec/support/cycle_analytics_helpers.rb
@@ -51,12 +51,41 @@ module CycleAnalyticsHelpers
end
def deploy_master(environment: 'production')
- CreateDeploymentService.new(project, user, {
- environment: environment,
- ref: 'master',
- tag: false,
- sha: project.repository.commit('master').sha
- }).execute
+ dummy_job =
+ case environment
+ when 'production'
+ dummy_production_job
+ when 'staging'
+ dummy_staging_job
+ else
+ raise ArgumentError
+ end
+
+ CreateDeploymentService.new(dummy_job).execute
+ end
+
+ def dummy_production_job
+ @dummy_job ||= new_dummy_job('production')
+ end
+
+ def dummy_staging_job
+ @dummy_job ||= new_dummy_job('staging')
+ end
+
+ def dummy_pipeline
+ @dummy_pipeline ||=
+ Ci::Pipeline.new(sha: project.repository.commit('master').sha)
+ end
+
+ def new_dummy_job(environment)
+ Ci::Build.new(
+ project: project,
+ user: user,
+ environment: environment,
+ ref: 'master',
+ tag: false,
+ name: 'dummy',
+ pipeline: dummy_pipeline)
end
end