Skip to content

Commit

Permalink
mark widgets that do not depend upon date
Browse files Browse the repository at this point in the history
  • Loading branch information
kbrock committed Mar 20, 2017
1 parent 053b5ee commit 0a2c5f9
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ description: chart_guest_os_information_any_os
title: Guest OS Information
content_type: chart
options:
:timezone_matters: false
visibility:
:roles:
- _ALL_
Expand All @@ -14,4 +15,4 @@ miq_schedule_options:
:value: "1"
:unit: daily
enabled: true
read_only: true
read_only: true
3 changes: 2 additions & 1 deletion product/dashboard/widgets/chart_vendor_and_guest_os.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ description: chart_vendor_and_guest_os
title: Vendor and Guest OS Chart
content_type: chart
options:
:timezone_matters: false
visibility:
:roles:
- _ALL_
Expand All @@ -14,4 +15,4 @@ miq_schedule_options:
:value: "1"
:unit: daily
enabled: true
read_only: true
read_only: true
3 changes: 2 additions & 1 deletion product/dashboard/widgets/report_top_storage_consumers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ options:
- ems_cluster.name
- used_disk_storage
:row_count: 10
:timezone_matters: false
visibility:
:roles:
- _ALL_
Expand All @@ -19,4 +20,4 @@ miq_schedule_options:
:value: "1"
:unit: daily
enabled: true
read_only: true
read_only: true
18 changes: 17 additions & 1 deletion spec/models/miq_widget_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,8 @@ def add_dashboard_for_user(db_name, userid, group)
MiqReport.seed_report("Vendor and Guest OS")
MiqWidget.seed_widget("chart_vendor_and_guest_os")

# tests are written for timezone_matters = true
widget.options[:timezone_matters] = true if widget.options
@role = FactoryGirl.create(:miq_user_role)
@group = FactoryGirl.create(:miq_group, :miq_user_role => @role)
@user1 = FactoryGirl.create(:user,
Expand All @@ -591,14 +593,15 @@ def add_dashboard_for_user(db_name, userid, group)
before do
widget.make_memberof(@ws1)
widget.make_memberof(@ws2)
widget.queue_generate_content
end

it "queued based on group/TZs of User's in the group" do
widget.queue_generate_content
expect(MiqQueue.count).to eq(1)
end

it "contents created for each timezone of the group" do
widget.queue_generate_content
MiqQueue.first.deliver
expect(MiqWidgetContent.count).to eq(2)
MiqWidgetContent.all.each do |content|
Expand All @@ -608,7 +611,20 @@ def add_dashboard_for_user(db_name, userid, group)
end
end

it "contents created for one timezone per group with timezone_matters = false" do
widget.options = {:timezone_matters => false }
widget.queue_generate_content
MiqQueue.first.deliver
expect(MiqWidgetContent.count).to eq(1)
MiqWidgetContent.all.each do |content|
expect(content.user_id).to be_nil
expect(content.miq_group_id).to eq(@group.id)
expect(content.timezone).to eq("UTC")
end
end

it "when changing to self service group" do
widget.queue_generate_content
MiqQueue.first.deliver
MiqWidgetContent.all.each do |content|
expect(content.user_id).to be_nil
Expand Down

0 comments on commit 0a2c5f9

Please sign in to comment.