diff options
author | Matija Čupić <matteeyah@gmail.com> | 2018-01-30 00:44:53 +0100 |
---|---|---|
committer | Matija Čupić <matteeyah@gmail.com> | 2018-02-05 18:58:19 +0100 |
commit | b48d8c8ad0bb2874db6b4c9accb3bebd19e9f2c8 (patch) | |
tree | b3639bb715f458a6023e7f4556cb3ffcb4167aa8 | |
parent | 9eb3bb5cffbd18a744be2553ab2be7cb7843b029 (diff) | |
download | gitlab-ce-b48d8c8ad0bb2874db6b4c9accb3bebd19e9f2c8.tar.gz |
Return all variables after UPDATE
4 files changed, 36 insertions, 2 deletions
diff --git a/app/controllers/groups/variables_controller.rb b/app/controllers/groups/variables_controller.rb index c0eff63da18..afa98aa8267 100644 --- a/app/controllers/groups/variables_controller.rb +++ b/app/controllers/groups/variables_controller.rb @@ -16,7 +16,12 @@ module Groups def update respond_to do |format| format.json do - return head :ok if @group.update(variables_params) + if @group.update(variables_params) + variables = @group.variables + .map { |variable| variable.present(current_user: current_user) } + + return render status: :ok, json: { variables: variables } + end render status: :bad_request, json: @group.errors.full_messages end diff --git a/app/controllers/projects/variables_controller.rb b/app/controllers/projects/variables_controller.rb index 2f03603bd1d..58fa600eb34 100644 --- a/app/controllers/projects/variables_controller.rb +++ b/app/controllers/projects/variables_controller.rb @@ -15,7 +15,12 @@ class Projects::VariablesController < Projects::ApplicationController def update respond_to do |format| format.json do - return head :ok if @project.update(variables_params) + if @project.update(variables_params) + variables = @project.variables + .map { |variable| variable.present(current_user: current_user) } + + return render status: :ok, json: { variables: variables } + end render status: :bad_request, json: @project.errors.full_messages end diff --git a/spec/controllers/groups/variables_controller_spec.rb b/spec/controllers/groups/variables_controller_spec.rb index a462d64c0f5..4927a9ee402 100644 --- a/spec/controllers/groups/variables_controller_spec.rb +++ b/spec/controllers/groups/variables_controller_spec.rb @@ -78,6 +78,12 @@ describe Groups::VariablesController do expect(response).to have_gitlab_http_status(:ok) end + + it 'has all variables in response' do + subject + + expect(response.body).to include(group.variables.reload.to_json) + end end context 'with a deleted variable' do @@ -101,6 +107,12 @@ describe Groups::VariablesController do expect(response).to have_gitlab_http_status(:ok) end + + it 'has all variables in response' do + subject + + expect(response.body).to include(group.variables.reload.to_json) + end end end end diff --git a/spec/controllers/projects/variables_controller_spec.rb b/spec/controllers/projects/variables_controller_spec.rb index ab8915c58d0..ddba6cd83f4 100644 --- a/spec/controllers/projects/variables_controller_spec.rb +++ b/spec/controllers/projects/variables_controller_spec.rb @@ -87,6 +87,12 @@ describe Projects::VariablesController do expect(response).to have_gitlab_http_status(:ok) end + + it 'has all variables in response' do + subject + + expect(response.body).to include(project.variables.reload.to_json) + end end context 'with a deleted variable' do @@ -110,6 +116,12 @@ describe Projects::VariablesController do expect(response).to have_gitlab_http_status(:ok) end + + it 'has all variables in response' do + subject + + expect(response.body).to include(project.variables.reload.to_json) + end end end end |