Skip to content

Commit

Permalink
Utilize queue_refresh call within GitBasedDomainImportService
Browse files Browse the repository at this point in the history
  • Loading branch information
eclarizio committed Dec 2, 2016
1 parent 7462b29 commit d5ee1dd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 24 deletions.
14 changes: 1 addition & 13 deletions app/controllers/miq_ae_tools_controller.rb
Expand Up @@ -215,19 +215,7 @@ def retrieve_git_datastore
git_repo_id = setup_results[:git_repo_id]
new_git_repo = setup_results[:new_git_repo?]

task_options = {
:action => "Retrieve git repository",
:userid => current_user.userid
}
queue_options = {
:class_name => "GitRepository",
:method_name => "refresh",
:instance_id => git_repo_id,
:role => "git_owner",
:args => []
}

task_id = MiqTask.generic_action_with_callback(task_options, queue_options)
task_id = git_based_domain_import_service.queue_refresh(git_repo_id)
response_json = {:task_id => task_id, :git_repo_id => git_repo_id, :new_git_repo => new_git_repo}
rescue => err
add_flash(_("Error during repository setup: %{error_message}") % {:error_message => err.message}, :error)
Expand Down
14 changes: 3 additions & 11 deletions spec/controllers/miq_ae_tools_controller_spec.rb
Expand Up @@ -326,16 +326,7 @@

context "when everything works fine" do
let(:git_repo) { double("GitRepository", :id => 123) }
let(:task_options) { {:action => "Retrieve git repository", :userid => controller.current_user.userid} }
let(:queue_options) do
{
:class_name => "GitRepository",
:method_name => "refresh",
:instance_id => 123,
:role => "git_owner",
:args => []
}
end
let(:git_based_domain_import_service) { double("GitBasedDomainImportService") }

before do
allow(git_repository_service).to receive(:setup).with(
Expand All @@ -344,7 +335,8 @@
"gitpassword",
"gitverifyssl"
).and_return({:git_repo_id => git_repo.id, :new_git_repo? => false})
allow(MiqTask).to receive(:generic_action_with_callback).with(task_options, queue_options).and_return(321)
allow(GitBasedDomainImportService).to receive(:new).and_return(git_based_domain_import_service)
allow(git_based_domain_import_service).to receive(:queue_refresh).with(123).and_return(321)
end

it "responds with task information" do
Expand Down

0 comments on commit d5ee1dd

Please sign in to comment.