diff --git a/app/controllers/concerns/better_together/wizard_methods.rb b/app/controllers/concerns/better_together/wizard_methods.rb index dcac948cb..4c9b8dabb 100644 --- a/app/controllers/concerns/better_together/wizard_methods.rb +++ b/app/controllers/concerns/better_together/wizard_methods.rb @@ -15,9 +15,8 @@ def determine_wizard_outcome # rubocop:todo Metrics/AbcSize raise StandardError, "Wizard #{wizard_identifier} was not found. Have you run the seeds?" unless wizard if wizard.completed? - flash[:notice] = wizard.success_message - # TODO: This needs to be adjusted for private platforms. Flash message is not retained after wizard completion - redirect_to wizard.success_path + flash.keep(:notice) + redirect_to wizard.success_path, notice: wizard.success_message else next_step_path, flash_key, message = wizard_next_step_info flash[flash_key] = message if message diff --git a/spec/requests/better_together/wizard_completion_spec.rb b/spec/requests/better_together/wizard_completion_spec.rb new file mode 100644 index 000000000..b6736e4da --- /dev/null +++ b/spec/requests/better_together/wizard_completion_spec.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +require 'rails_helper' + +RSpec.describe 'Setup Wizard completion' do + let!(:wizard) { BetterTogether::Wizard.find_by!(identifier: 'host_setup') } + + before do + wizard.mark_completed + end + + it 'redirects to the success path with notice preserved' do # rubocop:disable RSpec/MultipleExpectations + get better_together.setup_wizard_path(locale: I18n.locale) + expect(response).to redirect_to(wizard.success_path) + + # The controller preserves the notice in the flash; assert it directly + expect(flash[:notice]).to eq(wizard.success_message) + end +end