summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2018-03-07 14:51:41 +0100
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2018-03-07 14:54:11 +0100
commit5ceb439d211caccfe791bef968ba4a6e1bf38a4b (patch)
tree2a46ae21c1b68966c51b311103fe99aa3a35be5a
parentc9d2fd3cffbe3c1d85de05d9d26bcabd19676256 (diff)
downloadgitlab-ce-backstage/gb/add-pipeline-build-variables-tests.tar.gz
Remove enforcing uniqueness of build variablesbackstage/gb/add-pipeline-build-variables-tests
-rw-r--r--app/models/ci/build.rb2
-rw-r--r--spec/models/ci/build_spec.rb17
2 files changed, 9 insertions, 10 deletions
diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb
index 79e473c85b7..b230b7f47ef 100644
--- a/app/models/ci/build.rb
+++ b/app/models/ci/build.rb
@@ -268,7 +268,7 @@ module Ci
variables += pipeline.pipeline_schedule.job_variables if pipeline.pipeline_schedule
variables += persisted_environment_variables if environment
- variables.reverse.uniq { |variable| variable.fetch(:key) }.reverse
+ variables
end
def features
diff --git a/spec/models/ci/build_spec.rb b/spec/models/ci/build_spec.rb
index 692c4cc81e0..6e202de0db9 100644
--- a/spec/models/ci/build_spec.rb
+++ b/spec/models/ci/build_spec.rb
@@ -1873,14 +1873,13 @@ describe Ci::Build do
pipeline.variables.build(key: 'MYVAR', value: 'pipeline value')
end
- it 'removes duplicates and leaves the latest occurence' do
- expect(subject.count { |variable| variable.fetch(:key) == 'MYVAR' })
- .to be 1
- end
-
it 'overrides YAML variable using a pipeline variable' do
- is_expected.not_to include(key: 'MYVAR', value: 'myvar', public: true)
- is_expected.to include(key: 'MYVAR', value: 'pipeline value', public: false)
+ variables = subject.reverse.uniq { |variable| variable[:key] }.reverse
+
+ expect(variables)
+ .not_to include(key: 'MYVAR', value: 'myvar', public: true)
+ expect(variables)
+ .to include(key: 'MYVAR', value: 'pipeline value', public: false)
end
end
@@ -1921,8 +1920,8 @@ describe Ci::Build do
context 'when build has environment and user-provided variables' do
let(:expected_variables) do
predefined_variables.map { |variable| variable.fetch(:key) } +
- %w[YAML_VARIABLE CI_ENVIRONMENT_NAME CI_ENVIRONMENT_SLUG
- CI_ENVIRONMENT_URL]
+ %w[YAML_VARIABLE CI_ENVIRONMENT_NAME CI_ENVIRONMENT_SLUG
+ CI_ENVIRONMENT_URL]
end
before do