Rails2から4へ移行を試みています。
ほぼ終わったのですが、認証をDeviseに変えたのが祟ったか
test:integration で躓いています。
ご指導ください。
出沢
問題
ユーザ認証が通りません。
rails server を起動してブラウザでの認証は通ります。
1. devise.rbにて認証keyはusernameにしてあります。
config.authentication_keys = [:username]
2. ソース
===== test/integration/login_test.rb =====
# -*- coding: utf-8 -*-
require 'test_helper'
class LoginTest < ActionDispatch::IntegrationTest
fixtures :users
test "Appを呼ぶと" do
get "/app"
assert_redirected_to "/users/sign_in","ログインを求められる"
post user_session_path,username: "aaron",password: "aaronpass"
assert_equal nil,flash[:alert]
assert_equal "Signed in successfully.",flash[:notice]
end
3. 結果
rake test:integration
1) Failure:
AppTest#test_Appを呼ぶと
[/home/dezawa/MSDN/msdn/test/integration/app_test.rb:12]:
Expected: nil
Actual: "Invalid email or password."
12行めは assert_equal nil,flash[:alert] の所です。
log/test.log
---------------------
AppTest: test_Appを呼ぶと
---------------------
Started GET "/app" for 127.0.0.1 at 2013-12-26 16:21:28 +0900
Processing by AppController#index as HTML
Completed 401 Unauthorized in 110ms
Started POST "/users/sign_in" for 127.0.0.1 at 2013-12-26 16:21:29 +0900
Processing by Devise::SessionsController#create as HTML
Parameters: {"username"=>"aaron", "password"=>"[FILTERED]"}
Completed 401 Unauthorized in 1ms
Processing by Devise::SessionsController#new as HTML
Parameters: {"username"=>"aaron", "password"=>"[FILTERED]"}
Rendered devise/shared/_links.erb (2.0ms)
Rendered devise/sessions/new.html.erb within layouts/application (93.8ms)
Completed 200 OK in 176ms (Views: 149.2ms | ActiveRecord: 0.0ms)
4. 環境
Ubintu 13.10 on VMweare Player
ruby 1.9.3p194 (2012-04-20 revision 35410) [i686-linux]
Rails 4.0.1
devise (3.2.1)
--
ML: rails@ruby.ml.fdiary.net
使い方: http://QuickML.com/