Return all variables after UPDATE
This commit is contained in:
parent
9eb3bb5cff
commit
b48d8c8ad0
4 changed files with 36 additions and 2 deletions
|
@ -16,7 +16,12 @@ module Groups
|
||||||
def update
|
def update
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.json do
|
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
|
render status: :bad_request, json: @group.errors.full_messages
|
||||||
end
|
end
|
||||||
|
|
|
@ -15,7 +15,12 @@ class Projects::VariablesController < Projects::ApplicationController
|
||||||
def update
|
def update
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.json do
|
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
|
render status: :bad_request, json: @project.errors.full_messages
|
||||||
end
|
end
|
||||||
|
|
|
@ -78,6 +78,12 @@ describe Groups::VariablesController do
|
||||||
|
|
||||||
expect(response).to have_gitlab_http_status(:ok)
|
expect(response).to have_gitlab_http_status(:ok)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'has all variables in response' do
|
||||||
|
subject
|
||||||
|
|
||||||
|
expect(response.body).to include(group.variables.reload.to_json)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with a deleted variable' do
|
context 'with a deleted variable' do
|
||||||
|
@ -101,6 +107,12 @@ describe Groups::VariablesController do
|
||||||
|
|
||||||
expect(response).to have_gitlab_http_status(:ok)
|
expect(response).to have_gitlab_http_status(:ok)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'has all variables in response' do
|
||||||
|
subject
|
||||||
|
|
||||||
|
expect(response.body).to include(group.variables.reload.to_json)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -87,6 +87,12 @@ describe Projects::VariablesController do
|
||||||
|
|
||||||
expect(response).to have_gitlab_http_status(:ok)
|
expect(response).to have_gitlab_http_status(:ok)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'has all variables in response' do
|
||||||
|
subject
|
||||||
|
|
||||||
|
expect(response.body).to include(project.variables.reload.to_json)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with a deleted variable' do
|
context 'with a deleted variable' do
|
||||||
|
@ -110,6 +116,12 @@ describe Projects::VariablesController do
|
||||||
|
|
||||||
expect(response).to have_gitlab_http_status(:ok)
|
expect(response).to have_gitlab_http_status(:ok)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'has all variables in response' do
|
||||||
|
subject
|
||||||
|
|
||||||
|
expect(response.body).to include(project.variables.reload.to_json)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue