Skip to content

Instantly share code, notes, and snippets.

@pinzolo
Last active January 15, 2017 14:14
Show Gist options
  • Save pinzolo/2b151f8377646976e899 to your computer and use it in GitHub Desktop.
Save pinzolo/2b151f8377646976e899 to your computer and use it in GitHub Desktop.
Devise.setup do |config|
# 複数モデルを可能にする
config.scoped_views = true
# スコープごとのサインアウトを可能にする
# デフォルトの状態ではコメントアウトされているので、コメントアウトを外して false を設定する
config.sign_out_all_scopes = false
end
require 'test_helper'
class Admins::SessionsControllerTest < ActionController::TestCase
def setup
@request.env['devise.mapping'] = Devise.mappings[:admin]
@admin = create(:admin)
@user = create(:user)
end
test '管理者としてサインアウトしても、ユーザーとしてはサインアウトしない' do
sign_in(@admin)
sign_in(@user)
delete :destroy
assert_not @controller.send(:all_signed_out?)
# assert @controller.signed_in?(@user) は動かなかった
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment