Skip to content
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

Load dialog fields with updated values on workflow submit #17855

Merged
merged 2 commits into from
Aug 22, 2018

Conversation

d-m-u
Copy link
Contributor

@d-m-u d-m-u commented Aug 13, 2018

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1594469

We need to run load_values_into_fields inside the resource action workflow, not where they're currently running because with the changes to how and when we load field values, this functionality broke.

I think that the api needs to be passing the changed field values into the resource action workflow when we make the submit workflow call. Otherwise the field values automate sees by the time we get to https://github.com/ManageIQ/manageiq/blob/master/app/models/resource_action_workflow.rb#L81 will be the default values only, not the updated fields you changed on the dialog.

The setup this applies to is a custom button on a generic object.

Related to

ManageIQ/manageiq-api#448

@d-m-u
Copy link
Contributor Author

d-m-u commented Aug 13, 2018

@miq-bot add_label bug, blocker, gaprindashvili/yes
@miq-bot assign @gmcculloug
@miq-bot add_reviewer @eclarizio

@@ -21,14 +21,19 @@ def initialize(values, requester, resource_action, options = {})

Vmdb::Deprecation.deprecate_methods(self, :dialogs => :dialog)

def submit_request
def submit_request(data)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we provide a default value (data = {}) which would remove the need to pass empty hashes in service_template and the specs?

Also, service_template and the specs is not a good band name. 🎻 🥁

Copy link
Member

@eclarizio eclarizio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know it's still WIP, but since a review was requested: spec please? 😄

@d-m-u d-m-u changed the title [WIP] Load dialog fields with updated values on workflow submit Load dialog fields with updated values on workflow submit Aug 14, 2018
@d-m-u
Copy link
Contributor Author

d-m-u commented Aug 14, 2018

@miq-bot remove_label wip

@miq-bot miq-bot removed the wip label Aug 14, 2018
@d-m-u
Copy link
Contributor Author

d-m-u commented Aug 20, 2018

@eclarizio can you please take another look for me?

Copy link
Member

@eclarizio eclarizio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding the spec, but I think you need to add a spec for the #submit_request method as well, since that's really the main method you changed and is what the API will be calling into.

@@ -21,14 +21,19 @@ def initialize(values, requester, resource_action, options = {})

Vmdb::Deprecation.deprecate_methods(self, :dialogs => :dialog)

def submit_request
def submit_request(data = {})
update_dialog_field_values(data) if data.present?
Copy link
Member

@eclarizio eclarizio Aug 20, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


Disregard. My mistake, when testing I set a variable of `test` to a valid hash and `test2` to an empty hash and when I went to test `.present?` I used `test.present?` which of course returned true. `test2.present?` does indeed return false.

@miq-bot
Copy link
Member

miq-bot commented Aug 22, 2018

This pull request is not mergeable. Please rebase and repush.

@gmcculloug
Copy link
Member

@eclarizio PTAL
@d-m-u Hoping you and @eclarizio can discuss the expect_any_instance_of warnings to see if there is a way to avoid them. 😱

@d-m-u
Copy link
Contributor Author

d-m-u commented Aug 22, 2018

@eclarizio @gmcculloug it's complaining because I moved those existing lines, not because I added anything that has an expect_any_instance_of

@miq-bot
Copy link
Member

miq-bot commented Aug 22, 2018

Some comments on commits d-m-u/manageiq@3f41da8~...72fb15e

spec/models/resource_action_workflow_spec.rb

  • ⚠️ - 116 - Detected expect_any_instance_of. This RSpec method is highly discouraged, please only use when absolutely necessary.
  • ⚠️ - 166 - Detected expect_any_instance_of. This RSpec method is highly discouraged, please only use when absolutely necessary.
  • ⚠️ - 186 - Detected expect_any_instance_of. This RSpec method is highly discouraged, please only use when absolutely necessary.
  • ⚠️ - 96 - Detected expect_any_instance_of. This RSpec method is highly discouraged, please only use when absolutely necessary.

@miq-bot
Copy link
Member

miq-bot commented Aug 22, 2018

Checked commits d-m-u/manageiq@3f41da8~...72fb15e with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0
2 files checked, 0 offenses detected
Everything looks fine. ⭐

@eclarizio
Copy link
Member

@d-m-u The @resource_action is what the expect_any_instance_of is actually referencing, right? If you change it from expect_any_instance_of(ResourceAction) to expect(@resource_action), do the tests still pass? If so, I'd say we could make the quick change to clean up the code. If it doesn't work for some reason and we'd have to dig further into why the passed in resource_action isn't the one that is getting those calls executed on it, then I'd say we should leave it.

@d-m-u
Copy link
Contributor Author

d-m-u commented Aug 22, 2018

@eclarizio sorry but changing that makes the tests fail.

Copy link
Member

@eclarizio eclarizio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No problem, I think it's fine to leave it the way it is then, especially since you didn't introduce those lines and they were simply moved.

@gmcculloug gmcculloug merged commit 5f6e52b into ManageIQ:master Aug 22, 2018
@gmcculloug gmcculloug added this to the Sprint 93 Ending Aug 27, 2018 milestone Aug 22, 2018
@simaishi simaishi removed the blocker label Sep 17, 2018
@d-m-u d-m-u deleted the bz1594469 branch February 1, 2019 20:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants