0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2024-11-22 09:20:29 +01:00

FIX: reset user's progress on wizard skip

Dieser Commit ist enthalten in:
Faizaan Gagan 2021-08-13 17:49:31 +05:30
Ursprung bfa190e98b
Commit 61c92ec768
3 geänderte Dateien mit 21 neuen und 0 gelöschten Zeilen

Datei anzeigen

@ -69,6 +69,7 @@ class CustomWizard::WizardController < ::ApplicationController
end end
submission.remove if submission.present? submission.remove if submission.present?
wizard.reset_user_progress!
end end
render json: result render json: result

Datei anzeigen

@ -286,6 +286,14 @@ class CustomWizard::Wizard
end end
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! def final_cleanup!
if id == user.custom_fields['redirect_to_wizard'] if id == user.custom_fields['redirect_to_wizard']
user.custom_fields.delete('redirect_to_wizard') user.custom_fields.delete('redirect_to_wizard')

Datei anzeigen

@ -86,4 +86,16 @@ describe CustomWizard::WizardController do
expect(list.any? { |submission| submission.id == current_submission.id }).to eq(false) expect(list.any? { |submission| submission.id == current_submission.id }).to eq(false)
end 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 end