Sha256: bc2a4ab5bf966bb50b8f2738a1edeab560c6a84620b3aad864e1886acdca330c
Contents?: true
Size: 1.13 KB
Versions: 7
Compression:
Stored size: 1.13 KB
Contents
require 'authlogic/test_case' include Authlogic::TestCase module TbCore::SessionHelper # Use this helper in controller specs to establish a login session # - admin: Set to true to create a super_admin # - permissions: One or more permissions you want to assign to the user (a role will be auto generated) # def activate_session(admin: false, permissions: nil) activate_authlogic() if permissions permissions = [permissions] unless permissions.is_a?(Array) role = SpudRole.create(:name => 'New Role', :permission_tags => permissions) else role = nil end @user = FactoryGirl.create(:spud_user, {super_admin: admin, role: role}) SpudUserSession.create(@user) return @user end # Returns the current user # def current_user return @user end end # Insert the session helper into RSpec if it is in use # if defined?(RSpec) RSpec.configure do |config| config.include TbCore::SessionHelper end end # Auto load the spud_user factory if FactoryGirl is in use # if defined?(FactoryGirl) Dir[TbCore::Engine.root.join('spec/factories/spud_user_factories.rb')].each{ |f| require f } end
Version data entries
7 entries across 7 versions & 1 rubygems