Skip to content

Commit

Permalink
SessionControllerのテストを整理
Browse files Browse the repository at this point in the history
  • Loading branch information
inside-hakumai committed Oct 24, 2018
1 parent b44f7ae commit 5f7fccf
Showing 1 changed file with 23 additions and 6 deletions.
29 changes: 23 additions & 6 deletions test/controllers/sessions_controller_test.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,31 @@
require 'test_helper'

class SessionsControllerTest < ActionDispatch::IntegrationTest
test "should get login" do
get sessions_login_url
assert_response :success

test 'should not get login' do
# ログイン用のURLは "/login" に設定されており, "/sessions/login" は使用できない
assert_raises(ActionController::RoutingError) do
get '/sessions/login'
end
end

test 'should not get logout' do
# ログアウト用のURLは "/logout" に設定されており, "/sessions/logout" は使用できない
assert_raises(ActionController::RoutingError) do
get '/sessions/logout'
end
end

test 'should be redirected to google authentication page' do
# ログイン用のURLにアクセスするとGoogleの認証ページにリダイレクトされる
get '/login'
assert_response :redirect
end

test "should get logout" do
get sessions_logout_url
assert_response :success
test 'should get logout' do
# ログアウト用のURLに(未ログイン状態で)アクセスするとトップページにリダイレクトされる
get '/logout'
assert_response :redirect
end

end

0 comments on commit 5f7fccf

Please sign in to comment.