diff options
author | Matija Čupić <matteeyah@gmail.com> | 2018-03-17 12:17:40 +0100 |
---|---|---|
committer | Matija Čupić <matteeyah@gmail.com> | 2018-03-17 16:33:36 +0100 |
commit | 53915c5c54c06182717b457375ae771ee01558fd (patch) | |
tree | e270fe3c239f6fd91871b5157665abfe2aa8867b | |
parent | 763c82f0b304362be71ca82e551381609db19bf8 (diff) | |
download | gitlab-ce-53915c5c54c06182717b457375ae771ee01558fd.tar.gz |
Alias secret_key and secret_value to key and value
-rw-r--r-- | app/controllers/groups/variables_controller.rb | 7 | ||||
-rw-r--r-- | app/controllers/projects/variables_controller.rb | 7 | ||||
-rw-r--r-- | app/models/ci/group_variable.rb | 3 | ||||
-rw-r--r-- | app/models/ci/variable.rb | 3 |
4 files changed, 8 insertions, 12 deletions
diff --git a/app/controllers/groups/variables_controller.rb b/app/controllers/groups/variables_controller.rb index 2794d5fe6ec..91e394c8ce8 100644 --- a/app/controllers/groups/variables_controller.rb +++ b/app/controllers/groups/variables_controller.rb @@ -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 diff --git a/app/controllers/projects/variables_controller.rb b/app/controllers/projects/variables_controller.rb index 3cbfe7b3cc1..ffe93522ca6 100644 --- a/app/controllers/projects/variables_controller.rb +++ b/app/controllers/projects/variables_controller.rb @@ -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 diff --git a/app/models/ci/group_variable.rb b/app/models/ci/group_variable.rb index 1dd0e050ba9..65399557289 100644 --- a/app/models/ci/group_variable.rb +++ b/app/models/ci/group_variable.rb @@ -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" diff --git a/app/models/ci/variable.rb b/app/models/ci/variable.rb index 7c71291de84..bcad55f115f 100644 --- a/app/models/ci/variable.rb +++ b/app/models/ci/variable.rb @@ -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" |