Add specs for method that exposes build variables hash

This commit is contained in:
Grzegorz Bizon 2018-03-27 13:46:22 +02:00
parent 3ab013634d
commit a60ccef9fe
2 changed files with 12 additions and 3 deletions

View file

@ -288,9 +288,6 @@ module Ci
.to_runner_variables
end
##
# TODO, add specs
#
def variables_hash
scoped_variables.to_hash
end

View file

@ -2053,6 +2053,18 @@ describe Ci::Build do
end
end
describe '#variables_hash' do
before do
project.variables.create!(key: 'MY_VAR', value: 'my value 1')
pipeline.variables.create!(key: 'MY_VAR', value: 'my value 2')
end
it 'returns a regular hash created in valid order' do
expect(build.variables_hash).to include('MY_VAR': 'my value 2')
expect(build.variables_hash).not_to include('MY_VAR': 'my value 1')
end
end
describe 'state transition: any => [:pending]' do
let(:build) { create(:ci_build, :created) }