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