|
177 | 177 | expect(result[@group1]).to match_array([@user1]) |
178 | 178 | end |
179 | 179 |
|
| 180 | + it 'ignores a group that no longer exists' do |
| 181 | + @user1.update(:miq_groups => [@group2]) |
| 182 | + @group1.destroy |
| 183 | + result = @widget_report_vendor_and_guest_os.reload.grouped_subscribers |
| 184 | + expect(result.size).to eq(0) |
| 185 | + end |
| 186 | + |
180 | 187 | it 'ignores the group that has no members' do |
181 | 188 | @user1.delete |
182 | 189 | result = @widget_report_vendor_and_guest_os.grouped_subscribers |
@@ -300,8 +307,8 @@ def add_dashboard_for_user(db_name, userid, group) |
300 | 307 | MiqReport.seed_report("Top CPU Consumers weekly") |
301 | 308 |
|
302 | 309 | role1 = FactoryBot.create(:miq_user_role, :name => 'EvmRole-support') |
303 | | - group1 = FactoryBot.create(:miq_group, :description => "EvmGroup-support", :miq_user_role => role1) |
304 | | - user1 = FactoryBot.create(:user, :miq_groups => [group1]) |
| 310 | + @group1 = FactoryBot.create(:miq_group, :description => "EvmGroup-support", :miq_user_role => role1) |
| 311 | + user1 = FactoryBot.create(:user, :miq_groups => [@group1]) |
305 | 312 |
|
306 | 313 | @user2 = FactoryBot.create(:user_admin) |
307 | 314 | @group2 = @user2.current_group |
@@ -332,7 +339,7 @@ def add_dashboard_for_user(db_name, userid, group) |
332 | 339 | read_only: true |
333 | 340 | ') |
334 | 341 |
|
335 | | - ws1 = FactoryBot.create(:miq_widget_set, :name => "default", :userid => user1.userid, :owner => group1) |
| 342 | + ws1 = FactoryBot.create(:miq_widget_set, :name => "default", :userid => user1.userid, :owner => @group1) |
336 | 343 | ws2 = FactoryBot.create(:miq_widget_set, :name => "default", :userid => @user2.userid, :owner => @group2) |
337 | 344 |
|
338 | 345 | @widget = MiqWidget.sync_from_hash(attrs) |
@@ -407,6 +414,17 @@ def add_dashboard_for_user(db_name, userid, group) |
407 | 414 | expect(task_id).to be_nil |
408 | 415 | end |
409 | 416 |
|
| 417 | + it "does not generate content for a deleted group" do |
| 418 | + @widget.visibility[:roles] = "_ALL_" |
| 419 | + @group2.delete |
| 420 | + |
| 421 | + expect(@widget).to receive(:queue_generate_content_for_users_or_group).with("MiqGroup", @group1.description, any_args).once |
| 422 | + task_id = @widget.queue_generate_content |
| 423 | + |
| 424 | + expect(MiqTask.count).to eq(1) |
| 425 | + expect(task_id).to eq(MiqTask.first.id) |
| 426 | + end |
| 427 | + |
410 | 428 | it "does not generate content if content_type of widget is 'menu'" do |
411 | 429 | @widget.update(:content_type => "menu") |
412 | 430 | expect(@widget).not_to receive(:queue_generate_content_for_users_or_group) |
|
0 commit comments