Skip to content

Commit

Permalink
Merge pull request #14112 from imtayadeway/api/delete-service-templat…
Browse files Browse the repository at this point in the history
…es-with-post

Delete service templates via POST
  • Loading branch information
abellotti authored Mar 1, 2017
2 parents 8cd3703 + 163cdad commit f05a091
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 @@ -1737,6 +1737,8 @@
:post:
- :name: edit
:identifier: catalogitem_edit
- :name: delete
:identifier: catalogitem_delete
:delete:
- :name: delete
:identifier: catalogitem_delete
Expand Down
28 changes: 28 additions & 0 deletions spec/requests/api/service_templates_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,34 @@
expect { st.reload }.to raise_error(ActiveRecord::RecordNotFound)
end

it "can delete a service template via POST with an appropriate role" do
api_basic_authorize(action_identifier(:service_templates, :delete))
service_template = FactoryGirl.create(:service_template)

expect do
run_post(service_templates_url(service_template.id), :action => "delete")
end.to change(ServiceTemplate, :count).by(-1)

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

it "will not delete a service template via POST without an appropriate role" do
api_basic_authorize
service_template = FactoryGirl.create(:service_template)

expect do
run_post(service_templates_url(service_template.id), :action => "delete")
end.not_to change(ServiceTemplate, :count)

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

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

Expand Down

0 comments on commit f05a091

Please sign in to comment.