Skip to content

Commit

Permalink
Remove dead href parsing paths
Browse files Browse the repository at this point in the history
If hrefs were supplied in the request body, they should have already
been parsed by `BaseController#update_multiple_collections` and given to
these methods as the id for the resource they represent. So these parts
of the code should been unreachable, and can be replaced by an empty
hash in the event that all other attempts to parse the resource at hand
have failed.

Follow up to ManageIQ#13671
  • Loading branch information
imtayadeway committed Jan 27, 2017
1 parent 479460f commit 207fd39
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 12 deletions.
3 changes: 1 addition & 2 deletions app/controllers/api/subcollections/policies.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ def parse_policy(data, collection, klass)
guid = data["guid"]
return klass.find_by(:guid => guid) if guid.present?

href = data["href"]
href =~ %r{^.*/#{collection}/#{BaseController::CID_OR_ID_MATCHER}$} ? klass.find(from_cid(href.split('/').last)) : {}
{}
end

def policy_subcollection_action(ctype, policy)
Expand Down
11 changes: 1 addition & 10 deletions app/controllers/api/subcollections/tags.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,16 +80,7 @@ def parse_tag(data)
return {:category => category, :name => name} if category && name
return tag_path_to_spec(name) if name && name[0] == '/'

parse_tag_from_href(data)
end

def parse_tag_from_href(data)
href = data["href"]
tag = if href && href.match(%r{^.*/tags/#{BaseController::CID_OR_ID_MATCHER}$})
klass = collection_class(:tags)
klass.find(from_cid(href.split('/').last))
end
tag.present? ? tag_path_to_spec(tag.name).merge(:id => tag.id) : {}
{}
end

def tag_path_to_spec(path)
Expand Down

0 comments on commit 207fd39

Please sign in to comment.