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

Fix cid constant namespacing in the API #13671

Merged
merged 2 commits into from
Jan 27, 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
4 changes: 1 addition & 3 deletions app/controllers/api/base_controller/parser.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
module Api
class BaseController
module Parser
include CompressedIds

def parse_api_request
@req = RequestAdapter.new(request, params)
end
Expand Down Expand Up @@ -104,7 +102,7 @@ def parse_id(resource, collection)
end

def href_id(href, collection)
if href.present? && href.match(%r{^.*/#{collection}/(#{CID_OR_ID_MATCHER})$})
if href.present? && href.match(%r{^.*/#{collection}/(#{BaseController::CID_OR_ID_MATCHER})$})
from_cid(Regexp.last_match(1))
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/api/subcollections/policies.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def parse_policy(data, collection, klass)
return klass.find_by(:guid => guid) if guid.present?

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

def policy_subcollection_action(ctype, policy)
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/api/subcollections/tags.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def parse_tag(data)

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