Skip to content

Commit

Permalink
update tenant_quotas_spec to check for correct href
Browse files Browse the repository at this point in the history
simplify normalize_href
  • Loading branch information
Jillian Tullo committed Apr 19, 2017
1 parent 9c77b3a commit 6c2adb7
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 13 deletions.
13 changes: 1 addition & 12 deletions app/controllers/api/base_controller/normalizer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,24 +91,13 @@ def normalize_url(value)
# Let's normalize an href based on type and id value
#
def normalize_href(type, value)
# If it is already a string, ie "/vms/:id/", OR it is defined as a collection
if type.kind_of?(String) || collection_config[type].options.include?(:collection)
collection_href(type, value)
else # If it is not a string and not defined as a collection
subcollection_href(type, value)
end
type.to_s == @req.subcollection ? subcollection_href(type, value) : collection_href(type, value)
end

#
# Subcollection href
#
def subcollection_href(type, value)
normalize_url("#{@req.collection}/#{@req.c_id}/#{type}/#{value}")
end

#
# Collection href
#
def collection_href(type, value)
normalize_url("#{type}/#{value}")
end
Expand Down
2 changes: 1 addition & 1 deletion spec/requests/api/tenant_quotas_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
expect(response).to have_http_status(:ok)
quota.reload
expect(quota.value).to eq(5)
expect(response.parsed_body).to include('href' => /quotas/)
expect(response.parsed_body).to include('href' => a_string_including("tenants/#{tenant.id}/quotas/#{quota.id}"))
end

it "can update multiple quotas from a tenant with POST" do
Expand Down

0 comments on commit 6c2adb7

Please sign in to comment.