1
0
Fork 0
mirror of https://github.com/paper-trail-gem/paper_trail.git synced 2022-11-09 11:33:19 -05:00
paper-trail-gem--paper_trail/test/test_helper.rb

45 lines
1.1 KiB
Ruby
Raw Normal View History

2011-02-08 12:16:35 -05:00
# Configure Rails Envinronment
ENV["RAILS_ENV"] = "test"
ENV["DB"] ||= "sqlite"
2011-02-08 12:16:35 -05:00
require File.expand_path("../dummy/config/environment.rb", __FILE__)
require "rails/test_help"
require 'shoulda'
require 'ffaker'
2009-05-27 11:21:20 -04:00
Rails.backtrace_cleaner.remove_silencers!
2011-02-08 12:16:35 -05:00
# Run any available migration
ActiveRecord::Migrator.migrate File.expand_path("../dummy/db/migrate/", __FILE__)
2010-03-18 14:02:55 -04:00
2011-02-08 12:16:35 -05:00
# Load support files
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
# global setup block resetting Thread.current
class ActiveSupport::TestCase
teardown do
Thread.current[:paper_trail] = nil
end
end
2011-02-08 12:16:35 -05:00
#
# Helpers
#
2010-03-18 14:02:55 -04:00
2011-02-08 12:16:35 -05:00
def change_schema
ActiveRecord::Migration.verbose = false
ActiveRecord::Schema.define do
remove_column :widgets, :sacrificial_column
add_column :versions, :custom_created_at, :datetime
end
2011-02-08 12:16:35 -05:00
ActiveRecord::Migration.verbose = true
end
def restore_schema
ActiveRecord::Migration.verbose = false
ActiveRecord::Schema.define do
add_column :widgets, :sacrificial_column, :string
remove_column :versions, :custom_created_at
end
ActiveRecord::Migration.verbose = true
end