diff --git a/definitions/procedures/packages/update_all_confirmation.rb b/definitions/procedures/packages/update_all_confirmation.rb index e4b81ad29..af7f7f3ae 100644 --- a/definitions/procedures/packages/update_all_confirmation.rb +++ b/definitions/procedures/packages/update_all_confirmation.rb @@ -8,11 +8,18 @@ class UpdateAllConfirmation < ForemanMaintain::Procedure def run if @packages.nil? || @packages.empty? - question = "\nWARNING: No specific packages to update were provided\n" \ - "so we are going to update all available packages.\n" \ - "To Upgrade to next version use 'foreman-maintain upgrade'.\n\n" \ - "Do you want to proceed with update of everything regardless\n" \ - 'of the recommendations?' + command = ForemanMaintain.command_name + + question = <<~MSG + WARNING: No specific packages to update were provided + so we are going to update all available packages. We + recommend using the update command to update to a minor + version and/or operating system using '#{command} update'. + To upgrade to the next #{feature(:instance).product_name} version use '#{command} upgrade'. + Do you want to proceed with update of everything regardless of + the recommendations? + MSG + answer = ask_decision(question, actions_msg: 'y(yes), q(quit)') abort! unless answer == :yes end diff --git a/lib/foreman_maintain.rb b/lib/foreman_maintain.rb index f941b2c0e..9b31a2fe5 100644 --- a/lib/foreman_maintain.rb +++ b/lib/foreman_maintain.rb @@ -174,6 +174,10 @@ def pkg_and_cmd_name [main_package_name, 'foreman-maintain'] end + def command_name + pkg_and_cmd_name[1] + end + def perform_self_upgrade package_name, command = pkg_and_cmd_name diff --git a/test/definitions/procedures/packages/update_all_confirmation_test.rb b/test/definitions/procedures/packages/update_all_confirmation_test.rb new file mode 100644 index 000000000..c115b27ed --- /dev/null +++ b/test/definitions/procedures/packages/update_all_confirmation_test.rb @@ -0,0 +1,51 @@ +require 'test_helper' +require_relative '../../test_helper' +require_relative '../../../../definitions/procedures/packages/update_all_confirmation' + +describe Procedures::Packages::UpdateAllConfirmation do + include ::DefinitionsTestHelper + + def skip_mock_package_manager + true + end + + subject do + Procedures::Packages::UpdateAllConfirmation.new + end + + it 'contains the proper message for Foreman' do + assume_feature_present(:foreman_install) + + question = <<~MSG + WARNING: No specific packages to update were provided + so we are going to update all available packages. We + recommend using the update command to update to a minor + version and/or operating system using 'foreman-maintain update'. + To upgrade to the next Foreman version use 'foreman-maintain upgrade'. + Do you want to proceed with update of everything regardless of + the recommendations? + MSG + + subject.expects(:ask_decision).with(question, :actions_msg => "y(yes), q(quit)").returns(:yes) + + run_procedure(subject) + end + + it 'contains the proper message for Satellite' do + assume_feature_present(:satellite) + + question = <<~MSG + WARNING: No specific packages to update were provided + so we are going to update all available packages. We + recommend using the update command to update to a minor + version and/or operating system using 'satellite-maintain update'. + To upgrade to the next Satellite version use 'satellite-maintain upgrade'. + Do you want to proceed with update of everything regardless of + the recommendations? + MSG + + subject.expects(:ask_decision).with(question, :actions_msg => "y(yes), q(quit)").returns(:yes) + + run_procedure(subject) + end +end