From 6652fb82964d5b09de5b7139bf725008fa077e3a Mon Sep 17 00:00:00 2001 From: John Prause Date: Tue, 12 Dec 2017 15:18:09 -0500 Subject: [PATCH 01/21] [Changelog] Update for Sprint 75 [skip ci] --- CHANGELOG.md | 121 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 121 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7b2c0891247d..084f7ef76165 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,61 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) +## Unreleased as of Sprint 75 ending 2017-12-11 + +### Added +- Authentication + - Handle OpenID-Connect authentication client protocol [(#16495)](https://github.com/ManageIQ/manageiq/pull/16495) +- Control + - Default name to description for MiqAlertSet and MiqPolicySet [(#16529)](https://github.com/ManageIQ/manageiq/pull/16529) +- Core + - Binary blob purging [(#16524)](https://github.com/ManageIQ/manageiq/pull/16524) + - GenericObjectDefinition: add pretty & translatable type names [(#16563)](https://github.com/ManageIQ/manageiq/pull/16563) +- Providers + - Allow unassignment of specific tags/objects in assignment_mixin [(#16401)](https://github.com/ManageIQ/manageiq/pull/16401) + - Call super from all the EmbeddedAnsible subclasses' #initialize methods [(#16543)](https://github.com/ManageIQ/manageiq/pull/16543) + - Add middleware server to available fields in advanced search [(#16562)](https://github.com/ManageIQ/manageiq/pull/16562) +- Provisioning + - Change provision daialog "vLan" to "Virtual Network" [(#16537)](https://github.com/ManageIQ/manageiq/pull/16537) +- Services + - Parse default value in Service Dialog [(#16555)](https://github.com/ManageIQ/manageiq/pull/16555) + +### Fixed +- Chargeback + - Fix max method on empty array in chargeback storage report [(#16575)](https://github.com/ManageIQ/manageiq/pull/16575) +- Core + - Replace conditions with scope [(#16399)](https://github.com/ManageIQ/manageiq/pull/16399) + - Fixes virtual_totals when a default_scope exists [(#16518)](https://github.com/ManageIQ/manageiq/pull/16518) + - Add supported_consoles to VM [(#16519)](https://github.com/ManageIQ/manageiq/pull/16519) + - Looks like self is needed on PRODUCT_NAME and VERSION calls [(#16556)](https://github.com/ManageIQ/manageiq/pull/16556) + - Handle deprecated classes in arel [(#16560)](https://github.com/ManageIQ/manageiq/pull/16560) + - Skip seeding of categories if their creation is invalid [(#16568)](https://github.com/ManageIQ/manageiq/pull/16568) + - Don't return a duplicate object from MiqGroup#settings [(#16572)](https://github.com/ManageIQ/manageiq/pull/16572) + - Add an ENV variable to override the PG version check in production [(#16573)](https://github.com/ManageIQ/manageiq/pull/16573) + - Fix cached query for total unregistered vms [(#16577)](https://github.com/ManageIQ/manageiq/pull/16577) + - No need to call normalized_status [(#16578)](https://github.com/ManageIQ/manageiq/pull/16578) + - Cache invalidation... [(#16601)](https://github.com/ManageIQ/manageiq/pull/16601) + - Handle autoload error not caught by safe_constantize [(#16608)](https://github.com/ManageIQ/manageiq/pull/16608) + - Use the server IP for the AWX database host when the rails config is no good [(#16621)](https://github.com/ManageIQ/manageiq/pull/16621) + - Fix error in timeout checking for job without target [(#16627)](https://github.com/ManageIQ/manageiq/pull/16627) +- i18n + - Dont store unnecessary i18n files in git [(#16590)](https://github.com/ManageIQ/manageiq/pull/16590) + - Add missing model names into locale/en.yml [(#16604)](https://github.com/ManageIQ/manageiq/pull/16604) +- Providers + - Allow proxying WebMKS consoles using the WebsocketWorker [(#16490)](https://github.com/ManageIQ/manageiq/pull/16490) + - Set CloudVolume name to ID if empty [(#16554)](https://github.com/ManageIQ/manageiq/pull/16554) + - Catalog Item type list is dependent on installed providers [(#16559)](https://github.com/ManageIQ/manageiq/pull/16559) + - Destroy ems alert statuses when ems is destroyed [(#16592)](https://github.com/ManageIQ/manageiq/pull/16592) + - Add the missing container template openshift to the en.yml [(#16595)](https://github.com/ManageIQ/manageiq/pull/16595) + - Allowing OperatingSystem for CloudManager graph refresh [(#16605)](https://github.com/ManageIQ/manageiq/pull/16605) +- Services + - Change the type name for the catalog Item from 'Container Template' to 'Openshift Template' [(#16639)](https://github.com/ManageIQ/manageiq/pull/16639) +- Smart State + - Use Hostname or IP Address when connecting for SSA [(#16533)](https://github.com/ManageIQ/manageiq/pull/16533) +- UI + - Update Catalog tab of Publish VM dialog [(#16599)](https://github.com/ManageIQ/manageiq/pull/16599) + - Set default values for help menu link target types in settings.yml [(#16549)](https://github.com/ManageIQ/manageiq/pull/16549) + ## Unreleased as of Sprint 74 ending 2017-11-27 ### Added @@ -107,6 +162,72 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) - Providers - Revert "Replace ContainerLabelTagMapping.controls_tag? with Tag.controlled_by_mapping scope" [(#16462)](https://github.com/ManageIQ/manageiq/pull/16462) +## Gaprindashvili Beta2 + +### Added +- Alerts + - Seed MiqAlerts used for Prometheus Alerts [(#16479)](https://github.com/ManageIQ/manageiq/pull/16479) +- Ansible + - Add log_output option for embedded ansible service [(#16414)](https://github.com/ManageIQ/manageiq/pull/16414) +- Automate + - Add #raw_stdout_via_worker method [(#16441)](https://github.com/ManageIQ/manageiq/pull/16441) + - Imports old associations [(#16471)](https://github.com/ManageIQ/manageiq/pull/16471) +- Core + - Remove the column reordering tool and the schema structure validations [(#16488)](https://github.com/ManageIQ/manageiq/pull/16488) + - Added Product name to VMDB::Appliance [(#16409)](https://github.com/ManageIQ/manageiq/pull/16409) + - Added User Agent to VMDB::Appliance [(#16410)](https://github.com/ManageIQ/manageiq/pull/16410) +- Providers + - Add tag categories for VM migration [(#16402)](https://github.com/ManageIQ/manageiq/pull/16402) + - Add requests and limits to Persistent Volume Claim [(#16026)](https://github.com/ManageIQ/manageiq/pull/16026) + - Add ems_infra_admin_ui feature [(#16403)](https://github.com/ManageIQ/manageiq/pull/16403) + - Update ems_infra_admin_ui feature to role assignment [(#16484)](https://github.com/ManageIQ/manageiq/pull/16484) + - Move graph refresh internals logging to debug [(#16442)](https://github.com/ManageIQ/manageiq/pull/16442) +- Reporting + - Add scope :without_configuration_profile_id needed by Foreman explorer UI [(#16439)](https://github.com/ManageIQ/manageiq/pull/16439) +- Services + - Name service during provisioning from dialog input [(#16338)](https://github.com/ManageIQ/manageiq/pull/16338) + +### Fixed +- Automate + - Adds field unique validator check to dialog [(#16487)](https://github.com/ManageIQ/manageiq/pull/16487) +- Authentication + - Fixes a stack trace issue (500) during API authentication. [(#16520)](https://github.com/ManageIQ/manageiq/pull/16520) +- Core + - Add purging for vim_performance_tag_values with disabled tags [(#16425)](https://github.com/ManageIQ/manageiq/pull/16425) + - Add a connection to the pool if there is only one for embedded ansible [(#16477)](https://github.com/ManageIQ/manageiq/pull/16477) + - Fix Expression builder argument error by reverting #5506 [(#16255)](https://github.com/ManageIQ/manageiq/pull/16255) + - Move the notifications to include more of the setup [(#16508)](https://github.com/ManageIQ/manageiq/pull/16508) + - Finish simplifying NTP configuration using Settings [(#16393)](https://github.com/ManageIQ/manageiq/pull/16393) + - Fix issue where plugin settings had higher precedence than manageiq [(#16535)](https://github.com/ManageIQ/manageiq/pull/16535) +- i18n + - Fix string interpolations [(#16468)](https://github.com/ManageIQ/manageiq/pull/16468) + - Add Middleware Server EAP/Wildfly translation [(#16492)](https://github.com/ManageIQ/manageiq/pull/16492) +- Providers + - Fix has_required_role? for InventoryCollectorWorker [(#16415)](https://github.com/ManageIQ/manageiq/pull/16415) + - Missing cascade delete for host_storages [(#16440)](https://github.com/ManageIQ/manageiq/pull/16440) + - Truncate name of refresh task to 255 [(#16444)](https://github.com/ManageIQ/manageiq/pull/16444) + - Datastores duplicated after a refresh [(#16408)](https://github.com/ManageIQ/manageiq/pull/16408) + - Added a Maintenance key to the hash struct [(#16464)](https://github.com/ManageIQ/manageiq/pull/16464) + - Refresh new target do not run post_refresh [(#16436)](https://github.com/ManageIQ/manageiq/pull/16436) + - Add two new types to MW server factories [(#16478)](https://github.com/ManageIQ/manageiq/pull/16478) + - Container ssa annotate success [(#15031)](https://github.com/ManageIQ/manageiq/pull/15031) + - Require handsoap in VimConnectMixin [(#16450)](https://github.com/ManageIQ/manageiq/pull/16450) + - Require miq_fault_tolerant_vim in raw_connect [(#16500)](https://github.com/ManageIQ/manageiq/pull/16500) + - Unique EmsRefresh.refresh targets if there are over 1,000 targets [(#16432)](https://github.com/ManageIQ/manageiq/pull/16432) +- RBAC + - Standalone ServiceUI product features require, updating affected roles [(#16329)](https://github.com/ManageIQ/manageiq/pull/16329) + - Fix nil cases of allocated disk types in chargeback reporting [(#16434)](https://github.com/ManageIQ/manageiq/pull/16434) + - Add Missing button features to miq_features.yaml [(#16027)](https://github.com/ManageIQ/manageiq/pull/16027) +- Replication + - Prevent replication subscription to the same region as the current region [(#16446)](https://github.com/ManageIQ/manageiq/pull/16446) + - Scope Tenant#name validation to the current region [(#16506)](https://github.com/ManageIQ/manageiq/pull/16506) +- Reporting + - Fixed syntax with `orderby` in RSS Feed YAML files [(#16493)](https://github.com/ManageIQ/manageiq/pull/16493) +- Services + - ServiceTemplate: add scope for unassigned items. [(#16445)](https://github.com/ManageIQ/manageiq/pull/16445) +- UI + - Fix resize approval to work for editing requests [(#16381)](https://github.com/ManageIQ/manageiq/pull/16381) + ## Unreleased as of Sprint 72 ending 2017-10-30 ### Added From e4c1c8efc583748e06f5b0b9842fec83f21f63be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cain=C3=A3=20Costa?= Date: Thu, 4 Jan 2018 13:32:03 -0200 Subject: [PATCH 02/21] Disable all Hawkular workers --- lib/workers/miq_worker_types.rb | 8 -------- 1 file changed, 8 deletions(-) diff --git a/lib/workers/miq_worker_types.rb b/lib/workers/miq_worker_types.rb index 70331db08e65..b0e5c8f8dd6a 100644 --- a/lib/workers/miq_worker_types.rb +++ b/lib/workers/miq_worker_types.rb @@ -20,10 +20,6 @@ "ManageIQ::Providers::Google::CloudManager::MetricsCollectorWorker" => %i(manageiq_default), "ManageIQ::Providers::Google::CloudManager::RefreshWorker" => %i(manageiq_default), "ManageIQ::Providers::Google::NetworkManager::RefreshWorker" => %i(manageiq_default), - "ManageIQ::Providers::Hawkular::DatawarehouseManager::EventCatcher" => %i(manageiq_default), - "ManageIQ::Providers::Hawkular::DatawarehouseManager::RefreshWorker" => %i(manageiq_default), - "ManageIQ::Providers::Hawkular::MiddlewareManager::EventCatcher" => %i(manageiq_default), - "ManageIQ::Providers::Hawkular::MiddlewareManager::RefreshWorker" => %i(manageiq_default), "ManageIQ::Providers::Kubernetes::ContainerManager::EventCatcher" => %i(manageiq_default), "ManageIQ::Providers::Kubernetes::ContainerManager::MetricsCollectorWorker" => %i(manageiq_default), "ManageIQ::Providers::Kubernetes::ContainerManager::InventoryCollectorWorker" => %i(manageiq_default), @@ -107,8 +103,6 @@ ManageIQ::Providers::EmbeddedAnsible::AutomationManager::RefreshWorker ManageIQ::Providers::Foreman::ConfigurationManager::RefreshWorker ManageIQ::Providers::Foreman::ProvisioningManager::RefreshWorker - ManageIQ::Providers::Hawkular::MiddlewareManager::RefreshWorker - ManageIQ::Providers::Hawkular::DatawarehouseManager::RefreshWorker ManageIQ::Providers::Kubernetes::ContainerManager::InventoryCollectorWorker ManageIQ::Providers::Kubernetes::ContainerManager::RefreshWorker ManageIQ::Providers::Lenovo::PhysicalInfraManager::RefreshWorker @@ -143,8 +137,6 @@ ManageIQ::Providers::Azure::CloudManager::EventCatcher ManageIQ::Providers::AnsibleTower::AutomationManager::EventCatcher ManageIQ::Providers::EmbeddedAnsible::AutomationManager::EventCatcher - ManageIQ::Providers::Hawkular::MiddlewareManager::EventCatcher - ManageIQ::Providers::Hawkular::DatawarehouseManager::EventCatcher ManageIQ::Providers::Google::CloudManager::EventCatcher ManageIQ::Providers::Kubernetes::ContainerManager::EventCatcher ManageIQ::Providers::Kubernetes::MonitoringManager::EventCatcher From 97734c90a6b1e7438d99fb53482d8a7edc9cd947 Mon Sep 17 00:00:00 2001 From: Erik Clarizio Date: Thu, 4 Jan 2018 09:52:26 -0800 Subject: [PATCH 03/21] Ensure that field associations get created during API import https://bugzilla.redhat.com/show_bug.cgi?id=1518942 --- lib/services/dialog_import_service.rb | 28 ++++++++++++------- .../services/dialog_import_service_spec.rb | 6 ++++ 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/lib/services/dialog_import_service.rb b/lib/services/dialog_import_service.rb index d88f36306fed..2ce9d71ae0ea 100644 --- a/lib/services/dialog_import_service.rb +++ b/lib/services/dialog_import_service.rb @@ -91,7 +91,9 @@ def build_resource_actions(dialog) def import(dialog) @dialog_import_validator.determine_dialog_validity(dialog) new_dialog = Dialog.create(dialog.except('dialog_tabs')) + association_list = build_association_list(dialog) new_dialog.update!(dialog.merge('dialog_tabs' => build_dialog_tabs(dialog))) + build_associations(new_dialog, association_list) new_dialog end @@ -109,6 +111,19 @@ def build_association_list(dialog) associations end + def build_associations(dialog, association_list) + fields = dialog.dialog_fields + association_list.each do |association| + association.values.each do |values| + values.each do |responder| + next if fields.select { |field| field.name == responder }.empty? + DialogFieldAssociation.create(:trigger_id => fields.find { |field| field.name.include?(association.keys.first) }.id, + :respond_id => fields.find { |field| field.name == responder }.id) + end + end + end + end + def create_import_file_upload(file_contents) ImportFileUpload.create.tap do |import_file_upload| import_file_upload.store_binary_data_as_yml(file_contents, "Service dialog import") @@ -128,16 +143,9 @@ def import_from_dialogs(dialogs) "resource_actions" => build_resource_actions(dialog) ) ) - fields = new_or_existing_dialog.dialog_fields - (associations_to_be_created + build_old_association_list(fields).flatten).reject(&:blank?).each do |association| - association.values.each do |values| - values.each do |responder| - next if fields.select { |field| field.name == responder }.empty? - DialogFieldAssociation.create(:trigger_id => fields.find { |field| field.name.include?(association.keys.first) }.id, - :respond_id => fields.find { |field| field.name == responder }.id) - end - end - end + old_associations = build_old_association_list(new_or_existing_dialog.dialog_fields).flatten + association_list = (associations_to_be_created + old_associations).reject(&:blank?) + build_associations(new_or_existing_dialog, association_list) end end diff --git a/spec/lib/services/dialog_import_service_spec.rb b/spec/lib/services/dialog_import_service_spec.rb index 9d4737d9a34e..37e089b4457e 100644 --- a/spec/lib/services/dialog_import_service_spec.rb +++ b/spec/lib/services/dialog_import_service_spec.rb @@ -454,6 +454,12 @@ end.to change(Dialog, :count).by(1) end + it "creates field associations" do + expect do + dialog_import_service.import(dialogs.first) + end.to change(DialogFieldAssociation, :count).by(1) + end + it 'will raise record invalid for invalid dialog' do dialog_import_service.import(dialogs.first) From ce7064ac432223944acc6686fad087677ee02f41 Mon Sep 17 00:00:00 2001 From: Milan Zazrivec Date: Fri, 5 Jan 2018 17:11:30 +0100 Subject: [PATCH 04/21] Add missing gettext into MiqUserRole https://bugzilla.redhat.com/show_bug.cgi?id=1526440 --- app/models/miq_user_role.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/miq_user_role.rb b/app/models/miq_user_role.rb index 6c867a6d6951..aa4db4de9ae2 100644 --- a/app/models/miq_user_role.rb +++ b/app/models/miq_user_role.rb @@ -22,8 +22,8 @@ class MiqUserRole < ApplicationRecord FIXTURE_YAML = "#{FIXTURE_PATH}.yml" RESTRICTIONS = { - :user => "Only User Owned", - :user_or_group => "Only User or Group Owned" + :user => N_('Only User Owned'), + :user_or_group => N_('Only User or Group Owned') } def feature_identifiers From e442aa8ed310549b8e34adf9cdcceece0a637c18 Mon Sep 17 00:00:00 2001 From: Erik Clarizio Date: Fri, 5 Jan 2018 08:12:05 -0800 Subject: [PATCH 05/21] Handle field association building by name instead of id https://bugzilla.redhat.com/show_bug.cgi?id=1518942 --- app/models/dialog.rb | 12 ++++++- app/models/dialog_group.rb | 1 - lib/services/dialog_import_service.rb | 26 +++++++------- .../services/dialog_import_service_spec.rb | 36 +++++++++++++++++++ spec/models/dialog_spec.rb | 16 +++++++-- 5 files changed, 73 insertions(+), 18 deletions(-) diff --git a/app/models/dialog.rb b/app/models/dialog.rb index 355c863194b6..e841ab901301 100644 --- a/app/models/dialog.rb +++ b/app/models/dialog.rb @@ -124,6 +124,8 @@ def content(target = nil, resource_action = nil, all_attributes = false) # Creates a new item without an ID, # Removes any items not passed in the content. def update_tabs(tabs) + association_list = dialog_import_service.build_association_list("dialog_tabs" => tabs) + transaction do updated_tabs = [] tabs.each do |dialog_tab| @@ -134,11 +136,15 @@ def update_tabs(tabs) updated_tabs << tab end else - updated_tabs << DialogImportService.new.build_dialog_tabs('dialog_tabs' => [dialog_tab]).first + updated_tabs << dialog_import_service.build_dialog_tabs('dialog_tabs' => [dialog_tab]).first end end self.dialog_tabs = updated_tabs end + + transaction do + dialog_import_service.build_associations(self, association_list) + end end def deep_copy(new_attributes = {}) @@ -162,4 +168,8 @@ def reject_if_has_resource_actions raise _("Dialog cannot be deleted because it is connected to other components.") end end + + def dialog_import_service + @dialog_import_service ||= DialogImportService.new + end end diff --git a/app/models/dialog_group.rb b/app/models/dialog_group.rb index ac7ff5778ba3..dcdfc66e54dc 100644 --- a/app/models/dialog_group.rb +++ b/app/models/dialog_group.rb @@ -23,7 +23,6 @@ def update_dialog_fields(fields) resource_action_fields = field.delete('resource_action') || {} update_resource_fields(resource_action_fields, dialog_field) dialog_field.update_attributes(field.except('id', 'href', 'dialog_group_id', 'dialog_field_responders')) - dialog_field.update_dialog_field_responders(field['dialog_field_responders']) updated_fields << dialog_field end else diff --git a/lib/services/dialog_import_service.rb b/lib/services/dialog_import_service.rb index 2ce9d71ae0ea..6fb126640a0a 100644 --- a/lib/services/dialog_import_service.rb +++ b/lib/services/dialog_import_service.rb @@ -97,7 +97,18 @@ def import(dialog) new_dialog end - private + def build_associations(dialog, association_list) + fields = dialog.dialog_fields + association_list.each do |association| + association.values.each do |values| + values.each do |responder| + next if fields.select { |field| field.name == responder }.empty? + DialogFieldAssociation.create(:trigger_id => fields.find { |field| field.name.include?(association.keys.first) }.id, + :respond_id => fields.find { |field| field.name == responder }.id) + end + end + end + end def build_association_list(dialog) associations = [] @@ -111,18 +122,7 @@ def build_association_list(dialog) associations end - def build_associations(dialog, association_list) - fields = dialog.dialog_fields - association_list.each do |association| - association.values.each do |values| - values.each do |responder| - next if fields.select { |field| field.name == responder }.empty? - DialogFieldAssociation.create(:trigger_id => fields.find { |field| field.name.include?(association.keys.first) }.id, - :respond_id => fields.find { |field| field.name == responder }.id) - end - end - end - end + private def create_import_file_upload(file_contents) ImportFileUpload.create.tap do |import_file_upload| diff --git a/spec/lib/services/dialog_import_service_spec.rb b/spec/lib/services/dialog_import_service_spec.rb index 37e089b4457e..f2dc1e5acc7d 100644 --- a/spec/lib/services/dialog_import_service_spec.rb +++ b/spec/lib/services/dialog_import_service_spec.rb @@ -468,4 +468,40 @@ end.to raise_error(ActiveRecord::RecordInvalid, /Validation failed: Name is not unique within region/) end end + + describe "#build_associations" do + let(:dialog) { instance_double("Dialog", :dialog_fields => dialog_fields) } + let(:field1) { instance_double("DialogField", :id => 123, :name => "field1") } + let(:field2) { instance_double("DialogField", :id => 321, :name => "field2") } + let(:dialog_fields) { [field1, field2] } + let(:association_list) { [{"field1" => %w(responder1 field2)}] } + + it "creates dialog field associations" do + expect do + dialog_import_service.build_associations(dialog, association_list) + end.to change(DialogFieldAssociation, :count).by(1) + end + end + + describe "#build_association_list" do + let(:dialog) do + { + "dialog_tabs" => [{ + "dialog_groups" => [{ + "dialog_fields" => [field1, field2, field3] + }] + }] + } + end + + let(:field1) { {"name" => "field1", "dialog_field_responders" => %w(field2 field3)} } + let(:field2) { {"name" => "field2", "dialog_field_responders" => %w(field3)} } + let(:field3) { {"name" => "field3"} } + + it "creates an association list of ids based on names" do + expect(dialog_import_service.build_association_list(dialog)).to eq( + [{"field1" => %w(field2 field3)}, {"field2" => %w(field3)}] + ) + end + end end diff --git a/spec/models/dialog_spec.rb b/spec/models/dialog_spec.rb index 1d03aa3f4102..dca5e9e0352d 100644 --- a/spec/models/dialog_spec.rb +++ b/spec/models/dialog_spec.rb @@ -265,13 +265,15 @@ 'dialog_tab_id' => dialog_tab.first.id, 'dialog_fields' => [{ - 'id' => dialog_field.first.id, - 'dialog_group_id' => dialog_group.first.id + 'id' => dialog_field.first.id, + 'name' => dialog_field.first.name, + 'dialog_group_id' => dialog_group.first.id, + 'dialog_field_responders' => %w(dialog_field2) }] }, { 'label' => 'group 2', 'dialog_fields' => [{ - 'name' => 'dialog_field', + 'name' => 'dialog_field2', 'label' => 'field_label' }] } @@ -301,6 +303,14 @@ dialog.update_tabs(updated_content) expect(dialog.reload.dialog_tabs.count).to eq(2) end + + it "creates associations with the correct ids" do + expect do + dialog.update_tabs(updated_content) + end.to change(DialogFieldAssociation, :count).by(1) + expect(DialogFieldAssociation.first.trigger_id).to eq(dialog_field.first.id) + expect(DialogFieldAssociation.first.respond_id).to eq(dialog_field.first.id + 1) + end end context 'with a dialog tab removed from the dialog tabs collection' do From 2ede836323c8d0fbe48fe1648bda0f14b2314101 Mon Sep 17 00:00:00 2001 From: Piotr Kliczewski Date: Fri, 5 Jan 2018 16:06:32 +0100 Subject: [PATCH 06/21] Reconnect host on provider add We need to make sure that when we remove a provider and add it again we will keep using the same host entities. Without this change add and remove provider cause to duplicate hosts. Fixes https://bugzilla.redhat.com/1528859 --- .../infra_manager.rb | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/app/models/manager_refresh/inventory_collection_default/infra_manager.rb b/app/models/manager_refresh/inventory_collection_default/infra_manager.rb index 201e2a4bc9bf..d9c0608e605c 100644 --- a/app/models/manager_refresh/inventory_collection_default/infra_manager.rb +++ b/app/models/manager_refresh/inventory_collection_default/infra_manager.rb @@ -281,11 +281,47 @@ def hosts(extra_attributes = {}) :builder_params => { :ems_id => ->(persister) { persister.manager.id }, }, + :custom_reconnect_block => reconnect_block } attributes.merge!(extra_attributes) end + def vms(extra_attributes = {}) + attributes = { + :custom_reconnect_block => reconnect_block + } + + super(attributes.merge!(extra_attributes)) + end + + def reconnect_block + lambda do |inventory_collection, inventory_objects_index, attributes_index| + relation = inventory_collection.model_class.where(:ems_id => nil) + + return if relation.count <= 0 + + inventory_objects_index.each_slice(100) do |batch| + relation.where(inventory_collection.manager_ref.first => batch.map(&:first)).each do |record| + index = inventory_collection.object_index_with_keys(inventory_collection.manager_ref_to_cols, record) + + # We need to delete the record from the inventory_objects_index and attributes_index, otherwise it + # would be sent for create. + inventory_object = inventory_objects_index.delete(index) + hash = attributes_index.delete(index) + + record.assign_attributes(hash.except(:id, :type)) + if !inventory_collection.check_changed? || record.changed? + record.save! + inventory_collection.store_updated_records(record) + end + + inventory_object.id = record.id + end + end + end + end + def host_storages(extra_attributes = {}) attributes = { :model_class => ::HostStorage, From 5d87baeeeddc85ccc268eecc6c78c0cbe920169c Mon Sep 17 00:00:00 2001 From: Milan Zazrivec Date: Mon, 8 Jan 2018 16:17:22 +0100 Subject: [PATCH 07/21] Add missing gettext into MiqAction https://bugzilla.redhat.com/show_bug.cgi?id=1526401 --- app/models/miq_action.rb | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/app/models/miq_action.rb b/app/models/miq_action.rb index 1852511f6114..f75e3724dab2 100644 --- a/app/models/miq_action.rb +++ b/app/models/miq_action.rb @@ -8,20 +8,20 @@ class MiqAction < ApplicationRecord silence_warnings do const_set("TYPES", - "create_snapshot" => "Create a Snapshot", - "email" => "Send an E-mail", - "snmp_trap" => "Send an SNMP Trap", - "tag" => "Tag", - "reconfigure_memory" => "Reconfigure Memory", - "reconfigure_cpus" => "Reconfigure CPUs", - "custom_automation" => "Invoke a Custom Automation", - "evaluate_alerts" => "Evaluate Alerts", - "assign_scan_profile" => "Assign Profile to Analysis Task", - "set_custom_attribute" => "Set a Custom Attribute in vCenter", - "inherit_parent_tags" => "Inherit Parent Tags", - "remove_tags" => "Remove Tags", - "delete_snapshots_by_age" => "Delete Snapshots by Age", - "run_ansible_playbook" => "Run Ansible Playbook" + "create_snapshot" => N_("Create a Snapshot"), + "email" => N_("Send an E-mail"), + "snmp_trap" => N_("Send an SNMP Trap"), + "tag" => N_("Tag"), + "reconfigure_memory" => N_("Reconfigure Memory"), + "reconfigure_cpus" => N_("Reconfigure CPUs"), + "custom_automation" => N_("Invoke a Custom Automation"), + "evaluate_alerts" => N_("Evaluate Alerts"), + "assign_scan_profile" => N_("Assign Profile to Analysis Task"), + "set_custom_attribute" => N_("Set a Custom Attribute in vCenter"), + "inherit_parent_tags" => N_("Inherit Parent Tags"), + "remove_tags" => N_("Remove Tags"), + "delete_snapshots_by_age" => N_("Delete Snapshots by Age"), + "run_ansible_playbook" => N_("Run Ansible Playbook") ) end From efaa339af78a230eed513d002ce4487ae162a977 Mon Sep 17 00:00:00 2001 From: Piotr Kliczewski Date: Mon, 8 Jan 2018 17:19:39 +0100 Subject: [PATCH 08/21] Reconnect host on provider add Persister expect all the methods to define collection attributes when performin targeted refresh so moving the lambda. Fixes https://bugzilla.redhat.com/1528859 --- .../infra_manager.rb | 67 ++++++++++++------- 1 file changed, 43 insertions(+), 24 deletions(-) diff --git a/app/models/manager_refresh/inventory_collection_default/infra_manager.rb b/app/models/manager_refresh/inventory_collection_default/infra_manager.rb index d9c0608e605c..b1f4d92a26b0 100644 --- a/app/models/manager_refresh/inventory_collection_default/infra_manager.rb +++ b/app/models/manager_refresh/inventory_collection_default/infra_manager.rb @@ -281,7 +281,30 @@ def hosts(extra_attributes = {}) :builder_params => { :ems_id => ->(persister) { persister.manager.id }, }, - :custom_reconnect_block => reconnect_block + :custom_reconnect_block => lambda do |inventory_collection, inventory_objects_index, attributes_index| + relation = inventory_collection.model_class.where(:ems_id => nil) + + return if relation.count <= 0 + + inventory_objects_index.each_slice(100) do |batch| + relation.where(inventory_collection.manager_ref.first => batch.map(&:first)).each do |record| + index = inventory_collection.object_index_with_keys(inventory_collection.manager_ref_to_cols, record) + + # We need to delete the record from the inventory_objects_index and attributes_index, otherwise it + # would be sent for create. + inventory_object = inventory_objects_index.delete(index) + hash = attributes_index.delete(index) + + record.assign_attributes(hash.except(:id, :type)) + if !inventory_collection.check_changed? || record.changed? + record.save! + inventory_collection.store_updated_records(record) + end + + inventory_object.id = record.id + end + end + end } attributes.merge!(extra_attributes) @@ -289,37 +312,33 @@ def hosts(extra_attributes = {}) def vms(extra_attributes = {}) attributes = { - :custom_reconnect_block => reconnect_block - } + :custom_reconnect_block => lambda do |inventory_collection, inventory_objects_index, attributes_index| + relation = inventory_collection.model_class.where(:ems_id => nil) - super(attributes.merge!(extra_attributes)) - end + return if relation.count <= 0 - def reconnect_block - lambda do |inventory_collection, inventory_objects_index, attributes_index| - relation = inventory_collection.model_class.where(:ems_id => nil) + inventory_objects_index.each_slice(100) do |batch| + relation.where(inventory_collection.manager_ref.first => batch.map(&:first)).each do |record| + index = inventory_collection.object_index_with_keys(inventory_collection.manager_ref_to_cols, record) - return if relation.count <= 0 + # We need to delete the record from the inventory_objects_index and attributes_index, otherwise it + # would be sent for create. + inventory_object = inventory_objects_index.delete(index) + hash = attributes_index.delete(index) - inventory_objects_index.each_slice(100) do |batch| - relation.where(inventory_collection.manager_ref.first => batch.map(&:first)).each do |record| - index = inventory_collection.object_index_with_keys(inventory_collection.manager_ref_to_cols, record) + record.assign_attributes(hash.except(:id, :type)) + if !inventory_collection.check_changed? || record.changed? + record.save! + inventory_collection.store_updated_records(record) + end - # We need to delete the record from the inventory_objects_index and attributes_index, otherwise it - # would be sent for create. - inventory_object = inventory_objects_index.delete(index) - hash = attributes_index.delete(index) - - record.assign_attributes(hash.except(:id, :type)) - if !inventory_collection.check_changed? || record.changed? - record.save! - inventory_collection.store_updated_records(record) + inventory_object.id = record.id end - - inventory_object.id = record.id end end - end + } + + super(attributes.merge!(extra_attributes)) end def host_storages(extra_attributes = {}) From c629003edf87e4608f05d96ff6b0ef28fb495647 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tadej=20Borov=C5=A1ak?= Date: Fri, 5 Jan 2018 14:42:47 +0100 Subject: [PATCH 09/21] Remove duplicated CustomAttributeMixin include Source for ExtManagementSystem contains duplicated include of CustomAttributeMixin module. This commit removes include call that has been added last. --- app/models/ext_management_system.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/app/models/ext_management_system.rb b/app/models/ext_management_system.rb index 3d52177f4293..b82f22e9dad7 100644 --- a/app/models/ext_management_system.rb +++ b/app/models/ext_management_system.rb @@ -30,7 +30,6 @@ def self.supported_types_and_descriptions_hash belongs_to :provider has_many :child_managers, :class_name => 'ExtManagementSystem', :foreign_key => 'parent_ems_id' - include CustomAttributeMixin belongs_to :tenant has_many :container_deployments, :foreign_key => :deployed_on_ems_id, :inverse_of => :deployed_on_ems has_many :endpoints, :as => :resource, :dependent => :destroy, :autosave => true From 7697bbece8d00b69d45f0d59bb3173c88b9333ba Mon Sep 17 00:00:00 2001 From: Douglas Gabriel Date: Thu, 21 Dec 2017 15:27:44 -0300 Subject: [PATCH 10/21] adding hostname format validation --- Gemfile | 2 +- app/models/ext_management_system.rb | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Gemfile b/Gemfile index 9346ecea9be4..2af1d1f242ba 100644 --- a/Gemfile +++ b/Gemfile @@ -46,7 +46,7 @@ gem "manageiq-messaging", :require => false, :git = gem "manageiq-network_discovery", "~>0.1.2", :require => false gem "memoist", "~>0.15.0", :require => false gem "mime-types", "~>2.6.1", :path => File.expand_path("mime-types-redirector", __dir__) -gem "more_core_extensions", "~>3.3" +gem "more_core_extensions", "~>3.5" gem "nakayoshi_fork", "~>0.0.3" # provides a more CoW friendly fork (GC a few times before fork) gem "net-ldap", "~>0.14.0", :require => false gem "net-ping", "~>1.7.4", :require => false diff --git a/app/models/ext_management_system.rb b/app/models/ext_management_system.rb index 3d52177f4293..342518e92de1 100644 --- a/app/models/ext_management_system.rb +++ b/app/models/ext_management_system.rb @@ -76,7 +76,7 @@ def self.supported_types_and_descriptions_hash validates :name, :presence => true, :uniqueness => {:scope => [:tenant_id]} validates :hostname, :presence => true, :if => :hostname_required? - validate :hostname_uniqueness_valid?, :if => :hostname_required? + validate :hostname_uniqueness_valid?, :hostname_format_valid?, :if => :hostname_required? scope :with_eligible_manager_types, ->(eligible_types) { where(:type => eligible_types) } @@ -92,6 +92,11 @@ def hostname_uniqueness_valid? errors.add(:hostname, N_("has to be unique per provider type")) if existing_hostnames.include?(hostname.downcase) end + def hostname_format_valid? + return if hostname.ipaddress? || hostname.hostname? + errors.add(:hostname, _("format is invalid.")) + end + include NewWithTypeStiMixin include UuidMixin include EmsRefresh::Manager From 0d6e97436173326912dd8fdd6e121bf8fed9ca53 Mon Sep 17 00:00:00 2001 From: Tina Fitzgerald Date: Mon, 8 Jan 2018 14:33:58 -0500 Subject: [PATCH 11/21] Prevent quota error for invalid service_template. Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1531914 --- app/models/mixins/miq_provision_quota_mixin.rb | 1 + .../models/service_template_provision_request_quota_spec.rb | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/app/models/mixins/miq_provision_quota_mixin.rb b/app/models/mixins/miq_provision_quota_mixin.rb index 267969ecabff..f64f06a22a14 100644 --- a/app/models/mixins/miq_provision_quota_mixin.rb +++ b/app/models/mixins/miq_provision_quota_mixin.rb @@ -319,6 +319,7 @@ def vm_quota_values(pr, result) end def service_quota_values(request, result) + return unless request.service_template request.service_template.service_resources.each do |sr| if request.service_template.service_type == 'composite' bundle_quota_values(sr, result) diff --git a/spec/models/service_template_provision_request_quota_spec.rb b/spec/models/service_template_provision_request_quota_spec.rb index 77b8894658d1..9674e03c991d 100644 --- a/spec/models/service_template_provision_request_quota_spec.rb +++ b/spec/models/service_template_provision_request_quota_spec.rb @@ -104,6 +104,12 @@ def create_service_bundle(user, items, options = {}) context "active_provisions_by_tenant," do let(:quota_method) { :active_provisions_by_tenant } it_behaves_like "check_quota" + + it "invalid service_template does not raise error" do + requests = load_queue + requests.first.update_attributes(:service_template => nil) + expect { request.check_quota(quota_method) }.not_to raise_error + end end context "active_provisions_by_group," do From 14830a7ac7567bbccb1fd13f191f20566e79a3ee Mon Sep 17 00:00:00 2001 From: Drew Bomhof Date: Wed, 20 Dec 2017 16:58:01 -0500 Subject: [PATCH 12/21] Added get_targets_for base class methods 1. Turns on RBAC filtering by default at the base class level for all allowed_ methods in the CloudManager class https://bugzilla.redhat.com/show_bug.cgi?id=1514237 --- .../providers/cloud_manager/provision_workflow.rb | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/app/models/manageiq/providers/cloud_manager/provision_workflow.rb b/app/models/manageiq/providers/cloud_manager/provision_workflow.rb index 7da381ecb5ae..0821296f42a3 100644 --- a/app/models/manageiq/providers/cloud_manager/provision_workflow.rb +++ b/app/models/manageiq/providers/cloud_manager/provision_workflow.rb @@ -22,7 +22,9 @@ def allowed_cloud_subnets(_options = {}) az_id = src[:availability_zone_id].to_i if (cn = CloudNetwork.find_by(:id => src[:cloud_network_id])) - cn.cloud_subnets.each_with_object({}) do |cs, hash| + + targets = get_targets_for_source(cn, :cloud_filter, CloudNetwork, 'cloud_subnets') + targets.each_with_object({}) do |cs, hash| next if !az_id.zero? && az_id != cs.availability_zone_id hash[cs.id] = "#{cs.name} (#{cs.cidr}) | #{cs.availability_zone.try(:name)}" end @@ -33,10 +35,8 @@ def allowed_cloud_subnets(_options = {}) def allowed_guest_access_key_pairs(_options = {}) source = load_ar_obj(get_source_vm) - ems = source.try(:ext_management_system) - - return {} if ems.nil? - ems.key_pairs.each_with_object({}) { |kp, h| h[kp.id] = kp.name } + targets = get_targets_for_ems(source, :cloud_filter, ManageIQ::Providers, 'key_pairs') + targets.each_with_object({}) { |kp, h| h[kp.id] = kp.name } end def allowed_security_groups(_options = {}) @@ -51,8 +51,8 @@ def allowed_security_groups(_options = {}) def allowed_floating_ip_addresses(_options = {}) return {} unless (src_obj = provider_or_tenant_object) - - src_obj.floating_ips.available.each_with_object({}) do |ip, h| + targets = get_targets_for_source(src_obj, :cloud_filter, FloatingIp, 'floating_ips.available') + targets.each_with_object({}) do |ip, h| h[ip.id] = ip.address end end From 449f2eea8149faba6fcdaf6d974116259eb52ed0 Mon Sep 17 00:00:00 2001 From: Drew Bomhof Date: Thu, 21 Dec 2017 14:43:58 -0500 Subject: [PATCH 13/21] Added Specs around the RBAC'd allowed_ methods --- .../cloud_manager/provision_workflow_spec.rb | 151 ++++++++++++++++++ 1 file changed, 151 insertions(+) create mode 100644 spec/models/manageiq/providers/cloud_manager/provision_workflow_spec.rb diff --git a/spec/models/manageiq/providers/cloud_manager/provision_workflow_spec.rb b/spec/models/manageiq/providers/cloud_manager/provision_workflow_spec.rb new file mode 100644 index 000000000000..5f5bd9ec2e59 --- /dev/null +++ b/spec/models/manageiq/providers/cloud_manager/provision_workflow_spec.rb @@ -0,0 +1,151 @@ +describe ManageIQ::Providers::CloudManager::ProvisionWorkflow do + include Spec::Support::WorkflowHelper + + let(:admin) { FactoryGirl.create(:user_with_group) } + let(:ems) { FactoryGirl.create(:ems_cloud) } + let(:template) { FactoryGirl.create(:miq_template, :name => "template", :ext_management_system => ems) } + let(:workflow) do + stub_dialog + allow_any_instance_of(User).to receive(:get_timezone).and_return(Time.zone) + allow_any_instance_of(described_class).to receive(:update_field_visibility) + described_class.new({:src_vm_id => template.id}, admin.userid) + end + + context "with empty relationships" do + it "#allowed_availability_zones" do + expect(workflow.allowed_availability_zones).to eq({}) + end + + it "#allowed_guest_access_key_pairs" do + expect(workflow.allowed_guest_access_key_pairs).to eq({}) + end + + it "#allowed_security_groups" do + expect(workflow.allowed_security_groups).to eq({}) + end + end + + context "with valid relationships" do + it "#allowed_availability_zones" do + az = FactoryGirl.create(:availability_zone) + ems.availability_zones << az + expect(workflow.allowed_availability_zones).to be_empty + end + + it "#allowed_guest_access_key_pairs" do + kp = AuthPrivateKey.create(:name => "auth_1") + ems.key_pairs << kp + expect(workflow.allowed_guest_access_key_pairs).to eq(kp.id => kp.name) + end + end + + context "without applied tags" do + context "availability_zones" do + it "#get_targets_for_ems" do + az = FactoryGirl.create(:availability_zone) + ems.availability_zones << az + filtered = workflow.send(:get_targets_for_ems, ems, :cloud_filter, AvailabilityZone, + 'availability_zones') + expect(filtered.size).to eq(1) + expect(filtered.first.name).to eq(az.name) + end + + it "returns an empty array when no targets are found" do + filtered = workflow.send(:get_targets_for_ems, ems, :cloud_filter, AvailabilityZone, + 'availability_zones') + expect(filtered).to eq([]) + end + end + + context "floating_ips" do + it "#get_targets_for_source" do + fip1 = FactoryGirl.create(:floating_ip, :cloud_network_only => true, + :ext_management_system => ems.network_manager) + filtered = workflow.send(:get_targets_for_source, ems, :cloud_filter, FloatingIp, + 'floating_ips.available') + expect(filtered.size).to eq(1) + expect(filtered.first.name).to eq(fip1.name) + end + end + end + + context "with applied tags" do + before do + FactoryGirl.create(:classification_cost_center_with_tags) + admin.current_group.entitlement = Entitlement.create!(:filters => {'managed' => [['/managed/cc/001']], + 'belongsto' => []}) + + 2.times { FactoryGirl.create(:availability_zone, :ems_id => ems.id) } + 2.times do + FactoryGirl.create(:security_group, :name => "sgb_1", + :ext_management_system => ems.network_manager) + end + ems.flavors << FactoryGirl.create(:flavor, :name => "t1.micro", :supports_32_bit => true, + :supports_64_bit => true) + ems.flavors << FactoryGirl.create(:flavor, :name => "m1.large", :supports_32_bit => false, + :supports_64_bit => true) + + tagged_zone = ems.availability_zones.first + tagged_flavor = ems.flavors.first + Classification.classify(tagged_zone, 'cc', '001') + Classification.classify(tagged_flavor, 'cc', '001') + end + + context "availability_zones" do + it "#get_targets_for_ems" do + expect(ems.availability_zones.size).to eq(2) + expect(ems.availability_zones.first.tags.size).to eq(1) + expect(ems.availability_zones.last.tags.size).to eq(0) + filtered = workflow.send(:get_targets_for_ems, ems, :cloud_filter, AvailabilityZone, + 'availability_zones') + expect(filtered.size).to eq(1) + end + end + end + + context "with VPC relationships" do + before do + @az1 = FactoryGirl.create(:availability_zone, :ext_management_system => ems) + @az2 = FactoryGirl.create(:availability_zone, :ext_management_system => ems) + @az3 = FactoryGirl.create(:availability_zone, :ext_management_system => ems) + + @cn1 = FactoryGirl.create(:cloud_network, :ext_management_system => ems.network_manager) + + @cs1 = FactoryGirl.create(:cloud_subnet, :cloud_network => @cn1, + :availability_zone => @az1, + :ext_management_system => ems.network_manager) + @cs2 = FactoryGirl.create(:cloud_subnet, :cloud_network => @cn1, + :availability_zone => @az2, + :ext_management_system => ems.network_manager) + + @ip1 = FactoryGirl.create(:floating_ip, :cloud_network_only => true, + :ext_management_system => ems.network_manager) + @ip2 = FactoryGirl.create(:floating_ip, :cloud_network_only => false, + :ext_management_system => ems.network_manager) + end + + context "#allowed_cloud_subnets" do + it "without a cloud_network", :skip_before do + expect(workflow.allowed_cloud_subnets.length).to be_zero + end + + it "with a cloud_network" do + workflow.values[:cloud_network] = [@cn1.id, @cn1.name] + expect(workflow.allowed_cloud_subnets.length).to eq(2) + end + + it "with an cloud_network and Availability Zone" do + workflow.values[:cloud_network] = [@cn1.id, @cn1.name] + workflow.values[:placement_availability_zone] = [@az1.id, @az1.name] + + expect(workflow.allowed_cloud_subnets.length).to eq(1) + end + end + + context "#allowed_floating_ip_addresses" do + it "returns floating_ip_addresses" do + expect(workflow.allowed_floating_ip_addresses).to eq(@ip1.id => @ip1.address, @ip2.id => @ip2.address) + end + end + end +end From fb066087e7a2a6671dfe97b697636a0a8d3a2eda Mon Sep 17 00:00:00 2001 From: Nick Carboni Date: Mon, 8 Jan 2018 17:03:05 -0500 Subject: [PATCH 14/21] Don't expect nil values in the container logger output Previously this spec would fail if HOSTNAME was not set --- spec/lib/vmdb/loggers/container_logger_spec.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/spec/lib/vmdb/loggers/container_logger_spec.rb b/spec/lib/vmdb/loggers/container_logger_spec.rb index 6a0f6563d87c..6f6366b59cf5 100644 --- a/spec/lib/vmdb/loggers/container_logger_spec.rb +++ b/spec/lib/vmdb/loggers/container_logger_spec.rb @@ -2,7 +2,7 @@ it "stuff" do time = Time.now result = described_class.new.call("INFO", time, "some_program", "testing 1, 2, 3") - expect(JSON.parse(result)).to eq( + expected = { "@timestamp" => time.strftime("%Y-%m-%dT%H:%M:%S.%6N "), "hostname" => ENV["HOSTNAME"], "level" => "info", @@ -10,6 +10,7 @@ "pid" => $PROCESS_ID, "service" => "some_program", "tid" => Thread.current.object_id.to_s(16), - ) + }.delete_nils + expect(JSON.parse(result)).to eq(expected) end end From 4ee58cdca3427041d3a0d95df6b5a4e9d8d109c4 Mon Sep 17 00:00:00 2001 From: Brandon Dunne Date: Tue, 9 Jan 2018 09:42:14 -0500 Subject: [PATCH 15/21] Fix typo --- spec/models/miq_alert_status_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/models/miq_alert_status_spec.rb b/spec/models/miq_alert_status_spec.rb index 9b810cfd048f..23e5ed52465c 100644 --- a/spec/models/miq_alert_status_spec.rb +++ b/spec/models/miq_alert_status_spec.rb @@ -21,7 +21,7 @@ describe "Validation" do it "should reject unexpected severities" do expect do - FactoryGirl.create(:miq_alert_status, :severity => 'awsome') + FactoryGirl.create(:miq_alert_status, :severity => 'awesome') end.to raise_error(ActiveRecord::RecordInvalid, "Validation failed: Severity must be accepted") end end From 6b8d51d7982d783a6fc3fef5169b7b59fe513209 Mon Sep 17 00:00:00 2001 From: Brandon Dunne Date: Tue, 9 Jan 2018 10:25:57 -0500 Subject: [PATCH 16/21] Remove unnecessary block syntax in factory definition --- spec/factories/account.rb | 3 +- spec/factories/auth_key_pair_amazon.rb | 3 +- spec/factories/auth_key_pair_cloud.rb | 3 +- spec/factories/auth_key_pair_openstack.rb | 3 +- spec/factories/availability_zone.rb | 12 +-- spec/factories/cloud_tenants.rb | 3 +- spec/factories/cloud_volume_backup.rb | 3 +- spec/factories/container_nodes.rb | 3 +- spec/factories/containers.rb | 3 +- spec/factories/custom_attribute.rb | 3 +- spec/factories/dialog_field.rb | 18 ++--- spec/factories/ext_management_system.rb | 93 ++++++++--------------- spec/factories/guest_device.rb | 3 +- spec/factories/host_aggregate.rb | 3 +- spec/factories/middleware_datasource.rb | 6 +- spec/factories/middleware_domain.rb | 3 +- spec/factories/middleware_messaging.rb | 6 +- spec/factories/middleware_server_group.rb | 3 +- spec/factories/middleware_servers.rb | 9 +-- spec/factories/miq_product_feature.rb | 3 +- spec/factories/miq_report_result.rb | 3 +- spec/factories/miq_schedule_worker.rb | 3 +- spec/factories/miq_task.rb | 3 +- spec/factories/orchestration_stack.rb | 33 +++----- spec/factories/physical_infra_manager.rb | 3 +- spec/factories/pxe_image.rb | 7 +- spec/factories/scan_item.rb | 3 +- spec/factories/service.rb | 15 +--- spec/factories/service_template.rb | 9 +-- spec/factories/vmdb_metric.rb | 3 +- spec/factories/vmdb_table.rb | 11 +-- 31 files changed, 89 insertions(+), 190 deletions(-) diff --git a/spec/factories/account.rb b/spec/factories/account.rb index 964ace62abf7..9bf1bd18346d 100644 --- a/spec/factories/account.rb +++ b/spec/factories/account.rb @@ -1,6 +1,5 @@ FactoryGirl.define do - factory :account do - end + factory :account factory :account_user, :parent => :account do name 'bob' diff --git a/spec/factories/auth_key_pair_amazon.rb b/spec/factories/auth_key_pair_amazon.rb index 1572d1e46e4d..11b9ecd1f88c 100644 --- a/spec/factories/auth_key_pair_amazon.rb +++ b/spec/factories/auth_key_pair_amazon.rb @@ -1,4 +1,3 @@ FactoryGirl.define do - factory :auth_key_pair_amazon, :class => "ManageIQ::Providers::Amazon::CloudManager::AuthKeyPair" do - end + factory :auth_key_pair_amazon, :class => "ManageIQ::Providers::Amazon::CloudManager::AuthKeyPair" end diff --git a/spec/factories/auth_key_pair_cloud.rb b/spec/factories/auth_key_pair_cloud.rb index ed7acc898946..bc34953ff397 100644 --- a/spec/factories/auth_key_pair_cloud.rb +++ b/spec/factories/auth_key_pair_cloud.rb @@ -1,4 +1,3 @@ FactoryGirl.define do - factory :auth_key_pair_cloud, :class => "ManageIQ::Providers::CloudManager::AuthKeyPair" do - end + factory :auth_key_pair_cloud, :class => "ManageIQ::Providers::CloudManager::AuthKeyPair" end diff --git a/spec/factories/auth_key_pair_openstack.rb b/spec/factories/auth_key_pair_openstack.rb index 88d411535ce8..cf17941e7e70 100644 --- a/spec/factories/auth_key_pair_openstack.rb +++ b/spec/factories/auth_key_pair_openstack.rb @@ -1,4 +1,3 @@ FactoryGirl.define do - factory :auth_key_pair_openstack, :class => "ManageIQ::Providers::Openstack::CloudManager::AuthKeyPair" do - end + factory :auth_key_pair_openstack, :class => "ManageIQ::Providers::Openstack::CloudManager::AuthKeyPair" end diff --git a/spec/factories/availability_zone.rb b/spec/factories/availability_zone.rb index 32710f014abd..b627abbcdb1e 100644 --- a/spec/factories/availability_zone.rb +++ b/spec/factories/availability_zone.rb @@ -3,21 +3,17 @@ sequence(:name) { |n| "availability_zone_#{seq_padded_for_sorting(n)}" } end - factory :availability_zone_amazon, :parent => :availability_zone, :class => "ManageIQ::Providers::Amazon::CloudManager::AvailabilityZone" do - end + factory :availability_zone_amazon, :parent => :availability_zone, :class => "ManageIQ::Providers::Amazon::CloudManager::AvailabilityZone" factory :availability_zone_azure, :parent => :availability_zone, :class => "ManageIQ::Providers::Azure::CloudManager::AvailabilityZone" - factory :availability_zone_openstack, :parent => :availability_zone, :class => "ManageIQ::Providers::Openstack::CloudManager::AvailabilityZone" do - end + factory :availability_zone_openstack, :parent => :availability_zone, :class => "ManageIQ::Providers::Openstack::CloudManager::AvailabilityZone" - factory :availability_zone_openstack_null, :parent => :availability_zone_openstack, :class => "ManageIQ::Providers::Openstack::CloudManager::AvailabilityZoneNull" do - end + factory :availability_zone_openstack_null, :parent => :availability_zone_openstack, :class => "ManageIQ::Providers::Openstack::CloudManager::AvailabilityZoneNull" - factory :availability_zone_google, :parent => :availability_zone, :class => "ManageIQ::Providers::Google::CloudManager::AvailabilityZone" do - end + factory :availability_zone_google, :parent => :availability_zone, :class => "ManageIQ::Providers::Google::CloudManager::AvailabilityZone" factory :availability_zone_vmware, :parent => :availability_zone, diff --git a/spec/factories/cloud_tenants.rb b/spec/factories/cloud_tenants.rb index b2b486057962..2acd52a3ed14 100644 --- a/spec/factories/cloud_tenants.rb +++ b/spec/factories/cloud_tenants.rb @@ -5,6 +5,5 @@ sequence(:ems_ref) { |n| "ems_ref_#{seq_padded_for_sorting(n)}" } end - factory :cloud_tenant_openstack, :class => "ManageIQ::Providers::Openstack::CloudManager::CloudTenant", :parent => :cloud_tenant do - end + factory :cloud_tenant_openstack, :class => "ManageIQ::Providers::Openstack::CloudManager::CloudTenant", :parent => :cloud_tenant end diff --git a/spec/factories/cloud_volume_backup.rb b/spec/factories/cloud_volume_backup.rb index 59eac7cf1e36..75b4b6fce1cd 100644 --- a/spec/factories/cloud_volume_backup.rb +++ b/spec/factories/cloud_volume_backup.rb @@ -4,6 +4,5 @@ sequence(:ems_ref) { |n| "ems_ref_#{seq_padded_for_sorting(n)}" } end - factory :cloud_volume_backup_openstack, :parent => :cloud_volume_backup, :class => "ManageIQ::Providers::Openstack::CloudManager::CloudVolumeBackup" do - end + factory :cloud_volume_backup_openstack, :parent => :cloud_volume_backup, :class => "ManageIQ::Providers::Openstack::CloudManager::CloudVolumeBackup" end diff --git a/spec/factories/container_nodes.rb b/spec/factories/container_nodes.rb index 5b41a153eea1..11edaccab66a 100644 --- a/spec/factories/container_nodes.rb +++ b/spec/factories/container_nodes.rb @@ -8,6 +8,5 @@ factory :kubernetes_node, :aliases => ['app/models/manageiq/providers/kubernetes/container_manager/container_node'], :class => 'ManageIQ::Providers::Kubernetes::ContainerManager::ContainerNode', - :parent => :container_node do - end + :parent => :container_node end diff --git a/spec/factories/containers.rb b/spec/factories/containers.rb index 1efcc99a419d..ce3cc8006bc4 100644 --- a/spec/factories/containers.rb +++ b/spec/factories/containers.rb @@ -6,6 +6,5 @@ factory :kubernetes_container, :aliases => ['app/models/manageiq/providers/kubernetes/container_manager/container'], :class => 'ManageIQ::Providers::Kubernetes::ContainerManager::Container', - :parent => :container do - end + :parent => :container end diff --git a/spec/factories/custom_attribute.rb b/spec/factories/custom_attribute.rb index 7707e39c0aef..5be8725c01e0 100644 --- a/spec/factories/custom_attribute.rb +++ b/spec/factories/custom_attribute.rb @@ -1,6 +1,5 @@ FactoryGirl.define do - factory :custom_attribute do - end + factory :custom_attribute factory :miq_custom_attribute, :parent => :custom_attribute do source 'EVM' diff --git a/spec/factories/dialog_field.rb b/spec/factories/dialog_field.rb index 5b61c75e6c27..9ae703793550 100644 --- a/spec/factories/dialog_field.rb +++ b/spec/factories/dialog_field.rb @@ -3,18 +3,10 @@ name "Dialog Field" end - factory :dialog_field_text_box, :parent => :dialog_field, :class => "DialogFieldTextBox" do - end - - factory :dialog_field_tag_control, :parent => :dialog_field, :class => "DialogFieldTagControl" do - end - - factory :dialog_field_button, :parent => :dialog_field, :class => "DialogFieldButton" do - end - - factory :dialog_field_sorted_item, :parent => :dialog_field, :class => "DialogFieldSortedItem" do - end + factory :dialog_field_button, :parent => :dialog_field, :class => "DialogFieldButton" + factory :dialog_field_sorted_item, :parent => :dialog_field, :class => "DialogFieldSortedItem" + factory :dialog_field_tag_control, :parent => :dialog_field, :class => "DialogFieldTagControl" + factory :dialog_field_text_box, :parent => :dialog_field, :class => "DialogFieldTextBox" - factory :dialog_field_drop_down_list, :parent => :dialog_field_sorted_item, :class => "DialogFieldDropDownList" do - end + factory :dialog_field_drop_down_list, :parent => :dialog_field_sorted_item, :class => "DialogFieldDropDownList" end diff --git a/spec/factories/ext_management_system.rb b/spec/factories/ext_management_system.rb index 65a059e809ce..6b0bdb119efd 100644 --- a/spec/factories/ext_management_system.rb +++ b/spec/factories/ext_management_system.rb @@ -35,102 +35,86 @@ factory :ems_infra, :aliases => ["manageiq/providers/infra_manager"], :class => "ManageIQ::Providers::InfraManager", - :parent => :ext_management_system do - end + :parent => :ext_management_system factory :ems_physical_infra, :aliases => ["manageiq/providers/physical_infra_manager"], :class => "ManageIQ::Providers::PhysicalInfraManager", - :parent => :ext_management_system do - end + :parent => :ext_management_system factory :ems_cloud, :aliases => ["manageiq/providers/cloud_manager"], :class => "ManageIQ::Providers::CloudManager", - :parent => :ext_management_system do - end + :parent => :ext_management_system factory :ems_datawarehouse, :aliases => ["manageiq/providers/datawarehouse_manager"], :class => "ManageIQ::Providers::DatawarehouseManager", - :parent => :ext_management_system do - end + :parent => :ext_management_system factory :ems_network, :aliases => ["manageiq/providers/network_manager"], :class => "ManageIQ::Providers::NetworkManager", - :parent => :ext_management_system do - end + :parent => :ext_management_system factory :ems_storage, :aliases => ["manageiq/providers/storage_manager"], :class => "ManageIQ::Providers::StorageManager", - :parent => :ext_management_system do - end + :parent => :ext_management_system factory :ems_cinder, :aliases => ["manageiq/providers/storage_manager/cinder_manager"], :class => "ManageIQ::Providers::StorageManager::CinderManager", - :parent => :ext_management_system do - end + :parent => :ext_management_system factory :ems_swift, :aliases => ["manageiq/providers/storage_manager/swift_manager"], :class => "ManageIQ::Providers::StorageManager::SwiftManager", - :parent => :ext_management_system do - end + :parent => :ext_management_system factory :ems_container, :aliases => ["manageiq/providers/container_manager"], :class => "ManageIQ::Providers::ContainerManager", - :parent => :ext_management_system do - end + :parent => :ext_management_system factory :ems_middleware, :aliases => ["manageiq/providers/middleware_manager"], :class => "ManageIQ::Providers::MiddlewareManager", - :parent => :ext_management_system do - end + :parent => :ext_management_system factory :configuration_manager, :aliases => ["manageiq/providers/configuration_manager"], :class => "ManageIQ::Providers::ConfigurationManager", - :parent => :ext_management_system do - end + :parent => :ext_management_system # Automation managers factory :automation_manager, :aliases => ["manageiq/providers/automation_manager"], :class => "ManageIQ::Providers::AutomationManager", - :parent => :ext_management_system do - end + :parent => :ext_management_system factory :external_automation_manager, :aliases => ["manageiq/providers/external_automation_manager"], :class => "ManageIQ::Providers::ExternalAutomationManager", - :parent => :automation_manager do - end + :parent => :automation_manager factory :embedded_automation_manager, :aliases => ["manageiq/providers/embedded_automation_manager"], :class => "ManageIQ::Providers::EmbeddedAutomationManager", - :parent => :automation_manager do - end + :parent => :automation_manager factory :provisioning_manager, :aliases => ["manageiq/providers/provisioning_manager"], :class => "ManageIQ::Providers::ProvisioningManager", - :parent => :ext_management_system do - end + :parent => :ext_management_system # Leaf classes for ems_infra factory :ems_vmware, :aliases => ["manageiq/providers/vmware/infra_manager"], :class => "ManageIQ::Providers::Vmware::InfraManager", - :parent => :ems_infra do - end + :parent => :ems_infra factory :ems_vmware_with_authentication, :parent => :ems_vmware do @@ -142,8 +126,7 @@ factory :ems_microsoft, :aliases => ["manageiq/providers/microsoft/infra_manager"], :class => "ManageIQ::Providers::Microsoft::InfraManager", - :parent => :ems_infra do - end + :parent => :ems_infra factory :ems_microsoft_with_authentication, :parent => :ems_microsoft do @@ -155,8 +138,7 @@ factory :ems_redhat, :aliases => ["manageiq/providers/redhat/infra_manager"], :class => "ManageIQ::Providers::Redhat::InfraManager", - :parent => :ems_infra do - end + :parent => :ems_infra factory :ems_redhat_v3, :parent => :ems_redhat do @@ -185,8 +167,7 @@ factory :ems_openstack_infra, :aliases => ["manageiq/providers/openstack/infra_manager"], :class => "ManageIQ::Providers::Openstack::InfraManager", - :parent => :ems_infra do - end + :parent => :ems_infra factory :ems_openstack_infra_with_stack, :parent => :ems_openstack_infra do @@ -216,14 +197,12 @@ factory :ems_vmware_cloud, :aliases => ["manageiq/providers/vmware/cloud_manager"], :class => "ManageIQ::Providers::Vmware::CloudManager", - :parent => :ems_cloud do - end + :parent => :ems_cloud factory :ems_vmware_cloud_network, :aliases => ["manageiq/providers/vmware/network_manager"], :class => "ManageIQ::Providers::Vmware::NetworkManager", - :parent => :ems_cloud do - end + :parent => :ems_cloud # Leaf classes for ems_cloud @@ -258,14 +237,12 @@ factory :ems_azure, :aliases => ["manageiq/providers/azure/cloud_manager"], :class => "ManageIQ::Providers::Azure::CloudManager", - :parent => :ems_cloud do - end + :parent => :ems_cloud factory :ems_azure_network, :aliases => ["manageiq/providers/azure/network_manager"], :class => "ManageIQ::Providers::Azure::NetworkManager", - :parent => :ems_network do - end + :parent => :ems_network factory :ems_azure_with_authentication, :parent => :ems_azure do @@ -279,8 +256,7 @@ factory :ems_openstack, :aliases => ["manageiq/providers/openstack/cloud_manager"], :class => "ManageIQ::Providers::Openstack::CloudManager", - :parent => :ems_cloud do - end + :parent => :ems_cloud factory :ems_openstack_with_authentication, :parent => :ems_openstack do @@ -293,14 +269,12 @@ factory :ems_openstack_network, :aliases => ["manageiq/providers/openstack/network_manager"], :class => "ManageIQ::Providers::Openstack::NetworkManager", - :parent => :ems_network do - end + :parent => :ems_network factory :ems_nuage_network, :aliases => ["manageiq/providers/nuage/network_manager"], :class => "ManageIQ::Providers::Nuage::NetworkManager", - :parent => :ems_network do - end + :parent => :ems_network factory :ems_google, :aliases => ["manageiq/providers/google/cloud_manager"], @@ -328,8 +302,7 @@ factory :ems_kubernetes, :aliases => ["manageiq/providers/kubernetes/container_manager"], :class => "ManageIQ::Providers::Kubernetes::ContainerManager", - :parent => :ems_container do - end + :parent => :ems_container factory :ems_kubernetes_with_authentication_err, :parent => :ems_kubernetes do @@ -342,8 +315,7 @@ factory :ems_openshift, :aliases => ["manageiq/providers/openshift/container_manager"], :class => "ManageIQ::Providers::Openshift::ContainerManager", - :parent => :ems_container do - end + :parent => :ems_container # Leaf classes for configuration_manager @@ -380,22 +352,19 @@ factory :provisioning_manager_foreman, :aliases => ["manageiq/providers/foreman/provisioning_manager"], :class => "ManageIQ::Providers::Foreman::ProvisioningManager", - :parent => :provisioning_manager do - end + :parent => :provisioning_manager # Leaf classes for middleware_manager factory :ems_hawkular, :aliases => ["manageiq/providers/hawkular/middleware_manager"], :class => "ManageIQ::Providers::Hawkular::MiddlewareManager", - :parent => :ems_middleware do - end + :parent => :ems_middleware # Leaf classes for datawarehouse_manager factory :ems_hawkular_datawarehouse, :aliases => ["manageiq/providers/hawkular/datawarehouse_manager"], :class => "ManageIQ::Providers::Hawkular::DatawarehouseManager", - :parent => :ems_datawarehouse do - end + :parent => :ems_datawarehouse end diff --git a/spec/factories/guest_device.rb b/spec/factories/guest_device.rb index b80d64644e8d..aa4d6ad8032d 100644 --- a/spec/factories/guest_device.rb +++ b/spec/factories/guest_device.rb @@ -1,6 +1,5 @@ FactoryGirl.define do - factory :guest_device do - end + factory :guest_device factory :guest_device_nic, :parent => :guest_device do sequence(:device_name) { |n| "Network Adapter #{seq_padded_for_sorting(n)}" } diff --git a/spec/factories/host_aggregate.rb b/spec/factories/host_aggregate.rb index e1a0a2145935..84882e358da0 100644 --- a/spec/factories/host_aggregate.rb +++ b/spec/factories/host_aggregate.rb @@ -3,6 +3,5 @@ sequence(:name) { |n| " host_aggregate_#{seq_padded_for_sorting(n)}" } end - factory :host_aggregate_openstack, :parent => :host_aggregate, :class => "ManageIQ::Providers::Openstack::CloudManager::HostAggregate" do - end + factory :host_aggregate_openstack, :parent => :host_aggregate, :class => "ManageIQ::Providers::Openstack::CloudManager::HostAggregate" end diff --git a/spec/factories/middleware_datasource.rb b/spec/factories/middleware_datasource.rb index ac9113e9b1aa..607a7e1e1514 100644 --- a/spec/factories/middleware_datasource.rb +++ b/spec/factories/middleware_datasource.rb @@ -1,12 +1,10 @@ FactoryGirl.define do - factory :middleware_datasource do - end + factory :middleware_datasource factory :hawkular_middleware_datasource, :aliases => ['app/models/manageiq/providers/hawkular/middleware_manager/middleware_datasource'], :class => 'ManageIQ::Providers::Hawkular::MiddlewareManager::MiddlewareDatasource', - :parent => :middleware_datasource do - end + :parent => :middleware_datasource factory :hawkular_middleware_datasource_initialized, :parent => :hawkular_middleware_datasource do diff --git a/spec/factories/middleware_domain.rb b/spec/factories/middleware_domain.rb index debc7aadd837..c663ff5c25ce 100644 --- a/spec/factories/middleware_domain.rb +++ b/spec/factories/middleware_domain.rb @@ -6,6 +6,5 @@ factory :hawkular_middleware_domain, :aliases => ['app/models/manageiq/providers/hawkular/middleware_manager/middleware_domain'], :class => 'ManageIQ::Providers::Hawkular::MiddlewareManager::MiddlewareDomain', - :parent => :middleware_domain do - end + :parent => :middleware_domain end diff --git a/spec/factories/middleware_messaging.rb b/spec/factories/middleware_messaging.rb index b1a6c6deba91..0ae5d1a5efc9 100644 --- a/spec/factories/middleware_messaging.rb +++ b/spec/factories/middleware_messaging.rb @@ -1,12 +1,10 @@ FactoryGirl.define do - factory :middleware_messaging do - end + factory :middleware_messaging factory :hawkular_middleware_messaging, :aliases => ['app/models/manageiq/providers/hawkular/middleware_manager/middleware_messaging'], :class => 'ManageIQ::Providers::Hawkular::MiddlewareManager::MiddlewareMessaging', - :parent => :middleware_messaging do - end + :parent => :middleware_messaging factory :hawkular_middleware_messaging_initialized, :parent => :hawkular_middleware_messaging do diff --git a/spec/factories/middleware_server_group.rb b/spec/factories/middleware_server_group.rb index 6eb5921feb67..17dbef49c49a 100644 --- a/spec/factories/middleware_server_group.rb +++ b/spec/factories/middleware_server_group.rb @@ -6,6 +6,5 @@ factory :hawkular_middleware_server_group, :aliases => ['app/models/manageiq/providers/hawkular/middleware_manager/middleware_server_group'], :class => 'ManageIQ::Providers::Hawkular::MiddlewareManager::MiddlewareServerGroup', - :parent => :middleware_server_group do - end + :parent => :middleware_server_group end diff --git a/spec/factories/middleware_servers.rb b/spec/factories/middleware_servers.rb index 56da2578c51e..5bb215e73d0f 100644 --- a/spec/factories/middleware_servers.rb +++ b/spec/factories/middleware_servers.rb @@ -7,18 +7,15 @@ factory :hawkular_middleware_server, :aliases => ['app/models/manageiq/providers/hawkular/middleware_manager/middleware_server'], :class => 'ManageIQ::Providers::Hawkular::MiddlewareManager::MiddlewareServer', - :parent => :middleware_server do - end + :parent => :middleware_server factory :hawkular_middleware_server_wildfly, :aliases => ['app/models/manageiq/providers/hawkular/middleware_manager/middleware_server_wildfly'], :class => 'ManageIQ::Providers::Hawkular::MiddlewareManager::MiddlewareServerWildfly', - :parent => :middleware_server do - end + :parent => :middleware_server factory :hawkular_middleware_server_eap, :aliases => ['app/models/manageiq/providers/hawkular/middleware_manager/middleware_server_eap'], :class => 'ManageIQ::Providers::Hawkular::MiddlewareManager::MiddlewareServerEap', - :parent => :hawkular_middleware_server_wildfly do - end + :parent => :hawkular_middleware_server_wildfly end diff --git a/spec/factories/miq_product_feature.rb b/spec/factories/miq_product_feature.rb index 5f24127ae0fb..e5f0c05086a9 100644 --- a/spec/factories/miq_product_feature.rb +++ b/spec/factories/miq_product_feature.rb @@ -1,6 +1,5 @@ FactoryGirl.define do - factory :miq_product_feature do - end + factory :miq_product_feature factory :miq_product_feature_everything, :parent => :miq_product_feature do identifier "everything" diff --git a/spec/factories/miq_report_result.rb b/spec/factories/miq_report_result.rb index 2e35c28e5ffc..0afa28799ce7 100644 --- a/spec/factories/miq_report_result.rb +++ b/spec/factories/miq_report_result.rb @@ -1,6 +1,5 @@ FactoryGirl.define do - factory :miq_report_result do - end + factory :miq_report_result factory :miq_chargeback_report_result, :parent => :miq_report_result do sequence(:name) { |n| "Test Chargeback Report Result #{seq_padded_for_sorting(n)}" } diff --git a/spec/factories/miq_schedule_worker.rb b/spec/factories/miq_schedule_worker.rb index 440a271cf806..92a3b7d3d575 100644 --- a/spec/factories/miq_schedule_worker.rb +++ b/spec/factories/miq_schedule_worker.rb @@ -1,4 +1,3 @@ FactoryGirl.define do - factory :miq_schedule_worker, :parent => :miq_worker, :class => "MiqScheduleWorker" do - end + factory :miq_schedule_worker, :parent => :miq_worker, :class => "MiqScheduleWorker" end diff --git a/spec/factories/miq_task.rb b/spec/factories/miq_task.rb index 0017c759125e..6b49d5969d0d 100644 --- a/spec/factories/miq_task.rb +++ b/spec/factories/miq_task.rb @@ -5,6 +5,5 @@ sequence(:name) { |n| "task_#{seq_padded_for_sorting(n)}" } end - factory :miq_task_plain, :class => :miq_task do - end + factory :miq_task_plain, :class => :miq_task end diff --git a/spec/factories/orchestration_stack.rb b/spec/factories/orchestration_stack.rb index 933c1f0c8da5..10482594967c 100644 --- a/spec/factories/orchestration_stack.rb +++ b/spec/factories/orchestration_stack.rb @@ -3,21 +3,17 @@ ems_ref "1" end - factory :orchestration_stack_cloud, :parent => :orchestration_stack, :class => "ManageIQ::Providers::CloudManager::OrchestrationStack" do - end + factory :orchestration_stack_cloud, :parent => :orchestration_stack, :class => "ManageIQ::Providers::CloudManager::OrchestrationStack" factory :orchestration_stack_cloud_with_template, :parent => :orchestration_stack, :class => "ManageIQ::Providers::CloudManager::OrchestrationStack" do orchestration_template { FactoryGirl.create(:orchestration_template) } end - factory :orchestration_stack_amazon, :parent => :orchestration_stack, :class => "ManageIQ::Providers::Amazon::CloudManager::OrchestrationStack" do - end + factory :orchestration_stack_amazon, :parent => :orchestration_stack, :class => "ManageIQ::Providers::Amazon::CloudManager::OrchestrationStack" - factory :orchestration_stack_azure, :parent => :orchestration_stack, :class => "ManageIQ::Providers::Azure::CloudManager::OrchestrationStack" do - end + factory :orchestration_stack_azure, :parent => :orchestration_stack, :class => "ManageIQ::Providers::Azure::CloudManager::OrchestrationStack" - factory :orchestration_stack_openstack, :parent => :orchestration_stack, :class => "ManageIQ::Providers::Openstack::CloudManager::OrchestrationStack" do - end + factory :orchestration_stack_openstack, :parent => :orchestration_stack, :class => "ManageIQ::Providers::Openstack::CloudManager::OrchestrationStack" factory :orchestration_stack_openstack_infra, :parent => :orchestration_stack, @@ -35,8 +31,7 @@ :class => "ManageIQ::Providers::Openstack::InfraManager::OrchestrationStack" do end - factory :orchestration_stack_parameter_openstack_infra, :class => "OrchestrationStackParameter" do - end + factory :orchestration_stack_parameter_openstack_infra, :class => "OrchestrationStackParameter" factory :orchestration_stack_parameter_openstack_infra_compute, :parent => :orchestration_stack_parameter_openstack_infra do after :create do |x| @@ -52,14 +47,11 @@ end end - factory :orchestration_stack_resource, :class => "OrchestrationStackResource" do - end + factory :orchestration_stack_resource, :class => "OrchestrationStackResource" - factory :orchestration_stack_resource_openstack_infra, :class => "OrchestrationStackResource" do - end + factory :orchestration_stack_resource_openstack_infra, :class => "OrchestrationStackResource" - factory :orchestration_stack_output, :class => "OrchestrationStackOutput" do - end + factory :orchestration_stack_output, :class => "OrchestrationStackOutput" factory :orchestration_stack_resource_openstack_infra_compute, :parent => :orchestration_stack_resource_openstack_infra do @@ -77,12 +69,9 @@ end end - factory :ansible_tower_job, :class => "ManageIQ::Providers::AnsibleTower::AutomationManager::Job" do - end + factory :ansible_tower_job, :class => "ManageIQ::Providers::AnsibleTower::AutomationManager::Job" - factory :embedded_ansible_job, :class => "ManageIQ::Providers::EmbeddedAnsible::AutomationManager::Job" do - end + factory :embedded_ansible_job, :class => "ManageIQ::Providers::EmbeddedAnsible::AutomationManager::Job" - factory :orchestration_stack_vmware_cloud, :parent => :orchestration_stack, :class => "ManageIQ::Providers::Vmware::CloudManager::OrchestrationStack" do - end + factory :orchestration_stack_vmware_cloud, :parent => :orchestration_stack, :class => "ManageIQ::Providers::Vmware::CloudManager::OrchestrationStack" end diff --git a/spec/factories/physical_infra_manager.rb b/spec/factories/physical_infra_manager.rb index d8b308341f7e..cbf29c45890a 100644 --- a/spec/factories/physical_infra_manager.rb +++ b/spec/factories/physical_infra_manager.rb @@ -1,5 +1,4 @@ FactoryGirl.define do factory :generic_physical_infra, - :class => "ManageIQ::Providers::PhysicalInfraManager" do - end + :class => "ManageIQ::Providers::PhysicalInfraManager" end diff --git a/spec/factories/pxe_image.rb b/spec/factories/pxe_image.rb index ae3c91932893..585781d1177f 100644 --- a/spec/factories/pxe_image.rb +++ b/spec/factories/pxe_image.rb @@ -6,9 +6,6 @@ kernel_options "vga=788 -- quiet" end - factory :pxe_image_ipxe, :parent => :pxe_image, :class => 'PxeImageIpxe' do - end - - factory :pxe_image_pxelinux, :parent => :pxe_image, :class => 'PxeImagePxelinux' do - end + factory :pxe_image_ipxe, :parent => :pxe_image, :class => 'PxeImageIpxe' + factory :pxe_image_pxelinux, :parent => :pxe_image, :class => 'PxeImagePxelinux' end diff --git a/spec/factories/scan_item.rb b/spec/factories/scan_item.rb index b8845fb43adc..720b78bc8447 100644 --- a/spec/factories/scan_item.rb +++ b/spec/factories/scan_item.rb @@ -1,6 +1,5 @@ FactoryGirl.define do - factory :scan_item do - end + factory :scan_item factory :scan_item_category_default, :parent => :scan_item do attributes do diff --git a/spec/factories/service.rb b/spec/factories/service.rb index c84fdef58afd..496448c3ad3f 100644 --- a/spec/factories/service.rb +++ b/spec/factories/service.rb @@ -3,15 +3,8 @@ sequence(:name) { |n| "service_#{seq_padded_for_sorting(n)}" } end - factory :service_orchestration, :class => :ServiceOrchestration, :parent => :service do - end - - factory :service_ansible_tower, :class => :ServiceAnsibleTower, :parent => :service do - end - - factory :service_ansible_playbook, :class => :ServiceAnsiblePlaybook, :parent => :service do - end - - factory :service_container_template, :class => :ServiceContainerTemplate, :parent => :service do - end + factory :service_orchestration, :class => :ServiceOrchestration, :parent => :service + factory :service_ansible_tower, :class => :ServiceAnsibleTower, :parent => :service + factory :service_ansible_playbook, :class => :ServiceAnsiblePlaybook, :parent => :service + factory :service_container_template, :class => :ServiceContainerTemplate, :parent => :service end diff --git a/spec/factories/service_template.rb b/spec/factories/service_template.rb index 2d0d11a6f5b1..a9a4dea1f112 100644 --- a/spec/factories/service_template.rb +++ b/spec/factories/service_template.rb @@ -1,11 +1,6 @@ FactoryGirl.define do - factory :service_template do - end - - factory :service_template_orchestration, :class => 'ServiceTemplateOrchestration', :parent => :service_template do - end - + factory :service_template + factory :service_template_orchestration, :class => 'ServiceTemplateOrchestration', :parent => :service_template factory :service_template_ansible_playbook, :class => 'ServiceTemplateAnsiblePlaybook', :parent => :service_template - factory :service_template_container_template, :class => 'ServiceTemplateContainerTemplate', :parent => :service_template end diff --git a/spec/factories/vmdb_metric.rb b/spec/factories/vmdb_metric.rb index 660ba71b778f..f96d1e13d39e 100644 --- a/spec/factories/vmdb_metric.rb +++ b/spec/factories/vmdb_metric.rb @@ -1,6 +1,5 @@ FactoryGirl.define do - factory :vmdb_metric do - end + factory :vmdb_metric factory :vmdb_metric_hourly, :parent => :vmdb_metric do capture_interval_name "hourly" diff --git a/spec/factories/vmdb_table.rb b/spec/factories/vmdb_table.rb index 279097dfa02d..b852c8c61a3a 100644 --- a/spec/factories/vmdb_table.rb +++ b/spec/factories/vmdb_table.rb @@ -1,10 +1,5 @@ FactoryGirl.define do - factory :vmdb_table do - end - - factory :vmdb_table_evm, :parent => :vmdb_table, :class => "VmdbTableEvm" do - end - - factory :vmdb_table_text, :parent => :vmdb_table, :class => "VmdbTableText" do - end + factory :vmdb_table + factory :vmdb_table_evm, :parent => :vmdb_table, :class => "VmdbTableEvm" + factory :vmdb_table_text, :parent => :vmdb_table, :class => "VmdbTableText" end From 3b6ec62e56e24a8d42b3d4e55945265d414c3b96 Mon Sep 17 00:00:00 2001 From: Drew Bomhof Date: Tue, 9 Jan 2018 12:14:58 -0500 Subject: [PATCH 17/21] Remove get_timezone allow_any_instance_of --- .../manageiq/providers/cloud_manager/provision_workflow_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/models/manageiq/providers/cloud_manager/provision_workflow_spec.rb b/spec/models/manageiq/providers/cloud_manager/provision_workflow_spec.rb index 5f5bd9ec2e59..908470ab4625 100644 --- a/spec/models/manageiq/providers/cloud_manager/provision_workflow_spec.rb +++ b/spec/models/manageiq/providers/cloud_manager/provision_workflow_spec.rb @@ -6,7 +6,7 @@ let(:template) { FactoryGirl.create(:miq_template, :name => "template", :ext_management_system => ems) } let(:workflow) do stub_dialog - allow_any_instance_of(User).to receive(:get_timezone).and_return(Time.zone) + allow(User).to receive_messages(:server_timezone => "UTC") allow_any_instance_of(described_class).to receive(:update_field_visibility) described_class.new({:src_vm_id => template.id}, admin.userid) end From 827e8a860363b78f342f111fb6c42764a6994c03 Mon Sep 17 00:00:00 2001 From: Harpreet Kataria Date: Tue, 9 Jan 2018 12:18:33 -0500 Subject: [PATCH 18/21] Fixed control explorer feature id Fixed control explorer feature id for EvmRole-security, EvmRole-support,EvmRole-auditor, EvmRole-approver roles. This was causing confusion by not showing them as selected in the Product features tree whereas these roles did have an access to Control explorer in UI. Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1525598 --- db/fixtures/miq_user_roles.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/db/fixtures/miq_user_roles.yml b/db/fixtures/miq_user_roles.yml index 7380ed689af1..300275272ecc 100644 --- a/db/fixtures/miq_user_roles.yml +++ b/db/fixtures/miq_user_roles.yml @@ -102,7 +102,7 @@ - chargeback_reports - customization_template_view - iso_datastore_view - - control_explorer_view + - control_explorer - dashboard - ems_cluster_show - ems_cluster_show_list @@ -195,7 +195,7 @@ - chargeback_reports - customization_template_view - iso_datastore_view - - control_explorer_view + - control_explorer - dashboard - ems_cluster_show - ems_cluster_show_list @@ -477,7 +477,7 @@ - compute - chargeback - chargeback_reports - - control_explorer_view + - control_explorer - dashboard - datastore - ems_cluster_show @@ -562,7 +562,7 @@ - compute - chargeback - chargeback_reports - - control_explorer_view + - control_explorer - dashboard - datastore - ems_cluster_show From ac514d2233d60524dbcdcc45b5b1e3f0eb7f7aca Mon Sep 17 00:00:00 2001 From: Jason Frey Date: Tue, 9 Jan 2018 16:08:40 -0500 Subject: [PATCH 19/21] Fix .rubocop_local.yml --- .rubocop_local.yml | 37 +++++++++---------------------------- 1 file changed, 9 insertions(+), 28 deletions(-) diff --git a/.rubocop_local.yml b/.rubocop_local.yml index 3784dc7ce29f..e55f18c21ba2 100644 --- a/.rubocop_local.yml +++ b/.rubocop_local.yml @@ -1,52 +1,33 @@ +AllCops: + Exclude: + - lib/generators/provider/templates/**/* + - db/schema.rb GlobalVars: AllowedVariables: # Loggers - - $audit_log - $api_log + - $audit_log - $aws_log - $azure_log + - $cn_monitoring_log - $container_log - $datawarehouse_log - $fog_log + - $kube_log - $lenovo_log - $log - $miq_ae_logger + - $mw_log - $policy_log - $rails_log - $rhevm_log - - $kube_log - - $mw_log - - $cn_monitoring_log - $scvmm_log + - $vcloud_log - $vim_log - $websocket_log - - $vcloud_log - # In Automate methods - - $evm -# -# Special Exclusions -# -AllCops: - TargetRubyVersion: 2.2 - Exclude: - - lib/generators/provider/templates/**/* - - db/schema.rb - - vendor/**/* -ClassAndModuleCamelCase: - Exclude: - - lib/miq_automation_engine/service_models/*.rb -FileName: - Exclude: - - lib/miq_automation_engine/service_models/*.rb -Metrics/LineLength: - Exclude: - - Gemfile Rails/Exit: Exclude: - lib/workers/bin/* Rails/Output: Exclude: - lib/workers/bin/* -Style/ExtraSpacing: - Exclude: - - Gemfile From a32f8bca5c2f492c9877984251cfbdb4cdba7092 Mon Sep 17 00:00:00 2001 From: Brandon Dunne Date: Tue, 9 Jan 2018 17:20:41 -0500 Subject: [PATCH 20/21] Update rubocop:disable calls for v0.52.1 --- lib/extensions/ar_virtual.rb | 2 +- spec/lib/extensions/virtual_total_spec.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/extensions/ar_virtual.rb b/lib/extensions/ar_virtual.rb index 416720a0cd2b..084f057006e6 100644 --- a/lib/extensions/ar_virtual.rb +++ b/lib/extensions/ar_virtual.rb @@ -605,7 +605,7 @@ def preloaders_for_one(association, records, scope) # syntax from the original codebase. # # rubocop:disable Style/BlockDelimiters, Style/SpaceAfterComma, Style/HashSyntax - # rubocop:disable Style/AlignHash, Metrics/AbcSize, Metrics/MethodLength + # rubocop:disable Layout/AlignHash, Metrics/AbcSize, Metrics/MethodLength class JoinDependency def instantiate(result_set, aliases) primary_key = aliases.column_alias(join_root, join_root.primary_key) diff --git a/spec/lib/extensions/virtual_total_spec.rb b/spec/lib/extensions/virtual_total_spec.rb index 4d5b45b99cb7..31d0edbb3aca 100644 --- a/spec/lib/extensions/virtual_total_spec.rb +++ b/spec/lib/extensions/virtual_total_spec.rb @@ -1,6 +1,6 @@ describe VirtualTotal do before(:each) do - # rubocop:disable Style/SingleLineMethods, Style/EmptyLineBetweenDefs, Style/AccessorMethodName + # rubocop:disable Style/SingleLineMethods, Layout/EmptyLineBetweenDefs, Naming/AccessorMethodName class VitualTotalTestBase < ActiveRecord::Base self.abstract_class = true @@ -68,7 +68,7 @@ def self.connection; VitualTotalTestBase.connection end scope :published, -> { where(:published => true) } scope :wip, -> { where(:published => false) } end - # rubocop:enable Style/SingleLineMethods, Style/EmptyLineBetweenDefs, Style/AccessorMethodName + # rubocop:enable Style/SingleLineMethods, Layout/EmptyLineBetweenDefs, Naming/AccessorMethodName end after(:each) do From 27e3f82fffe0a6efe509ff7b17595c254f49b929 Mon Sep 17 00:00:00 2001 From: Brandon Dunne Date: Tue, 9 Jan 2018 17:21:23 -0500 Subject: [PATCH 21/21] update rubocop dependency --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 3fbcaa46fb7d..0780d92557bf 100644 --- a/Gemfile +++ b/Gemfile @@ -214,7 +214,7 @@ unless ENV["APPLIANCE"] group :development do gem "foreman" gem "haml_lint", "~>0.20.0", :require => false - gem "rubocop", "~>0.49.0", :require => false + gem "rubocop", "~>0.52.1", :require => false # ruby_parser is required for i18n string extraction gem "ruby_parser", :require => false gem "scss_lint", "~>0.48.0", :require => false