【发布时间】:2009-10-28 13:05:32
【问题描述】:
尽管创建了管理员用户会话,但我无法在集成测试中访问需要管理员用户的 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 - 所以不确定如何解决这个问题...
【问题讨论】:
-
你有roles_user模型吗?
-
不,我在角色和用户之间建立了 habtm 关联
标签: ruby-on-rails integration-testing authlogic