Alias secret_key and secret_value to key and value

上级 763c82f0
......@@ -35,12 +35,7 @@ module Groups
end
def group_variables_params
filtered_params = params.permit(variables_attributes: [*variable_params_attributes])
filtered_params["variables_attributes"].each do |variable|
variable["key"] = variable.delete("secret_key")
variable["value"] = variable.delete("secret_value")
end
filtered_params
params.permit(variables_attributes: [*variable_params_attributes])
end
def variable_params_attributes
......
......@@ -32,12 +32,7 @@ class Projects::VariablesController < Projects::ApplicationController
end
def variables_params
filtered_params = params.permit(variables_attributes: [*variable_params_attributes])
filtered_params["variables_attributes"].each do |variable|
variable["key"] = variable.delete("secret_key")
variable["value"] = variable.delete("secret_value")
end
filtered_params
params.permit(variables_attributes: [*variable_params_attributes])
end
def variable_params_attributes
......
......@@ -6,6 +6,9 @@ module Ci
belongs_to :group
alias_attribute :secret_key, :key
alias_attribute :secret_value, :value
validates :key, uniqueness: {
scope: :group_id,
message: "(%{value}) has already been taken"
......
......@@ -6,6 +6,9 @@ module Ci
belongs_to :project
alias_attribute :secret_key, :key
alias_attribute :secret_value, :value
validates :key, uniqueness: {
scope: [:project_id, :environment_scope],
message: "(%{value}) has already been taken"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册