Anybody else have this problem with Anna Chan’s ScopedAccess plugin?
Using a around_filter with ScopedAccess::Filter or the scoped_access helper works fine in normal usage, but when running rake test:functionals, the scope from previously run tests carries over into later tests. In other words with_scope is being set but not removed.
Maybe this is because the controllers are not being torn down after the corresponding functional test is run? I’m tired of peppering my functional test setup methods with Whatever.reset_scope. Anybody have a quick fix for me? I have other things to do, and I’d like to avoid looking deeper into this one…



Yup, this is the problem with around_filters… sometimes they don’t get cleaned up. Use the meantime_filter plugin, which uses yield.
Ben,
Thanks for the link. I’ll have to give it a try.
It turns out that the problem is actually caused by the verify actioncontroller helper. It is appending its before filter to the end of the filter chain, so when verify does a redirect, it does so after the scope has already been set in a before filter. Consequently the scope never gets closed because the after filter never gets run. I think that verify should be using prepend_before_filter rather than before_filter so that it takes precedence.
I’m creating a patch for verify now.
BTW - A work around is to put all calls to verify above any filters in your controller definition.
Example:
verify :only => :create, :method => :post, :redirect_to => {:action => 'new'} scoped_access Entity, ScopedAccess::MethodScoping.new(:org_control_id => 25)