diff --git a/app/controllers/api/v2/base_controller.rb b/app/controllers/api/v2/base_controller.rb index 4f62ebff7983..1f5f51f88b85 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 9321bf5811d6..2d5f4d1adab9 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -145,7 +145,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 29a7d56a451a..176fc82bf2ea 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 b42a7095541b..4af932c318d4 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 954a5ed123be..1e95f2c9b03d 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 e1e0864bcebf..608e508ab13c 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 79bbb44c072a..23a57005bd7d 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 4026a1246732..8a6737332049 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 8e83e12f0ae5..a979175fc0d2 100644 --- a/app/controllers/templates_controller.rb +++ b/app/controllers/templates_controller.rb @@ -160,8 +160,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 3c4eb19af224..b95631d10b5b 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 0fb3e1a92b4d..dbdba8b4ac7d 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 9b36fdad0290..efd3e95848ca 100644 --- a/app/helpers/layout_helper.rb +++ b/app/helpers/layout_helper.rb @@ -133,8 +133,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 @@ -243,7 +243,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 514cfcde58bd..957410abad90 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 e8ae7b1af184..45b7a26f645f 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 7076476dbc35..a5c8a923d133 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/compute_resources/foreman/model/vmware.rb b/app/models/compute_resources/foreman/model/vmware.rb index d3cc197ec34e..d0963b2dafbc 100644 --- a/app/models/compute_resources/foreman/model/vmware.rb +++ b/app/models/compute_resources/foreman/model/vmware.rb @@ -793,12 +793,12 @@ def set_vm_volumes_attributes(vm, vm_attrs) end def build_vmrc_uri(host, vmid, ticket) - uri = URI::Generic.build(:scheme => 'vmrc', - :userinfo => "clone:#{ticket}", - :host => host, - :port => 443, - :path => '/', - :query => "moid=#{vmid}").to_s + uri = URI::Generic.build(:scheme => 'vmrc', + :userinfo => "clone:#{ticket}", + :host => host, + :port => 443, + :path => '/', + :query => "moid=#{vmid}").to_s # VMRC doesn't like brackets around IPv6 addresses uri.sub(/(.*)\[/, '\1').sub(/(.*)\]/, '\1') end diff --git a/app/models/concerns/orchestration/compute.rb b/app/models/concerns/orchestration/compute.rb index ee7f9f01738e..7cbfc2581d32 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 fdd8dff965d1..04d6bfc00457 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/puppetca.rb b/app/models/concerns/orchestration/puppetca.rb index de0f262b8aac..7897f01ccca2 100644 --- a/app/models/concerns/orchestration/puppetca.rb +++ b/app/models/concerns/orchestration/puppetca.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 753d2864027a..97e05d401e97 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 305b832f9208..513467d85c83 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 dbde6d000564..d96ae6e9175d 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 e63032e5a5b2..1908e96b8d6a 100644 --- a/app/models/host/managed.rb +++ b/app/models/host/managed.rb @@ -407,7 +407,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 4301c70baa07..e348c02378d5 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 f909f760536e..627b3950710f 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 0d3e36561f44..adcdc7bed237 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 4da4bc9e4e39..47c49b089192 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 c5e606cd0cb9..15f25f6c908d 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 726cbeb5c462..60796aeb6062 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 d6168ec0a70d..5b96ad2359f4 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 59014ec3a37f..cc512624563e 100644 --- a/app/services/foreman/renderer/scope/macros/base.rb +++ b/app/services/foreman/renderer/scope/macros/base.rb @@ -191,8 +191,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 01cabaeeac03..ca8613338a8b 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 118f0c29dc4d..f77247771fc1 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 6df4881dd025..4852e48237eb 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 ed47e1d24ea9..1deb5a7760f1 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,7 +49,7 @@ def test_should_update_correctly resource = resources.first 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 @@ -62,9 +62,9 @@ def test_should_destroy_correctly resource2 = resources[1] 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 a2583d594715..4c17b32395ad 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 5e1bdacc804d..447efb2334d9 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 2cd217dfb3af..af621d69270f 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 @@ -1551,17 +1551,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 e20a793d90ef..2f7cad89c4e3 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 ed24af525bf0..756e08ae8d1b 100644 --- a/test/controllers/users_controller_test.rb +++ b/test/controllers/users_controller_test.rb @@ -465,8 +465,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 @@ -475,7 +475,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 d106e43c955c..303e4ad42e90 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 707cdf34bbc7..dae4e4a4f7fc 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/compute_resources/vmware_test.rb b/test/models/compute_resources/vmware_test.rb index b941576f8ab6..12c97d631c13 100644 --- a/test/models/compute_resources/vmware_test.rb +++ b/test/models/compute_resources/vmware_test.rb @@ -22,15 +22,15 @@ class Foreman::Model::VmwareTest < ActiveSupport::TestCase volumes_attributes = { "new_volumes" => { "size_gb" => "10", "_delete" => ""}, "0" => { "size_gb" => "1", "_delete" => ""}} - attrs_in = HashWithIndifferentAccess.new("cpus" => "1", - "interfaces_attributes" => interfaces_attributes, - "volumes_attributes" => volumes_attributes) - - attrs_parsed = HashWithIndifferentAccess.new("cpus" => "1", - "interfaces_attributes" => {"new_interfaces" => {"type" => "VirtualE1000", "network" => "Test network", "_delete" => ""}, - "0" => {"type" => "VirtualVmxnet3", "network" => "Test network", "_delete" => ""}}, - "volumes_attributes" => {"new_volumes" => {"size_gb" => "10", "_delete" => ""}, - "0" => {"size_gb" => "1", "_delete" => ""}}) + attrs_in = HashWithIndifferentAccess.new("cpus" => "1", + "interfaces_attributes" => interfaces_attributes, + "volumes_attributes" => volumes_attributes) + + attrs_parsed = HashWithIndifferentAccess.new("cpus" => "1", + "interfaces_attributes" => {"new_interfaces" => {"type" => "VirtualE1000", "network" => "Test network", "_delete" => ""}, + "0" => {"type" => "VirtualVmxnet3", "network" => "Test network", "_delete" => ""}}, + "volumes_attributes" => {"new_volumes" => {"size_gb" => "10", "_delete" => ""}, + "0" => {"size_gb" => "1", "_delete" => ""}}) mock_vm = mock('vm') mock_vm.expects(:save).returns(mock_vm) diff --git a/test/models/concerns/hostext/operating_system_test.rb b/test/models/concerns/hostext/operating_system_test.rb index 1370d7547ee3..495769234426 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 5485276e4a1e..9fc832fa6525 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 c9fbc97b5c7e..54b49c6ef3b9 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 671de92211e0..8e8f78c9d9f8 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 f53244fa7e36..365656cfe105 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 ad4172223b82..a051183afc2a 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 c598a76ded56..358325ef5253 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 d82d690318f1..8f52471cfef4 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 5a16783bc15e..7997b0142a6d 100644 --- a/test/models/user_test.rb +++ b/test/models/user_test.rb @@ -356,9 +356,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? @@ -383,8 +383,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 @@ -397,10 +397,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 @@ -411,10 +411,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 d79499e8e584..2deb7742ee7c 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 c061a83e2067..a1a4286c891c 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 4ba8fe64f6b8..9b706018c0b1 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 471aa0f6ed16..9c33c71dd462 100644 --- a/test/unit/net/dhcp_test.rb +++ b/test/unit/net/dhcp_test.rb @@ -34,7 +34,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 @@ -74,8 +74,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 @@ -86,16 +86,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) - assert record1.conflicts.empty? + :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 @@ -104,8 +104,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 @@ -115,8 +115,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 @@ -135,9 +135,9 @@ 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) - assert record1.conflicts.empty? + :network => "127.0.0.0", :ip => "127.0.0.2", + "proxy" => subnets(:one).dhcp_proxy) + assert_empty record1.conflicts assert record1.valid? end @@ -156,8 +156,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 rec.conflicts.empty? @@ -178,8 +178,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 939b64d2ec92..dcf0b8134f15 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 89888bad701a..9f8844d01d2b 100644 --- a/test/unit/tasks/seeds_test.rb +++ b/test/unit/tasks/seeds_test.rb @@ -103,11 +103,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