From 19856e92a0f5a42ed455ab7ceca5bf1cc5755e3a Mon Sep 17 00:00:00 2001 From: Harpreet Kataria Date: Mon, 1 Jun 2020 09:01:22 -0400 Subject: [PATCH] Removed `MiqRolesFeature.none?` check Adjusted test to verify that product features are renamed even when there are no MiqRoleFeatures. --- .../20200520211047_adjust_chargeback_reports_features.rb | 2 -- ...200520211047_adjust_chargeback_reports_features_spec.rb | 7 ++++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/db/migrate/20200520211047_adjust_chargeback_reports_features.rb b/db/migrate/20200520211047_adjust_chargeback_reports_features.rb index bcde355b4..5bf04810a 100644 --- a/db/migrate/20200520211047_adjust_chargeback_reports_features.rb +++ b/db/migrate/20200520211047_adjust_chargeback_reports_features.rb @@ -32,8 +32,6 @@ def down say_with_time 'Adjusting chargeback reports features to explorer views' do admin_feature = MiqProductFeature.find_or_create_by!(:identifier => 'chargeback_reports') - return if MiqRolesFeature.none? - MiqRolesFeature.where(:miq_product_feature_id => admin_feature.id).each do |feature| old_feature_ids.each do |id| MiqRolesFeature.create!(:miq_product_feature_id => id, :miq_user_role_id => feature.miq_user_role_id) diff --git a/spec/migrations/20200520211047_adjust_chargeback_reports_features_spec.rb b/spec/migrations/20200520211047_adjust_chargeback_reports_features_spec.rb index fec98c046..0a17e9a40 100644 --- a/spec/migrations/20200520211047_adjust_chargeback_reports_features_spec.rb +++ b/spec/migrations/20200520211047_adjust_chargeback_reports_features_spec.rb @@ -62,11 +62,16 @@ expect(view_feature4.reload.identifier).to eq('chargeback_report_only') end - it 'skips feature renaming when no role features are set' do + it 'product feature is renamed when no role features are set' do migrate assigned = roles_feature_stub.where(:miq_user_role_id => user_role_id) expect(assigned.count).to eq(0) + + expect(view_feature1.reload.identifier).to eq('chargeback_download_csv') + expect(view_feature2.reload.identifier).to eq('chargeback_download_pdf') + expect(view_feature3.reload.identifier).to eq('chargeback_download_text') + expect(view_feature4.reload.identifier).to eq('chargeback_report_only') end end end