尽管创建了管理员用户会话,但我无法访问需要管理员用户的集成测试中的 url。我的测试因 302 错误而失败。
class NewsItemsController < ApplicationController
before_filter :require_admin_user, :except => [:show, :index, :feed]
etc...
end
--test/inetgration/admin_stories.rb --
require 'test_helper'
class AdminStoriesTest < ActionController::IntegrationTest
fixtures :all
setup :activate_authlogic
# if user is an admin he can create a new news_item
def test_creating_a_news_item
assert UserSession.create(users(:admin))
get "news_items/new"
assert_response :success
#etc...
end
end
我在 test.log 中有以下内容:
Unable to load roles_user, underlying cause no such file to load -- roles_user
正如您所期望的那样,我的固定文件被命名为roles_users.yml - 所以不确定如何解决这个问题......