-
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
Separate queue put from publish event so we don't queue put twice #18178
Conversation
@miq-bot add_label bug |
@miq-bot add_label hammer/yes, blocker |
@miq-bot remove_label wip |
@miq-bot add_reviewer @mkanoor |
@@ -100,7 +100,8 @@ def invoke(target, source = nil) | |||
MiqQueue.put(queue_opts(target, args)) | |||
end | |||
|
|||
def publish_event(source, target, args) | |||
def publish_event(source, target, args = nil) | |||
args ||= resource_action.automate_queue_hash(target, {}, User.current_user) |
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.
Would be useful to test that the method calls resource_action.automate_queue_hash
when called without an args
parameter since that is the logic being added.
bbea863
to
c1fec3c
Compare
spec/models/custom_button_spec.rb
Outdated
describe "publish event" do | ||
context "with blank args" do | ||
it "resource action calls automate_queue_hash" do | ||
Timecop.freeze(Time.now.utc) 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.
Does not look like we need Timecop
here?
spec/models/custom_button_spec.rb
Outdated
|
||
context "with args" do | ||
it "resource action doesn't call automate_queue_hash" do | ||
Timecop.freeze(Time.now.utc) 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.
Same here.
spec/models/custom_button_spec.rb
Outdated
context "with args" do | ||
it "resource action doesn't call automate_queue_hash" do | ||
Timecop.freeze(Time.now.utc) do | ||
expect(resource_action).not_to receive(:automate_queue_hash).with(vm, {}, user) |
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.
You can drop the with(<params>)
since you do not expect it to be called at all.
c1fec3c
to
6a6b595
Compare
Checked commit d-m-u@6a6b595 with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0 |
Separate queue put from publish event so we don't queue put twice (cherry picked from commit 7b34f5b)
Hammer backport details:
|
The main repo part of https://github.com/ManageIQ/manageiq-api/pull/506/files. We're currently not creating custom button events for custom buttons with dialogs, because invoke never gets called. But invoke also does a queue put, which both custom buttons with and without dialogs handle, so the line to create custom button events needed to be later than the queue put as to not do the queue twice.
related
ManageIQ/manageiq-api#506