Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Léo-Paul Géneau
gitlab-ce
Commits
f84d3dc0
Commit
f84d3dc0
authored
Jul 19, 2018
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix deserializing yaml variables in imported projects
parent
59eb9938
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
5 deletions
+34
-5
lib/gitlab/serializer/ci/variables.rb
lib/gitlab/serializer/ci/variables.rb
+3
-2
spec/lib/gitlab/serializer/ci/variables_spec.rb
spec/lib/gitlab/serializer/ci/variables_spec.rb
+3
-3
spec/models/ci/build_spec.rb
spec/models/ci/build_spec.rb
+28
-0
No files found.
lib/gitlab/serializer/ci/variables.rb
View file @
f84d3dc0
...
...
@@ -13,8 +13,9 @@ module Gitlab
object
=
YAML
.
safe_load
(
string
,
[
Symbol
])
object
.
map
do
|
variable
|
variable
[
:key
]
=
variable
[
:key
].
to_s
variable
variable
.
symbolize_keys
.
tap
do
|
variable
|
variable
[
:key
]
=
variable
[
:key
].
to_s
end
end
end
...
...
spec/lib/gitlab/serializer/ci/variables_spec.rb
View file @
f84d3dc0
require
'spec_helper'
require
'
fast_
spec_helper'
describe
Gitlab
::
Serializer
::
Ci
::
Variables
do
subject
do
...
...
@@ -6,11 +6,11 @@ describe Gitlab::Serializer::Ci::Variables do
end
let
(
:object
)
do
[{
key: :key
,
value:
'value'
,
public:
true
},
[{
'key'
=>
:key
,
'value'
=>
'value'
,
'public'
=>
true
},
{
key:
'wee'
,
value:
1
,
public:
false
}]
end
it
'converts keys into strings'
do
it
'converts keys into strings
and symbolizes hash
'
do
is_expected
.
to
eq
([
{
key:
'key'
,
value:
'value'
,
public:
true
},
{
key:
'wee'
,
value:
1
,
public:
false
}
...
...
spec/models/ci/build_spec.rb
View file @
f84d3dc0
...
...
@@ -2269,6 +2269,34 @@ describe Ci::Build do
end
end
describe
'#yaml_variables'
do
before
do
build
.
update_attribute
(
:yaml_variables
,
variables
)
end
context
'when serialized valu is a symbolized hash'
do
let
(
:variables
)
do
[{
key: :VARIABLE
,
value:
'my value 1'
}]
end
it
'keeps symbolizes keys and stringifies variables names'
do
expect
(
build
.
yaml_variables
)
.
to
eq
[{
key:
'VARIABLE'
,
value:
'my value 1'
}]
end
end
context
'when serialized value is a hash with string keys'
do
let
(
:variables
)
do
[{
'key'
=>
:VARIABLE
,
'value'
=>
'my value 2'
}]
end
it
'symblizes variables hash'
do
expect
(
build
.
yaml_variables
)
.
to
eq
[{
key:
'VARIABLE'
,
value:
'my value 2'
}]
end
end
end
describe
'state transition: any => [:pending]'
do
let
(
:build
)
{
create
(
:ci_build
,
:created
)
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment