Skip to content

Commit

Permalink
Populate timestamp of CustomButtonEvent.
Browse files Browse the repository at this point in the history
A timestamp without value would break MiqReport.

https://bugzilla.redhat.com/show_bug.cgi?id=1511126
  • Loading branch information
lfu committed Aug 24, 2018
1 parent 2c4745b commit 54c0388
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions app/models/custom_button.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ def publish_event(source, target, args)
:user_id => args[:user_id],
:group_id => args[:miq_group_id],
:tenant_id => args[:tenant_id],
:timestamp => Time.now.utc,
:full_data => {
:args => args,
:automate_entry_point => resource_action.ae_path,
Expand Down
5 changes: 4 additions & 1 deletion spec/models/custom_button_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,10 @@
%i(invoke invoke_async).each do |method|
describe "##{method}" do
it "publishes CustomButtonEvent" do
User.with_user(user) { custom_button.send(method, vm, 'UI') }
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(
Expand Down

0 comments on commit 54c0388

Please sign in to comment.