Skip to content

Commit

Permalink
Fixes #6971,bz1085417 - api handle nonexistent id
Browse files Browse the repository at this point in the history
In capsule and product APIs, the show action for a nonexistant id fails
to give a proper 404.

for example /api/products/123123 where product 123132 does not exist
product gives 500 no resource loaded

capsule gives protected method `resource_name' called for
  • Loading branch information
Dustin Tsang committed Aug 11, 2014
1 parent 71d9d2b commit 5a6d9ca
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
8 changes: 4 additions & 4 deletions app/controllers/katello/api/v2/capsules_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,16 @@ def show
super
end

def resource_name
:smart_proxy
end

protected

def resource_class
SmartProxy
end

def resource_name
:smart_proxy
end

def authorized
User.current.allowed_to?(params.slice(:action, :id).merge(controller: 'api/v2/smart_proxies'))
end
Expand Down
3 changes: 2 additions & 1 deletion app/controllers/katello/api/v2/products_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ def sync
protected

def find_product
@product = Product.find_by_id(params[:id]) if params[:id]
@product = Product.find_by_id(params[:id])
fail HttpErrors::NotFound, _("Couldn't find product '%s'") % params[:id] unless @product
end

def find_activation_key
Expand Down

0 comments on commit 5a6d9ca

Please sign in to comment.