From 52ebeb5a89927058e1eba5bda777852011f001eb Mon Sep 17 00:00:00 2001 From: Katarzyna Kobierska Date: Tue, 13 Sep 2016 12:26:44 +0200 Subject: [PATCH] Build attributes with hash, fix gitlab yaml processor tests --- .../ci/create_pipeline_builds_service.rb | 17 ++++++++--- spec/lib/ci/gitlab_ci_yaml_processor_spec.rb | 28 ++++++++++++++----- 2 files changed, 34 insertions(+), 11 deletions(-) diff --git a/app/services/ci/create_pipeline_builds_service.rb b/app/services/ci/create_pipeline_builds_service.rb index c7a624f38ce..3c12b806438 100644 --- a/app/services/ci/create_pipeline_builds_service.rb +++ b/app/services/ci/create_pipeline_builds_service.rb @@ -13,16 +13,25 @@ module Ci private def create_build(build_attributes) - build_attributes = build_attributes.merge( + build_attributes = { + stage_idx: build_attributes[:stage_idx], + stage: build_attributes[:stage], + commands: build_attributes[:commands], + tag_list: build_attributes[:tag_list], + name: build_attributes[:name], + when: build_attributes[:when], + allow_failure: build_attributes[:allow_failure], + environment: build_attributes[:environment], + yaml_variables: build_attributes[:yaml_variables], + options: build_attributes[:options], pipeline: pipeline, project: pipeline.project, ref: pipeline.ref, tag: pipeline.tag, user: current_user, trigger_request: trigger_request - ) - # OPTIMIZE: We copy over all attributes of Job into Build, therefore this workaround - build_attributes = build_attributes.except(:only, :except) + } + pipeline.builds.create(build_attributes) end diff --git a/spec/lib/ci/gitlab_ci_yaml_processor_spec.rb b/spec/lib/ci/gitlab_ci_yaml_processor_spec.rb index 6dedd25e9d3..317259f0c27 100644 --- a/spec/lib/ci/gitlab_ci_yaml_processor_spec.rb +++ b/spec/lib/ci/gitlab_ci_yaml_processor_spec.rb @@ -26,7 +26,9 @@ module Ci allow_failure: false, when: "on_success", environment: nil, - yaml_variables: [] + yaml_variables: [], + only: nil, + except: nil }) end @@ -443,7 +445,9 @@ module Ci allow_failure: false, when: "on_success", environment: nil, - yaml_variables: [] + yaml_variables: [], + only: nil, + except: nil }) end @@ -471,7 +475,9 @@ module Ci allow_failure: false, when: "on_success", environment: nil, - yaml_variables: [] + yaml_variables: [], + only: nil, + except: nil }) end end @@ -716,7 +722,9 @@ module Ci when: "on_success", allow_failure: false, environment: nil, - yaml_variables: [] + yaml_variables: [], + only: nil, + except: nil }) end @@ -859,7 +867,9 @@ module Ci when: "on_success", allow_failure: false, environment: nil, - yaml_variables: [] + yaml_variables: [], + only: nil, + except: nil }) end end @@ -904,7 +914,9 @@ module Ci when: "on_success", allow_failure: false, environment: nil, - yaml_variables: [] + yaml_variables: [], + only: nil, + except: nil }) expect(subject.second).to eq({ stage: "build", @@ -916,7 +928,9 @@ module Ci when: "on_success", allow_failure: false, environment: nil, - yaml_variables: [] + yaml_variables: [], + only: nil, + except: nil }) end end -- GitLab