Skip to content

Commit

Permalink
feat(test): Migrate access permissions tests
Browse files Browse the repository at this point in the history
  • Loading branch information
laugmanuel committed May 8, 2024
1 parent 9ed76ba commit 3702c86
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 16 deletions.
2 changes: 1 addition & 1 deletion app/models/foreman_wreckingball/cpu_hot_add_status.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def self.host_association
end

def self.description
N_('Enabling CPU hot-add disables vNUMA, the virtual machine will instead use UMA. This might cause a performance degration.') # rubocop:disable Metrics/LineLength
N_('Enabling CPU hot-add disables vNUMA, the virtual machine will instead use UMA. This might cause a performance degration.') # rubocop:disable Layout/LineLength
end

def self.supports_remediate?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def import!
delete_removed_clusters
create_new_clusters
end
logger.info("Import clusters for '#{compute_resource}' completed. Added: #{counters[:added] || 0}, Updated: #{counters[:updated] || 0}, Deleted: #{counters[:deleted] || 0} clusters") # rubocop:disable Metrics/LineLength
logger.info("Import clusters for '#{compute_resource}' completed. Added: #{counters[:added] || 0}, Updated: #{counters[:updated] || 0}, Deleted: #{counters[:deleted] || 0} clusters") # rubocop:disable Layout/LineLength
end

def delete_removed_clusters
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def import!
import_hypervisors(cluster)
delete_removed_hypervisors(cluster)
end
logger.info("Import hypervisors for '#{compute_resource}' completed. Added: #{counters[:added] || 0}, Updated: #{counters[:updated] || 0}, Deleted: #{counters[:deleted] || 0} hypervisors") # rubocop:disable Metrics/LineLength
logger.info("Import hypervisors for '#{compute_resource}' completed. Added: #{counters[:added] || 0}, Updated: #{counters[:updated] || 0}, Deleted: #{counters[:deleted] || 0} hypervisors") # rubocop:disable Layout/LineLength
end

def import_hypervisors(cluster)
Expand Down
13 changes: 0 additions & 13 deletions lib/tasks/foreman_vmware_checks_tasks.rake
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,4 @@ namespace :test do
end
end

namespace :foreman_wreckingball do
require 'rubocop/rake_task'
RuboCop::RakeTask.new(:rubocop) do |task|
task.patterns = ["#{ForemanWreckingball::Engine.root}/app/**/*.rb",
"#{ForemanWreckingball::Engine.root}/lib/**/*.rb",
"#{ForemanWreckingball::Engine.root}/test/**/*.rb"]
end
rescue LoadError => e
raise e unless Rails.env.production?
end

Rake::Task[:test].enhance ['test:foreman_wreckingball']

require 'rubocop/rake_task'
18 changes: 18 additions & 0 deletions test/unit/foreman_wreckingball/access_permissions_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# frozen_string_literal: true

require 'test_plugin_helper'
require 'unit/shared/access_permissions_test_base'

# Permissions are added in AccessPermissions with lists of controllers and
# actions that they enable access to. For non-admin users, we need to test
# that there are permissions available that cover every controller action, else
# it can't be delegated and this will lead to parts of the application that
# aren't functional for non-admin users.
#
# In particular, it's important that actions for AJAX requests are added to
# an appropriate permission so views using those requests function.
class AccessPermissionsTest < ActiveSupport::TestCase
include AccessPermissionsTestBase

check_routes(ForemanWreckingball::Engine.routes, [])
end

0 comments on commit 3702c86

Please sign in to comment.