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 #14628 - do not call metadata generate when cloning repos #5963

Merged
merged 1 commit into from Apr 14, 2016
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 5 additions & 3 deletions app/lib/actions/katello/repository/create.rb
Expand Up @@ -46,15 +46,17 @@ def plan(repository, clone = false, plan_create = false)

concurrence do
plan_action(::Actions::Pulp::Repos::Update, repository.product) if repository.product.sync_plan
plan_self(:repository_id => repository.id)
plan_self(:repository_id => repository.id, :clone => clone)
end
end
end

def run
::User.current = ::User.anonymous_api_admin
repository = ::Katello::Repository.find(input[:repository_id])
ForemanTasks.async_task(Katello::Repository::MetadataGenerate, repository)
unless input[:clone]
repository = ::Katello::Repository.find(input[:repository_id])
ForemanTasks.async_task(Katello::Repository::MetadataGenerate, repository)
end
ensure
::User.current = nil
end
Expand Down
22 changes: 22 additions & 0 deletions test/actions/katello/repository_test.rb
Expand Up @@ -34,6 +34,28 @@ class CreateTest < TestBase
end
plan_action action, repository
end

it 'no clone flag means generate metadata in run phase' do
repository.expects(:save!)
action.expects(:action_subject).with(repository)
action.execution_plan.stub_planned_action(::Actions::Katello::Product::ContentCreate) do |content_create|
content_create.stubs(input: { content_id: 123 })
end
plan = plan_action action, repository
run_action plan
plan.run.label.must_equal "Actions::Katello::Repository::MetadataGenerate"
end

it 'clone flag disables metadata generation' do
repository.expects(:save!)
action.expects(:action_subject).with(repository)
action.execution_plan.stub_planned_action(::Actions::Katello::Product::ContentCreate) do |content_create|
content_create.stubs(input: { content_id: 123 })
end
plan = plan_action action, repository, true
run_action plan
plan.run.must_equal nil
end
end

class CreateFailTest < TestBase
Expand Down