summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKamil Trzciński <ayufan@ayufan.eu>2018-08-22 22:20:57 +0200
committerKamil Trzciński <ayufan@ayufan.eu>2018-08-22 22:20:57 +0200
commitccd28d3dae80a84b1a79e7e3b20f0d0757f48a65 (patch)
tree9e90056de978ffedd322bda543f041ae545e69f6
parentebcd1ac55bb9be1c20ddda449d6098c3e65c8fcc (diff)
downloadgitlab-ce-kamil-refactor-ci-builds.tar.gz
-rw-r--r--app/models/ci/build.rb3
-rw-r--r--app/models/ci/build_environment_deployment.rb6
2 files changed, 5 insertions, 4 deletions
diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb
index 00316d828b4..743a2c131d7 100644
--- a/app/models/ci/build.rb
+++ b/app/models/ci/build.rb
@@ -34,8 +34,8 @@ module Ci
end
has_one :config, class_name: 'Ci::BuildConfig'
- has_one :environment_deployment, class_name: 'Ci::BuildEnvironmentDeployment'
has_one :metadata, class_name: 'Ci::BuildMetadata'
+ has_one :environment_deployment, class_name: 'Ci::BuildEnvironmentDeployment'
has_one :runner_session, class_name: 'Ci::BuildRunnerSession', validate: true, inverse_of: :build
accepts_nested_attributes_for :runner_session
@@ -225,7 +225,6 @@ module Ci
build_environment_deployment(
environment: environment,
- deployment: last_deployment,
action: ensure_config.environment_action
)
end
diff --git a/app/models/ci/build_environment_deployment.rb b/app/models/ci/build_environment_deployment.rb
index d3dbb7622a4..60b1f7fc3dd 100644
--- a/app/models/ci/build_environment_deployment.rb
+++ b/app/models/ci/build_environment_deployment.rb
@@ -2,7 +2,6 @@ module Ci
class BuildEnvironmentDeployment
belongs_to :build, class_name: 'Ci::Build'
belongs_to :environment, class_name: 'Environment'
- belongs_to :deployment, class_name: 'Deployment'
enum :action {
start: 1,
@@ -11,10 +10,13 @@ module Ci
validates :build, presence: true
validates :environment, presence: true
- validates :deployment, presence: true
delegate :name, to: :environment, prefix: true
+ def deployment
+ self.build.last_deployment
+ end
+
def outdated?
build.success? && !deployment&.latest?
end