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

Return result of destroy action to user, not nil #14097

Merged
merged 2 commits into from
Mar 21, 2017
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
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

def copy_resource(type, id, data = {})
Expand Down
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