Commit 1b4a244d authored by Lin Jen-Shin's avatar Lin Jen-Shin

Rename to Gitlab::Serialize::Ci::Variables

Feedback:
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/8088#note_20133176
parent cc1eb7fe
......@@ -10,7 +10,7 @@ module Ci
has_many :deployments, as: :deployable
serialize :options
serialize :yaml_variables, Gitlab::Serialize::YamlVariables
serialize :yaml_variables, Gitlab::Serialize::Ci::Variables
validates :coverage, numericality: true, allow_blank: true
validates_presence_of :ref
......
module Gitlab
module Serialize
module Ci
# This serializer could make sure our YAML variables' keys and values
# are always strings. This is more for legacy build data because
# from now on we convert them into strings before saving to database.
module Variables
extend self
def load(string)
return unless string
object = YAML.safe_load(string, [Symbol])
object.map(&Variables.method(:convert_key_value_to_string))
end
def dump(object)
YAML.dump(object)
end
private
def convert_key_value_to_string(variable)
variable[:key] = variable[:key].to_s
variable[:value] = variable[:value].to_s
variable
end
end
end
end
end
module Gitlab
module Serialize
# This serializer could make sure our YAML variables' keys and values
# are always strings. This is more for legacy build data because
# from now on we convert them into strings before saving to database.
module YamlVariables
extend self
def load(string)
return unless string
object = YAML.safe_load(string, [Symbol])
object.map(&YamlVariables.method(:convert_key_value_to_string))
end
def dump(object)
YAML.dump(object)
end
private
def convert_key_value_to_string(variable)
variable[:key] = variable[:key].to_s
variable[:value] = variable[:value].to_s
variable
end
end
end
end
require 'spec_helper'
describe Gitlab::Serialize::YamlVariables do
describe Gitlab::Serialize::Ci::Variables do
subject do
described_class.load(described_class.dump(object))
end
......
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