Skip to content

Commit

Permalink
added test covering loading dashboard for specific group
Browse files Browse the repository at this point in the history
  • Loading branch information
yrudman committed Jul 31, 2018
1 parent c8c8277 commit 4c56fb1
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions spec/models/miq_widget_set_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,36 @@
expect(MiqWidgetSet.find_with_same_order([g2.id.to_s, g1.id.to_s])).to eq([g2, g1])
end
end

context "loading group specific defaul dashboard" do
describe ".sync_from_file" do
let(:dashboard_name) { "Dashboard for Group" }
before do
@yml_file = Tempfile.new('default_dashboard_for_group.yaml')
yml_data = YAML.safe_load(<<~DOC, [Symbol])
---
name: #{dashboard_name}
read_only: t
set_type: MiqWidgetSet
description: Test Dashboard for Group
owner_type: MiqGroup
owner_description: #{group.description}
set_data_by_description:
:col1:
- chart_vendor_and_guest_os
DOC
File.write(@yml_file.path, yml_data.to_yaml)
end

after do
@yml_file.close(true)
end

it "loads dashboard for specific group" do
described_class.sync_from_file(@yml_file.path)
dashboard = MiqWidgetSet.find_by(:name => dashboard_name)
expect(dashboard.owner_id).to eq(group.id)
end
end
end
end

0 comments on commit 4c56fb1

Please sign in to comment.