-
Notifications
You must be signed in to change notification settings - Fork 143
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
Add flag to initialize field default values #485
Conversation
@eclarizio can you 👀 please? |
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 feel like this would be much better as a parameter. For example, if the parameter of "init_defaults" is passed in as true, then we remove the :submit_workflow => true
and use :init_defaults => true
instead, cause otherwise as you have it now it's going to always call automate, no?
8941245
to
6311303
Compare
d4c8f5d
to
b41704a
Compare
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.
One small comment but otherwise I think this should do what we want. 👍
58c3f88
to
01c7c09
Compare
@miq-bot remove_label wip |
Hey @eclarizio can you please review again? |
@@ -469,6 +476,8 @@ def init_st(service_template, resource_action) | |||
let(:ra1) { FactoryGirl.create(:resource_action, :action => "Provision", :dialog => dialog1) } | |||
let(:st1) { FactoryGirl.create(:service_template, :name => "service template 1") } | |||
let(:sc) { FactoryGirl.create(:service_template_catalog, :name => "sc", :description => "sc description") } | |||
let(:product_settings) { double(:run_automate_methods_on_service_catalog_api_submit => run_automate_methods_on_service_catalog_api_submit) } |
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 don't think product_settings
is being used anywhere currently?
@miq-bot add_reviewer @tinaafitz |
@d-m-u if this will be able to be backported, please add the gaprindashvili/yes and hammer/yes labels |
@miq-bot add_label blocker |
@miq-bot add_label bug |
@miq-bot add_label gaprindashvili/yes, hammer/yes |
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.
Couple more spec comments, but the code itself should be fine
@@ -469,6 +476,7 @@ def init_st(service_template, resource_action) | |||
let(:ra1) { FactoryGirl.create(:resource_action, :action => "Provision", :dialog => dialog1) } | |||
let(:st1) { FactoryGirl.create(:service_template, :name => "service template 1") } | |||
let(:sc) { FactoryGirl.create(:service_template_catalog, :name => "sc", :description => "sc description") } | |||
let(:run_automate_methods_on_service_catalog_api_submit) { 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.
Now that you fixed the product_settings
not being used anywhere, this variable isn't being used either. I figured you meant to change line 372 (https://github.com/ManageIQ/manageiq-api/pull/485/files#diff-e129a646c1b31a559a2192293c958cf9R372) to use product_settings
which then uses this variable.
|
||
context "with the product setting not allowing automate to run on submit" do | ||
let(:template_no_display) { FactoryGirl.create(:service_template, :display => false) } | ||
let(:run_automate_methods_on_service_catalog_api_submit) { false } |
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.
Is this variable being used anywhere?
Egad, 's a blocker here, we need eyes far sharper than mine, @abellotti if we turn this into a wrestling match, and I tag you in... 🤼♂️ |
@@ -14,6 +15,16 @@ def order_service_template(id, data, scheduled_time = nil) | |||
|
|||
private | |||
|
|||
def request_from_ui? |
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.
Can you use auth_mechanism
here instead? https://github.com/ManageIQ/manageiq-api/pull/488/files#diff-a7e4db9275b9f3963c7d8d24685f6bb8R6
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.
Didn't we determine that it would be better to verify the token instead of solely going on if it's an http basic request versus token to know if the request is coming from the UI? At least that was my understanding from the conversation at #476 (comment).
Maybe that method could be extended or used in another way, but I don't think simply changing to use auth_mechanism
is the correct solution.
@miq-bot assign @abellotti |
@bdunne can you review,...Mr. Alberto is tied up at the moment. This is for a blocker issue. |
@@ -14,6 +15,16 @@ def order_service_template(id, data, scheduled_time = nil) | |||
|
|||
private | |||
|
|||
def request_from_ui? | |||
return false if request.headers["x-auth-token"].blank? | |||
!token_info.empty? |
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.
Prefer .present?
over !x.empty?
let(:product_settings) { double(:run_automate_methods_on_service_api_submit => run_automate_methods_on_service_api_submit) } | ||
|
||
before do | ||
stub_settings_merge(:product => product_settings) |
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.
Shouldn't this be a hash rather than a double and let
blocks?
let(:ra2) { FactoryGirl.create(:resource_action, :action => "Provision", :dialog => dialog1) } | ||
let(:st2) { FactoryGirl.create(:service_template, :name => "service template 2", :display => true) } | ||
let(:sc) { FactoryGirl.create(:service_template_catalog, :name => "sc", :description => "sc description") } | ||
let(:run_automate_methods_on_service_api_submit) { 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.
Why is this in a let
block?
Checked commit d-m-u@f2f024a with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0 |
Thanks @bdunne! |
Add flag to initialize field default values (cherry picked from commit 73eee92) https://bugzilla.redhat.com/show_bug.cgi?id=1635673
Hammer backport details:
|
Add flag to initialize field default values (cherry picked from commit 73eee92) https://bugzilla.redhat.com/show_bug.cgi?id=1639413
Gaprindashvili backport details:
|
Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1635673
At this point if a service dialog gets ordered via the API, it will not honor defaults on static fields. To remedy this, this adds a flag to the call to also let us call
load_values_into_fields(values, false)
, thus honoring the default values. This builds on the recent changes to ManageIQ/manageiq#17844Related:
ManageIQ/manageiq#18061