Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #29611 - Manifest delete refreshes library #8677

Merged
merged 1 commit into from
Apr 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion app/lib/actions/katello/organization/manifest_delete.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion app/lib/actions/katello/organization/manifest_import.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
32 changes: 13 additions & 19 deletions test/actions/katello/organization_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand All @@ -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
Expand Down Expand Up @@ -306,19 +302,17 @@ 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)

assert_action_planned_with(action,
::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
Expand Down