sorcery v0.9.0からソルトの生成とパスワードの暗号化の処理がbefore_save
からbefore_validation
に移された。この影響で、テストのためにログインパスワードを上書きするときにupdate_attribute
を使っているとログインできずにテストが落ちるようになった。
これはupdate_attribute
がバリデーションをスキップするためにbefore_validation
のフックが発火されないためだ。
対策としてはupdate_attributes
もしくはupdate_attributes!
を使えばいい。
module AuthenticationForFeatureRequest def login user, password = 'login' user.update_attributes password: password page.driver.post sessions_url, {email: user.email, password: password} visit root_url end end