diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 87d8e2014b3..a16935c552e 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 bb7e89179e2..511e52d5b12 100644 --- a/app/controllers/api/v2/hostgroups_controller.rb +++ b/app/controllers/api/v2/hostgroups_controller.rb @@ -52,7 +52,7 @@ def show 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 a4d5b926026..be86af5f2b8 100644 --- a/app/controllers/api/v2/operatingsystems_controller.rb +++ b/app/controllers/api/v2/operatingsystems_controller.rb @@ -25,7 +25,7 @@ class OperatingsystemsController < V2::BaseController 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 b112616ed70..dd3983ac03b 100644 --- a/app/controllers/api/v2/trends_controller.rb +++ b/app/controllers/api/v2/trends_controller.rb @@ -16,7 +16,7 @@ def show 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 32bccec5bc8..d6bf1fd5b23 100644 --- a/app/controllers/hosts_controller.rb +++ b/app/controllers/hosts_controller.rb @@ -249,7 +249,7 @@ def setBuild 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 a88ed70a921..65eb30fefeb 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -448,7 +448,7 @@ def edit_inline(object, property, options = {}) 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 @@ def notifications 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 1e9e02f1b26..cc85f8355aa 100644 --- a/app/helpers/home_helper.rb +++ b/app/helpers/home_helper.rb @@ -3,7 +3,7 @@ def render_vertical_menu(menu_name, mobile = false) 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 314b180df9d..b66a50a1d1d 100644 --- a/app/helpers/hosts_and_hostgroups_helper.rb +++ b/app/helpers/hosts_and_hostgroups_helper.rb @@ -37,7 +37,7 @@ def realm_field(f, can_override = false, override = false) :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 b0cf8e53365..bbfe3bf72b0 100644 --- a/app/helpers/reports_helper.rb +++ b/app/helpers/reports_helper.rb @@ -14,7 +14,7 @@ def reports_since(builder) 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 164e2517e0c..dfe07f48c4b 100644 --- a/app/models/compute_resources/foreman/model/libvirt.rb +++ b/app/models/compute_resources/foreman/model/libvirt.rb @@ -168,7 +168,7 @@ def console(uuid) # 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 b830cbadb30..dd36e8eac55 100644 --- a/app/models/compute_resources/foreman/model/openstack.rb +++ b/app/models/compute_resources/foreman/model/openstack.rb @@ -44,7 +44,7 @@ def tenant=(name) 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 53e73b2e584..8724447941d 100644 --- a/app/models/concerns/hostext/search.rb +++ b/app/models/concerns/hostext/search.rb @@ -90,7 +90,7 @@ module Search 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 @@ def search_by_puppetclass(key, operator, value) 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 c52bd93cc30..27f4ce5a06f 100644 --- a/app/models/host/base.rb +++ b/app/models/host/base.rb @@ -32,7 +32,7 @@ class Base < ApplicationRecord 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 4ce9286a99b..a57cfec3045 100644 --- a/app/models/nic/base.rb +++ b/app/models/nic/base.rb @@ -139,7 +139,7 @@ def fqdn 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 8066bfd4c9e..1b4bd4995dc 100644 --- a/app/models/setting/provisioning.rb +++ b/app/models/setting/provisioning.rb @@ -92,7 +92,7 @@ def validate_safemode_render(record) 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 070e059618e..a11e34f7094 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 b9238ea1f39..d9c856bac98 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 e5e55dfb086..490ef78603d 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 @@ def up 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 FakeLookupValue < ApplicationRecord 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 24c3530c4b4..19dd7be1e69 100644 --- a/lib/foreman/foreman_url_renderer.rb +++ b/lib/foreman/foreman_url_renderer.rb @@ -11,7 +11,7 @@ def default_url_options # 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 becdabd0ba0..34cd6922eb1 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 da3235312f5..6c64090a567 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 ad7a5b5d6c4..3974115fe56 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= 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 5d46e0c25db..fd3d28e3b7e 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 737b5094f77..5f433a5abd1 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 e5b6eb85c94..ff0aa8f6437 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 4d4e6592bde..ceeef3aa0ac 100755 --- a/test/controllers/api/v2/locations_controller_test.rb +++ b/test/controllers/api/v2/locations_controller_test.rb @@ -45,7 +45,7 @@ def setup 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 8489e99af0d..d20081c73c8 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 2a0bc1b2ebc..37c1c3be1e6 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 44045b680b5..1f4388d5ce0 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 cc75e7b1ece..ede2c053fb1 100644 --- a/test/controllers/api/v2/ptables_controller_test.rb +++ b/test/controllers/api/v2/ptables_controller_test.rb @@ -149,7 +149,7 @@ def setup 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 @@ def setup 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 657ec47132b..c59cd338844 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 187fd728cc4..16527b18e52 100644 --- a/test/controllers/environments_controller_test.rb +++ b/test/controllers/environments_controller_test.rb @@ -158,7 +158,7 @@ def setup_import_classes 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 636e843c5b0..bfed31e8b49 100644 --- a/test/controllers/hostgroups_controller_test.rb +++ b/test/controllers/hostgroups_controller_test.rb @@ -185,7 +185,7 @@ def setup_user(operation, type = 'hostgroups') 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 @@ def setup_user(operation, type = 'hostgroups') 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 0991b8b6735..fc9878bd03b 100644 --- a/test/controllers/hosts_controller_test.rb +++ b/test/controllers/hosts_controller_test.rb @@ -432,7 +432,7 @@ def setup_user_and_host(operation, filter = nil, &block) 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 Host::Test < Host::Base; end 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 93d2f013020..980ecb4fea1 100644 --- a/test/controllers/shared/basic_rest_response_test.rb +++ b/test/controllers/shared/basic_rest_response_test.rb @@ -109,7 +109,7 @@ def basic_pagination_rendered_test 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 07fc9b99fc4..4ded619fb82 100644 --- a/test/controllers/ssh_keys_controller_test.rb +++ b/test/controllers/ssh_keys_controller_test.rb @@ -2,7 +2,7 @@ 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 c1dad299c7e..8541054ab6d 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 9a2fc9730d7..29a4fc33fea 100644 --- a/test/models/lookup_value_test.rb +++ b/test/models/lookup_value_test.rb @@ -284,7 +284,7 @@ def setup 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 6d3f732e782..46127410a36 100644 --- a/test/models/organization_test.rb +++ b/test/models/organization_test.rb @@ -46,7 +46,7 @@ def invalid_org_name_list 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 c2586670f52..0ff842ed80d 100644 --- a/test/models/template_test.rb +++ b/test/models/template_test.rb @@ -187,7 +187,7 @@ class TemplateTest < ActiveSupport::TestCase 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 31ef39c9ce7..f53d243d2ae 100644 --- a/test/models/user_test.rb +++ b/test/models/user_test.rb @@ -38,7 +38,7 @@ def test_roles 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 @@ def setup 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 @@ def setup 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 @@ def setup 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 b91e0c4d33e..df20e58cdd1 100644 --- a/test/unit/menu_mapper_test.rb +++ b/test/unit/menu_mapper_test.rb @@ -183,7 +183,7 @@ def test_delete_missing 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