Skip to content

Commit

Permalink
Merge pull request #14110 from imtayadeway/api/delete-templates-with-…
Browse files Browse the repository at this point in the history
…post

Delete templates via POST
  • Loading branch information
abellotti authored Mar 1, 2017
2 parents 22db667 + 806ec25 commit 69331df
Show file tree
Hide file tree
Showing 2 changed files with 32 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 @@ -1971,6 +1971,8 @@
:disabled: true
- :name: set_ownership
:identifier: miq_template_ownership
- :name: delete
:identifier: miq_template_delete
:delete:
- :name: delete
:identifier: miq_template_delete
Expand Down
30 changes: 30 additions & 0 deletions spec/requests/api/templates_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,34 @@
RSpec.describe "Templates API" do
describe "POST /api/templates/:c_id with DELETE action" do
it "deletes a template with an appropriate role" do
api_basic_authorize(action_identifier(:templates, :delete))
template = FactoryGirl.create(:template)

expect do
run_post(templates_url(template.id), :action => "delete")
end.to change(MiqTemplate, :count).by(-1)

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

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

expect do
run_post(templates_url(template.id), :action => "delete")
end.not_to change(MiqTemplate, :count)

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

describe "tags subcollection" do
it "can list a template's tags" do
template = FactoryGirl.create(:template)
Expand Down

0 comments on commit 69331df

Please sign in to comment.