Skip to content

Commit

Permalink
Avoid jumping in the middle of an application form flow
Browse files Browse the repository at this point in the history
  • Loading branch information
fumimowdan committed Oct 2, 2023
1 parent b0e853b commit 27395ce
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/services/step_flow.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def matches?(request)
end

def current_step(form, requested_step_name)
return if form.blank? && requested_step_name != ApplicationRouteStep::ROUTE_KEY
return ApplicationRouteStep.new(Form.new) unless form

STEPS.fetch(requested_step_name).new(form)
Expand Down
7 changes: 7 additions & 0 deletions spec/services/step_flow_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,13 @@
let(:form) { nil }
let(:step_name) { "personal-details" }

it { is_expected.to be_nil }
end

context "when form is nil and requested step is application-route" do
let(:form) { nil }
let(:step_name) { "application-route" }

it { is_expected.to be_instance_of(ApplicationRouteStep) }
end

Expand Down

0 comments on commit 27395ce

Please sign in to comment.