Skip to content

Commit

Permalink
Merge pull request #14097 from isimluk/rhbz#1414881
Browse files Browse the repository at this point in the history
Return result of destroy action to user, not nil
(cherry picked from commit 9aa0cfe)

https://bugzilla.redhat.com/show_bug.cgi?id=1434952
  • Loading branch information
abellotti authored and simaishi committed Apr 13, 2017
1 parent e1c19c7 commit 9608b90
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app/controllers/api/orchestration_templates_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ class OrchestrationTemplatesController < BaseController
def delete_resource(type, id, data = {})
klass = collection_class(type)
resource = resource_search(id, type, klass)
super
result = super
resource.raw_destroy if resource.kind_of?(OrchestrationTemplateVnfd)
result
end
end
end
12 changes: 12 additions & 0 deletions spec/requests/api/orchestration_template_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,18 @@
expect(OrchestrationTemplate.exists?(cfn.id)).to be_falsey
end

it 'runs callback before_destroy on the model' do
api_basic_authorize collection_action_identifier(:orchestration_templates, :delete)

cfn = FactoryGirl.create(:orchestration_template_vnfd_with_content)
api_basic_authorize collection_action_identifier(:orchestration_templates, :delete)
expect_any_instance_of(OrchestrationTemplateVnfd).to receive(:raw_destroy).with(no_args) # callback on the model
run_delete(orchestration_templates_url(cfn.id))

expect(response).to have_http_status(:no_content)
expect(OrchestrationTemplate.exists?(cfn.id)).to be_falsey
end

it 'supports multiple orchestration_template delete' do
api_basic_authorize collection_action_identifier(:orchestration_templates, :delete)

Expand Down

0 comments on commit 9608b90

Please sign in to comment.