-
Notifications
You must be signed in to change notification settings - Fork 897
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
Return href on create #15005
Return href on create #15005
Conversation
probably some type/collection check missing, href should have reflect tags here.
|
probably also need tests checking href on creating subcollections, and simply fetching subcollections via expand and these are returned with proper href. tested ok by hand, but should be in rspecs if not there. Thanks. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @jntullo, minor changes below. However, I'm still getting results with creating tags, should be getting /api/tags/# href, can you look into this ? Thanks.
{
"name" : "hi",
"description" : "Hello",
"category" : { "id" : 40 }
}
{
"results": [
{
"href": "http://localhost:3000/api/results/165",
"id": 165,
"name": "/managed/department/hi"
}
]
}
spec/requests/api/blueprints_spec.rb
Outdated
@@ -128,8 +128,8 @@ | |||
|
|||
expected = { | |||
"results" => a_collection_containing_exactly( | |||
a_hash_including("name" => "foo", "description" => "bar"), | |||
a_hash_including("name" => "baz", "description" => "qux") | |||
a_hash_including("name" => "foo", "description" => "bar", "href" => a_string_including("/api/results")), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would prefer using results_url instead of "/api/results", same below.
spec/requests/api/tags_spec.rb
Outdated
tag_category = Category.find(tag.category.id) | ||
expect(tag_category).to eq(category) | ||
|
||
expect(result["href"]).to include("/api/results/#{tag.id}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
using results_url(tag.id) instead of "/api/results/#{tag.id}"
@@ -43,10 +43,15 @@ | |||
it "can create a quota from a tenant" do | |||
api_basic_authorize action_identifier(:quotas, :create, :subcollection_actions, :post) | |||
|
|||
expected = { | |||
'results' => [ | |||
a_hash_including('href' => a_string_including('api/results/')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
results_url
Checked commits jntullo/manageiq@a2caa5a~...b0fec4e with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0 |
@abellotti bump |
yeay, happy tags href returned. Thanks @jntullo for this enhancement 😍 |
The
{:add_href => true}
is not being sent tonormalize_hash
as it is looping through theresults
on create. As a result, thehref
was not being added to the resources. It does not appear that:add_href
is actually serving any purpose.Removing the condition on
:add_href
appropriately adds thehref
to the resources and maintains other functionality.@miq-bot add_label api, enhancement
@miq-bot assign @abellotti
Pivotal ticket