zombocom/wicked

around_action with yielding breaks wicked?

Closed this issue · 2 comments

dpsk commented

Using Rails 5 and latest wicked gem i have following in the application_controller.rb:

  around_action :set_time_zone

  def set_time_zone(&action)
    Time.use_zone(Time.find_zone(current_time_zone), &action)
  end

Here is the definition of use_zone:

    #  the application's default timezone.
    def use_zone(time_zone)
      new_zone = find_zone!(time_zone)
      begin
        old_zone, ::Time.zone = ::Time.zone, new_zone
        yield
      ensure
        ::Time.zone = old_zone
      end
    end

on setup_wizard line @step = setup_step_from(params[:id]) from wicked i get following error:

The requested step did not match any steps defined for this controller.

@step being nil here.

Controller is pretty simple one:

  include Wicked::Wizard
  steps :link_account

I tried to debug it a bit and wasn't able to pinpoint an issue, it looks like the_step varialbe is :link_account at the start of the method but nil later?

Any hints?

UPD: Downgrading wicked to 1.0 version fixed the issue.

1.0 has a major security vulnerability https://snyk.io/vuln/SNYK-RUBY-WICKED-20111

Can you try to make a failing test case? This repo uses integration style testing, there is a dummy rails app, you add new controllers and views to that, then call it via the tests.

dpsk commented

Thanks for letting me know this.

I believe i found an issue, old version allowed us to use params[:id] on show action as actual id and not a step, it's now should be mapped via nested route, so we are going to change our code and upgrade!