Commit 53915c5c authored by Matija Čupić's avatar Matija Čupić

Alias secret_key and secret_value to key and value

parent 763c82f0
...@@ -35,12 +35,7 @@ module Groups ...@@ -35,12 +35,7 @@ module Groups
end end
def group_variables_params def group_variables_params
filtered_params = params.permit(variables_attributes: [*variable_params_attributes]) 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
end end
def variable_params_attributes def variable_params_attributes
......
...@@ -32,12 +32,7 @@ class Projects::VariablesController < Projects::ApplicationController ...@@ -32,12 +32,7 @@ class Projects::VariablesController < Projects::ApplicationController
end end
def variables_params def variables_params
filtered_params = params.permit(variables_attributes: [*variable_params_attributes]) 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
end end
def variable_params_attributes def variable_params_attributes
......
...@@ -6,6 +6,9 @@ module Ci ...@@ -6,6 +6,9 @@ module Ci
belongs_to :group belongs_to :group
alias_attribute :secret_key, :key
alias_attribute :secret_value, :value
validates :key, uniqueness: { validates :key, uniqueness: {
scope: :group_id, scope: :group_id,
message: "(%{value}) has already been taken" message: "(%{value}) has already been taken"
......
...@@ -6,6 +6,9 @@ module Ci ...@@ -6,6 +6,9 @@ module Ci
belongs_to :project belongs_to :project
alias_attribute :secret_key, :key
alias_attribute :secret_value, :value
validates :key, uniqueness: { validates :key, uniqueness: {
scope: [:project_id, :environment_scope], scope: [:project_id, :environment_scope],
message: "(%{value}) has already been taken" message: "(%{value}) has already been taken"
......
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