Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refs #11754 - moves content view history to scoped search
- Loading branch information
Showing
13 changed files
with
98 additions
and
76 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
app/controllers/katello/api/v2/content_view_histories_controller.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
module Katello | ||
class Api::V2::ContentViewHistoriesController < Api::V2::ApiController | ||
include Katello::Concerns::FilteredAutoCompleteSearch | ||
|
||
before_filter :find_content_view | ||
|
||
api :GET, "/content_views/:id/history", N_("Show a content view's history") | ||
param :id, :number, :desc => N_("content view numeric identifier"), :required => true | ||
def index | ||
respond_for_index :collection => scoped_search(index_relation.uniq, :katello_content_view_version_id, :asc, :resource_class => ContentViewHistory) | ||
end | ||
|
||
def index_relation | ||
ContentViewHistory.joins(:content_view_version).where("#{ContentViewVersion.table_name}.content_view_id" => @view.id) | ||
end | ||
|
||
private | ||
|
||
def find_content_view | ||
@view = ContentView.find(params[:content_view_id]) if params[:content_view_id] | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 0 additions & 31 deletions
31
app/models/katello/glue/elastic_search/content_view_history.rb
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
...vascripts/bastion_katello/content-views/details/histories/content-view-history.factory.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/** | ||
* @ngdoc service | ||
* @name Bastion.content-views.factory:ContentViewHistory | ||
* | ||
* @requires BastionResource | ||
* @requires CurrentOrganization | ||
* | ||
* @description | ||
* Provides a BastionResource for interacting with content view histories. | ||
*/ | ||
angular.module('Bastion.content-views').factory('ContentViewHistory', | ||
['BastionResource', 'CurrentOrganization', | ||
function (BastionResource, CurrentOrganization) { | ||
|
||
return BastionResource('/katello/api/v2/content_views/:contentViewId/history/:action', | ||
{id: '@id', contentViewId: '@contentViewId', 'organization_id': CurrentOrganization}, | ||
{ | ||
autocomplete: {method: 'GET', isArray: true, params: {action: 'auto_complete_search'}} | ||
} | ||
); | ||
}] | ||
); |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
test/controllers/api/v2/content_view_histories_controller_test.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
require "katello_test_helper" | ||
|
||
module Katello | ||
class Api::V2::ContentViewHistoriesControllerTest < ActionController::TestCase | ||
def models | ||
@library_dev_staging_view = ContentView.find(katello_content_views(:library_dev_staging_view)) | ||
end | ||
|
||
def permissions | ||
@view_permission = :view_content_views | ||
@create_permission = :create_content_views | ||
@update_permission = :edit_content_views | ||
@destroy_permission = :destroy_content_views | ||
end | ||
|
||
def setup | ||
setup_controller_defaults_api | ||
models | ||
permissions | ||
end | ||
|
||
def test_index | ||
get :index, :content_view_id => @library_dev_staging_view | ||
|
||
assert_response :success | ||
assert_template 'katello/api/v2/content_view_histories/index' | ||
end | ||
|
||
def test_index_protected | ||
allowed_perms = [@view_permission] | ||
denied_perms = [@create_permission, @update_permission, :destroy_content_views] | ||
|
||
assert_protected_action(:index, allowed_perms, denied_perms) do | ||
get :index, :content_view_id => @library_dev_staging_view.id | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters