Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@step is never set #299

Open
camerondrysdale opened this issue Sep 1, 2023 · 2 comments
Open

@step is never set #299

camerondrysdale opened this issue Sep 1, 2023 · 2 comments

Comments

@camerondrysdale
Copy link

I tried this out on a very simple controller like so:

class AdminController < AuthenticatedController
  include Wicked::Wizard
  steps :step_1, :step_2, :step_3

  def show
    render_wizard
  end
end

I've found a couple of what seem like bugs that prevented this from working and redirected straight away to /.

First on this line: https://github.com/zombocom/wicked/blob/main/lib/wicked/wizard.rb#L81
This guard clause is pointless:

return if params[:id].nil?

Because you default to the first step already:

the_step ||= steps.first

And the latter code prevents @step from being set causing it to think the Wizard is complete and redirect to /.

Secondly on this line: https://github.com/zombocom/wicked/blob/main/lib/wicked/wizard.rb#L64
You're comparing steps that have been converted to a string to one that is not:

resolved_step = valid_steps.detect { |stp| stp.to_s == the_step }

It should be:

resolved_step = valid_steps.detect { |stp| stp.to_s == the_step.to_s }
@camerondrysdale
Copy link
Author

In order to get this working, I've had to vendorize the gem and fix both of those lines and then it works fine. But I'm surprised no one else has encountered this issue... unless I've missed some settings in the controller?

@schneems
Copy link
Member

schneems commented Sep 1, 2023

This is very similar to a controller we already have a test for https://github.com/zombocom/wicked/blob/main/test/dummy/app/controllers/bar_controller.rb

One thing that jumps out is you don't have an update action. No clue if that's related though.

Tests ran and were passing last year https://github.com/zombocom/wicked/actions/runs/4343778022.

Maybe try to convert your example into a test case and see if you can get it to fail the same way.

Also: I would take a PR that adds cron to run tests at regular intervals, like weekly/monthly, (instead of just on PR). Being able to trigger them manually as well would be nice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants