diff options
author | Kamil Trzcinski <ayufan@ayufan.eu> | 2016-06-14 19:34:48 +0300 |
---|---|---|
committer | Kamil Trzcinski <ayufan@ayufan.eu> | 2016-06-14 19:34:48 +0300 |
commit | 14a02a6a95353948d00f8f973b35b80ac06f4599 (patch) | |
tree | d9dbdee6528f1dfeb7a827e95c35e707436e7d49 /app/services/create_deployment_service.rb | |
parent | 006b65098806fde2a467d9a79347d2978c992e89 (diff) |
Improve design after review
Diffstat (limited to 'app/services/create_deployment_service.rb')
-rw-r--r-- | app/services/create_deployment_service.rb | 20 |
1 files changed, 4 insertions, 16 deletions
diff --git a/app/services/create_deployment_service.rb b/app/services/create_deployment_service.rb index eec1773073e..efeb9df9527 100644 --- a/app/services/create_deployment_service.rb +++ b/app/services/create_deployment_service.rb @@ -2,7 +2,9 @@ require_relative 'base_service' class CreateDeploymentService < BaseService def execute(deployable = nil) - environment = create_or_find_environment(params[:environment]) + environment = project.environments.find_or_create_by( + name: params[:environment] + ) project.deployments.create( environment: environment, @@ -10,21 +12,7 @@ class CreateDeploymentService < BaseService tag: params[:tag], sha: params[:sha], user: current_user, - deployable: deployable, + deployable: deployable ) end - - private - - def create_or_find_environment(environment) - find_environment(environment) || create_environment(environment) - end - - def create_environment(environment) - project.environments.create(name: environment) - end - - def find_environment(environment) - project.environments.find_by(name: environment) - end end |