Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete templates via POST #14110

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions config/api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1967,6 +1967,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