Spiegel von
https://github.com/paviliondev/discourse-custom-wizard.git
synchronisiert 2024-11-09 20:02:54 +01:00
FIX: reset user's progress on wizard skip
Dieser Commit ist enthalten in:
Ursprung
bfa190e98b
Commit
61c92ec768
3 geänderte Dateien mit 21 neuen und 0 gelöschten Zeilen
|
@ -69,6 +69,7 @@ class CustomWizard::WizardController < ::ApplicationController
|
|||
end
|
||||
|
||||
submission.remove if submission.present?
|
||||
wizard.reset_user_progress!
|
||||
end
|
||||
|
||||
render json: result
|
||||
|
|
|
@ -286,6 +286,14 @@ class CustomWizard::Wizard
|
|||
end
|
||||
end
|
||||
|
||||
def reset_user_progress!
|
||||
UserHistory.where(
|
||||
action: UserHistory.actions[:custom_wizard_step],
|
||||
acting_user_id: user.id,
|
||||
context: id
|
||||
).destroy_all
|
||||
end
|
||||
|
||||
def final_cleanup!
|
||||
if id == user.custom_fields['redirect_to_wizard']
|
||||
user.custom_fields.delete('redirect_to_wizard')
|
||||
|
|
|
@ -86,4 +86,16 @@ describe CustomWizard::WizardController do
|
|||
|
||||
expect(list.any? { |submission| submission.id == current_submission.id }).to eq(false)
|
||||
end
|
||||
|
||||
it "starts from the first step if user visits after skipping the wizard" do
|
||||
put '/w/super-mega-fun-wizard/steps/step_1.json', params: {
|
||||
fields: {
|
||||
step_1_field_1: "Text input"
|
||||
}
|
||||
}
|
||||
put '/w/super-mega-fun-wizard/skip.json'
|
||||
get '/w/super-mega-fun-wizard.json'
|
||||
|
||||
expect(response.parsed_body["start"]).to eq('step_1')
|
||||
end
|
||||
end
|
||||
|
|
Laden …
In neuem Issue referenzieren