diff options
author | Matija Čupić <matteeyah@gmail.com> | 2018-02-06 17:56:54 +0100 |
---|---|---|
committer | Matija Čupić <matteeyah@gmail.com> | 2018-02-06 17:56:54 +0100 |
commit | efcdc269e03836e78dcc8d460621c948ac02bc24 (patch) | |
tree | a29e5d401d4182bf7823e91e3948d4ad8f3a95be /app | |
parent | d05cc9c6a6e46ed024a275240be0a5137622e474 (diff) | |
download | gitlab-ce-efcdc269e03836e78dcc8d460621c948ac02bc24.tar.gz |
Fix static_analysis failurece-39118-dynamic-pipeline-variables-fe
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/groups/variables_controller.rb | 16 | ||||
-rw-r--r-- | app/controllers/projects/variables_controller.rb | 12 |
2 files changed, 22 insertions, 6 deletions
diff --git a/app/controllers/groups/variables_controller.rb b/app/controllers/groups/variables_controller.rb index 0ebfebd6682..913e13bf734 100644 --- a/app/controllers/groups/variables_controller.rb +++ b/app/controllers/groups/variables_controller.rb @@ -11,20 +11,28 @@ module Groups end def update - if @group.update(variables_params) + if @group.update(group_variables_params) respond_to do |format| - format.json { return render status: :ok, json: { variables: GroupVariableSerializer.new.represent(@group.variables) } } + format.json { return render_group_variables } end else respond_to do |format| - format.json { render status: :bad_request, json: @group.errors.full_messages } + format.json { render_error } end end end private - def variables_params + def render_group_variables + render status: :ok, json: { variables: GroupVariableSerializer.new.represent(@group.variables) } + end + + def render_error + render status: :bad_request, json: @group.errors.full_messages + end + + def group_variables_params params.permit(variables_attributes: [*variable_params_attributes]) end diff --git a/app/controllers/projects/variables_controller.rb b/app/controllers/projects/variables_controller.rb index 329e1cdfef0..7eb509e2e64 100644 --- a/app/controllers/projects/variables_controller.rb +++ b/app/controllers/projects/variables_controller.rb @@ -12,17 +12,25 @@ class Projects::VariablesController < Projects::ApplicationController def update if @project.update(variables_params) respond_to do |format| - format.json { return render status: :ok, json: { variables: VariableSerializer.new.represent(@project.variables) } } + format.json { return render_variables } end else respond_to do |format| - format.json { render status: :bad_request, json: @project.errors.full_messages } + format.json { render_error } end end end private + def render_variables + render status: :ok, json: { variables: VariableSerializer.new.represent(@project.variables) } + end + + def render_error + render status: :bad_request, json: @project.errors.full_messages + end + def variables_params params.permit(variables_attributes: [*variable_params_attributes]) end |