-
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
Create custom button events for each object in target list #18042
Create custom button events for each object in target list #18042
Conversation
@miq-bot add_label bug |
app/models/custom_button.rb
Outdated
@@ -131,7 +135,6 @@ def invoke_async(target, source = nil) | |||
:action => "Calling automate for user #{userid}", | |||
:userid => 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.
Why did this change?
e9b586a
to
458c268
Compare
spec/models/custom_button_spec.rb
Outdated
:event_type => 'button.trigger.start', | ||
:user_id => user.id | ||
) | ||
expect(CustomButtonEvent.first[:full_data]).to include( |
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 this be merged into the expectation above?
:full_data => a_hash_including(:automate_entry_point => "/SYSTEM/PROCESS/Request")
spec/models/custom_button_spec.rb
Outdated
%i(invoke invoke_async).each do |method| | ||
describe "##{method}" do | ||
it "publishes CustomButtonEvents with multiple vms" 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.
How is time related to this?
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.
Because custom button events have timestamps.
app/models/custom_button.rb
Outdated
|
||
def create_event(source, target, args) | ||
CustomButtonEvent.create!( | ||
:event_type => 'button.trigger.start', |
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.
This appears to be indented more than 2 spaces
458c268
to
f305d9a
Compare
spec/models/custom_button_spec.rb
Outdated
@@ -326,5 +328,29 @@ | |||
end | |||
end | |||
end | |||
|
|||
%i(invoke invoke_async).each do |method| | |||
describe "##{method}" 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.
Also, shouldn't this be merged into the describe
above?
debb360
to
783f8b1
Compare
spec/models/custom_button_spec.rb
Outdated
@@ -303,8 +305,8 @@ | |||
EvmSpecHelper.local_miq_server(:is_master => true, :zone => Zone.seed) | |||
end | |||
|
|||
%i(invoke invoke_async).each do |method| | |||
describe "##{method}" do | |||
context "with only one VM" 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.
What do you think of this?
%i(invoke invoke_async).each do |method|
describe "##{method}", "publishes CustomButtonEvent(s)" do
it "with a single VM" do
Timecop.freeze(Time.now.utc) do
User.with_user(user) { custom_button.send(method, vm, 'UI') }
expect(CustomButtonEvent.first.timestamp).to be_within(0.01).of(Time.now.utc)
end
expect(CustomButtonEvent.count).to eq(1)
expect(CustomButtonEvent.first).to have_attributes(
:source => 'UI',
:target_id => vm.id,
:target_type => 'VmOrTemplate',
:type => 'CustomButtonEvent',
:event_type => 'button.trigger.start',
:user_id => user.id,
:full_data => a_hash_including(:automate_entry_point => "/SYSTEM/PROCESS/Request")
)
end
it "with multiple vms" do
Timecop.freeze(Time.now.utc) do
User.with_user(user) { custom_button.send(method, [vm, vm2, vm3], 'UI') }
expect(CustomButtonEvent.first.timestamp).to be_within(0.01).of(Time.now.utc)
end
expect(CustomButtonEvent.count).to eq(3)
expect(CustomButtonEvent.first).to have_attributes(
:source => 'UI',
:target_id => vm.id,
:target_type => 'VmOrTemplate',
:type => 'CustomButtonEvent',
:event_type => 'button.trigger.start',
:user_id => user.id,
:full_data => a_hash_including(:automate_entry_point => "/SYSTEM/PROCESS/Request")
)
end
end
end
783f8b1
to
f5dcc96
Compare
Checked commit d-m-u@f5dcc96 with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0 |
…28224 Create custom button events for each object in target list (cherry picked from commit 4b78ead) Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1628224
Hammer backport details:
|
Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1628224
When we originally added CustomButtonEvents we didn't account for CustomButtons being run on multiple objects at once. I think we should be creating events for all the objects a custom button runs on.