Update remaining endpoints
This commit is contained in:
parent
f0f3f38576
commit
dcd4ea473c
|
|
@ -88,8 +88,7 @@ module API
|
|||
variable = user_group.variables.find_by(key: params[:key])
|
||||
not_found!('GroupVariable') unless variable
|
||||
|
||||
status 204
|
||||
variable.destroy
|
||||
destroy_conditionally!(variable)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ module API
|
|||
def check_unmodified_since!(last_modified)
|
||||
if_unmodified_since = Time.parse(headers['If-Unmodified-Since']) rescue nil
|
||||
|
||||
if if_unmodified_since && last_modified > if_unmodified_since
|
||||
if if_unmodified_since && last_modified && last_modified > if_unmodified_since
|
||||
render_api_error!('412 Precondition Failed', 412)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -117,8 +117,7 @@ module API
|
|||
not_found!('PipelineSchedule') unless pipeline_schedule
|
||||
authorize! :admin_pipeline_schedule, pipeline_schedule
|
||||
|
||||
status :accepted
|
||||
present pipeline_schedule.destroy, with: Entities::PipelineScheduleDetails
|
||||
destroy_conditionally!(pipeline_schedule)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
require_dependency 'declarative_policy'
|
||||
|
||||
module API
|
||||
# Projects API
|
||||
class Projects < Grape::API
|
||||
include PaginationParams
|
||||
|
||||
|
|
|
|||
|
|
@ -76,9 +76,7 @@ module API
|
|||
delete ':id/protected_branches/:name', requirements: BRANCH_ENDPOINT_REQUIREMENTS do
|
||||
protected_branch = user_project.protected_branches.find_by!(name: params[:name])
|
||||
|
||||
protected_branch.destroy
|
||||
|
||||
status 204
|
||||
destroy_conditionally!(protected_branch)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -655,9 +655,8 @@ module API
|
|||
end
|
||||
delete ":id/services/:service_slug" do
|
||||
service = user_project.find_or_initialize_service(params[:service_slug].underscore)
|
||||
# Todo: Check if this done the right way
|
||||
check_unmodified_since!(service.updated_at)
|
||||
|
||||
destroy_conditionally!(service) do
|
||||
attrs = service_attributes(service).inject({}) do |hash, key|
|
||||
hash.merge!(key => nil)
|
||||
end
|
||||
|
|
@ -666,6 +665,7 @@ module API
|
|||
render_api_error!('400 Bad Request', 400)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
desc 'Get the service settings for project' do
|
||||
success Entities::ProjectService
|
||||
|
|
|
|||
|
|
@ -408,8 +408,11 @@ module API
|
|||
requires :impersonation_token_id, type: Integer, desc: 'The ID of the impersonation token'
|
||||
end
|
||||
delete ':impersonation_token_id' do
|
||||
status 204
|
||||
find_impersonation_token.revoke!
|
||||
token = find_impersonation_token
|
||||
|
||||
destroy_conditionally!(token) do
|
||||
token.revoke!
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -88,6 +88,7 @@ module API
|
|||
variable = user_project.variables.find_by(key: params[:key])
|
||||
not_found!('Variable') unless variable
|
||||
|
||||
# Variables don't have any timestamp. Therfore, destroy unconditionally.
|
||||
status 204
|
||||
variable.destroy
|
||||
end
|
||||
|
|
|
|||
|
|
@ -267,8 +267,7 @@ describe API::PipelineSchedules do
|
|||
delete api("/projects/#{project.id}/pipeline_schedules/#{pipeline_schedule.id}", master)
|
||||
end.to change { project.pipeline_schedules.count }.by(-1)
|
||||
|
||||
expect(response).to have_http_status(:accepted)
|
||||
expect(response).to match_response_schema('pipeline_schedule')
|
||||
expect(response).to have_http_status(204)
|
||||
end
|
||||
|
||||
it 'responds with 404 Not Found if requesting non-existing pipeline_schedule' do
|
||||
|
|
|
|||
Loading…
Reference in New Issue