Skip to content
Permalink
Browse files

Fixes #14825: Don't require organization to search repositories (#5999)

  • Loading branch information
ehelms authored and daviddavis committed May 2, 2016
1 parent 5d88cd2 commit f4ae98f3ba8097d59df45c6dbb1c33ba2e80618f
@@ -2,7 +2,7 @@ module Katello
class Api::V2::RepositoriesController < Api::V2::ApiController
include Katello::Concerns::FilteredAutoCompleteSearch

before_filter :find_organization, :only => [:index, :auto_complete_search]
before_filter :find_optional_organization, :only => [:index, :auto_complete_search]
before_filter :find_product, :only => [:index, :auto_complete_search]
before_filter :find_product_for_create, :only => [:create]
before_filter :find_organization_from_product, :only => [:create]
@@ -36,7 +36,7 @@ class Api::V2::RepositoriesController < Api::V2::ApiController

api :GET, "/repositories", N_("List of enabled repositories")
api :GET, "/content_views/:id/repositories", N_("List of repositories for a content view")
param :organization_id, :number, :required => true, :desc => N_("ID of an organization to show repositories in")
param :organization_id, :number, :desc => N_("ID of an organization to show repositories in")
param :product_id, :number, :desc => N_("ID of a product to show repositories of")
param :environment_id, :number, :desc => N_("ID of an environment to show repositories in")
param :content_view_id, :number, :desc => N_("ID of a content view to show repositories in")
@@ -105,7 +105,12 @@ def index_relation_environment(query)
instance_ids += instances.where(:library_instance_id => nil)
query = Repository.where(:id => instance_ids)
elsif (params[:library] && !params[:environment_id]) || (params[:environment_id].blank? && params[:content_view_version_id].blank? && params[:content_view_id].blank?)
query = query.where(:content_view_version_id => @organization.default_content_view.versions.first.id)

if @organization
query = query.where(:content_view_version_id => @organization.default_content_view.versions.first.id)
else
query = query.in_default_view
end
end
query
end
@@ -316,6 +321,7 @@ def gpg_key_content

def find_product
@product = Product.find(params[:product_id]) if params[:product_id]
find_organization_from_product if @organization.nil? && @product
end

def find_product_for_create
@@ -83,7 +83,7 @@ def assert_response_ids(response, expected)
def test_index_with_product_id
ids = Repository.where(:product_id => @product.id, :library_instance_id => nil).pluck(:id)

response = get :index, :product_id => @product.id, :organization_id => @organization.id
response = get :index, :product_id => @product.id
response_ids = JSON.parse(response.body)['results'].map { |repo| repo['id'] }

assert_response :success

0 comments on commit f4ae98f

Please sign in to comment.
You can’t perform that action at this time.