Skip to content

Commit

Permalink
raise not found error on DELETE
Browse files Browse the repository at this point in the history
  • Loading branch information
Jillian Tullo committed Aug 4, 2017
1 parent f9bf14e commit 050aaf9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app/controllers/api/authentications_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ def delete_resource(type, id, _data = {})
raise "Delete not supported for #{authentication_ident(auth)}" unless auth.respond_to?(:delete_in_provider_queue)
task_id = auth.delete_in_provider_queue
action_result(true, "Deleting #{authentication_ident(auth)}", :task_id => task_id)
rescue ActiveRecord::RecordNotFound => err
@req.method == :delete ? raise(err) : action_result(false, err.to_s)
rescue => err
action_result(false, err.to_s)
end
Expand Down
8 changes: 8 additions & 0 deletions spec/requests/api/authentications_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,14 @@

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

it 'will raise an error if the authentication does not exist' do
api_basic_authorize action_identifier(:authentications, :delete, :resource_actions, :delete)

run_delete(authentications_url(999_999))

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

describe 'OPTIONS /api/authentications' do
Expand Down

0 comments on commit 050aaf9

Please sign in to comment.