Revision 5ee5f52d
Added by Brad Buckingham almost 10 years ago
app/lib/actions/katello/capsule_content/sync.rb | ||
---|---|---|
def plan(capsule_content, environment = nil)
|
||
fail _("Action not allowed for the default capsule.") if capsule_content.default_capsule?
|
||
|
||
if environment && !capsule_content.lifecycle_environments.include?(environment)
|
||
fail _("Lifecycle environment '%{environment}' is not attached to this capsule.") % { :environment => environment.name }
|
||
end
|
||
|
||
repository_ids = if environment
|
||
capsule_content.pulp_repos(environment).map(&:pulp_id)
|
||
end
|
test/actions/katello/capsule_content_test.rb | ||
---|---|---|
|
||
class SyncTest < TestBase
|
||
let(:action_class) { ::Actions::Katello::CapsuleContent::Sync }
|
||
let(:staging_environment) { katello_environments(:staging) }
|
||
|
||
it 'plans' do
|
||
capsule_content.add_lifecycle_environment(environment)
|
||
action = create_and_plan_action(action_class, capsule_content)
|
||
assert_action_planed_with(action, ::Actions::Pulp::Consumer::SyncNode) do |(input)|
|
||
input.must_equal(consumer_uuid: @capsule_system.uuid,
|
||
... | ... | |
end
|
||
|
||
it 'allows limiting scope of the syncing to one environment' do
|
||
capsule_content.add_lifecycle_environment(environment)
|
||
action = create_and_plan_action(action_class, capsule_content, environment)
|
||
assert_action_planed_with(action, ::Actions::Pulp::Consumer::SyncNode) do |(input)|
|
||
input[:repo_ids].size.must_equal 4
|
||
... | ... | |
create_and_plan_action(action_class, capsule_content, environment)
|
||
end
|
||
end
|
||
it 'fails when trying to sync a lifecyle environment that is not attached' do
|
||
capsule_content.add_lifecycle_environment(environment)
|
||
|
||
Katello::CapsuleContent.any_instance.stubs(:lifecycle_environments).returns([])
|
||
assert_raises(RuntimeError) do
|
||
create_and_plan_action(action_class, capsule_content, staging_environment)
|
||
end
|
||
end
|
||
end
|
||
|
||
class UpdateWithoutContentTest < TestBase
|
Also available in: Unified diff
fixes #6871 / BZ 1125397 - capsule - add error case for content sync
If the user attempts to sync a lifecyle environment that isn't attached
to the capsule, generate an error to the user.