Skip to content

Commit

Permalink
Merge pull request #14111 from imtayadeway/api/delete-services-with-post
Browse files Browse the repository at this point in the history
Delete services via POST
  • Loading branch information
abellotti authored Mar 1, 2017
2 parents f05a091 + 232a3c4 commit 1e2e0c4
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
2 changes: 2 additions & 0 deletions config/api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1825,6 +1825,8 @@
:identifier: service_admin
- :name: suspend
:identifier: service_admin
- :name: delete
:identifier: service_delete
:delete:
- :name: delete
:identifier: service_delete
Expand Down
28 changes: 28 additions & 0 deletions spec/requests/api/services_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,34 @@
expect { svc.reload }.to raise_error(ActiveRecord::RecordNotFound)
end

it "can be deleted via POST with an appropriate role" do
service = FactoryGirl.create(:service)
api_basic_authorize(action_identifier(:services, :delete))

expect do
run_post(services_url(service.id), :action => "delete")
end.to change(Service, :count).by(-1)

expected = {
"success" => true,
"message" => "services id: #{service.id} deleting",
"href" => a_string_matching(services_url(service.id))
}
expect(response.parsed_body).to include(expected)
expect(response).to have_http_status(:ok)
end

it "won't delete a service via POST without an appropriate role" do
service = FactoryGirl.create(:service)
api_basic_authorize

expect do
run_post(services_url(service.id), :action => "delete")
end.not_to change(Service, :count)

expect(response).to have_http_status(:forbidden)
end

it "supports multiple resource deletes" do
api_basic_authorize collection_action_identifier(:services, :delete)

Expand Down

0 comments on commit 1e2e0c4

Please sign in to comment.