Skip to content

Commit

Permalink
Ensure route_to action works if code is blank string
Browse files Browse the repository at this point in the history
  • Loading branch information
angusmcleod committed Mar 5, 2024
1 parent 895ee9d commit 140f11e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/custom_wizard/action.rb
Expand Up @@ -425,7 +425,7 @@ def route_to
).perform
end

if action['code']
if action['code'].present?
@submission.fields[action['code']] = SecureRandom.hex(8)
url += "&#{action['code']}=#{@submission.fields[action['code']]}"
end
Expand Down
22 changes: 17 additions & 5 deletions spec/components/custom_wizard/action_spec.rb
Expand Up @@ -212,11 +212,23 @@ def update_template(template)
end
end

it 're-routes a user' do
wizard = CustomWizard::Builder.new(@template[:id], user).build
updater = wizard.create_updater(wizard.steps.last.id, {})
updater.update
expect(updater.result[:redirect_on_next]).to eq("https://google.com")
context "route to action" do
it 're-routes a user' do
wizard = CustomWizard::Builder.new(@template[:id], user).build
updater = wizard.create_updater(wizard.steps.last.id, {})
updater.update
expect(updater.result[:redirect_on_next]).to eq("https://google.com")
end

it "works if the code field has a blank string" do
wizard_template[:actions].last[:code] = " "
update_template(wizard_template)

wizard = CustomWizard::Builder.new(@template[:id], user).build
updater = wizard.create_updater(wizard.steps.last.id, {})
updater.update
expect(updater.result[:redirect_on_next]).to eq("https://google.com")
end
end

context "standard subscription actions" do
Expand Down

0 comments on commit 140f11e

Please sign in to comment.