0
여기에 무슨 일이 일어날 지 이해하려고 애를 썼습니다.
User
공장에서 Devise.friendly_token
을 사용합니다.Devise.friendly_token은 항상 같은 해시를 반환합니다.
require 'spec_helper'
describe SessionsController do
before do
@user = User.gen!
puts "Token = #{@user.authentication_token}" # <--- debugging output
end
describe "#create" do
context "when sending ..." do
it "renders a json hash ..." do
api_sign_in @user
expect(last_response.status).to eq(201)
end
end
context "when sending ..." do
it "renders a json hash ..." do
user = User.gen!(email: "[email protected]")
puts "Token2 = #{user.authentication_token}" # <--- debugging output
api_sign_in user
expect(last_response.status).to eq(422)
end
end
end
describe "#destroy" do
context "when sending ..." do
it "renders a json hash ..." do
api_sign_out @user
expect(last_response.status).to eq(200)
end
end
end
end
디버깅 출력 토큰은 모든 호출에 동일한 해시 것을 보여준다 다음
FactoryGirl.define do
factory :user do
email "[email protected]"
password "secret"
authentication_token Devise.friendly_token
end
end
몇몇 테스트에서 I는 공장을 사용한다. 이상한! 콘솔에서 Devise.friendly_token
을 테스트하면 모든 실행마다 임의의 해시 가 생성됩니다. 그것이 내가 implementation을 바라보기를 기대하는 것입니다.
큰 디자인 문제가 있다고 생각합니다. 제발 도와주세요.
다시 한번 감사드립니다. 사양에서 정상적으로 작동합니다. 'User' 모델에서'Devise.friendly_token'을 사용할 때 어떻게해야합니까? – JJD
무슨 뜻인지 잘 모르겠습니다. 'User' 모델에서'Devise.friendly_token'을 어떻게 사용합니까? –