0
我有一个从ApplicationController
继承的基本管理控制器。为了测试Admin::BaseController
之前的过滤器,我在这个规范中创建了一个匿名控制器。测试子应用程序控制器
require 'spec_helper'
describe Admin::BaseController do
it { should be_a(ApplicationController) }
controller do
def index
render :text => ''
end
end
context 'when current user is not an admin' do
it 'redirects to root path' do
get :index
response.should redirect_to(root_path)
end
end
end
但是,当我提出一个请求index
行动,它并不过滤器之前Admin::BaseController
调用。
当我在ApplicationController
而不是Admin::BaseController
中定义该筛选器并运行测试时,它可以工作。显然这个匿名控制器继承自ApplicationController
。我怎样才能改变这种行为?