diff --git a/lib/gitlab/ci/variables/collection/item.rb b/lib/gitlab/ci/variables/collection/item.rb index 222aa06b800..7da6d09d440 100644 --- a/lib/gitlab/ci/variables/collection/item.rb +++ b/lib/gitlab/ci/variables/collection/item.rb @@ -34,7 +34,7 @@ module Gitlab def self.fabricate(resource) case resource when Hash - self.new(resource) + self.new(resource.symbolize_keys) when ::HasVariable self.new(resource.to_runner_variable) when self diff --git a/spec/lib/gitlab/ci/variables/collection/item_spec.rb b/spec/lib/gitlab/ci/variables/collection/item_spec.rb index adb3ff4321f..46874662edd 100644 --- a/spec/lib/gitlab/ci/variables/collection/item_spec.rb +++ b/spec/lib/gitlab/ci/variables/collection/item_spec.rb @@ -75,6 +75,14 @@ describe Gitlab::Ci::Variables::Collection::Item do expect(resource).to eq variable end + it 'supports using a hash with stringified values' do + variable = { 'key' => 'VARIABLE', 'value' => 'my value' } + + resource = described_class.fabricate(variable) + + expect(resource).to eq(key: 'VARIABLE', value: 'my value') + end + it 'supports using an active record resource' do variable = create(:ci_variable, key: 'CI_VAR', value: '123') resource = described_class.fabricate(variable)