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

Fix call to process_tasks to run the right thing #17255

Merged
merged 2 commits into from
Apr 17, 2018

Conversation

d-m-u
Copy link
Contributor

@d-m-u d-m-u commented Apr 5, 2018

process_tasks should call make_retire_request, not make_request.

@d-m-u
Copy link
Contributor Author

d-m-u commented Apr 5, 2018

@tinaafitz can you 👀 for me please?

@d-m-u
Copy link
Contributor Author

d-m-u commented Apr 5, 2018

@miq-bot add_label bug
@miq-bot add_label retirement

@@ -121,7 +120,7 @@ def retirement_check
_log.log_backtrace(err)
end
end

_log.info("#{retirement_due?} : is value for if retirement is due DREWDREWDREW")
Copy link
Member

Choose a reason for hiding this comment

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

@d-m-u We can remove this message.

if options[:task] == "refresh_ems" && respond_to?("refresh_ems")

if options[:task] == 'retire_now'
options = {:task => options[:task], :userid => User.current_user.try(:userid), :src_ids => options[:ids]}
Copy link
Member

Choose a reason for hiding this comment

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

@d-m-u Were we going to use src_id instead of src_ids here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we need all the things here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@d-m-u d-m-u changed the title [WIP] Fix call to process_tasks to run the right thing Fix call to process_tasks to run the right thing Apr 9, 2018
@d-m-u d-m-u changed the title Fix call to process_tasks to run the right thing [WIP] Fix call to process_tasks to run the right thing Apr 9, 2018
@d-m-u d-m-u force-pushed the fixing_retire_request_call branch from b863530 to 33a5aff Compare April 9, 2018 16:00
@d-m-u d-m-u changed the title [WIP] Fix call to process_tasks to run the right thing Fix call to process_tasks to run the right thing Apr 9, 2018
@miq-bot miq-bot removed the wip label Apr 9, 2018
@d-m-u d-m-u force-pushed the fixing_retire_request_call branch from 33a5aff to 12920a9 Compare April 10, 2018 16:11
@d-m-u
Copy link
Contributor Author

d-m-u commented Apr 10, 2018

@tinaafitz can you review please

options = {:task => task, :userid => current_user, :ids => objs, :src_ids => objs}
(klass.to_s + "RetireRequest").constantize.make_request(@request_id, options, current_user)
def make_retire_request(*options)
options = {:src_ids => options.present? ? options.first : id, :src_klass => options.present? ? self : name}
Copy link
Member

Choose a reason for hiding this comment

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

options.present? ? self : name

Why self vs name? Shouldn't it always be name?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it's bimodal, so the UI retirement is always name but we call make_retire_request without options from the mixin in the other case which has the model name as self.

Copy link
Member

Choose a reason for hiding this comment

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

I guess my point is that if options is present, :src_klass is a class, otherwise it's a string.

irb(main):001:0> a = Module.new { def bd_self; self; end; def bd_name; name; end }
=> #<Module:0x0000000007c3d1b8>
irb(main):002:0> Vm.singleton_class.prepend(a)
=> #<Class:Vm(id: integer, vendor: string, ...)>
irb(main):003:0> Vm.bd_self
=> Vm(id: integer, vendor: string, ...)
irb(main):004:0> Vm.bd_name
=> "Vm"

@d-m-u d-m-u force-pushed the fixing_retire_request_call branch from 12920a9 to 79271cf Compare April 10, 2018 18:28
@d-m-u d-m-u changed the title Fix call to process_tasks to run the right thing [WIP] Fix call to process_tasks to run the right thing Apr 10, 2018
@miq-bot miq-bot added the wip label Apr 10, 2018
@d-m-u d-m-u force-pushed the fixing_retire_request_call branch from 79271cf to fe90861 Compare April 10, 2018 21:08
@d-m-u d-m-u changed the title [WIP] Fix call to process_tasks to run the right thing Fix call to process_tasks to run the right thing Apr 10, 2018
@miq-bot miq-bot removed the wip label Apr 10, 2018
options = {:task => task, :userid => current_user, :ids => objs, :src_ids => objs}
(klass.to_s + "RetireRequest").constantize.make_request(@request_id, options, current_user)
def make_retire_request(*src_ids)
options = {:src_ids => src_ids.present? ? src_ids.first : id}
Copy link
Member

Choose a reason for hiding this comment

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

Can you add some tests? Since the array is not splatted above, I think you'll find that you end up with something like

{:src_ids => [[1,2,3]]}

@d-m-u d-m-u force-pushed the fixing_retire_request_call branch 3 times, most recently from 759ff50 to 2135e28 Compare April 17, 2018 13:01
@d-m-u
Copy link
Contributor Author

d-m-u commented Apr 17, 2018

@tinaafitz can you review again please?

@d-m-u
Copy link
Contributor Author

d-m-u commented Apr 17, 2018

@mkanoor can you review please?

@mkanoor
Copy link
Contributor

mkanoor commented Apr 17, 2018

@d-m-u
Can you add a spec for service retire request.

@d-m-u d-m-u force-pushed the fixing_retire_request_call branch from 2135e28 to 50a360d Compare April 17, 2018 21:01
@d-m-u d-m-u force-pushed the fixing_retire_request_call branch from 50a360d to e1288e8 Compare April 17, 2018 21:03
@miq-bot
Copy link
Member

miq-bot commented Apr 17, 2018

Checked commits d-m-u/manageiq@e341d98~...e1288e8 with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0
4 files checked, 0 offenses detected
Everything looks fine. 🍰

@mkanoor mkanoor merged commit 66ad170 into ManageIQ:master Apr 17, 2018
@mkanoor mkanoor added this to the Sprint 84 Ending Apr 23, 2018 milestone Apr 17, 2018
@d-m-u d-m-u deleted the fixing_retire_request_call branch October 26, 2018 18:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants