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

Save the updated widget timestamp #19405

Merged
merged 1 commit into from
Oct 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions app/models/miq_widget.rb
Original file line number Diff line number Diff line change
Expand Up @@ -327,9 +327,7 @@ def find_or_build_contents_for_user(group, user, timezone = nil)
settings_for_build[:user_id] = user.id if user
settings_for_build[:timezone] = timezone if timezone
contents = miq_widget_contents.find_by(settings_for_build) || miq_widget_contents.build(settings_for_build)
contents.updated_at = Time.now.utc # Force updated timestamp to change when saved even if the new contents are the same

contents
contents.tap { |c| c.update!(:updated_at => Time.now.utc) }
end

# TODO: group/user support
Expand Down
2 changes: 2 additions & 0 deletions spec/models/miq_widget/report_content_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
it "#generate_one_content_for_user" do
content = widget.generate_one_content_for_user(@admin_group, @admin)
expect(content).to be_kind_of MiqWidgetContent
expect(content.updated_at).to be_within(2.seconds).of(Time.now.utc)
expect(content.contents.scan("</tr>").length).to eq(widget.options[:row_count] + 1)
expect(content.contents.scan("</td>").length).to eq(widget.options[:row_count] * widget.options[:col_order].length)
expect(content.contents.scan("</th>").length).to eq(widget.options[:col_order].length)
Expand All @@ -44,6 +45,7 @@
it "#generate_one_content_for_group" do
content = widget.generate_one_content_for_group(@admin.current_group, @admin.get_timezone)
expect(content).to be_kind_of MiqWidgetContent
expect(content.updated_at).to be_within(2.seconds).of(Time.now.utc)
expect(content.contents.scan("</tr>").length).to eq(widget.options[:row_count] + 1)
expect(content.contents.scan("</td>").length).to eq(widget.options[:row_count] * widget.options[:col_order].length)
expect(content.contents.scan("</th>").length).to eq(widget.options[:col_order].length)
Expand Down