Skip to content

Commit

Permalink
adjusting rspec to accomodate below: if widget contents for specific …
Browse files Browse the repository at this point in the history
…Timezone not found than remove Timezone from search and try to find contents again without specifying timezone
  • Loading branch information
yrudman committed Feb 20, 2019
1 parent 1cc4672 commit 80373b6
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions spec/models/miq_widget_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def add_dashboard_for_user(db_name, userid, group)
end

context "#contents_for_user" do
it "user owned" do
it "returns user owned widget contents in UTC timezone if user's timezone not specified" do
content = FactoryBot.create(:miq_widget_content,
:miq_widget => @widget_report_vendor_and_guest_os,
:user_id => @user1.id,
Expand All @@ -175,24 +175,26 @@ def add_dashboard_for_user(db_name, userid, group)
expect(@widget_report_vendor_and_guest_os.contents_for_user(@user1)).to eq(content)
end

it "owned by miq_group and in user's timezone" do
it "returns widget contents in user's timezone when content from different timezone also available" do
@user1.settings.store_path(:display, :timezone, "Eastern Time (US & Canada)")
content = FactoryBot.create(:miq_widget_content,
:miq_widget => @widget_report_vendor_and_guest_os,
:miq_group_id => @group1.id,
:timezone => "Eastern Time (US & Canada)"
)
expect(@widget_report_vendor_and_guest_os.contents_for_user(@user1)).to eq(content)
FactoryBot.create(:miq_widget_content,
:miq_widget => @widget_report_vendor_and_guest_os,
:miq_group_id => @group1.id,
:timezone => "UTC")
content_user_timezone = FactoryBot.create(:miq_widget_content,
:miq_widget => @widget_report_vendor_and_guest_os,
:miq_group_id => @group1.id,
:timezone => "Eastern Time (US & Canada)")
expect(@widget_report_vendor_and_guest_os.contents_for_user(@user1)).to eq(content_user_timezone)
end

it "owned by miq_group and not in user's timezone" do
it "returns widget contents if only content available is not in user's timezone" do
@user1.settings.store_path(:display, :timezone, "Eastern Time (US & Canada)")
FactoryBot.create(:miq_widget_content,
:miq_widget => @widget_report_vendor_and_guest_os,
:miq_group_id => @group1.id,
:timezone => "UTC"
)
expect(@widget_report_vendor_and_guest_os.contents_for_user(@user1)).to be_nil
content_utc = FactoryBot.create(:miq_widget_content,
:miq_widget => @widget_report_vendor_and_guest_os,
:miq_group_id => @group1.id,
:timezone => "UTC")
expect(@widget_report_vendor_and_guest_os.contents_for_user(@user1)).to eq(content_utc)
end

it "both user and miq_group owned" do
Expand Down

0 comments on commit 80373b6

Please sign in to comment.