forked from paper-trail-gem/paper_trail
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
36 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1 +1 @@ | |||
# Include hook code here | require 'paper_trail' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,43 +1,37 @@ | |||
require 'test/unit' | require 'rubygems' | ||
RAILS_ROOT = File.join(File.dirname(__FILE__), %w{.. .. .. ..}) | |||
$:.unshift(File.join(File.dirname(__FILE__), %w{.. lib})) | |||
|
|||
unless defined?(ActiveRecord) | |||
if File.directory? RAILS_ROOT + 'config' | |||
puts 'using config/boot.rb' | |||
ENV['RAILS_ENV'] = 'test' | |||
require File.join(RAILS_ROOT, 'config', 'boot.rb') | |||
else | |||
# simply use installed gems if available | |||
puts 'using rubygems' | |||
require 'rubygems' | |||
gem 'actionpack'; gem 'activerecord'; gem 'activesupport'; gem 'rails' | |||
end | |||
|
|
||
%w(action_pack action_controller active_record active_support initializer).each {|f| require f} | require 'test/unit' | ||
end | |||
require 'shoulda' | require 'shoulda' | ||
require 'paper_trail' | |||
|
|||
def connect_to_database | |||
config = YAML::load(IO.read(File.dirname(__FILE__) + '/database.yml')) | |||
ActiveRecord::Base.logger = Logger.new(File.dirname(__FILE__) + "/debug.log") | |||
|
|
||
db_adapter = ENV['DB'] || 'sqlite3' | require 'active_record' | ||
require 'action_controller' | |||
require 'action_controller/test_process' | |||
require 'active_support' | |||
require 'active_support/test_case' | |||
|
|
||
if db_adapter.nil? | require 'lib/paper_trail' | ||
raise "No DB Adapter selected. Pass the DB= option to pick one, or install Sqlite or Sqlite3." | |||
end | |||
|
|
||
ActiveRecord::Base.establish_connection(config[db_adapter]) | def connect_to_database | ||
ActiveRecord::Base.establish_connection( | |||
:adapter => "sqlite3", | |||
:database => ":memory:" | |||
) | |||
ActiveRecord::Migration.verbose = false | |||
end | end | ||
|
|
||
def load_schema | def load_schema | ||
connect_to_database | connect_to_database | ||
load(File.dirname(__FILE__) + "/schema.rb") | load File.dirname(__FILE__) + '/schema.rb' | ||
require File.dirname(__FILE__) + '/../rails/init.rb' | |||
end | end | ||
|
|
||
def change_schema | def change_schema | ||
load(File.dirname(__FILE__) + "/schema_change.rb") | load File.dirname(__FILE__) + '/schema_change.rb' | ||
end | |||
|
|||
class ActiveRecord::Base | |||
def logger | |||
@logger ||= Logger.new(nil) | |||
end | |||
end | end | ||
|
|||
load_schema |