-
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 BadRequestError when invalid attributes are specified #15040
Return BadRequestError when invalid attributes are specified #15040
Conversation
@miq-bot remove_label wip |
spec/requests/api/querying_spec.rb
Outdated
@@ -599,7 +598,7 @@ def create_vms_by_name(names) | |||
run_get vms_url, :expand => "resources,software" | |||
|
|||
expect_query_result(:vms, 1, 1) | |||
expect_result_resources_to_include_keys("resources", %w(id href guid name vendor software)) |
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.
I'm not sure I follow why these keys disappeared as a result of this change and whether that was intended?
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.
Ah, I see they were added back in the next commit. Is there a way of removing these changes from the history? Is this commit only 🍏 with this change?
spec/requests/api/querying_spec.rb
Outdated
@@ -739,7 +738,7 @@ def create_vms_by_name(names) | |||
run_get vms_url(vm1.id), :attributes => "disconnected" | |||
|
|||
expect(response).to have_http_status(:ok) | |||
expect_result_to_have_keys(%w(id href name vendor disconnected actions)) |
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.
Same question as with 90d453f#r115862423
@abellotti bump |
@jntullo can you resolve conflict and update ? Thanks. |
This pull request is not mergeable. Please rebase and repush. |
return empty array to select all attributes if only ID attributes are specified
…er; pass physical_attrs to functions instead of calling for them again
Checked commits jntullo/manageiq@f6c0ba5~...0780e5f with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0 |
Thanks @jntullo for making this enhancement. 😍 |
This PR consolidates attribute selection into one method,
validate_attr_selection
, which is able to then validate the selected attributes, and adds some other minor/related refactoring.By consolidating and returning the
physical_attrs
andvirtual_attrs
, it also removes the need to retrieve physical attributes viaphysical_attribute_selection
more than once.One issue encountered is when @additional_attributes is set for a subcollection, and therefore it does not respond to
attr_virtual?
orattr_physical?
, considering it as avirtual_attribute
removes any issues.render_resource_attr
is unnecessary asnormalize_hash
already ensures only the selected attributes are chosen and that they are not nil.@miq-bot add_label wip, api, enhancement
@miq-bot assign @abellotti
cc: @imtayadeway