Force second step build to overcome can_access? check
The can_access? check will fail if the wizard does not allow multiple submissions. This means that on the second build of the wizard on the final step of a single submission wizard, the wizard instance will have no steps, and an error will be thrown when logic assumes it does.
Dieser Commit ist enthalten in:
Ursprung
b2ed2c1dc7
Commit
dc7e43b6d7
4 geänderte Dateien mit 4 neuen und 3 gelöschten Zeilen
|
@ -23,7 +23,7 @@ class CustomWizard::StepsController < ::ApplicationController
|
||||||
if updater.success?
|
if updater.success?
|
||||||
wizard_id = update_params[:wizard_id]
|
wizard_id = update_params[:wizard_id]
|
||||||
builder = CustomWizard::Builder.new(wizard_id, current_user)
|
builder = CustomWizard::Builder.new(wizard_id, current_user)
|
||||||
@wizard = builder.build
|
@wizard = builder.build(force: true)
|
||||||
|
|
||||||
current_step = @wizard.find_step(update[:step_id])
|
current_step = @wizard.find_step(update[:step_id])
|
||||||
current_submission = @wizard.current_submission
|
current_submission = @wizard.current_submission
|
||||||
|
|
|
@ -30,7 +30,7 @@ class CustomWizard::Builder
|
||||||
|
|
||||||
def build(build_opts = {}, params = {})
|
def build(build_opts = {}, params = {})
|
||||||
return nil if !SiteSetting.custom_wizard_enabled || !@wizard
|
return nil if !SiteSetting.custom_wizard_enabled || !@wizard
|
||||||
return @wizard if !@wizard.can_access?
|
return @wizard if !@wizard.can_access? && !build_opts[:force]
|
||||||
|
|
||||||
build_opts[:reset] = build_opts[:reset] || @wizard.restart_on_revisit
|
build_opts[:reset] = build_opts[:reset] || @wizard.restart_on_revisit
|
||||||
|
|
||||||
|
|
|
@ -173,6 +173,8 @@ describe CustomWizard::Wizard do
|
||||||
progress_step("step_2", acting_user: trusted_user)
|
progress_step("step_2", acting_user: trusted_user)
|
||||||
progress_step("step_3", acting_user: trusted_user)
|
progress_step("step_3", acting_user: trusted_user)
|
||||||
|
|
||||||
|
@permitted_template["multiple_submissions"] = true
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
CustomWizard::Wizard.new(@permitted_template, trusted_user).can_access?
|
CustomWizard::Wizard.new(@permitted_template, trusted_user).can_access?
|
||||||
).to eq(true)
|
).to eq(true)
|
||||||
|
|
1
spec/fixtures/wizard.json
gevendort
1
spec/fixtures/wizard.json
gevendort
|
@ -3,7 +3,6 @@
|
||||||
"name": "Super Mega Fun Wizard",
|
"name": "Super Mega Fun Wizard",
|
||||||
"background": "#333333",
|
"background": "#333333",
|
||||||
"save_submissions": true,
|
"save_submissions": true,
|
||||||
"multiple_submissions": true,
|
|
||||||
"after_signup": false,
|
"after_signup": false,
|
||||||
"prompt_completion": false,
|
"prompt_completion": false,
|
||||||
"theme_id": 2,
|
"theme_id": 2,
|
||||||
|
|
Laden …
In neuem Issue referenzieren