From eca28f4a0f667056313947edf8fc2f84f7aa4302 Mon Sep 17 00:00:00 2001 From: akumari Date: Thu, 15 Feb 2024 15:42:18 +0530 Subject: [PATCH] Fixes #37425 - Fix Layout/ArgumentAlignment --- .rubocop.yml | 4 +++ app/controllers/api/v2/base_controller.rb | 2 +- app/controllers/application_controller.rb | 2 +- .../compute_attributes_controller.rb | 2 +- .../compute_resources_vms_controller.rb | 2 +- .../controller/external_usergroups_errors.rb | 6 ++-- .../controller/provisioning_templates.rb | 4 +-- app/controllers/key_pairs_controller.rb | 4 +-- .../notification_recipients_controller.rb | 2 +- app/controllers/templates_controller.rb | 4 +-- app/graphql/resolvers/concerns/collection.rb | 2 +- app/helpers/common_parameters_helper.rb | 10 +++--- app/helpers/layout_helper.rb | 6 ++-- app/helpers/provisioning_templates_helper.rb | 12 +++---- app/helpers/templates_helper.rb | 2 +- app/mailers/application_mailer.rb | 2 +- app/models/concerns/orchestration/compute.rb | 36 +++++++++---------- app/models/concerns/orchestration/dns.rb | 8 ++--- .../concerns/orchestration/puppet_ca.rb | 10 +++--- app/models/concerns/orchestration/realm.rb | 6 ++-- .../concerns/orchestration/ssh_provision.rb | 6 ++-- app/models/filter.rb | 8 ++--- app/models/host/managed.rb | 2 +- app/models/hostgroup.rb | 2 +- app/models/provisioning_template.rb | 2 +- app/models/role.rb | 2 +- app/models/user.rb | 2 +- app/models/usergroup_member.rb | 4 +-- .../plugin/medium_providers_registry.rb | 18 +++++----- app/services/ansible_fact_parser.rb | 4 +-- .../foreman/renderer/scope/macros/base.rb | 4 +-- app/services/power_manager/power_status.rb | 2 +- ...210115124508_template_kind_registration.rb | 4 +-- db/seeds.d/035-admin.rb | 8 ++--- .../v2/table_preferences_controller_test.rb | 10 +++--- .../api/v2/users_controller_test.rb | 4 +-- .../compute_resources_vms_controller_test.rb | 2 +- test/controllers/hosts_controller_test.rb | 30 ++++++++-------- test/controllers/key_pairs_controller_test.rb | 8 ++--- test/controllers/users_controller_test.rb | 6 ++-- test/models/compute_resource_test.rb | 6 ++-- .../compute_resources/openstack_test.rb | 2 +- .../concerns/hostext/operating_system_test.rb | 6 ++-- test/models/host_test.rb | 22 ++++++------ test/models/hostgroup_test.rb | 14 ++++---- test/models/hosts/base_test.rb | 2 +- test/models/nic_test.rb | 2 +- test/models/orchestration/dhcp_test.rb | 6 ++-- test/models/shared/taxonomies_base_test.rb | 2 +- test/models/subnet/ipv4_test.rb | 10 +++--- test/models/user_test.rb | 26 +++++++------- test/models/usergroup_test.rb | 2 +- test/unit/concerns/hostext_ownership_test.rb | 6 ++-- test/unit/host_build_status_test.rb | 6 ++-- test/unit/net/dhcp_test.rb | 34 +++++++++--------- test/unit/puppet_fact_parser_test.rb | 16 ++++----- test/unit/tasks/seeds_test.rb | 10 +++--- 57 files changed, 215 insertions(+), 211 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 05a6af3d54f..abd889a0cbf 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -23,6 +23,10 @@ Layout/LineLength: Layout/ParameterAlignment: Enabled: false +Layout/ArgumentAlignment: + EnforcedStyle: with_fixed_indentation + IndentationWidth: 2 + Metrics: Enabled: false diff --git a/app/controllers/api/v2/base_controller.rb b/app/controllers/api/v2/base_controller.rb index 4f62ebff798..1f5f51f88b8 100644 --- a/app/controllers/api/v2/base_controller.rb +++ b/app/controllers/api/v2/base_controller.rb @@ -166,7 +166,7 @@ def check_media_type def render_error(error, options = { }) options = set_error_details(error, options) render options.merge(:template => "api/v2/errors/#{error}", - :layout => 'api/v2/layouts/error_layout') + :layout => 'api/v2/layouts/error_layout') end end end diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 45b147ee849..19035b660b1 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -146,7 +146,7 @@ def smart_proxy_exception(exception = nil) process_error(:redirect => :back, :error_msg => exception.message) else process_error(:render => { :plain => exception.message }, - :error_msg => exception.message) + :error_msg => exception.message) end end diff --git a/app/controllers/compute_attributes_controller.rb b/app/controllers/compute_attributes_controller.rb index 29a7d56a451..176fc82bf2e 100644 --- a/app/controllers/compute_attributes_controller.rb +++ b/app/controllers/compute_attributes_controller.rb @@ -4,7 +4,7 @@ class ComputeAttributesController < ApplicationController def new @set = ComputeAttribute.new(:compute_profile_id => params[:compute_profile_id].to_i, - :compute_resource_id => params[:compute_resource_id].to_i) + :compute_resource_id => params[:compute_resource_id].to_i) end def create diff --git a/app/controllers/compute_resources_vms_controller.rb b/app/controllers/compute_resources_vms_controller.rb index b42a7095541..4af932c318d 100644 --- a/app/controllers/compute_resources_vms_controller.rb +++ b/app/controllers/compute_resources_vms_controller.rb @@ -24,7 +24,7 @@ def index render :partial => "compute_resources_vms/index/#{@compute_resource.provider.downcase}.json" else render :json => _('JSON VM listing is not supported for this compute resource.'), - :status => :not_implemented + :status => :not_implemented end end end diff --git a/app/controllers/concerns/foreman/controller/external_usergroups_errors.rb b/app/controllers/concerns/foreman/controller/external_usergroups_errors.rb index 954a5ed123b..1e95f2c9b03 100644 --- a/app/controllers/concerns/foreman/controller/external_usergroups_errors.rb +++ b/app/controllers/concerns/foreman/controller/external_usergroups_errors.rb @@ -23,9 +23,9 @@ def external_usergroups_error(group, exception) group.errors.add( :base, _("Could not refresh external usergroups: %{e} - %{message} - %{suggestion}") % - { :e => exception.class, - :message => exception.to_s, - :suggestion => suggestion_external_group(exception) } + { :e => exception.class, + :message => exception.to_s, + :suggestion => suggestion_external_group(exception) } ) end end diff --git a/app/controllers/concerns/foreman/controller/provisioning_templates.rb b/app/controllers/concerns/foreman/controller/provisioning_templates.rb index e1e0864bceb..608e508ab13 100644 --- a/app/controllers/concerns/foreman/controller/provisioning_templates.rb +++ b/app/controllers/concerns/foreman/controller/provisioning_templates.rb @@ -19,8 +19,8 @@ def default_template_url(template, hostgroup) protocol = uri.scheme url_for(:only_path => false, :action => :hostgroup_template, :controller => '/unattended', - :id => template.name, :hostgroup => hostgroup.title, :protocol => protocol, - :host => host, :port => port) + :id => template.name, :hostgroup => hostgroup.title, :protocol => protocol, + :host => host, :port => port) end # convert the file upload into a simple string to save in our db. diff --git a/app/controllers/key_pairs_controller.rb b/app/controllers/key_pairs_controller.rb index 79bbb44c072..23a57005bd7 100644 --- a/app/controllers/key_pairs_controller.rb +++ b/app/controllers/key_pairs_controller.rb @@ -18,7 +18,7 @@ def show def create if @compute_resource.recreate process_success :success_msg => _('Successfully recreated'), - :success_redirect => compute_resource_path(@compute_resource) + :success_redirect => compute_resource_path(@compute_resource) else process_error :error_msg => _('Could not recreate a new SSH key') end @@ -29,7 +29,7 @@ def destroy return not_found unless key_to_delete if @compute_resource.delete_key_from_resource(key_to_delete) process_success :success_msg => _('Successfully delete %s') % key_to_delete, - :success_redirect => compute_resource_path(@compute_resource) + :success_redirect => compute_resource_path(@compute_resource) else process_error :error_msg => _('Could not delete %s') % key_to_delete end diff --git a/app/controllers/notification_recipients_controller.rb b/app/controllers/notification_recipients_controller.rb index 4026a124673..8a673733204 100644 --- a/app/controllers/notification_recipients_controller.rb +++ b/app/controllers/notification_recipients_controller.rb @@ -33,7 +33,7 @@ def destroy_group count = NotificationRecipient. joins(:notification_blueprint). where(user_id: User.current.id, - notification_blueprints: { group: params[:group]}). + notification_blueprints: { group: params[:group]}). delete_all logger.debug("deleted #{count} notification recipents for group #{params[:group]}") diff --git a/app/controllers/templates_controller.rb b/app/controllers/templates_controller.rb index e57106e86ba..3e0081ceabe 100644 --- a/app/controllers/templates_controller.rb +++ b/app/controllers/templates_controller.rb @@ -162,8 +162,8 @@ def load_history return unless @template @history = Audit.descending .where(:auditable_id => @template.id, - :auditable_type => @template.class.base_class.name, - :action => %w(update create)) + :auditable_type => @template.class.base_class.name, + :action => %w(update create)) .select { |audit| audit_template? audit } end diff --git a/app/graphql/resolvers/concerns/collection.rb b/app/graphql/resolvers/concerns/collection.rb index 3c4eb19af22..b95631d10b5 100644 --- a/app/graphql/resolvers/concerns/collection.rb +++ b/app/graphql/resolvers/concerns/collection.rb @@ -65,7 +65,7 @@ def filter_list(search: nil, sort_by: nil, sort_direction: 'ASC', if has_taxonomix? taxonomy_ids = taxonomy_ids_for_filter(location_id: location_id, organization_id: organization_id, - location: location, organization: organization) + location: location, organization: organization) filters << taxonomy_id_filter(taxonomy_ids) if taxonomy_ids.any? end diff --git a/app/helpers/common_parameters_helper.rb b/app/helpers/common_parameters_helper.rb index 0fb3e1a92b4..dbdba8b4ac7 100644 --- a/app/helpers/common_parameters_helper.rb +++ b/app/helpers/common_parameters_helper.rb @@ -46,11 +46,11 @@ def hidden_value_field(f, field, disabled, options = {}) html_class += " masked-input" if hidden input = f.text_area(field, options.merge(:disabled => disabled, - :class => html_class, - :rows => 1, - :id => dom_id(f.object) + '_value', - :placeholder => _("Value"), - :value => f.object.value_before_type_cast)) + :class => html_class, + :rows => 1, + :id => dom_id(f.object) + '_value', + :placeholder => _("Value"), + :value => f.object.value_before_type_cast)) input_group(input, input_group_btn(hidden_toggle(f.object.hidden_value?), fullscreen_button("$(this).closest('.input-group').find('input,textarea')"))) end diff --git a/app/helpers/layout_helper.rb b/app/helpers/layout_helper.rb index 90f762d51c8..bea0c3b70b4 100644 --- a/app/helpers/layout_helper.rb +++ b/app/helpers/layout_helper.rb @@ -139,8 +139,8 @@ def collapsing_header(title, target, collapsed = '') def base_errors_for(obj) if obj.errors[:base].present? alert :header => _("Unable to save"), - :class => 'alert-danger base in fade', - :text => obj.errors[:base].map { |e| '
  • '.html_safe + e + '
  • '.html_safe }.join.html_safe + :class => 'alert-danger base in fade', + :text => obj.errors[:base].map { |e| '
  • '.html_safe + e + '
  • '.html_safe }.join.html_safe end end @@ -249,7 +249,7 @@ def new_child_fields_template(form_builder, association, options = { }) content_tag(:div, :class => "#{association}_fields_template form_template", :style => "display: none;") do form_builder.fields_for(association, options[:object], :child_index => "new_#{association}") do |f| render(:partial => options[:partial], :layout => options[:layout], - :locals => { options[:form_builder_local] => f }.merge(options[:form_builder_attrs])) + :locals => { options[:form_builder_local] => f }.merge(options[:form_builder_attrs])) end end end diff --git a/app/helpers/provisioning_templates_helper.rb b/app/helpers/provisioning_templates_helper.rb index 514cfcde58b..957410abad9 100644 --- a/app/helpers/provisioning_templates_helper.rb +++ b/app/helpers/provisioning_templates_helper.rb @@ -60,16 +60,16 @@ def building_hosts_path(template) def how_templates_are_determined alert(:class => 'alert-info', :header => _('How templates are determined'), - :text => ('

    ' + _("When editing a template, you must assign a list \ + :text => ('

    ' + _("When editing a template, you must assign a list \ of operating systems which this template can be used with. Optionally, you can \ restrict a template to a list of host groups.") + '

    ' + '

    ' + _("When a Host requests a template (e.g. during provisioning), Foreman \ will select the best match from the available templates of that type, in the \ following order:") + '

    ' + '' + - (_("The final entry, Operating System default, can be set by editing the %s page.") % - (link_to _("Operating System"), operatingsystems_path))).html_safe) +'
  • ' + _("Host group") + '
  • ' + +'
  • ' + _("Operating system default") + '
  • ' + +'' + +(_("The final entry, Operating System default, can be set by editing the %s page.") % + (link_to _("Operating System"), operatingsystems_path))).html_safe) end end diff --git a/app/helpers/templates_helper.rb b/app/helpers/templates_helper.rb index 011a7d06e74..22b165c6323 100644 --- a/app/helpers/templates_helper.rb +++ b/app/helpers/templates_helper.rb @@ -2,7 +2,7 @@ module TemplatesHelper def snippet_message(template) return unless template.snippet alert(:class => 'alert-info', :header => '', - :text => _("Not relevant for snippet")) + :text => _("Not relevant for snippet")) end def default_template_description diff --git a/app/mailers/application_mailer.rb b/app/mailers/application_mailer.rb index 7076476dbc3..a5c8a923d13 100644 --- a/app/mailers/application_mailer.rb +++ b/app/mailers/application_mailer.rb @@ -4,7 +4,7 @@ class ApplicationMailer < ActionMailer::Base include Roadie::Rails::Automatic default :delivery_method => proc { Setting[:delivery_method] }, - :from => proc { Setting[:email_reply_address] || "noreply@foreman.example.org" } + :from => proc { Setting[:email_reply_address] || "noreply@foreman.example.org" } after_action :set_delivery_options def self.delivery_settings diff --git a/app/models/concerns/orchestration/compute.rb b/app/models/concerns/orchestration/compute.rb index 8f24ff7ce17..4c83c68bd42 100644 --- a/app/models/concerns/orchestration/compute.rb +++ b/app/models/concerns/orchestration/compute.rb @@ -61,38 +61,38 @@ def queue_compute def queue_compute_create if find_image.try(:user_data) - queue.create(:name => _("Render user data template for %s") % self, :priority => 2, - :action => [self, :setUserData]) + queue.create(:name => _("Render user data template for %s") % self, :priority => 2, + :action => [self, :setUserData]) end - queue.create(:name => _("Set up compute instance %s") % self, :priority => 3, - :action => [self, :setCompute]) + queue.create(:name => _("Set up compute instance %s") % self, :priority => 3, + :action => [self, :setCompute]) if compute_provides?(:ip) || compute_provides?(:ip6) - queue.create(:name => _("Acquire IP addresses for %s") % self, :priority => 4, - :action => [self, :setComputeIP]) + queue.create(:name => _("Acquire IP addresses for %s") % self, :priority => 4, + :action => [self, :setComputeIP]) end - queue.create(:name => _("Query instance details for %s") % self, :priority => 5, - :action => [self, :setComputeDetails]) + queue.create(:name => _("Query instance details for %s") % self, :priority => 5, + :action => [self, :setComputeDetails]) if compute_provides?(:mac) && (mac_based_ipam?(:subnet) || mac_based_ipam?(:subnet6)) queue.create(:name => _("Set IP addresses for %s") % self, :priority => 6, - :action => [self, :setComputeIPAM]) + :action => [self, :setComputeIPAM]) end if compute_attributes && compute_attributes[:start] == '1' queue.create(:name => _("Power up compute instance %s") % self, :priority => 1000, - :action => [self, :setComputePowerUp]) + :action => [self, :setComputePowerUp]) end end def queue_compute_update return unless compute_update_required? logger.debug("Detected a change is required for compute resource") - queue.create(:name => _("Compute resource update for %s") % old, :priority => 7, - :action => [self, :setComputeUpdate]) + queue.create(:name => _("Compute resource update for %s") % old, :priority => 7, + :action => [self, :setComputeUpdate]) end def queue_compute_destroy return unless errors.empty? && compute_resource_id.present? && uuid - queue.create(:name => _("Removing compute instance %s") % self, :priority => 100, - :action => [self, :delCompute]) + queue.create(:name => _("Removing compute instance %s") % self, :priority => 100, + :action => [self, :delCompute]) end def setCompute @@ -125,10 +125,10 @@ def setUserData # actually used. For now, use foreman_url('built') in the template if template.nil? failure((_("%{image} needs user data, but %{os_link} is not associated to any provisioning template of the kind user_data. Please associate it with a suitable template or uncheck 'User data' for %{compute_resource_image_link}.") % - { :image => image.name, - :os_link => "#{operatingsystem.title}", - :compute_resource_image_link => - "#{image.name}"}).html_safe) + { :image => image.name, + :os_link => "#{operatingsystem.title}", + :compute_resource_image_link => + "#{image.name}"}).html_safe) return false end diff --git a/app/models/concerns/orchestration/dns.rb b/app/models/concerns/orchestration/dns.rb index 068c3f0e635..5a1a6557c1b 100644 --- a/app/models/concerns/orchestration/dns.rb +++ b/app/models/concerns/orchestration/dns.rb @@ -65,7 +65,7 @@ def queue_dns_create DNSInterface::RECORD_TYPES.each do |record_type| if dns_feasible?(record_type) queue.create(:name => _("Create %{type} for %{host}") % {:host => self, :type => dns_class(record_type).human}, :priority => 10, - :action => [self, :set_dns_record, record_type]) + :action => [self, :set_dns_record, record_type]) end end end @@ -75,7 +75,7 @@ def queue_dns_update DNSInterface::RECORD_TYPES.each do |record_type| if old.dns_feasible?(record_type) queue.create(:name => _("Remove %{type} for %{host}") % {:host => old, :type => dns_class(record_type).human }, :priority => 9, - :action => [old, :del_dns_record, record_type]) + :action => [old, :del_dns_record, record_type]) end end queue_dns_create @@ -86,7 +86,7 @@ def queue_dns_destroy DNSInterface::RECORD_TYPES.each do |record_type| if dns_feasible?(record_type) queue.create(:name => _("Remove %{type} for %{host}") % {:host => self, :type => dns_class(record_type).human}, :priority => 1, - :action => [self, :del_dns_record, record_type]) + :action => [self, :del_dns_record, record_type]) end end end @@ -98,7 +98,7 @@ def queue_remove_dns_conflicts DNSInterface::RECORD_TYPES.each do |record_type| if dns_feasible?(record_type) && dns_record(record_type) && dns_record(record_type).conflicting? queue.create(:name => _("Remove conflicting %{type} for %{host}") % {:host => self, :type => dns_class(record_type).human}, :priority => 0, - :action => [self, :del_conflicting_dns_record, record_type]) + :action => [self, :del_conflicting_dns_record, record_type]) end end end diff --git a/app/models/concerns/orchestration/puppet_ca.rb b/app/models/concerns/orchestration/puppet_ca.rb index 28de7246b11..cdd194a1700 100644 --- a/app/models/concerns/orchestration/puppet_ca.rb +++ b/app/models/concerns/orchestration/puppet_ca.rb @@ -66,14 +66,14 @@ def queue_puppetca def queue_puppetca_certname_reset post_queue.create(:name => _("Reset PuppetCA certname for %s") % self, :priority => 49, - :action => [self, :resetCertname]) + :action => [self, :resetCertname]) end def queue_puppetca_create post_queue.create(:name => _("Cleanup PuppetCA certificates for %s") % self, :priority => 51, - :action => [self, :delCertificate]) + :action => [self, :delCertificate]) post_queue.create(:name => _("Enable PuppetCA autosigning for %s") % self, :priority => 55, - :action => [self, :setAutosign]) + :action => [self, :setAutosign]) end def queue_puppetca_update @@ -97,13 +97,13 @@ def queue_puppetca_destroy return unless puppetca? && errors.empty? return unless Setting[:manage_puppetca] post_queue.create(:name => _("Delete PuppetCA certificates for %s") % self, :priority => 59, - :action => [self, :delCertificate]) + :action => [self, :delCertificate]) queue_puppetca_autosign_destroy true end def queue_puppetca_autosign_destroy post_queue.create(:name => _("Disable PuppetCA autosigning for %s") % self, :priority => 50, - :action => [self, :delAutosign]) + :action => [self, :delAutosign]) end end diff --git a/app/models/concerns/orchestration/realm.rb b/app/models/concerns/orchestration/realm.rb index 753d2864027..97e05d401e9 100644 --- a/app/models/concerns/orchestration/realm.rb +++ b/app/models/concerns/orchestration/realm.rb @@ -52,20 +52,20 @@ def queue_realm def queue_realm_create queue.create(:name => _("Create realm entry for %s") % self, :priority => 1, - :action => [self, :set_realm]) + :action => [self, :set_realm]) end def queue_realm_update # Update if the hostgroup is changed or if the realm is changed if hostgroup_id_changed? || realm_id_changed? queue.create(:name => _("Update realm entry for %s") % self, :priority => 1, - :action => [self, :update_realm]) + :action => [self, :update_realm]) end end def queue_realm_destroy return unless realm? && errors.empty? queue.create(:name => _("Delete realm entry for %s") % self, :priority => 50, - :action => [self, :del_realm]) + :action => [self, :del_realm]) end end diff --git a/app/models/concerns/orchestration/ssh_provision.rb b/app/models/concerns/orchestration/ssh_provision.rb index 828effb2f2a..5202f2e87ac 100644 --- a/app/models/concerns/orchestration/ssh_provision.rb +++ b/app/models/concerns/orchestration/ssh_provision.rb @@ -20,11 +20,11 @@ def queue_ssh_provision # I guess this is not going to happen on create as we might not have an ip address yet. def queue_ssh_provision_create post_queue.create(:name => _("Prepare post installation script for %s") % self, :priority => 2000, - :action => [self, :setSSHProvisionScript]) + :action => [self, :setSSHProvisionScript]) post_queue.create(:name => _("Wait for %s to come online") % self, :priority => 2001, - :action => [self, :setSSHWaitForResponse]) + :action => [self, :setSSHWaitForResponse]) post_queue.create(:name => _("Configure instance %s via SSH") % self, :priority => 2003, - :action => [self, :setSSHProvision]) + :action => [self, :setSSHProvision]) end def queue_ssh_provision_update diff --git a/app/models/filter.rb b/app/models/filter.rb index dbde6d00056..d96ae6e9175 100644 --- a/app/models/filter.rb +++ b/app/models/filter.rb @@ -206,10 +206,10 @@ def same_resource_type_permissions errors.add( :permissions, _('must be of same resource type (%{types}) - Role (%{role})') % - { - types: types.join(','), - role: role.name, - } + { + types: types.join(','), + role: role.name, + } ) end end diff --git a/app/models/host/managed.rb b/app/models/host/managed.rb index 7e2565e4f13..3075f466317 100644 --- a/app/models/host/managed.rb +++ b/app/models/host/managed.rb @@ -408,7 +408,7 @@ def handle_realm def disk_layout_source @disk_layout_source ||= if disk.present? Foreman::Renderer::Source::String.new(name: 'Custom disk layout', - content: disk.tr("\r", '')) + content: disk.tr("\r", '')) elsif ptable.present? Foreman::Renderer::Source::Database.new(ptable) end diff --git a/app/models/hostgroup.rb b/app/models/hostgroup.rb index 4301c70baa0..e348c02378d 100644 --- a/app/models/hostgroup.rb +++ b/app/models/hostgroup.rb @@ -126,7 +126,7 @@ def self.title_name def disk_layout_source @disk_layout_source ||= if ptable.present? Foreman::Renderer::Source::String.new(name: ptable.name, - content: ptable.layout.tr("\r", '')) + content: ptable.layout.tr("\r", '')) end end diff --git a/app/models/provisioning_template.rb b/app/models/provisioning_template.rb index f909f760536..627b3950710 100644 --- a/app/models/provisioning_template.rb +++ b/app/models/provisioning_template.rb @@ -99,7 +99,7 @@ def self.default_render_scope_class def clone deep_clone(:include => [:operatingsystems, :organizations, :locations], - :except => [:name, :locked, :default, :vendor]) + :except => [:name, :locked, :default, :vendor]) end def self.find_template(opts = {}) diff --git a/app/models/role.rb b/app/models/role.rb index 0d3e36561f4..adcdc7bed23 100644 --- a/app/models/role.rb +++ b/app/models/role.rb @@ -221,7 +221,7 @@ def disable_filters_overriding def clone(role_params = {}) new_role = deep_clone(:except => [:name, :builtin, :origin], - :include => [:locations, :organizations, { :filters => :permissions }]) + :include => [:locations, :organizations, { :filters => :permissions }]) new_role.attributes = role_params new_role.cloned_from_id = id new_role.filters = new_role.filters.select { |f| f.filterings.present? } diff --git a/app/models/user.rb b/app/models/user.rb index b2238dcf4bf..e3e244d898c 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -2,7 +2,7 @@ class User < ApplicationRecord audited :except => [:last_login_on, :password_hash, :password_salt, :password_confirmation], - :associations => [:roles, :usergroups] + :associations => [:roles, :usergroups] include Authorizable include Foreman::TelemetryHelper extend FriendlyId diff --git a/app/models/usergroup_member.rb b/app/models/usergroup_member.rb index 860f321e0d8..a1c94299075 100644 --- a/app/models/usergroup_member.rb +++ b/app/models/usergroup_member.rb @@ -49,8 +49,8 @@ def ensure_no_cycle def add_new_cache find_all_affected_users.each do |user| find_all_user_roles.each do |user_role| - CachedUserRole.create!(:user => user, :role => user_role.role, - :user_role => user_role) + CachedUserRole.create!(:user => user, :role => user_role.role, + :user_role => user_role) end find_all_usergroups.each do |group| diff --git a/app/registries/foreman/plugin/medium_providers_registry.rb b/app/registries/foreman/plugin/medium_providers_registry.rb index 726cbeb5c46..60796aeb606 100644 --- a/app/registries/foreman/plugin/medium_providers_registry.rb +++ b/app/registries/foreman/plugin/medium_providers_registry.rb @@ -32,20 +32,20 @@ def find_provider(entity) if valid_providers.count > 1 logger.error( 'Found more than one provider for %{entity}. Found: %{found}. Valid providers: %{providers}' % - { - entity: entity, - providers: providers.map { |provider| provider.class.name }, - found: valid_providers.map { |provider| provider.class.name }, - }) + { + entity: entity, + providers: providers.map { |provider| provider.class.name }, + found: valid_providers.map { |provider| provider.class.name }, + }) end unless valid_providers.present? logger.warn( 'Could not find a provider for %{entity}. Providers returned %{errors}' % - { - entity: entity, - errors: provider_instances.map { |provider| [provider.class.name, provider.errors] }.to_h, - }) + { + entity: entity, + errors: provider_instances.map { |provider| [provider.class.name, provider.errors] }.to_h, + }) end valid_providers.first diff --git a/app/services/ansible_fact_parser.rb b/app/services/ansible_fact_parser.rb index d6168ec0a70..5b96ad2359f 100644 --- a/app/services/ansible_fact_parser.rb +++ b/app/services/ansible_fact_parser.rb @@ -60,8 +60,8 @@ def get_facts_for_interface(iface_name) macaddress = mac_from_interface(interface) iface_facts = HashWithIndifferentAccess[ interface_facts.merge(:ipaddress => ipaddress, - :ipaddress6 => ipaddress6, - :macaddress => macaddress) + :ipaddress6 => ipaddress6, + :macaddress => macaddress) ] logger.debug { "Ansible interface #{interface} facts: #{iface_facts.inspect}" } iface_facts diff --git a/app/services/foreman/renderer/scope/macros/base.rb b/app/services/foreman/renderer/scope/macros/base.rb index 5ff29ec5d6f..54dda4787f3 100644 --- a/app/services/foreman/renderer/scope/macros/base.rb +++ b/app/services/foreman/renderer/scope/macros/base.rb @@ -194,8 +194,8 @@ def default_template_url(template, hostgroup) protocol = uri.scheme url_for(:only_path => false, :action => :hostgroup_template, :controller => '/unattended', - :id => template.name, :hostgroup => hostgroup.title, :protocol => protocol, - :host => host, :port => port) + :id => template.name, :hostgroup => hostgroup.title, :protocol => protocol, + :host => host, :port => port) end apipie :method, 'Returns an array of all possible host status classes sorted alphabetically by status name' do diff --git a/app/services/power_manager/power_status.rb b/app/services/power_manager/power_status.rb index 01cabaeeac0..ca8613338a8 100644 --- a/app/services/power_manager/power_status.rb +++ b/app/services/power_manager/power_status.rb @@ -47,7 +47,7 @@ def host_power_ping(result, timeout = DEFAULT_TIMEOUT) result[:statusText] = n_("Failed to retrieve power status for %{host} within %{req_timeout} second.", "Failed to retrieve power status for %{host} within %{req_timeout} seconds.", req_timeout) % - {host: host, req_timeout: req_timeout} + {host: host, req_timeout: req_timeout} result end end diff --git a/db/migrate/20210115124508_template_kind_registration.rb b/db/migrate/20210115124508_template_kind_registration.rb index 118f0c29dc4..f77247771fc 100644 --- a/db/migrate/20210115124508_template_kind_registration.rb +++ b/db/migrate/20210115124508_template_kind_registration.rb @@ -31,8 +31,8 @@ def up if template && !os_default_registration OsDefaultTemplate.create(template_kind: host_init_config_kind, - provisioning_template: template, - operatingsystem: os) + provisioning_template: template, + operatingsystem: os) end end end diff --git a/db/seeds.d/035-admin.rb b/db/seeds.d/035-admin.rb index 6df4881dd02..4852e48237e 100644 --- a/db/seeds.d/035-admin.rb +++ b/db/seeds.d/035-admin.rb @@ -48,10 +48,10 @@ elsif User.unscoped.only_admin.except_hidden.none? User.without_auditing do User.as_anonymous_admin do - user = User.new(:login => admin_login, - :firstname => ENV['SEED_ADMIN_FIRST_NAME'] || "Admin", - :lastname => ENV['SEED_ADMIN_LAST_NAME'] || "User", - :mail => (ENV['SEED_ADMIN_EMAIL'] || Setting[:administrator]).try(:dup)) + user = User.new(:login => admin_login, + :firstname => ENV['SEED_ADMIN_FIRST_NAME'] || "Admin", + :lastname => ENV['SEED_ADMIN_LAST_NAME'] || "User", + :mail => (ENV['SEED_ADMIN_EMAIL'] || Setting[:administrator]).try(:dup)) user.admin = true user.auth_source = src_internal user.locale = ENV['SEED_ADMIN_LOCALE'] if ENV['SEED_ADMIN_LOCALE'].present? diff --git a/test/controllers/api/v2/table_preferences_controller_test.rb b/test/controllers/api/v2/table_preferences_controller_test.rb index a29cc831db5..78b3521be74 100644 --- a/test/controllers/api/v2/table_preferences_controller_test.rb +++ b/test/controllers/api/v2/table_preferences_controller_test.rb @@ -29,7 +29,7 @@ def test_should_get_index_with_json_result def test_should_show_columns_correctly resource = resources.first TablePreference.create!(user: User.current, - name: resource, columns: expected_columns) + name: resource, columns: expected_columns) get :show, params: {user_id: User.current.id, id: resource} assert_response :success actual_columns = ActiveSupport::JSON.decode(@response.body)["columns"] @@ -49,9 +49,9 @@ def test_should_update_correctly resource = resources.first setup_user 'view', resource current_user = User.current - TablePreference.create!(user: User.current, - name: resource, columns: expected_columns) + name: resource, columns: expected_columns) + put :update, params: {user_id: User.current.id, id: resource, columns: expected_columns} assert_response :success columns = current_user.reload.table_preferences.first @@ -67,9 +67,9 @@ def test_should_destroy_correctly current_user = User.current TablePreference.create!(user: User.current, - name: resource1, columns: expected_columns) + name: resource1, columns: expected_columns) TablePreference.create!(user: User.current, - name: resource2, columns: expected_columns) + name: resource2, columns: expected_columns) delete :destroy, params: { user_id: User.current.id, id: resource1} assert_response :success diff --git a/test/controllers/api/v2/users_controller_test.rb b/test/controllers/api/v2/users_controller_test.rb index 7d6aff0d889..8a9a3c765dc 100644 --- a/test/controllers/api/v2/users_controller_test.rb +++ b/test/controllers/api/v2/users_controller_test.rb @@ -415,8 +415,8 @@ def user_one_as_anonymous_viewer :location_ids => [loc.id] as_user system_admin do post :create, params: { :user => min_valid_attrs.clone.update(:role_ids => roles.map { |role| role.id }, - :organization_ids => [org.id], - :location_ids => [loc.id]) } + :organization_ids => [org.id], + :location_ids => [loc.id]) } assert_response :success end end diff --git a/test/controllers/compute_resources_vms_controller_test.rb b/test/controllers/compute_resources_vms_controller_test.rb index 5e1bdacc804..447efb2334d 100644 --- a/test/controllers/compute_resources_vms_controller_test.rb +++ b/test/controllers/compute_resources_vms_controller_test.rb @@ -173,7 +173,7 @@ def test_should_create_vm(name = "new_test") get_test_vm @test_vm.class.any_instance.expects(:stop).raises(Fog::Errors::Error.new('Power error')) @request.env['HTTP_REFERER'] = compute_resource_vm_path(:compute_resource_id => @compute_resource.to_param, - :id => @test_vm.identity) + :id => @test_vm.identity) get :power, params: { :format => 'json', :id => @test_vm.uuid, :compute_resource_id => @compute_resource.to_param }, session: set_session_user assert_match /Power error/, flash[:error] assert_redirected_to @request.env['HTTP_REFERER'] diff --git a/test/controllers/hosts_controller_test.rb b/test/controllers/hosts_controller_test.rb index 21a68003240..f3e2a414d3f 100644 --- a/test/controllers/hosts_controller_test.rb +++ b/test/controllers/hosts_controller_test.rb @@ -974,7 +974,7 @@ class Host::Valid < Host::Managed; end test "host should get bmc status" do @host.stubs(:bmc_proxy).returns(nil) @host.interfaces.create(:name => "bmc1", :mac => '52:54:00:b0:0c:fc', :type => 'Nic::BMC', - :ip => '10.0.1.101', :username => 'user1111', :password => 'abc123456', :provider => 'IPMI') + :ip => '10.0.1.101', :username => 'user1111', :password => 'abc123456', :provider => 'IPMI') @host.power.stubs(:state).returns("on") get :bmc, params: { :id => @host.id }, session: set_session_user assert_response :success @@ -982,7 +982,7 @@ class Host::Valid < Host::Managed; end test "host update without BMC paasword in the params does not erase existing password" do bmc1 = @host.interfaces.build(:name => "bmc1", :mac => '52:54:00:b0:0c:fc', :type => 'Nic::BMC', - :ip => '10.0.1.101', :username => 'user1111', :password => 'abc123456', :provider => 'IPMI') + :ip => '10.0.1.101', :username => 'user1111', :password => 'abc123456', :provider => 'IPMI') assert bmc1.save old_password = bmc1.password put :update, params: { :commit => "Update", :id => @host.name, :host => {:interfaces_attributes => {"0" => {:id => bmc1.id} } } }, session: set_session_user @@ -992,7 +992,7 @@ class Host::Valid < Host::Managed; end test 'blank BMC password submitted in host does erase existing password' do bmc1 = @host.interfaces.build(:name => "bmc1", :mac => '52:54:00:b0:0c:fc', :type => 'Nic::BMC', - :ip => '10.0.1.101', :username => 'user1111', :password => 'abc123456', :provider => 'IPMI') + :ip => '10.0.1.101', :username => 'user1111', :password => 'abc123456', :provider => 'IPMI') assert bmc1.save put :update, params: { :commit => "Update", :id => @host.name, :host => {:interfaces_attributes => {"0" => {:id => bmc1.id, :password => ''} } } }, session: set_session_user @host = Host.find(@host.id) @@ -1002,7 +1002,7 @@ class Host::Valid < Host::Managed; end # To test that work-around for Rails bug - https://github.com/rails/rails/issues/11031 test "BMC password updates successful even if attrs serialized field is the only dirty field" do bmc1 = @host.interfaces.build(:name => "bmc1", :mac => '52:54:00:b0:0c:fc', :type => 'Nic::BMC', - :ip => '10.0.1.101', :username => 'user1111', :password => 'abc123456', :provider => 'IPMI') + :ip => '10.0.1.101', :username => 'user1111', :password => 'abc123456', :provider => 'IPMI') assert bmc1.save new_password = "topsecret" put :update, params: { :commit => "Update", :id => @host.name, :host => {:interfaces_attributes => {"0" => {:id => bmc1.id, :password => new_password, :mac => bmc1.mac} } } }, session: set_session_user @@ -1552,17 +1552,17 @@ def current_hosts_path(*args) def initialize_host User.current = users(:admin) disable_orchestration - @host = Host.create(:name => "myfullhost", - :mac => "aabbecddeeff", - :ip => "2.3.4.99", - :domain_id => domains(:mydomain).id, - :operatingsystem_id => operatingsystems(:redhat).id, - :architecture_id => architectures(:x86_64).id, - :subnet_id => subnets(:one).id, - :disk => "empty partition", - :root_pass => "123456789", - :location_id => taxonomies(:location1).id, - :organization_id => taxonomies(:organization1).id + @host = Host.create(:name => "myfullhost", + :mac => "aabbecddeeff", + :ip => "2.3.4.99", + :domain_id => domains(:mydomain).id, + :operatingsystem_id => operatingsystems(:redhat).id, + :architecture_id => architectures(:x86_64).id, + :subnet_id => subnets(:one).id, + :disk => "empty partition", + :root_pass => "123456789", + :location_id => taxonomies(:location1).id, + :organization_id => taxonomies(:organization1).id ) end end diff --git a/test/controllers/key_pairs_controller_test.rb b/test/controllers/key_pairs_controller_test.rb index e20a793d90e..2f7cad89c4e 100644 --- a/test/controllers/key_pairs_controller_test.rb +++ b/test/controllers/key_pairs_controller_test.rb @@ -26,8 +26,8 @@ class KeyPairsControllerTest < ActionController::TestCase test "should recreate a key pair" do Foreman::Model::EC2.any_instance.stubs(:recreate).returns(KeyPair.create(:name => "foreman-#{Foreman.uuid}", - :secret => "shhh", - :compute_resource_id => @compute_resource.id)) + :secret => "shhh", + :compute_resource_id => @compute_resource.id)) key_pair = FactoryBot.create(:key_pair) key_pair.compute_resource = @compute_resource post :create, params: { :compute_resource_id => @compute_resource.to_param }, session: set_session_user @@ -46,8 +46,8 @@ class KeyPairsControllerTest < ActionController::TestCase test "should create a key pair" do Foreman::Model::EC2.any_instance.stubs(:recreate).returns(KeyPair.create(:name => "foreman-#{Foreman.uuid}", - :secret => "shhh", - :compute_resource_id => @compute_resource.id)) + :secret => "shhh", + :compute_resource_id => @compute_resource.id)) post :create, params: { :compute_resource_id => @compute_resource.to_param }, session: set_session_user assert_response :redirect diff --git a/test/controllers/users_controller_test.rb b/test/controllers/users_controller_test.rb index 7bba858b848..49d1929eb1b 100644 --- a/test/controllers/users_controller_test.rb +++ b/test/controllers/users_controller_test.rb @@ -466,8 +466,8 @@ class UsersControllerTest < ActionController::TestCase context 'default taxonomies' do test 'accessing a regular page sets default taxonomies' do users(:one).update(:default_location_id => taxonomies(:location1).id, - :default_organization_id => taxonomies(:organization1).id, - :password => 'changeme') + :default_organization_id => taxonomies(:organization1).id, + :password => 'changeme') get :index, session: set_session_user(:one) assert_equal session['organization_id'], users(:one).default_organization_id @@ -476,7 +476,7 @@ class UsersControllerTest < ActionController::TestCase test 'users can update their own default taxonomies' do users(:one).update(:locations => [taxonomies(:location1)], - :organizations => [taxonomies(:organization1)]) + :organizations => [taxonomies(:organization1)]) put :update, params: { :id => users(:one).id, :user => { :default_location_id => taxonomies(:location1).id, diff --git a/test/models/compute_resource_test.rb b/test/models/compute_resource_test.rb index d106e43c955..303e4ad42e9 100644 --- a/test/models/compute_resource_test.rb +++ b/test/models/compute_resource_test.rb @@ -27,7 +27,7 @@ def setup Fog.mock! ComputeResource.any_instance.expects(:encryption_key).at_least_once.returns('25d224dd383e92a7e0c82b8bf7c985e815f34cf5') compute_resource = ComputeResource.new_provider(:name => "new12345", :provider => "EC2", :url => "eu-west-1", - :user => "username", :password => "abcdef") + :user => "username", :password => "abcdef") as_admin do assert compute_resource.save! end @@ -275,9 +275,9 @@ def setup require 'fog/ovirt/models/compute/volume' volume1 = Fog::Ovirt::Compute::Volume.new(:storage_domain => '', :size_gb => '1', :bootable => 'false', - :sparse => 'true', :wipe_after_delete => 'true', :name => 'disk1') + :sparse => 'true', :wipe_after_delete => 'true', :name => 'disk1') volume2 = Fog::Ovirt::Compute::Volume.new(:storage_domain => '', :size_gb => '1', :bootable => 'false', - :sparse => 'true', :wipe_after_delete => 'true', :name => 'disk2') + :sparse => 'true', :wipe_after_delete => 'true', :name => 'disk2') @vm.stubs(:volumes).returns([volume1, volume2]) diff --git a/test/models/compute_resources/openstack_test.rb b/test/models/compute_resources/openstack_test.rb index 707cdf34bbc..dae4e4a4f7f 100644 --- a/test/models/compute_resources/openstack_test.rb +++ b/test/models/compute_resources/openstack_test.rb @@ -52,7 +52,7 @@ class OpenstackTest < ActiveSupport::TestCase @compute_resource.stubs(:key_pair).returns(mocked_key_pair) @compute_resource.expects(:boot_from_volume).never @compute_resource.create_vm(:boot_from_volume => 'false', :nics => [""], - :flavor_ref => 'foo_flavor', :image_ref => 'foo_image') + :flavor_ref => 'foo_flavor', :image_ref => 'foo_image') end describe "formatting hints" do diff --git a/test/models/concerns/hostext/operating_system_test.rb b/test/models/concerns/hostext/operating_system_test.rb index 1370d7547ee..f1bfe0029e4 100644 --- a/test/models/concerns/hostext/operating_system_test.rb +++ b/test/models/concerns/hostext/operating_system_test.rb @@ -5,9 +5,9 @@ class OperatingSystemTest < ActiveSupport::TestCase context 'associated config templates' do setup do @host = Host.create(:name => "host.mydomain.net", :mac => "aabbccddeaff", - :ip => "2.3.04.03", :medium => media(:one), - :subnet => subnets(:one), :hostgroup => Hostgroup.find_by_name("Common"), - :architecture => Architecture.find_by(name: 'x86_64'), :disk => "aaa") + :ip => "2.3.04.03", :medium => media(:one), + :subnet => subnets(:one), :hostgroup => Hostgroup.find_by_name("Common"), + :architecture => Architecture.find_by(name: 'x86_64'), :disk => "aaa") end test "retrieves iPXE template if associated to the correct env and host group" do diff --git a/test/models/host_test.rb b/test/models/host_test.rb index 8865243d3ef..42d6e7d5454 100644 --- a/test/models/host_test.rb +++ b/test/models/host_test.rb @@ -256,11 +256,11 @@ class HostTest < ActiveSupport::TestCase User.current.roles << [roles(:manager)] assert_difference(-> { LookupValue.unscoped.count }, 1) do assert Host.create! :name => "abc.mydomain.net", :mac => "aabbecddeeff", :ip => "3.3.4.3", - :domain => domains(:mydomain), :operatingsystem => operatingsystems(:redhat), - :subnet => subnets(:two), :architecture => architectures(:x86_64), :medium => media(:one), - :organization => users(:one).organizations.first, :location => users(:one).locations.first, - :disk => "empty partition", - :lookup_values_attributes => {"new_123456" => {"lookup_key_id" => lookup_key.id, "value" => "some_value"}} + :domain => domains(:mydomain), :operatingsystem => operatingsystems(:redhat), + :subnet => subnets(:two), :architecture => architectures(:x86_64), :medium => media(:one), + :organization => users(:one).organizations.first, :location => users(:one).locations.first, + :disk => "empty partition", + :lookup_values_attributes => {"new_123456" => {"lookup_key_id" => lookup_key.id, "value" => "some_value"}} end end @@ -357,12 +357,12 @@ class HostTest < ActiveSupport::TestCase host.interfaces = [] host.populate_fields_from_facts( mock_parser(:domain => 'example.com', - :operatingsystem => 'RedHat', - :operatingsystemrelease => '6.2', - :macaddress_eth0 => '00:00:11:22:11:22', - :ipaddress_eth0 => '192.168.0.1', - :ipaddress6_eth0 => '2001:db8::1', - :interfaces => 'eth0'), + :operatingsystem => 'RedHat', + :operatingsystemrelease => '6.2', + :macaddress_eth0 => '00:00:11:22:11:22', + :ipaddress_eth0 => '192.168.0.1', + :ipaddress6_eth0 => '2001:db8::1', + :interfaces => 'eth0'), 'puppet', nil) assert_equal 'example.com', host.domain.name diff --git a/test/models/hostgroup_test.rb b/test/models/hostgroup_test.rb index 2b213c7eb8e..3d08eefc3d4 100644 --- a/test/models/hostgroup_test.rb +++ b/test/models/hostgroup_test.rb @@ -49,14 +49,14 @@ class HostgroupTest < ActiveSupport::TestCase # and overrides. pid = Time.now.to_i top = Hostgroup.new(:name => "topA", - :group_parameters_attributes => { pid += 1 => {"name" => "topA", "value" => "1"}, - pid += 1 => {"name" => "topB", "value" => "1"}, - pid += 1 => {"name" => "topC", "value" => "1"}}) + :group_parameters_attributes => { pid += 1 => {"name" => "topA", "value" => "1"}, + pid += 1 => {"name" => "topB", "value" => "1"}, + pid += 1 => {"name" => "topC", "value" => "1"}}) assert top.save second = Hostgroup.new(:name => "SecondA", :parent_id => top.id, - :group_parameters_attributes => { pid += 1 => {"name" => "topA", "value" => "2"}, - pid += 1 => {"name" => "secondA", "value" => "2"}}) + :group_parameters_attributes => { pid += 1 => {"name" => "topA", "value" => "2"}, + pid += 1 => {"name" => "secondA", "value" => "2"}}) assert second.save assert second.parameters.include? "topA" @@ -69,8 +69,8 @@ class HostgroupTest < ActiveSupport::TestCase assert_equal "2", second.parameters["secondA"] third = Hostgroup.new(:name => "ThirdA", :parent_id => second.id, - :group_parameters_attributes => { pid += 1 => {"name" => "topB", "value" => "3"}, - pid + 1 => {"name" => "topA", "value" => "3"}}) + :group_parameters_attributes => { pid += 1 => {"name" => "topB", "value" => "3"}, + pid + 1 => {"name" => "topA", "value" => "3"}}) assert third.save assert third.parameters.include? "topA" diff --git a/test/models/hosts/base_test.rb b/test/models/hosts/base_test.rb index 671de92211e..8e8f78c9d9f 100644 --- a/test/models/hosts/base_test.rb +++ b/test/models/hosts/base_test.rb @@ -23,7 +23,7 @@ class BaseTest < ActiveSupport::TestCase test "should make hostname lowercase" do host = Host::Base.new(:name => 'MYHOST', - :domain => FactoryBot.create(:domain, :name => "mydomainlowercase.net")) + :domain => FactoryBot.create(:domain, :name => "mydomainlowercase.net")) host.valid? assert_equal "myhost.mydomainlowercase.net", host.name end diff --git a/test/models/nic_test.rb b/test/models/nic_test.rb index f53244fa7e3..365656cfe10 100644 --- a/test/models/nic_test.rb +++ b/test/models/nic_test.rb @@ -19,7 +19,7 @@ def teardown test "type casting should return the correct class" do i = Nic::Base.create! :ip => "127.2.3.8", :mac => "babbccddeeff", :host => FactoryBot.create(:host), - :type => "Nic::Interface" + :type => "Nic::Interface" assert_equal "Nic::Interface", i.type end diff --git a/test/models/orchestration/dhcp_test.rb b/test/models/orchestration/dhcp_test.rb index fe73700a9a6..1354c4dca41 100644 --- a/test/models/orchestration/dhcp_test.rb +++ b/test/models/orchestration/dhcp_test.rb @@ -339,7 +339,7 @@ def host_with_loader(loader) as_admin do h = FactoryBot.create(:host, :with_dhcp_orchestration, :mac => "aa:bb:cc:dd:ee:ff") Nic::BMC.create!(:host_id => h.id, :mac => "da:aa:aa:ab:db:bb", :domain_id => h.domain_id, - :ip => h.ip.succ, :subnet_id => h.subnet_id, :name => "bmc-#{h}", :provider => 'IPMI') + :ip => h.ip.succ, :subnet_id => h.subnet_id, :name => "bmc-#{h}", :provider => 'IPMI') end h.reload bmc = h.interfaces.bmc.first @@ -391,7 +391,7 @@ def host_with_loader(loader) as_admin do h = FactoryBot.create(:host, :with_dhcp_orchestration, :mac => "aa:bb:cc:dd:ee:f1") Nic::BMC.create! :host => h, :mac => "aa:aa:aa:ab:bd:bb", :ip => h.ip.succ, :domain => h.domain, - :subnet => h.subnet, :name => "bmc1-#{h}", :provider => 'IPMI' + :subnet => h.subnet, :name => "bmc1-#{h}", :provider => 'IPMI' end h = Host.find(h.id) bmc = h.interfaces.bmc.first @@ -406,7 +406,7 @@ def host_with_loader(loader) as_admin do h = FactoryBot.create(:host, :with_dhcp_orchestration, :mac => "aa:aa:ad:ab:bb:cc") Nic::BMC.create!(:host => h, :mac => "aa:aa:ad:ab:bb:bb", :domain => h.domain, :subnet => h.subnet, - :name => "bmc-it", :provider => 'IPMI', :ip => h.ip.succ) + :name => "bmc-it", :provider => 'IPMI', :ip => h.ip.succ) end h.reload h.mac = next_mac(h.mac) diff --git a/test/models/shared/taxonomies_base_test.rb b/test/models/shared/taxonomies_base_test.rb index 260cfbfbb90..158c8a5f008 100644 --- a/test/models/shared/taxonomies_base_test.rb +++ b/test/models/shared/taxonomies_base_test.rb @@ -66,7 +66,7 @@ module TaxonomiesBaseTest domain = FactoryBot.build(:domain) cr_one = compute_resources(:one) cr_one.update(:"#{taxonomy_name.pluralize}" => [taxonomy], - :"#{opposite_taxonomy.pluralize}" => []) + :"#{opposite_taxonomy.pluralize}" => []) FactoryBot.create(:host, :compute_resource => cr_one, :domain => domain, diff --git a/test/models/subnet/ipv4_test.rb b/test/models/subnet/ipv4_test.rb index d82d690318f..8f52471cfef 100644 --- a/test/models/subnet/ipv4_test.rb +++ b/test/models/subnet/ipv4_test.rb @@ -187,11 +187,11 @@ def setup test "should not assign proxies without adequate features" do proxy = smart_proxies(:puppetmaster) subnet = Subnet::Ipv4.new(:name => "test subnet", - :network => "192.168.100.0", - :mask => "255.255.255.0", - :dhcp_id => proxy.id, - :dns_id => proxy.id, - :tftp_id => proxy.id) + :network => "192.168.100.0", + :mask => "255.255.255.0", + :dhcp_id => proxy.id, + :dns_id => proxy.id, + :tftp_id => proxy.id) refute subnet.save assert_equal "does not have the DNS feature", subnet.errors["dns_id"].first assert_equal "does not have the DHCP feature", subnet.errors["dhcp_id"].first diff --git a/test/models/user_test.rb b/test/models/user_test.rb index c062a1b30a8..52e6920139a 100644 --- a/test/models/user_test.rb +++ b/test/models/user_test.rb @@ -347,9 +347,9 @@ def setup_user(operation, type = 'users', search = nil) test "user with create permissions should be able to create" do setup_user "create" record = User.new :login => "dummy", :mail => "j@j.com", - :auth_source_id => AuthSourceInternal.first.id, - :organizations => User.current.organizations, - :locations => User.current.locations + :auth_source_id => AuthSourceInternal.first.id, + :organizations => User.current.organizations, + :locations => User.current.locations record.password_hash = "asd" assert record.save assert record.valid? @@ -374,8 +374,8 @@ def setup_user(operation, type = 'users', search = nil) create_role = Role.find_by_name 'create_users' extra_role = Role.where(:name => "foobar").first_or_create record = User.new :login => "dummy", :mail => "j@j.com", :auth_source_id => AuthSourceInternal.first.id, - :role_ids => [extra_role.id, create_role.id].map(&:to_s), - :organizations => users(:one).organizations, :locations => users(:one).locations + :role_ids => [extra_role.id, create_role.id].map(&:to_s), + :organizations => users(:one).organizations, :locations => users(:one).locations end record.password_hash = "asd" refute record.save @@ -388,10 +388,10 @@ def setup_user(operation, type = 'users', search = nil) setup_user "create" create_role = Role.find_by_name 'create_users' record = User.new(:login => "dummy", :mail => "j@j.com", - :auth_source_id => AuthSourceInternal.first.id, - :role_ids => [create_role.id.to_s], - :organizations => User.current.organizations, - :locations => User.current.locations) + :auth_source_id => AuthSourceInternal.first.id, + :role_ids => [create_role.id.to_s], + :organizations => User.current.organizations, + :locations => User.current.locations) record.password_hash = "asd" assert record.valid? assert record.save @@ -402,10 +402,10 @@ def setup_user(operation, type = 'users', search = nil) as_admin do extra_role = Role.where(:name => "foobar").first_or_create record = User.new(:login => "dummy", :mail => "j@j.com", - :auth_source_id => AuthSourceInternal.first.id, - :role_ids => [extra_role.id.to_s], - :organizations => User.current.organizations, - :locations => User.current.locations) + :auth_source_id => AuthSourceInternal.first.id, + :role_ids => [extra_role.id.to_s], + :organizations => User.current.organizations, + :locations => User.current.locations) record.password_hash = "asd" record.admin = true assert record.save diff --git a/test/models/usergroup_test.rb b/test/models/usergroup_test.rb index 364ce8506d6..a29f0f5e201 100644 --- a/test/models/usergroup_test.rb +++ b/test/models/usergroup_test.rb @@ -216,7 +216,7 @@ def populate_usergroups @usergroup = FactoryBot.create(:usergroup) auth_source_ldap = FactoryBot.create(:auth_source_ldap) @external = @usergroup.external_usergroups.new(:auth_source_id => auth_source_ldap.id, - :name => 'aname') + :name => 'aname') LdapFluff.any_instance.stubs(:ldap).returns(Net::LDAP.new) users(:one).update_column(:auth_source_id, auth_source_ldap.id) end diff --git a/test/unit/concerns/hostext_ownership_test.rb b/test/unit/concerns/hostext_ownership_test.rb index c061a83e206..a1a4286c891 100644 --- a/test/unit/concerns/hostext_ownership_test.rb +++ b/test/unit/concerns/hostext_ownership_test.rb @@ -9,9 +9,9 @@ class HostextOwnershipTest < ActiveSupport::TestCase context 'owner_type validations' do test "should not save if owner_type is not User or Usergroup" do host = Host.new :name => "myfullhost", :mac => "aabbecddeeff", :ip => "3.3.4.03", :medium => media(:one), - :domain => domains(:mydomain), :operatingsystem => operatingsystems(:redhat), :subnet => subnets(:two), - :architecture => architectures(:x86_64), :managed => true, - :owner_type => "UserGr(up" # should be Usergroup + :domain => domains(:mydomain), :operatingsystem => operatingsystems(:redhat), :subnet => subnets(:two), + :architecture => architectures(:x86_64), :managed => true, + :owner_type => "UserGr(up" # should be Usergroup assert_raises ArgumentError do host.valid? end diff --git a/test/unit/host_build_status_test.rb b/test/unit/host_build_status_test.rb index 4ba8fe64f6b..9b706018c0b 100644 --- a/test/unit/host_build_status_test.rb +++ b/test/unit/host_build_status_test.rb @@ -6,9 +6,9 @@ class HostBuildStatusTest < ActiveSupport::TestCase stub_smart_proxy_v2_features User.current = users(:admin) @host = Host.new(:name => "myfullhost", :mac => "aabbecddeeff", :ip => "2.3.4.03", :ptable => FactoryBot.build(:ptable), :medium => media(:one), - :domain => domains(:mydomain), :operatingsystem => operatingsystems(:redhat), :subnet => subnets(:one), - :architecture => architectures(:x86_64), :managed => true, - :owner_type => "User", :root_pass => "xybxa6JUkz63w") + :domain => domains(:mydomain), :operatingsystem => operatingsystems(:redhat), :subnet => subnets(:one), + :architecture => architectures(:x86_64), :managed => true, + :owner_type => "User", :root_pass => "xybxa6JUkz63w") # bypass host.valid? HostBuildStatus.any_instance.stubs(:host_status).returns(true) end diff --git a/test/unit/net/dhcp_test.rb b/test/unit/net/dhcp_test.rb index e9170995b59..00d4c24d06b 100644 --- a/test/unit/net/dhcp_test.rb +++ b/test/unit/net/dhcp_test.rb @@ -33,7 +33,7 @@ class DHCPTest < ActiveSupport::TestCase test "record should have dhcp attributes" do record = Net::DHCP::Record.new(:hostname => "test", :mac => "aa:bb:cc:dd:ee:ff", - :network => "127.0.0.0", :ip => "127.0.0.1", "proxy" => smart_proxies(:one)) + :network => "127.0.0.0", :ip => "127.0.0.1", "proxy" => smart_proxies(:one)) assert_equal({:hostname => "test", :mac => "aa:bb:cc:dd:ee:ff", :network => "127.0.0.0", :ip => "127.0.0.1", :related_macs => []}, record.send(:attrs)) end @@ -73,8 +73,8 @@ class DHCPTest < ActiveSupport::TestCase ProxyAPI::Resource.any_instance.stubs(:parse).with('lease').returns(proxy_lease) ProxyAPI::Resource.any_instance.stubs(:parse).with('').returns([]) record1 = Net::DHCP::Record.new(:hostname => "test1", :mac => "aa:bb:cc:dd:ee:ff", - :network => "127.0.0.0", :ip => "127.0.0.2", - "proxy" => subnets(:one).dhcp_proxy) + :network => "127.0.0.0", :ip => "127.0.0.2", + "proxy" => subnets(:one).dhcp_proxy) assert record1.conflicts.present? end @@ -85,16 +85,16 @@ class DHCPTest < ActiveSupport::TestCase ProxyAPI::Resource.any_instance.stubs(:parse).with('lease').returns(proxy_lease) ProxyAPI::Resource.any_instance.stubs(:parse).with('').returns([]) record1 = Net::DHCP::Record.new(:hostname => "test1", :mac => "aa:bb:cc:dd:ee:ff", - :network => "127.0.0.0", :ip => "127.0.0.1", - "proxy" => subnets(:one).dhcp_proxy) + :network => "127.0.0.0", :ip => "127.0.0.1", + "proxy" => subnets(:one).dhcp_proxy) assert_empty record1.conflicts end test "dhcp record validation should return false when proxy returns nil" do ProxyAPI::DHCP.any_instance.stubs(:record).returns(nil) record1 = Net::DHCP::Record.new(:hostname => "test1", :mac => "aa:bb:cc:dd:ee:ff", - :network => "127.0.0.0", :ip => "127.0.0.1", - "proxy" => subnets(:one).dhcp_proxy) + :network => "127.0.0.0", :ip => "127.0.0.1", + "proxy" => subnets(:one).dhcp_proxy) refute record1.valid? end @@ -103,8 +103,8 @@ class DHCPTest < ActiveSupport::TestCase ProxyAPI::Resource.any_instance.stubs(:get).with("127.0.0.0/ip/127.0.0.1").returns(@lease1_array) ProxyAPI::Resource.any_instance.stubs(:get).with("127.0.0.0/mac/aa:bb:cc:dd:ee:02").raises(RestClient::ResourceNotFound, 'Record not found') record1 = Net::DHCP::Record.new(:hostname => "discovered_host1", :mac => "aa:bb:cc:dd:ee:02", - :network => "127.0.0.0", :ip => "127.0.0.1", - "proxy" => subnets(:one).dhcp_proxy) + :network => "127.0.0.0", :ip => "127.0.0.1", + "proxy" => subnets(:one).dhcp_proxy) refute record1.conflicts.empty? refute record1.valid? end @@ -114,8 +114,8 @@ class DHCPTest < ActiveSupport::TestCase ProxyAPI::Resource.any_instance.stubs(:get).with("127.0.0.0/ip/127.0.0.1").returns(@lease1_array) ProxyAPI::Resource.any_instance.stubs(:get).with("127.0.0.0/ip/127.0.0.2").raises(RestClient::ResourceNotFound, 'Record not found') record1 = Net::DHCP::Record.new(:hostname => "discovered_host1", :mac => "aa:bb:cc:dd:ee:01", - :network => "127.0.0.0", :ip => "127.0.0.2", - "proxy" => subnets(:one).dhcp_proxy) + :network => "127.0.0.0", :ip => "127.0.0.2", + "proxy" => subnets(:one).dhcp_proxy) refute record1.conflicts.empty? refute record1.valid? end @@ -134,8 +134,8 @@ class DHCPTest < ActiveSupport::TestCase ProxyAPI::Resource.any_instance.stubs(:get).with("127.0.0.0/ip/127.0.0.1").returns(@lease1_array) ProxyAPI::Resource.any_instance.stubs(:get).with("127.0.0.0/ip/127.0.0.2").returns(lease2_array) record1 = Net::DHCP::Record.new(:hostname => "discovered_host1", :mac => "aa:bb:cc:dd:ee:01", - :network => "127.0.0.0", :ip => "127.0.0.2", - "proxy" => subnets(:one).dhcp_proxy) + :network => "127.0.0.0", :ip => "127.0.0.2", + "proxy" => subnets(:one).dhcp_proxy) assert_empty record1.conflicts assert record1.valid? end @@ -155,8 +155,8 @@ class DHCPTest < ActiveSupport::TestCase ProxyAPI::Resource.any_instance.stubs(:get).with("127.0.0.0/ip/127.0.0.2").returns(existing_lease_array) ProxyAPI::Resource.any_instance.stubs(:get).with("127.0.0.0/ip/127.0.0.1").returns(@lease1_array) rec = Net::DHCP::Record.new(:hostname => "a_host1", :mac => "aa:bb:cc:dd:ee:01", - :network => "127.0.0.0", :ip => "127.0.0.1", - "proxy" => subnets(:one).dhcp_proxy) + :network => "127.0.0.0", :ip => "127.0.0.1", + "proxy" => subnets(:one).dhcp_proxy) assert_equal "lease", subnets(:one).dhcp_proxy.record("127.0.0.0", "aa:bb:cc:dd:ee:01").type assert_equal "lease", subnets(:one).dhcp_proxy.records_by_ip("127.0.0.0", "127.0.0.2").first.type assert_empty rec.conflicts @@ -177,8 +177,8 @@ class DHCPTest < ActiveSupport::TestCase ProxyAPI::Resource.any_instance.stubs(:get).with("127.0.0.0/ip/127.0.0.2").returns(existing_lease_array) ProxyAPI::Resource.any_instance.stubs(:get).with("127.0.0.0/ip/127.0.0.1").returns(@lease1_array) rec = Net::DHCP::Record.new(:hostname => "a_host1", :mac => "aa:bb:cc:dd:ee:01", - :network => "127.0.0.0", :ip => "127.0.0.1", - "proxy" => subnets(:one).dhcp_proxy) + :network => "127.0.0.0", :ip => "127.0.0.1", + "proxy" => subnets(:one).dhcp_proxy) assert_equal "reservation", subnets(:one).dhcp_proxy.record("127.0.0.0", "aa:bb:cc:dd:ee:01").type assert_equal "reservation", subnets(:one).dhcp_proxy.records_by_ip("127.0.0.0", "127.0.0.2").first.type refute rec.conflicts.empty? diff --git a/test/unit/puppet_fact_parser_test.rb b/test/unit/puppet_fact_parser_test.rb index 77485d88e9d..6c8e4f6619e 100644 --- a/test/unit/puppet_fact_parser_test.rb +++ b/test/unit/puppet_fact_parser_test.rb @@ -16,8 +16,8 @@ def setup test "should parse virtual interfaces as vlan interfaces when facter < v3.0" do parser = PuppetFactParser.new(facterversion: '2.8.9', - interfaces: 'eth0_0', - ipaddress_eth0_0: '192.168.0.1') + interfaces: 'eth0_0', + ipaddress_eth0_0: '192.168.0.1') assert_equal 'eth0.0', parser.interfaces.keys.first assert_equal '192.168.0.1', parser.interfaces['eth0.0']['ipaddress'] end @@ -149,7 +149,7 @@ def setup test "should set version correctly for PSBM" do @importer = PuppetFactParser.new("operatingsystem" => "PSBM", - "operatingsystemrelease" => "2.6.32-042stab111.11") + "operatingsystemrelease" => "2.6.32-042stab111.11") assert_equal '2', os.major assert_equal '6', os.minor assert_os_idempotent @@ -168,8 +168,8 @@ def setup minor: "2.1511", description: "CentOS Linux 7.2.1511") @importer = PuppetFactParser.new("operatingsystem" => "CentOS", - "lsbdistdescription" => "CentOS Linux release 7.2.1511 (Core) ", - "operatingsystemrelease" => "7.2.1511") + "lsbdistdescription" => "CentOS Linux release 7.2.1511 (Core) ", + "operatingsystemrelease" => "7.2.1511") assert_valid os assert_os_idempotent end @@ -299,15 +299,15 @@ def setup assert_empty parser.send(:get_interfaces) parser = get_parser(facterversion: '3.1.2', - networking: {}) + networking: {}) assert_empty parser.send(:get_interfaces) parser = get_parser(facterversion: '3.1.2', - networking: { interfaces: {} }) + networking: { interfaces: {} }) assert_empty parser.send(:get_interfaces) parser = get_parser(facterversion: '3.1.2', - networking: { interfaces: nil}) + networking: { interfaces: nil}) assert_empty parser.send(:get_interfaces) parser = get_parser(structured_networking_facts) diff --git a/test/unit/tasks/seeds_test.rb b/test/unit/tasks/seeds_test.rb index 071b7685427..7cc880783be 100644 --- a/test/unit/tasks/seeds_test.rb +++ b/test/unit/tasks/seeds_test.rb @@ -104,11 +104,11 @@ def seed(*seed_files) test 'with environment overrides' do assert_difference 'User.unscoped.where(:login => "seed_test").count', 1 do - with_env('SEED_ADMIN_USER' => 'seed_test', - 'SEED_ADMIN_PASSWORD' => 'seed_secret', - 'SEED_ADMIN_FIRST_NAME' => 'Seed', - 'SEED_ADMIN_LAST_NAME' => 'Test', - 'SEED_ADMIN_EMAIL' => 'seed@example.net') do + with_env('SEED_ADMIN_USER' => 'seed_test', + 'SEED_ADMIN_PASSWORD' => 'seed_secret', + 'SEED_ADMIN_FIRST_NAME' => 'Seed', + 'SEED_ADMIN_LAST_NAME' => 'Test', + 'SEED_ADMIN_EMAIL' => 'seed@example.net') do seed end end