0
我有一些問題使用minitest測試基本設計登錄。rails設計使用燈具測試問題(未授權訪問)
我的測試:
test "user can sign in" do
@user = users(:someoneelse)
get new_user_session_path
assert_select "strong", "log in"
post user_session_path, user: { email: @user.email,
password: @user.password,
}
assert_redirected_to root_path
end
夾具
someoneelse:
email: [email protected]
encrypted_password: <%= Devise::Encryptor.digest(User, 'password') %>
created_at: <%= Time.zone.now %>
測試結果:
test_user_can_sign_in#UserFlowTest (0.81s)
Expected response to be a <3XX: redirect>, but was a <200: OK>
test/integration/user_flow_test.rb:17:in `block in <class:UserFlowTest>'
日誌尾
Started POST "https://stackoverflow.com/users/sign_in" for 127.0.0.1 at 2017-02-19 14:06:28 -0600
Processing by Devise::SessionsController#create as HTML
Parameters: {"user"=>{"email"=>"[email protected]", "password"=>"[FILTERED]"}}
Completed **401 Unauthorized in 1ms** (ActiveRecord: 0.0ms)
Processing by Devise::SessionsController#new as HTML
看起來用戶未經授權。夾具有問題嗎?
另外我怎樣才能讓minitest變得更加冗長?
謝謝。