Ezra's acl_system2 and flash not getting populated in functi

Hi all,

I am using the LoginGenerator and Ezra’s acl_system2 to protect
certain actions in my controllers. I have written some functional
tests to check for correct handling of redirects, flashes, etc. The
flashes however only get populated on the first get action in any
given test. Here is what I have so far:

In the controller:

class PageController < AC
before_filter => :login_required
access_control :DEFAULT => ‘admin’

def index

def permission_denied
flash[:message] = “You must log in as an administrator.”
redirect_to :controller => “account”, :action => "login

In the test:

ACTIONS = [:index, :new, :edit, :create, :update, :destroy]

def test_redirect_not_authenticated_user
ACTIONS.each do |a|
get a
assert_redirected_to :controller => ‘account’, :action => ‘login’

def test_redirect_not_admin
assert not_admin = User.authenticate(“not_admin”, “her_password”)
ACTIONS.each do |a|
get a, {}, { :user => route_admin }, nil
assert_redirected_to :controller => “account”, :action => “login”
#assert flash.has_key?(:message), “No flash after action #{a}”
#assert_equal “You must log in as an administrator.”, flash

The flash assertions work only for the first action. In the example
above the assert flash.has_key?(:message) test fails on the second
action :new. If I delete the :index element from ACTIONS, the test
fails on :edit and so on.

Why does the flash get populated only on the first get action?

Many thanks for any pointers,

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs