Skip to content

Commit c021067

Browse files
committed
Fix an issue with blank visibility
Followup to ManageIQ#23803 Fixes an issue seen when testing UI usage in ManageIQ/manageiq-ui-classic#9954 The client of this code shouldn't need to check if the visibility is missing the roles/groups key.
1 parent 30767da commit c021067

2 files changed

Lines changed: 6 additions & 0 deletions

File tree

app/models/miq_widget.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,7 @@ def visibility_values
456456

457457
typ = visibility.keys.first
458458
values = visibility.values.flatten
459+
return [] if typ.blank? || values.blank?
459460

460461
# Convert ids to useful strings for display
461462
case typ

spec/models/miq_widget_spec.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -961,6 +961,11 @@ def add_dashboard_for_user(db_name, userid, group)
961961
widget = FactoryBot.build(:miq_widget, :visibility => {:roles => ['_ALL_']})
962962
expect(widget.visibility_values).to eq([])
963963
end
964+
965+
it "handles blank visibility" do
966+
widget = FactoryBot.build(:miq_widget, :visibility => {})
967+
expect(widget.visibility_values).to eq([])
968+
end
964969
end
965970
end
966971

0 commit comments

Comments
 (0)