commit 630061d2734332c6a699147b1051e4dd054e16fb
Author: Michael Moll <kvedulv@kvedulv.de>
Date:   Sat Jun 9 17:04:34 2018 +0200

    Fixes #19775 - Fix Layout/ExtraSpacing cop

diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
index 87d8e2014..a16935c55 100644
--- a/.rubocop_todo.yml
+++ b/.rubocop_todo.yml
@@ -34,12 +34,6 @@ Layout/CaseIndentation:
 Layout/ClosingParenthesisIndentation:
   Enabled: false
 
-# Offense count: 55
-# Cop supports --auto-correct.
-# Configuration parameters: AllowForAlignment, ForceEqualSignAlignment.
-Layout/ExtraSpacing:
-  Enabled: false
-
 # Offense count: 30
 # Cop supports --auto-correct.
 # Configuration parameters: EnforcedStyle.
diff --git a/app/controllers/api/v2/hostgroups_controller.rb b/app/controllers/api/v2/hostgroups_controller.rb
index bb7e89179..511e52d5b 100644
--- a/app/controllers/api/v2/hostgroups_controller.rb
+++ b/app/controllers/api/v2/hostgroups_controller.rb
@@ -52,7 +52,7 @@ module Api
           param :domain_id, :number, :desc => N_('Domain ID')
           param :realm_id, :number, :desc => N_('Realm ID')
           param :config_group_ids, Array, :desc => N_("IDs of associated config groups")
-          param :group_parameters_attributes, Array, :required => false, :desc => N_("Array of parameters")  do
+          param :group_parameters_attributes, Array, :required => false, :desc => N_("Array of parameters") do
             param :name, String, :desc => N_("Name of the parameter"), :required => true
             param :value, String, :desc => N_("Parameter value"), :required => true
           end
diff --git a/app/controllers/api/v2/operatingsystems_controller.rb b/app/controllers/api/v2/operatingsystems_controller.rb
index a4d5b9260..be86af5f2 100644
--- a/app/controllers/api/v2/operatingsystems_controller.rb
+++ b/app/controllers/api/v2/operatingsystems_controller.rb
@@ -25,7 +25,7 @@ module Api
       param :ptable_id, String, :desc => N_("ID of partition table")
       param :config_template_id, String, :desc => N_("ID of template")
       param :provisioning_template_id, String, :desc => N_("ID of template")
-      param :os_parameters_attributes, Array, :required => false, :desc => N_("Array of parameters")  do
+      param :os_parameters_attributes, Array, :required => false, :desc => N_("Array of parameters") do
         param :name, String, :desc => N_("Name of the parameter"), :required => true
         param :value, String, :desc => N_("Parameter value"), :required => true
       end
diff --git a/app/controllers/api/v2/trends_controller.rb b/app/controllers/api/v2/trends_controller.rb
index b112616ed..dd3983ac0 100644
--- a/app/controllers/api/v2/trends_controller.rb
+++ b/app/controllers/api/v2/trends_controller.rb
@@ -16,7 +16,7 @@ module Api
       end
 
       api :POST, "/trends/", N_("Create a trend counter")
-      param :trendable_type, String,  :required => true
+      param :trendable_type, String, :required => true
       param :fact_name, String, :required => false
       param :name, String, :required => false
       def create
diff --git a/app/controllers/hosts_controller.rb b/app/controllers/hosts_controller.rb
index 32bccec5b..d6bf1fd5b 100644
--- a/app/controllers/hosts_controller.rb
+++ b/app/controllers/hosts_controller.rb
@@ -249,7 +249,7 @@ class HostsController < ApplicationController
 
   def cancelBuild
     if @host.built(false)
-      process_success :success_msg =>  _("Canceled pending build for %s") % @host.name, :success_redirect => :back
+      process_success :success_msg => _("Canceled pending build for %s") % @host.name, :success_redirect => :back
     else
       process_error :redirect => :back, :error_msg => _("Failed to cancel pending build for %{hostname} with the following errors: %{errors}") % {:hostname => @host.name, :errors => @host.errors.full_messages.join(', ')}
     end
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index a88ed70a9..65eb30fef 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -448,7 +448,7 @@ module ApplicationHelper
     update_url = options[:update_url] || url_for(object)
     type       = options[:type]
     title      = options[:title]
-    select_values     = [true, false].include?(value) ? [_('Yes'), _('No')] : options[:select_values]
+    select_values = [true, false].include?(value) ? [_('Yes'), _('No')] : options[:select_values]
 
     editable(object, property, {:type => type, :title => title, :value => value, :class => klass, :source => select_values, :url => update_url}.compact)
   end
@@ -553,7 +553,7 @@ module ApplicationHelper
   end
 
   def toast_notifiations_data
-    selected_toast_notifiations =  flash.select { |key, _| key != 'inline' }
+    selected_toast_notifiations = flash.select { |key, _| key != 'inline' }
 
     selected_toast_notifiations.map do |type, notification|
       notification.is_a?(Hash) ? notification : { :type => type, :message => notification }
diff --git a/app/helpers/home_helper.rb b/app/helpers/home_helper.rb
index 1e9e02f1b..cc85f8355 100644
--- a/app/helpers/home_helper.rb
+++ b/app/helpers/home_helper.rb
@@ -3,7 +3,7 @@ module HomeHelper
     authorized_menu_actions(Menu::Manager.items(menu_name).children).map do |menu|
       items = authorized_menu_actions(menu.children)
       render "home/vertical_menu", :menu_items => items, :menu_title => _(menu.caption), :menu_icon => menu.icon,
-                                   :menu_name => menu.name, :mobile_class => mobile ? 'visible-xs-block' : ''  if items.any?
+                                   :menu_name => menu.name, :mobile_class => mobile ? 'visible-xs-block' : '' if items.any?
     end.join(' ').html_safe
   end
 
diff --git a/app/helpers/hosts_and_hostgroups_helper.rb b/app/helpers/hosts_and_hostgroups_helper.rb
index 314b180df..b66a50a1d 100644
--- a/app/helpers/hosts_and_hostgroups_helper.rb
+++ b/app/helpers/hosts_and_hostgroups_helper.rb
@@ -37,7 +37,7 @@ module HostsAndHostgroupsHelper
                   :disable_button_enabled => override && !explicit_value?(:realm_id),
                   :user_set => user_set?(:realm_id)
                 },
-                { :help_inline   => :indicator }
+                { :help_inline => :indicator }
             ).html_safe
   end
 
diff --git a/app/helpers/reports_helper.rb b/app/helpers/reports_helper.rb
index b0cf8e533..bbfe3bf72 100644
--- a/app/helpers/reports_helper.rb
+++ b/app/helpers/reports_helper.rb
@@ -14,7 +14,7 @@ module ReportsHelper
     choices += (1..7).map{|i| OpenStruct.new :name => n_("%s day ago", "%s days ago", i) % i, :value => i.days.ago }
     choices += (1..3).map{|i| OpenStruct.new :name => n_("%s week ago", "%s weeks ago", i) % i, :value => i.week.ago }
     choices += (1..3).map{|i| OpenStruct.new :name => n_("%s month ago", "%s months ago", i) % i, :value => i.month.ago }
-    choices += [OpenStruct.new(:name => _("All Reports"), :value =>  Report.first(:select => "created_at").created_at)]
+    choices += [OpenStruct.new(:name => _("All Reports"), :value => Report.first(:select => "created_at").created_at)]
     builder.collection_select :reported_at_gt, choices, :value, :name, {:include_blank => _("Select a period")}
   end
 
diff --git a/app/models/compute_resources/foreman/model/libvirt.rb b/app/models/compute_resources/foreman/model/libvirt.rb
index 164e2517e..dfe07f48c 100644
--- a/app/models/compute_resources/foreman/model/libvirt.rb
+++ b/app/models/compute_resources/foreman/model/libvirt.rb
@@ -168,7 +168,7 @@ module Foreman::Model
       # Listen address cannot be updated while the guest is running
       # When we update the display password, we pass the existing listen address
       vm.update_display(:password => password, :listen => vm.display[:listen], :type => vm.display[:type])
-      WsProxy.start(:host => hypervisor.hostname, :host_port => vm.display[:port], :password => password).merge(:type =>  vm.display[:type], :name=> vm.name)
+      WsProxy.start(:host => hypervisor.hostname, :host_port => vm.display[:port], :password => password).merge(:type => vm.display[:type], :name=> vm.name)
     rescue ::Libvirt::Error => e
       if e.message =~ /cannot change listen address/
         logger.warn e
diff --git a/app/models/compute_resources/foreman/model/openstack.rb b/app/models/compute_resources/foreman/model/openstack.rb
index b830cbadb..dd36e8eac 100644
--- a/app/models/compute_resources/foreman/model/openstack.rb
+++ b/app/models/compute_resources/foreman/model/openstack.rb
@@ -44,7 +44,7 @@ module Foreman::Model
 
     def tenants
       if url =~ /\/v3\/auth\/tokens/
-        user_id       = identity_client.current_user_id
+        user_id = identity_client.current_user_id
         identity_client.list_user_projects(user_id).body["projects"].map { |p| Fog::Identity::OpenStack::V3::Project.new(p) }
       else
         client.tenants
diff --git a/app/models/concerns/hostext/search.rb b/app/models/concerns/hostext/search.rb
index 53e73b2e5..872444794 100644
--- a/app/models/concerns/hostext/search.rb
+++ b/app/models/concerns/hostext/search.rb
@@ -90,7 +90,7 @@ module Hostext
       end
 
       if SETTINGS[:login]
-        scoped_search :relation => :search_users, :on => :login,     :complete_value => true, :only_explicit => true, :rename => :'user.login',    :operators => ['= ', '~ '], :ext_method => :search_by_user, :aliases => [:owner]
+        scoped_search :relation => :search_users, :on => :login,     :complete_value => true, :only_explicit => true, :rename => :'user.login', :operators => ['= ', '~ '], :ext_method => :search_by_user, :aliases => [:owner]
         scoped_search :relation => :search_users, :on => :firstname, :complete_value => true, :only_explicit => true, :rename => :'user.firstname', :operators => ['= ', '~ '], :ext_method => :search_by_user
         scoped_search :relation => :search_users, :on => :lastname,  :complete_value => true, :only_explicit => true, :rename => :'user.lastname', :operators => ['= ', '~ '], :ext_method => :search_by_user
         scoped_search :relation => :search_users, :on => :mail,      :complete_value => true, :only_explicit => true, :rename => :'user.mail',     :operators => ['= ', '~ '], :ext_method => :search_by_user
@@ -138,7 +138,7 @@ module Hostext
       def search_by_hostgroup_and_descendants(key, operator, value)
         conditions = sanitize_sql_for_conditions(["hostgroups.title #{operator} ?", value_to_sql(operator, value)])
         # Only one hostgroup (first) is used to determined descendants. Future TODO - alert if result results more than one hostgroup
-        hostgroup     = Hostgroup.unscoped.with_taxonomy_scope.find_by(conditions)
+        hostgroup = Hostgroup.unscoped.with_taxonomy_scope.find_by(conditions)
         if hostgroup.present?
           hostgroup_ids = hostgroup.subtree_ids
           opts = "hosts.hostgroup_id IN (#{hostgroup_ids.join(',')})"
diff --git a/app/models/host/base.rb b/app/models/host/base.rb
index c52bd93cc..27f4ce5a0 100644
--- a/app/models/host/base.rb
+++ b/app/models/host/base.rb
@@ -32,7 +32,7 @@ module Host
 
     alias_attribute :hostname, :name
 
-    validates :name, :presence   => true, :uniqueness => true, :format => {:with => Net::Validations::HOST_REGEXP, :message => _(Net::Validations::HOST_REGEXP_ERR_MSG)}
+    validates :name, :presence => true, :uniqueness => true, :format => {:with => Net::Validations::HOST_REGEXP, :message => _(Net::Validations::HOST_REGEXP_ERR_MSG)}
     validate :host_has_required_interfaces
     validate :uniq_interfaces_identifiers
     validate :build_managed_only
diff --git a/app/models/nic/base.rb b/app/models/nic/base.rb
index 4ce9286a9..a57cfec30 100644
--- a/app/models/nic/base.rb
+++ b/app/models/nic/base.rb
@@ -139,7 +139,7 @@ module Nic
 
     def clone
       # do not copy system specific attributes
-      self.deep_clone(:except  => [:name, :mac, :ip, :ip6, :host_id])
+      self.deep_clone(:except => [:name, :mac, :ip, :ip6, :host_id])
     end
 
     # if this interface does not have MAC and is attached to other interface,
diff --git a/app/models/setting/provisioning.rb b/app/models/setting/provisioning.rb
index 8066bfd4c..1b4bd4995 100644
--- a/app/models/setting/provisioning.rb
+++ b/app/models/setting/provisioning.rb
@@ -92,7 +92,7 @@ class Setting::Provisioning < Setting
 
   def self.default_global_templates
     map_pxe_kind do |pxe_kind, templates|
-      self.set("global_#{pxe_kind}", N_("Global default %s template. This template gets deployed to all configured TFTP servers. It will not be affected by upgrades.") % pxe_kind, ProvisioningTemplate.global_default_name(pxe_kind), N_("Global default %s template") % pxe_kind, nil, { :collection =>  templates })
+      self.set("global_#{pxe_kind}", N_("Global default %s template. This template gets deployed to all configured TFTP servers. It will not be affected by upgrades.") % pxe_kind, ProvisioningTemplate.global_default_name(pxe_kind), N_("Global default %s template") % pxe_kind, nil, { :collection => templates })
     end
   end
 
diff --git a/app/models/trends/fact_trend.rb b/app/models/trends/fact_trend.rb
index 070e05961..a11e34f70 100644
--- a/app/models/trends/fact_trend.rb
+++ b/app/models/trends/fact_trend.rb
@@ -1,5 +1,5 @@
 class FactTrend < Trend
-  validates :trendable_id, :presence => true, :uniqueness => {:scope =>  [:trendable_type, :fact_value] }, :allow_blank => false
+  validates :trendable_id, :presence => true, :uniqueness => {:scope => [:trendable_type, :fact_value] }, :allow_blank => false
 
   before_save :update_fact_name
 
diff --git a/config.ru b/config.ru
index b9238ea1f..d9c856bac 100644
--- a/config.ru
+++ b/config.ru
@@ -2,10 +2,10 @@
 require 'rack'
 
 # load Rails environment
-require ::File.expand_path('../config/environment',  __FILE__)
+require ::File.expand_path('../config/environment', __FILE__)
 
 # apply a prefix to the application, if one is defined
 # e.g. http://some.server.com/prefix where '/prefix' is defined by env variable
-map ENV['RAILS_RELATIVE_URL_ROOT'] || '/'  do
+map ENV['RAILS_RELATIVE_URL_ROOT'] || '/' do
   run Foreman::Application
 end
diff --git a/db/migrate/20180403144853_convert_vm_attrs_to_hash.rb b/db/migrate/20180403144853_convert_vm_attrs_to_hash.rb
index e5e55dfb0..490ef7860 100644
--- a/db/migrate/20180403144853_convert_vm_attrs_to_hash.rb
+++ b/db/migrate/20180403144853_convert_vm_attrs_to_hash.rb
@@ -23,7 +23,7 @@ class ConvertVmAttrsToHash < ActiveRecord::Migration[5.1]
   YML_PARAMS = /!ruby\/[\w-]+:ActionController::Parameters/
 
   def transform_batch_columns(base, serialized_columns)
-    base.unscoped.select(serialized_columns + [:id]).find_each  do |object|
+    base.unscoped.select(serialized_columns + [:id]).find_each do |object|
       serialized_columns.each do |column|
         attributes = object.send :read_attribute_before_type_cast, column
         next if attributes.nil?
@@ -52,6 +52,6 @@ class ConvertVmAttrsToHash < ActiveRecord::Migration[5.1]
 
   class FakeLookupKey < ApplicationRecord
     self.table_name = 'lookup_keys'
-    self.inheritance_column  = nil
+    self.inheritance_column = nil
   end
 end
diff --git a/lib/foreman/foreman_url_renderer.rb b/lib/foreman/foreman_url_renderer.rb
index 24c3530c4..19dd7be1e 100644
--- a/lib/foreman/foreman_url_renderer.rb
+++ b/lib/foreman/foreman_url_renderer.rb
@@ -11,7 +11,7 @@ module Foreman
     # returns the URL for Foreman based on the required action
     def foreman_url(action = 'provision')
       # Get basic stuff
-      config   = URI.parse(Setting[:unattended_url])
+      config = URI.parse(Setting[:unattended_url])
       url_options = foreman_url_options_from_settings_or_request(config)
 
       host = @host
diff --git a/lib/tasks/jenkins.rake b/lib/tasks/jenkins.rake
index becdabd0b..34cd6922e 100644
--- a/lib/tasks/jenkins.rake
+++ b/lib/tasks/jenkins.rake
@@ -15,7 +15,7 @@ begin
       end
       minitest_plugins = [:pre_ci, 'webpack:try_compile', 'ci:setup:minitest']
       minitest_plugins << 'robottelo:setup:minitest' if ENV['GENERATE_ROBOTTELO_REPORT'] == 'true'
-      task :minitest  => minitest_plugins
+      task :minitest => minitest_plugins
     end
 
     task :rubocop do
diff --git a/lib/tasks/plugin_apipie.rake b/lib/tasks/plugin_apipie.rake
index da3235312..6c64090a5 100644
--- a/lib/tasks/plugin_apipie.rake
+++ b/lib/tasks/plugin_apipie.rake
@@ -12,7 +12,7 @@ task 'plugin:apipie:cache', :engine do |t, args|
     plugin = Foreman::Plugin.find(args[:engine])
 
     Apipie.configuration.ignored = plugin.apipie_ignored_controllers || []
-    api_controllers =  plugin.apipie_documented_controllers || ["#{@engine_root}/app/controllers/#{path_name}/api/*.rb"]
+    api_controllers = plugin.apipie_documented_controllers || ["#{@engine_root}/app/controllers/#{path_name}/api/*.rb"]
     Apipie.configuration.api_controllers_matcher = api_controllers
 
     Rake::Task['apipie:cache'].execute
diff --git a/lib/tasks/puppet.rake b/lib/tasks/puppet.rake
index ad7a5b5d6..3974115fe 100644
--- a/lib/tasks/puppet.rake
+++ b/lib/tasks/puppet.rake
@@ -26,7 +26,7 @@ namespace :puppet do
   namespace :import do
     desc "
     Update puppet environments and classes. Optional batch flag triggers run with no prompting\nUse proxy=<proxy name> to import from or get the first one by default"
-    task :puppet_classes,  [:batch, :envname] => :environment do |t, args|
+    task :puppet_classes, [:batch, :envname] => :environment do |t, args|
       User.as_anonymous_admin do
         args.batch = args.batch == "true"
         proxies = SmartProxy.with_features("Puppet")
diff --git a/lib/tasks/reports.rake b/lib/tasks/reports.rake
index 5d46e0c25..fd3d28e3b 100644
--- a/lib/tasks/reports.rake
+++ b/lib/tasks/reports.rake
@@ -100,7 +100,7 @@ namespace :reports do
     end
   end
 
-  task :daily  => :environment do
+  task :daily => :environment do
     process_notifications :daily
   end
 
diff --git a/test/controllers/api/v2/auth_sources_controller_test.rb b/test/controllers/api/v2/auth_sources_controller_test.rb
index 737b5094f..5f433a5ab 100644
--- a/test/controllers/api/v2/auth_sources_controller_test.rb
+++ b/test/controllers/api/v2/auth_sources_controller_test.rb
@@ -6,7 +6,7 @@ class Api::V2::AuthSourcesControllerTest < ActionController::TestCase
     assert_response :success
     auth_sources = ActiveSupport::JSON.decode(@response.body)
     refute_empty auth_sources
-    ids               = auth_sources['results'].map { |hash| hash['id'] }
+    ids = auth_sources['results'].map { |hash| hash['id'] }
     assert_includes ids, auth_sources(:internal).id
     assert_includes ids, auth_sources(:external).id
     assert_includes ids, auth_sources(:one).id
diff --git a/test/controllers/api/v2/interfaces_controller_test.rb b/test/controllers/api/v2/interfaces_controller_test.rb
index e5b6eb85c..ff0aa8f64 100644
--- a/test/controllers/api/v2/interfaces_controller_test.rb
+++ b/test/controllers/api/v2/interfaces_controller_test.rb
@@ -8,7 +8,7 @@ class Api::V2::InterfacesControllerTest < ActionController::TestCase
   def setup
     @host = FactoryBot.create(:host)
     @nic  = FactoryBot.create(:nic_managed, :host => @host)
-    @bond  = FactoryBot.create(:nic_bond, :host => @host)
+    @bond = FactoryBot.create(:nic_bond, :host => @host)
   end
 
   test "get index for specific host" do
diff --git a/test/controllers/api/v2/locations_controller_test.rb b/test/controllers/api/v2/locations_controller_test.rb
index 4d4e6592b..ceeef3aa0 100755
--- a/test/controllers/api/v2/locations_controller_test.rb
+++ b/test/controllers/api/v2/locations_controller_test.rb
@@ -45,7 +45,7 @@ class Api::V2::LocationsControllerTest < ActionController::TestCase
 
   test "should create location with parent" do
     parent_id = Location.first.id
-    post :create, params: { :location => { :name => "Test Location", :parent_id =>  parent_id } }
+    post :create, params: { :location => { :name => "Test Location", :parent_id => parent_id } }
     assert_response :success
     show_response = ActiveSupport::JSON.decode(@response.body)
     assert !show_response.empty?
diff --git a/test/controllers/api/v2/operatingsystems_controller_test.rb b/test/controllers/api/v2/operatingsystems_controller_test.rb
index 8489e99af..d20081c73 100644
--- a/test/controllers/api/v2/operatingsystems_controller_test.rb
+++ b/test/controllers/api/v2/operatingsystems_controller_test.rb
@@ -26,7 +26,7 @@ class Api::V2::OperatingsystemsControllerTest < ActionController::TestCase
   test "should create os with name and major version only" do
     os_params = minimum_required_os_params
     assert_difference('Operatingsystem.count') do
-      post :create, params: { :operatingsystem =>  os_params}
+      post :create, params: { :operatingsystem => os_params}
     end
     assert_response :created
     response = JSON.parse(@response.body)
diff --git a/test/controllers/api/v2/organizations_controller_test.rb b/test/controllers/api/v2/organizations_controller_test.rb
index 2a0bc1b2e..37c1c3be1 100755
--- a/test/controllers/api/v2/organizations_controller_test.rb
+++ b/test/controllers/api/v2/organizations_controller_test.rb
@@ -131,7 +131,7 @@ class Api::V2::OrganizationsControllerTest < ActionController::TestCase
 
   test "search organization" do
     organization = Organization.first
-    get :index, params: { :search =>  "name = \"#{organization.name}\"",  :format => 'json' }
+    get :index, params: { :search =>  "name = \"#{organization.name}\"", :format => 'json' }
     assert_response :success, "search organization name: '#{organization.name}' failed with code: #{@response.code}"
     response = JSON.parse(@response.body)
     assert_equal response['results'].length, 1
diff --git a/test/controllers/api/v2/override_values_controller_test.rb b/test/controllers/api/v2/override_values_controller_test.rb
index 44045b680..1f4388d5c 100644
--- a/test/controllers/api/v2/override_values_controller_test.rb
+++ b/test/controllers/api/v2/override_values_controller_test.rb
@@ -329,7 +329,7 @@ class Api::V2::OverrideValuesControllerTest < ActionController::TestCase
     lookup_key = FactoryBot.create(:variable_lookup_key, :puppetclass => puppetclasses(:two))
     refute lookup_key.override
     assert_difference('LookupValue.count', 1) do
-      post :create, params: { :smart_variable_id => lookup_key.id, :override_value =>  { :match => 'os=string'} }
+      post :create, params: { :smart_variable_id => lookup_key.id, :override_value => { :match => 'os=string'} }
     end
     assert_response :success
   end
@@ -381,7 +381,7 @@ class Api::V2::OverrideValuesControllerTest < ActionController::TestCase
   test_attributes :pid => 'bef0e457-16be-4ca6-bc56-fa32dff55a01'
   test "should not create invalid matcher for non existing attribute" do
     assert_difference('LookupValue.count', 0) do
-      post :create, params: { :smart_class_parameter_id => lookup_keys(:one).id, :override_value =>  { :match => 'hostgroup=nonexistingHG', :value => RFauxFactory.gen_alpha } }
+      post :create, params: { :smart_class_parameter_id => lookup_keys(:one).id, :override_value => { :match => 'hostgroup=nonexistingHG', :value => RFauxFactory.gen_alpha } }
     end
     assert_includes JSON.parse(response.body)['error']['message'], 'Validation failed: Match hostgroup=nonexistingHG does not match an existing host group'
   end
diff --git a/test/controllers/api/v2/ptables_controller_test.rb b/test/controllers/api/v2/ptables_controller_test.rb
index cc75e7b1e..ede2c053f 100644
--- a/test/controllers/api/v2/ptables_controller_test.rb
+++ b/test/controllers/api/v2/ptables_controller_test.rb
@@ -149,7 +149,7 @@ class Api::V2::PtablesControllerTest < ActionController::TestCase
 
   test_attributes :pid => '08520746-444b-47c9-a8a3-438170147453'
   test "search ptable" do
-    get :index, params: { :search =>  @ptable.name,  :format => 'json' }
+    get :index, params: { :search =>  @ptable.name, :format => 'json' }
     assert_response :success, "search ptable name: '#{@ptable.name}' failed with code: #{@response.code}"
     response = JSON.parse(@response.body)
     assert_equal response['results'].length, 1
@@ -162,7 +162,7 @@ class Api::V2::PtablesControllerTest < ActionController::TestCase
     org = Organization.first
     @ptable.organizations = [org]
     assert @ptable.save
-    get :index, params: {:search =>  @ptable.name, :organization_id => org.id,  :format => 'json' }
+    get :index, params: {:search => @ptable.name, :organization_id => org.id, :format => 'json' }
     assert_response :success, "search ptable by name and organization failed with code: #{@response.code}"
     response = JSON.parse(@response.body)
     assert_equal response['results'].length, 1
diff --git a/test/controllers/api/v2/smart_proxies_controller_test.rb b/test/controllers/api/v2/smart_proxies_controller_test.rb
index 657ec4713..c59cd3388 100644
--- a/test/controllers/api/v2/smart_proxies_controller_test.rb
+++ b/test/controllers/api/v2/smart_proxies_controller_test.rb
@@ -89,7 +89,7 @@ class Api::V2::SmartProxiesControllerTest < ActionController::TestCase
     put :update, params: { :id => smart_proxies(:one).to_param, :smart_proxy => valid_attrs }
     assert_response :success
     response = JSON.parse(@response.body)
-    refute_empty response.keys.select { |key|  any_needed_fields.include?(key) }
+    refute_empty response.keys.select { |key| any_needed_fields.include?(key) }
   end
 
   test_attributes :pid => '42d6b749-c047-4fd2-90ee-ffab7be558f9'
@@ -98,7 +98,7 @@ class Api::V2::SmartProxiesControllerTest < ActionController::TestCase
     put :update, params: { :id => smart_proxies(:one).to_param, :smart_proxy => valid_attrs }
     assert_response :success
     response = JSON.parse(@response.body)
-    refute_empty response.keys.select { |key|  any_needed_fields.include?(key) }
+    refute_empty response.keys.select { |key| any_needed_fields.include?(key) }
   end
 
   test_attributes :pid => 'f279640e-d7e9-48a3-aed8-7bf406e9d6f2'
diff --git a/test/controllers/environments_controller_test.rb b/test/controllers/environments_controller_test.rb
index 187fd728c..16527b18e 100644
--- a/test/controllers/environments_controller_test.rb
+++ b/test/controllers/environments_controller_test.rb
@@ -158,7 +158,7 @@ class EnvironmentsControllerTest < ActionController::TestCase
     post :obsolete_and_new, params:
       { "changed"=>
        {"obsolete" =>
-        {"env1"  => '["a","b","c","_destroy_"]'}
+        {"env1" => '["a","b","c","_destroy_"]'}
        }
      }, session: set_session_user
     assert Environment.unscoped.find_by_name("env1").hosts.count > 0
diff --git a/test/controllers/hostgroups_controller_test.rb b/test/controllers/hostgroups_controller_test.rb
index 636e843c5..bfed31e8b 100644
--- a/test/controllers/hostgroups_controller_test.rb
+++ b/test/controllers/hostgroups_controller_test.rb
@@ -185,7 +185,7 @@ class HostgroupsControllerTest < ActionController::TestCase
     end
 
     test 'should not escape lookup values on environment change' do
-      hostgroup = FactoryBot.create(:hostgroup, :environment => @environment, :puppetclass_ids =>  [@puppetclass.id])
+      hostgroup = FactoryBot.create(:hostgroup, :environment => @environment, :puppetclass_ids => [@puppetclass.id])
       lookup_key = FactoryBot.create(:puppetclass_lookup_key, :as_smart_class_param, :key_type => 'array',
                                      :default_value => ['a', 'b'], :override => true, :puppetclass => @puppetclass)
       lookup_value = FactoryBot.create(:lookup_value, :lookup_key => lookup_key, :match => "hostgroup=#{hostgroup.name}", :value => ["c", "d"])
@@ -193,7 +193,7 @@ class HostgroupsControllerTest < ActionController::TestCase
       FactoryBot.create(:environment_class, :puppetclass => @puppetclass, :environment => @environment, :puppetclass_lookup_key => lookup_key)
 
       # sending exactly what the host form would send which is lookup_value.value_before_type_cast
-      lk = {"lookup_values_attributes" => {lookup_key.id.to_s => {"value" => lookup_value.value_before_type_cast, "id" =>lookup_value.id, "lookup_key_id" =>  lookup_key.id, "_destroy" => false}}}
+      lk = {"lookup_values_attributes" => {lookup_key.id.to_s => {"value" => lookup_value.value_before_type_cast, "id" =>lookup_value.id, "lookup_key_id" => lookup_key.id, "_destroy" => false}}}
 
       params = {
         hostgroup_id: hostgroup.id,
diff --git a/test/controllers/hosts_controller_test.rb b/test/controllers/hosts_controller_test.rb
index 0991b8b67..fc9878bd0 100644
--- a/test/controllers/hosts_controller_test.rb
+++ b/test/controllers/hosts_controller_test.rb
@@ -432,7 +432,7 @@ class HostsControllerTest < ActionController::TestCase
     end
 
     hostgroup = hostgroups(:common)
-    post :update_multiple_hostgroup, params: { :host_names => host_names, :hostgroup  => { :id => hostgroup.id} }, session: set_session_user
+    post :update_multiple_hostgroup, params: { :host_names => host_names, :hostgroup => { :id => hostgroup.id} }, session: set_session_user
     assert_response :redirect
 
     host_names.each do |name|
@@ -1626,7 +1626,7 @@ class HostsControllerTest < ActionController::TestCase
       lookup_value = FactoryBot.create(:lookup_value, :lookup_key => lookup_key, :match => "fqdn=#{host.fqdn}", :value => ["c", "d"])
 
       # sending exactly what the host form would send which is lookup_value.value_before_type_cast
-      lk = {"lookup_values_attributes" => {lookup_key.id.to_s => {"value" => lookup_value.value_before_type_cast, "id" =>lookup_value.id, "lookup_key_id" =>  lookup_key.id, "_destroy" => false}}}
+      lk = {"lookup_values_attributes" => {lookup_key.id.to_s => {"value" => lookup_value.value_before_type_cast, "id" =>lookup_value.id, "lookup_key_id" => lookup_key.id, "_destroy" => false}}}
 
       params = {
         host_id: host.id,
diff --git a/test/controllers/shared/basic_rest_response_test.rb b/test/controllers/shared/basic_rest_response_test.rb
index 93d2f0130..980ecb4fe 100644
--- a/test/controllers/shared/basic_rest_response_test.rb
+++ b/test/controllers/shared/basic_rest_response_test.rb
@@ -109,7 +109,7 @@ module BasicRestResponseTest
           next if @controller.resource_name == "trend"
           @request.env['HTTP_REFERER'] = root_url
           get :index, params: {search: "name='A98$bcD#67Ef*g"}, session: set_session_user
-          assert (@response.body.include? "No entries found") ||  @response.body.match(/You are being.*redirected/)
+          assert (@response.body.include? "No entries found") || @response.body.match(/You are being.*redirected/)
         end
 
         teardown do
diff --git a/test/controllers/ssh_keys_controller_test.rb b/test/controllers/ssh_keys_controller_test.rb
index 07fc9b99f..4ded619fb 100644
--- a/test/controllers/ssh_keys_controller_test.rb
+++ b/test/controllers/ssh_keys_controller_test.rb
@@ -2,7 +2,7 @@ require 'test_helper'
 
 class SshKeysControllerTest < ActionController::TestCase
   let(:key) { 'ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBIhRoL6PfBRs9YwW3r2/pYeLrxRzEZSUO3Go8JivxMsguEKjJ3byHDPvPpMHhKKSZD/HJY/A+2Ndqp0ElB+t2qs= foreman@example.com' }
-  let(:ssh_key) { FactoryBot.create(:ssh_key)  }
+  let(:ssh_key) { FactoryBot.create(:ssh_key) }
   let(:user) { ssh_key.user }
 
   test 'new' do
diff --git a/test/mailers/application_mailer_test.rb b/test/mailers/application_mailer_test.rb
index c1dad299c..8541054ab 100644
--- a/test/mailers/application_mailer_test.rb
+++ b/test/mailers/application_mailer_test.rb
@@ -10,7 +10,7 @@ class ApplicationMailerTest < ActiveSupport::TestCase
   class TestMailer < ::ApplicationMailer
     def test(to, subject)
       mail(:to => to, :subject => subject) do |format|
-        format.html { render :plain =>  html_mail }
+        format.html { render :plain => html_mail }
       end
     end
 
diff --git a/test/models/lookup_value_test.rb b/test/models/lookup_value_test.rb
index 9a2fc9730..29a4fc33f 100644
--- a/test/models/lookup_value_test.rb
+++ b/test/models/lookup_value_test.rb
@@ -284,7 +284,7 @@ EOF
   end
 
   test "should create override value for smart variable with list validator and matching value" do
-    values_list = [ 'test',  'example', 30 ]
+    values_list = [ 'test', 'example', 30 ]
     validator_type = 'list'
     validator_rule = values_list.join(', ')
     smart_variable = FactoryBot.create(
diff --git a/test/models/organization_test.rb b/test/models/organization_test.rb
index 6d3f732e7..46127410a 100644
--- a/test/models/organization_test.rb
+++ b/test/models/organization_test.rb
@@ -46,7 +46,7 @@ class OrganizationTest < ActiveSupport::TestCase
   test "update with multi names" do
     organization = FactoryBot.create(:organization)
     valid_org_name_list.each do |new_name|
-      organization.name =  new_name
+      organization.name = new_name
       assert organization.valid?, "Validation failed for update with valid name: '#{new_name}' length: #{new_name.length})"
       assert_equal organization.name, new_name
     end
diff --git a/test/models/template_test.rb b/test/models/template_test.rb
index c2586670f..0ff842ed8 100644
--- a/test/models/template_test.rb
+++ b/test/models/template_test.rb
@@ -187,7 +187,7 @@ EOS
         template = Minitest::Mock.new
         template.expect(:ignore_locking, true)
         Template.expects(:import_without_save => template)
-        Template.import!('test', '',  { :force => true })
+        Template.import!('test', '', { :force => true })
         template.verify
       end
     end
diff --git a/test/models/user_test.rb b/test/models/user_test.rb
index 31ef39c9c..f53d243d2 100644
--- a/test/models/user_test.rb
+++ b/test/models/user_test.rb
@@ -38,7 +38,7 @@ end
 class UserTest < ActiveSupport::TestCase
   def setup
     User.current = users :admin
-    @user = User.create :auth_source => auth_sources(:one), :login => "foo", :mail  => "foo@bar.com"
+    @user = User.create :auth_source => auth_sources(:one), :login => "foo", :mail => "foo@bar.com"
   end
 
   # Presence
@@ -170,13 +170,13 @@ class UserTest < ActiveSupport::TestCase
   end
 
   test "user should login case insensitively" do
-    user = User.new :auth_source => auth_sources(:internal), :login => "user", :mail  => "foo1@bar.com", :password => "foo"
+    user = User.new :auth_source => auth_sources(:internal), :login => "user", :mail => "foo1@bar.com", :password => "foo"
     assert user.save!
     assert_equal user, User.try_to_login("USER", "foo")
   end
 
   test "user login should be case aware" do
-    user = User.new :auth_source => auth_sources(:one), :login => "User", :mail  => "foo1@bar.com", :password => "foo"
+    user = User.new :auth_source => auth_sources(:one), :login => "User", :mail => "foo1@bar.com", :password => "foo"
     assert user.save
     assert_equal user.login, "User"
     assert_equal user.lower_login, "user"
@@ -197,7 +197,7 @@ class UserTest < ActiveSupport::TestCase
   test "new internal user gets welcome mail" do
     ActionMailer::Base.deliveries = []
     Setting[:send_welcome_email] = true
-    User.create :auth_source => auth_sources(:internal), :login => "welcome", :mail  => "foo@example.com", :password => "qux", :mail_enabled => true
+    User.create :auth_source => auth_sources(:internal), :login => "welcome", :mail => "foo@example.com", :password => "qux", :mail_enabled => true
     mail = ActionMailer::Base.deliveries.detect { |delivery| delivery.subject =~ /Welcome to Foreman/ }
     assert mail
     assert_match /Username/, mail.body.encoded
@@ -206,7 +206,7 @@ class UserTest < ActiveSupport::TestCase
   test "other auth sources don't get welcome mail" do
     Setting[:send_welcome_email] = true
     assert_no_difference "ActionMailer::Base.deliveries.size" do
-      User.create :auth_source => auth_sources(:one), :login => "welcome", :mail  => "foo@bar.com", :password => "qux"
+      User.create :auth_source => auth_sources(:one), :login => "welcome", :mail => "foo@bar.com", :password => "qux"
     end
   end
 
diff --git a/test/unit/menu_mapper_test.rb b/test/unit/menu_mapper_test.rb
index b91e0c4d3..df20e58cd 100644
--- a/test/unit/menu_mapper_test.rb
+++ b/test/unit/menu_mapper_test.rb
@@ -183,7 +183,7 @@ class MenuMapperTest < ActiveSupport::TestCase
   test 'deleting all items' do
     # Exposed by deleting :last items
     Menu::Manager.map :test_menu do |menu|
-      menu.item :not_last, :url_hash=>  { :controller => 'hosts', :action => 'index'}
+      menu.item :not_last, :url_hash=> { :controller => 'hosts', :action => 'index'}
       menu.item :administration, :url_hash=> { :controller => 'hosts', :action => 'show'}, :last => true
       menu.item :help, :url_hash => { :controller => 'help', :action => 'show'}, :last => true
     end
