0
我想先在rails中进行测试,并且难以使用设计进行身份验证。 运行下面的测试rails设计sign_in不工作
require 'test_helper'
class EmployeesControllerTest < ActionController::TestCase
include Devise::Test::ControllerHelpers
def setup
@employee =employees(:one)
sign_in @employee
end
test "should get index" do
get :index
assert_response :success
end
test "should get new" do
get :new
assert_response :success
end
end
我的灯具是
one:
anrede: MyString
vorname: MyString
nachname: MyString
telefon: MyString
zimmer: MyString
status: Admin
zugriff: Besteller
department_id: 1
id: 1
email: [email protected]
status: Aktuell
encrypted_password: password
测试“应该得到指数”工作正常,但与“应该得到新的”我总是得到消息
Minitest::Assertion: Expected response to be a <2XX: success>, but was a <302: Found> redirect to <http://test.host/>
test/controllers/employees_controller_test.rb:20:in `block in <class:EmployeesControllerTest>'
看起来好像是
sign_in @employee
不工作?但是为什么在指数测试中呢?我只有在测试中遇到这个问题。运行开发服务器一切正常。
我使用Ubuntu,Rails的5.0.1,2.4.0红宝石,设计4.2.1
有人能帮忙吗?
你能张贴EmployeesController代码? – Anton