Spiegel von
https://github.com/paviliondev/discourse-custom-wizard.git
synchronisiert 2024-11-22 09:20:29 +01:00
Don't require fields on a step update
Dieser Commit ist enthalten in:
Ursprung
b201289358
Commit
1f1f2c5726
2 geänderte Dateien mit 12 neuen und 8 gelöschten Zeilen
|
@ -9,17 +9,13 @@ class CustomWizard::StepsController < ::ApplicationController
|
|||
wizard = @builder.build
|
||||
step = wizard.steps.select { |s| s.id == update_params[:step_id] }.first
|
||||
|
||||
if !step || step.fields.blank?
|
||||
raise Discourse::InvalidParameters.new(:step_id)
|
||||
end
|
||||
|
||||
field_ids = step.fields.map(&:id)
|
||||
raise Discourse::InvalidParameters.new(:step_id) if !step
|
||||
|
||||
update = update_params.to_h
|
||||
|
||||
update[:fields] = {}
|
||||
if params[:fields]
|
||||
update[:fields] = {}
|
||||
|
||||
field_ids = step.fields.map(&:id)
|
||||
params[:fields].each do |k, v|
|
||||
update[:fields][k] = v if field_ids.include? k
|
||||
end
|
||||
|
|
|
@ -31,4 +31,12 @@ describe CustomWizard::StepsController do
|
|||
expect(wizard.current_submission['step_1_field_1']).to eq("Text input")
|
||||
expect(wizard.start.id).to eq("step_2")
|
||||
end
|
||||
|
||||
it "works if the step has no fields" do
|
||||
put '/w/super-mega-fun-wizard/steps/step_1.json'
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
wizard = CustomWizard::Builder.new("super_mega_fun_wizard", user).build
|
||||
expect(wizard.start.id).to eq("step_2")
|
||||
end
|
||||
end
|
Laden …
In neuem Issue referenzieren