Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
module Katello
module Concerns
module BookmarkControllerValidatorExtensions
extend ActiveSupport::Concern
KATELLO_CONTROLLERS = %w[
/katello/api/v2/host_bootc_images
/katello/api/v2/flatpak_remotes
/katello/api/v2/flatpak_remote_repositories
].freeze

def valid_controllers_list
@valid_controllers_list ||= (["dashboard", "common_parameters", "/katello/api/v2/host_bootc_images", "/katello/api/v2/flatpak_remotes", "/katello/api/v2/flatpak_remote_repositories"] +
ActiveRecord::Base.connection.tables.map(&:to_s) +
Permission.resources.map(&:tableize)).uniq
super + KATELLO_CONTROLLERS
end
end
end
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
require 'katello_test_helper'

module Katello
class BookmarkControllerValidatorExtensionsTest < ActiveSupport::TestCase
Katello::Concerns::BookmarkControllerValidatorExtensions::KATELLO_CONTROLLERS.each do |controller|

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An alternative would be iterating over all controllers that include the katello flavor of the autocomplete concern and check those

test "#{controller} should be a valid bookmark controller" do
bookmark = FactoryBot.build_stubbed(:bookmark, :name => "#{controller} bookmark",
:controller => controller,
:query => 'search query',
:public => true)
assert bookmark.valid?, "#{controller} should be a valid bookmark controller, errors: #{bookmark.errors.full_messages}"
end
end
end
end
Loading