Commit 5ceb439d authored by Grzegorz Bizon's avatar Grzegorz Bizon

Remove enforcing uniqueness of build variables

parent c9d2fd3c
...@@ -268,7 +268,7 @@ module Ci ...@@ -268,7 +268,7 @@ module Ci
variables += pipeline.pipeline_schedule.job_variables if pipeline.pipeline_schedule variables += pipeline.pipeline_schedule.job_variables if pipeline.pipeline_schedule
variables += persisted_environment_variables if environment variables += persisted_environment_variables if environment
variables.reverse.uniq { |variable| variable.fetch(:key) }.reverse variables
end end
def features def features
......
...@@ -1873,14 +1873,13 @@ describe Ci::Build do ...@@ -1873,14 +1873,13 @@ describe Ci::Build do
pipeline.variables.build(key: 'MYVAR', value: 'pipeline value') pipeline.variables.build(key: 'MYVAR', value: 'pipeline value')
end 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 it 'overrides YAML variable using a pipeline variable' do
is_expected.not_to include(key: 'MYVAR', value: 'myvar', public: true) variables = subject.reverse.uniq { |variable| variable[:key] }.reverse
is_expected.to include(key: 'MYVAR', value: 'pipeline value', public: false)
expect(variables)
.not_to include(key: 'MYVAR', value: 'myvar', public: true)
expect(variables)
.to include(key: 'MYVAR', value: 'pipeline value', public: false)
end end
end end
...@@ -1921,8 +1920,8 @@ describe Ci::Build do ...@@ -1921,8 +1920,8 @@ describe Ci::Build do
context 'when build has environment and user-provided variables' do context 'when build has environment and user-provided variables' do
let(:expected_variables) do let(:expected_variables) do
predefined_variables.map { |variable| variable.fetch(:key) } + predefined_variables.map { |variable| variable.fetch(:key) } +
%w[YAML_VARIABLE CI_ENVIRONMENT_NAME CI_ENVIRONMENT_SLUG %w[YAML_VARIABLE CI_ENVIRONMENT_NAME CI_ENVIRONMENT_SLUG
CI_ENVIRONMENT_URL] CI_ENVIRONMENT_URL]
end end
before do before do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment