-
Notifications
You must be signed in to change notification settings - Fork 987
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
Fixes #12566 - host_parameters_attributes accepts nested flag #2928
Conversation
@@ -82,6 +82,12 @@ def show | |||
param_group :host, :as => :create | |||
|
|||
def create | |||
params[:host][:host_parameters_attributes] && params[:host] && params[:host][:host_parameters_attributes].each do |a| |
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.
Testing params[:host]
after accessing its :host_parameters_attributes
member is the wrong order, as the hypothetical error would be on the first condition.
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.
Oh, it's being tested twice - remove the first.
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.
Nitpick, use a longer variable name than a
please (attribute?).
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.
On Mon, Nov 23, 2015 at 07:23:51AM -0800, Dominic Cleal wrote:
@@ -82,6 +82,12 @@ def show
param_group :host, :as => :createdef create
params[:host][:host_parameters_attributes] && params[:host] && params[:host][:host_parameters_attributes].each do |a|
Oh, it's being tested twice - remove the first.
Yeah, completely screwed copy+paste operation :-)
Later,
Lukas #lzap Zapletal
Expect it like any other method, i.e. Other comments:
|
3dda76d
to
064b095
Compare
All done, except the extra documentation desc field, I don't know Later, |
Attributes of Parameter (name, value) and attributes that accepts_nested supports (_destroy)? |
@@ -1,6 +1,9 @@ | |||
module Api | |||
module V1 | |||
class HostsController < V1::BaseController | |||
include Api::CompatibilityChecker | |||
before_filter :check_create_host_nested, :only => [:create] |
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.
Applicable for :update too?
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.
Applicable for :update too?
Pushed, without unit test tho, don't think it's necessary.
Later,
Lukas #lzap Zapletal
064b095
to
1a42b92
Compare
2015-11-27T11:42:40 [app] [I] Started POST "/api/v2/hosts" for 127.0.0.1 at 2015-11-27 11:42:40 +0000 2015-11-27T11:42:41 [app] [I] Processing by Api::V2::HostsController#create as JSON 2015-11-27T11:42:41 [app] [I] Parameters: {"host"=>{"name"=>"test12566a", "hostgroup_name"=>"libvirt", "compute_resource_name"=>"localhost", "host_parameters_attributes"=>{"0"=>{"name"=>"myparam", "value"=>"[FILTERED]", "nested"=>"true"}}}, "apiv"=>"v2"} ... | ActiveRecord::UnknownAttributeError: unknown attribute: nested
|
How to document both array and hash input? Later, |
I don't know, you'll have to look at apipie-bindings. Documenting one is probably fine. |
1a42b92
to
27bc465
Compare
Right, documented the array with a comment for hash. Pushed. Later, |
do we want to support both array and a hash? AFAIR one is for create the
other for update?
|
There are test failures, please take a look. |
We do support both now, the checker just deletes the attribute and Later, |
Strange, my rubocop was/is green. Fixed. Later, |
You may have to take into account that our Jenkins jobs are configured to test the PR when rebased/merged onto develop (to pick up any potential logical/non-patch conflicts). It's possible that a test passes on the branch but not when added to the current state of the base branch. |
Damn squashed it into incorrect PR, hold on. |
27bc465
to
2fd6b76
Compare
Pushed. |
@@ -62,7 +65,10 @@ def show | |||
param :owner_type, Host::Base::OWNER_TYPES, :desc => N_("Host's owner type") | |||
param :puppet_ca_proxy_id, :number | |||
param :image_id, :number | |||
param :host_parameters_attributes, Array | |||
param :host_parameters_attributes, Array, :desc => N_("Host's parameters (array or indexed hash)") do | |||
param :name, String, :desc => "Name of the parameter", :required => true |
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.
missing string extraction here
2fd6b76
to
43d09dd
Compare
@@ -45,7 +48,10 @@ def show | |||
param :owner_id, :number | |||
param :puppet_ca_proxy_id, :number | |||
param :image_id, :number | |||
param :host_parameters_attributes, Array | |||
param :host_parameters_attributes, Array, :desc => N_("Host's parameters (array or indexed hash)") do |
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.
indentation's off here, and there's no need for translations in the v1 controller
This missed 1.10.0 as the latest comment wasn't fixed, but remains on the .1 list. If you could rebase it and fix the comment, it'd be appreciated. |
Hello? Quite a trival comment, but please fix it and rebase the PR. |
Merged as and fixed up in 7ee381e. |
This is for compatibility reasons. I wish we had an expectation for deprecation
warnings, so we can actually silence them and also test them! Should not be too
difficult to do I guess, ideas?