From a2959b274b0df32d8d8e2ee3b01c6e4eba7b9d70 Mon Sep 17 00:00:00 2001 From: Quinn James <35753203+qcjames53@users.noreply.github.com> Date: Mon, 3 Jul 2023 11:02:26 -0400 Subject: [PATCH] Fixes #36530 - Fixed up /katello/api/sync_plans/:sync_plan_id/products and /katello/api/repositories/:repository_id/sync API endpoints. (#10632) Fixed broken ktests --- app/controllers/katello/api/v2/sync_controller.rb | 1 - app/models/katello/repository.rb | 4 ++++ app/views/katello/api/v2/sync/index.json.rabl | 1 - config/routes/api/v2.rb | 1 + test/controllers/api/v2/sync_controller_test.rb | 2 +- 5 files changed, 6 insertions(+), 3 deletions(-) delete mode 100644 app/views/katello/api/v2/sync/index.json.rabl diff --git a/app/controllers/katello/api/v2/sync_controller.rb b/app/controllers/katello/api/v2/sync_controller.rb index b43d502264f..cf324a004f6 100644 --- a/app/controllers/katello/api/v2/sync_controller.rb +++ b/app/controllers/katello/api/v2/sync_controller.rb @@ -4,7 +4,6 @@ class Api::V2::SyncController < Api::V2::ApiController before_action :find_object, :only => [:index] before_action :ensure_library, :only => [:index] - api :GET, "/organizations/:organization_id/products/:product_id/sync", N_("Get status of repo synchronisation for given product") api :GET, "/repositories/:repository_id/sync", N_("Get status of synchronisation for given repository") def index respond_for_async(:resource => @obj.sync_status) diff --git a/app/models/katello/repository.rb b/app/models/katello/repository.rb index 1fbf499ec44..ccd76734ba6 100644 --- a/app/models/katello/repository.rb +++ b/app/models/katello/repository.rb @@ -947,6 +947,10 @@ def in_content_view?(content_view) content_view.repositories.include? self end + def sync_status + return latest_dynflow_sync + end + protected def unit_type_for_removal(type_class = nil) diff --git a/app/views/katello/api/v2/sync/index.json.rabl b/app/views/katello/api/v2/sync/index.json.rabl deleted file mode 100644 index 4296aca962b..00000000000 --- a/app/views/katello/api/v2/sync/index.json.rabl +++ /dev/null @@ -1 +0,0 @@ -extends 'katello/api/v2/common/async' diff --git a/config/routes/api/v2.rb b/config/routes/api/v2.rb index 67ad91dbc2c..9ec5312b4e0 100644 --- a/config/routes/api/v2.rb +++ b/config/routes/api/v2.rb @@ -484,6 +484,7 @@ class ActionDispatch::Routing::Mapper end api_resources :sync_plans, :only => [:index, :show, :update, :destroy] do + api_resources :products, :only => [:index] get :auto_complete_search, :on => :collection put :sync end diff --git a/test/controllers/api/v2/sync_controller_test.rb b/test/controllers/api/v2/sync_controller_test.rb index ddc4b6e8b98..615a7cb11fc 100644 --- a/test/controllers/api/v2/sync_controller_test.rb +++ b/test/controllers/api/v2/sync_controller_test.rb @@ -22,7 +22,7 @@ def setup end def test_index - Product.any_instance.expects(:sync_status).returns([{}]) + Product.any_instance.expects(:sync_status).returns([]) get :index, params: { :product_id => @product.cp_id, :organization_id => @organization.id } assert_response :success