From e801fb0f70bf25e184b89c937c5df849e120fb71 Mon Sep 17 00:00:00 2001 From: Partha Aji Date: Sun, 26 Apr 2020 12:44:04 -0400 Subject: [PATCH] Fixes #29611 - Manifest delete refreshes library (#8677) This commit makes the ManifestDelete and Manifest Import refresh only the rh library repositories. Prior to this commit even non library repositories belonging to content views were checked for refresh. --- .../katello/organization/manifest_delete.rb | 3 +- .../katello/organization/manifest_import.rb | 3 +- test/actions/katello/organization_test.rb | 32 ++++++++----------- 3 files changed, 17 insertions(+), 21 deletions(-) diff --git a/app/lib/actions/katello/organization/manifest_delete.rb b/app/lib/actions/katello/organization/manifest_delete.rb index c7e664efb6c..5cb959917ae 100644 --- a/app/lib/actions/katello/organization/manifest_delete.rb +++ b/app/lib/actions/katello/organization/manifest_delete.rb @@ -13,7 +13,8 @@ def plan(organization) plan_action(Candlepin::Owner::DestroyImports, label: organization.label) if SETTINGS[:katello][:use_pulp] - organization.products.redhat.flat_map(&:repositories).each do |repo| + repositories = ::Katello::Repository.in_default_view.in_product(::Katello::Product.redhat.in_org(organization)) + repositories.each do |repo| plan_action(Katello::Repository::RefreshRepository, repo) end end diff --git a/app/lib/actions/katello/organization/manifest_import.rb b/app/lib/actions/katello/organization/manifest_import.rb index ec1c31775d6..d1de8295b80 100644 --- a/app/lib/actions/katello/organization/manifest_import.rb +++ b/app/lib/actions/katello/organization/manifest_import.rb @@ -18,7 +18,8 @@ def plan(organization, path, force) plan_action(Candlepin::Owner::ImportProducts, :organization_id => organization.id) if manifest_update && SETTINGS[:katello][:use_pulp] - organization.products.redhat.flat_map(&:repositories).each do |repo| + repositories = ::Katello::Repository.in_default_view.in_product(::Katello::Product.redhat.in_org(organization)) + repositories.each do |repo| plan_action(Katello::Repository::RefreshRepository, repo) end end diff --git a/test/actions/katello/organization_test.rb b/test/actions/katello/organization_test.rb index 7709508bd86..507314e2256 100644 --- a/test/actions/katello/organization_test.rb +++ b/test/actions/katello/organization_test.rb @@ -104,9 +104,7 @@ class ManifestRefreshTest < TestBase it 'plans' do acme_org = taxonomies(:empty_organization) upstream = {} - rhel7 = katello_repositories(:rhel_7_x86_64) acme_org.stubs(:owner_details).returns({}) - acme_org.products.stubs(:redhat).returns([rhel7.product]) action.stubs(:action_subject).with(acme_org) action.stubs(:rand).returns('1234') plan_action(action, acme_org) @@ -134,11 +132,11 @@ class ManifestRefreshTest < TestBase organization_id: acme_org.id, dependency: found.first.output ) - assert_action_planned_with(action, - ::Actions::Katello::Repository::RefreshRepository, - rhel7, - dependency: found.first.output - ) + + assert_action_planned_with(action, ::Actions::Katello::Repository::RefreshRepository) do |repo, options| + assert repo.library_instance? + assert_equal options, dependency: found.first.output + end end it 'plans & create audit record for organization with comment manifest refreshed' do @@ -218,8 +216,7 @@ class ManifestImportTest < TestBase let(:action_class) { ::Actions::Katello::Organization::ManifestImport } it 'plans' do - rhel7 = katello_repositories(:rhel_7_x86_64) - organization.products.stubs(:redhat).returns([rhel7.product]) + organization = taxonomies(:empty_organization) action.stubs(:action_subject).with(organization) plan_action(action, organization, '/tmp/1234.zip', false) @@ -233,10 +230,9 @@ class ManifestImportTest < TestBase ::Actions::Candlepin::Owner::ImportProducts, organization_id: organization.id ) - assert_action_planned_with(action, - ::Actions::Katello::Repository::RefreshRepository, - rhel7 - ) + assert_action_planned_with(action, ::Actions::Katello::Repository::RefreshRepository) do |args| + assert args.first.library_instance? + end end it 'plans & create audit record for organization with comment manifest imported' do @@ -306,8 +302,7 @@ class ManifestDeleteTest < TestBase let(:action_class) { ::Actions::Katello::Organization::ManifestDelete } it 'plans' do - rhel7 = katello_repositories(:rhel_7_x86_64) - organization.products.stubs(:redhat).returns([rhel7.product]) + organization = taxonomies(:empty_organization) action.stubs(:action_subject).with(organization) plan_action(action, organization) @@ -315,10 +310,9 @@ class ManifestDeleteTest < TestBase ::Actions::Candlepin::Owner::DestroyImports, label: organization.label ) - assert_action_planned_with(action, - ::Actions::Katello::Repository::RefreshRepository, - rhel7 - ) + assert_action_planned_with(action, ::Actions::Katello::Repository::RefreshRepository) do |args| + assert args.first.library_instance? + end end it 'creates audit record for organization after manifest deletion' do