Skip to content

Commit

Permalink
Fixes #13903 - Move release version list to be host based (Katello#6078)
Browse files Browse the repository at this point in the history
  • Loading branch information
jlsherrill committed Jun 3, 2016
1 parent c7746d6 commit 536c81e
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 21 deletions.
Expand Up @@ -153,6 +153,13 @@ def product_content
respond_for_index(:collection => full_result_response(results))
end

api :GET, "/hosts/:host_id/subscriptions/available_release_versions", N_("Show releases available for the content host")
param :host_id, String, :desc => N_("id of host"), :required => true
def available_release_versions
releases = @host.content_facet.try(:available_releases) || []
respond_for_index :collection => full_result_response(releases)
end

private

def validate_content_overrides(content_params)
Expand Down
12 changes: 0 additions & 12 deletions app/controllers/katello/api/v2/systems_controller.rb
Expand Up @@ -80,18 +80,6 @@ def show
respond
end

api :GET, "/systems/:id/releases", N_("Show releases available for the content host"), :deprecated => true
param :id, String, :desc => N_("UUID of the content host"), :required => true
desc <<-DESC
A hint for choosing the right value for the releaseVer param
DESC
def releases
response = { :results => @system.available_releases,
:total => @system.available_releases.size,
:subtotal => @system.available_releases.size }
respond_for_index :collection => response
end

private

def system_params_to_host_params(sys_params)
Expand Down
5 changes: 0 additions & 5 deletions config/routes/api/v2.rb
Expand Up @@ -240,14 +240,9 @@ class ActionDispatch::Routing::Mapper
end

api_resources :systems, :only => [:index, :show, :create, :update, :destroy] do
member do
get :releases
end
collection do
get :auto_complete_search
end
api_resources :activation_keys, :only => [:index]
api_resources :host_collections, :only => [:index]
api_resources :products, :only => [:index]
end

Expand Down
1 change: 1 addition & 0 deletions config/routes/overrides.rb
Expand Up @@ -83,6 +83,7 @@ def matches?(request)
put :auto_attach
get :product_content
get :events
get :available_release_versions
put :content_override
put :remove_subscriptions
put :add_subscriptions
Expand Down
Expand Up @@ -15,8 +15,8 @@
* Provides the functionality for the content host details action pane.
*/
angular.module('Bastion.content-hosts').controller('ContentHostDetailsInfoController',
['$scope', '$q', 'translate', 'ContentHost', 'ContentView', 'Organization', 'CurrentOrganization', 'ContentHostsHelper',
function ($scope, $q, translate, ContentHost, ContentView, Organization, CurrentOrganization, ContentHostsHelper) {
['$scope', '$q', 'translate', 'HostSubscription', 'ContentView', 'Organization', 'CurrentOrganization', 'ContentHostsHelper',
function ($scope, $q, translate, HostSubscription, ContentView, Organization, CurrentOrganization, ContentHostsHelper) {
function doubleColonNotationToObject(dotString) {
var doubleColonObject = {}, tempObject, parts, part, key, property;
for (property in dotString) {
Expand Down Expand Up @@ -84,7 +84,7 @@ angular.module('Bastion.content-hosts').controller('ContentHostDetailsInfoContro
$scope.releaseVersions = function () {
var deferred = $q.defer();

ContentHost.releaseVersions({ id: $scope.host.subscription_facet_attributes.uuid }, function (response) {
HostSubscription.releaseVersions({ id: $scope.host.id }, function (response) {
if (response.total === 0) {
$scope.showVersionAlert = true;
}
Expand Down
Expand Up @@ -16,7 +16,8 @@ angular.module('Bastion.hosts').factory('HostSubscription',
removeSubscriptions: {method: 'put', isArray: false, params: {action: 'remove_subscriptions'}},
addSubscriptions: {method: 'put', isArray: false, params: {action: 'add_subscriptions'}},
productContent: {method: 'get', isArray: false, params: {action: 'product_content'}},
contentOverride: {method: 'put', isArray: false, params: {action: 'content_override'}}
contentOverride: {method: 'put', isArray: false, params: {action: 'content_override'}},
releaseVersions: {method: 'get', isArray: false, params: {action: 'available_release_versions'}}
});

}]
Expand Down
6 changes: 6 additions & 0 deletions test/controllers/api/v2/host_subscriptions_controller_test.rb
Expand Up @@ -205,6 +205,12 @@ def test_invalid_content_fails
assert_response 400
end

def test_available_release_versions
get :available_release_versions, :host_id => @host.id

assert_response :success
end

def test_destroy
assert_sync_task(::Actions::Katello::Host::Unregister, @host)
delete :destroy, :host_id => @host.id
Expand Down

0 comments on commit 536c81e

Please sign in to comment.