Sha256: 676696d35f54cdac1516d9ac2efb7f080bc4c205dbb8a1bc5906aada3a98113a

Contents?: true

Size: 1.3 KB

Versions: 1

Compression:

Stored size: 1.3 KB

Contents

require 'rubygems'
require 'active_record'
require File.join File.dirname(__FILE__), '..', 'lib', 'permissive'

module PermissiveSpecHelper
  def self.clear_log
    File.open(PermissiveSpecHelper.log_path, 'w') do |file|
      file.puts ''
    end
  end

  def self.db_up
    ActiveRecord::Base.establish_connection({:adapter => 'sqlite3', :database => ':memory:', :pool => 5, :timeout => 5000})
    silence_stream(STDOUT) do
      ActiveRecord::Schema.define do
        create_table :permissive_users, :force => true do |t|
          t.timestamps
        end
        create_table :permissive_users_with_roles, :force => true do |t|
          t.string :role
          t.timestamps
        end
        create_table :permissive_organizations, :force => true do |t|
          t.timestamps
        end
        create_table :permissive_permissions do |t|
          t.integer :permitted_object_id
          t.string :permitted_object_type, :limit => 32
          t.integer :scoped_object_id
          t.string :scoped_object_type, :limit => 32
          t.integer :mask, :default => 0
        end
      end
    end
  end

  def self.log_path
    @log_path ||= File.join(File.dirname(__FILE__), 'spec.log')
  end
end

# Setup the logging
PermissiveSpecHelper.clear_log
ActiveRecord::Base.logger = Logger.new(PermissiveSpecHelper.log_path)

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
permissive-0.2.4.alpha spec/spec_helper.rb