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

Clean up test helper.

This commit is contained in:
Andy Stewart 2010-03-18 18:02:55 +00:00
parent bc22f9cf59
commit b88af80916
7 changed files with 37 additions and 63 deletions

View file

@ -1 +1 @@
# Include hook code here
require 'paper_trail'

View file

@ -1,15 +1,15 @@
# Generated by jeweler
# DO NOT EDIT THIS FILE DIRECTLY
# Instead, edit Jeweler::Tasks in rakefile, and run the gemspec command
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
# -*- encoding: utf-8 -*-
Gem::Specification.new do |s|
s.name = %q{paper_trail}
s.version = "1.4.0"
s.version = "1.4.1"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Andy Stewart"]
s.date = %q{2010-01-06}
s.date = %q{2010-03-18}
s.email = %q{boss@airbladesoftware.com}
s.extra_rdoc_files = [
"README.md"
@ -29,9 +29,7 @@ Gem::Specification.new do |s|
"lib/paper_trail/has_paper_trail.rb",
"lib/paper_trail/version.rb",
"paper_trail.gemspec",
"rails/init.rb",
"tasks/paper_trail_tasks.rake",
"test/database.yml",
"test/paper_trail_controller_test.rb",
"test/paper_trail_model_test.rb",
"test/paper_trail_schema_test.rb",

View file

@ -1 +0,0 @@
require 'paper_trail'

View file

@ -1,18 +0,0 @@
sqlite3:
adapter: sqlite3
database: ":memory:"
postgresql:
adapter: postgresql
username: postgres
password: postgres
database: paper_trail_plugin_test
min_messages: ERROR
mysql:
adapter: mysql
host: localhost
username: andy
password:
database: paper_trail_plugin_test
socket: /tmp/mysql.sock

View file

@ -1,4 +1,4 @@
require File.dirname(__FILE__) + '/test_helper.rb'
require 'test_helper'
class ApplicationController < ActionController::Base
def rescue_action(e)
@ -32,10 +32,11 @@ end
class PaperTrailControllerTest < ActionController::TestCase #Test::Unit::TestCase
tests WidgetsController
def setup
@controller = WidgetsController.new
@request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new
#@controller = WidgetsController.new
#@request = ActionController::TestRequest.new
#@response = ActionController::TestResponse.new
ActionController::Routing::Routes.draw do |map|
map.resources :widgets

View file

@ -1,4 +1,4 @@
require File.dirname(__FILE__) + '/test_helper.rb'
require 'test_helper'
class Widget < ActiveRecord::Base
has_paper_trail
@ -30,7 +30,7 @@ class HasPaperTrailModelTest < Test::Unit::TestCase
context 'A record' do
setup { @article = Article.create }
context 'which updates an ignored column' do
setup { @article.update_attributes :title => 'My first title' }
should_not_change('the number of versions') { Version.count }
@ -100,7 +100,7 @@ class HasPaperTrailModelTest < Test::Unit::TestCase
assert_match /update/i, @widget.versions.last.event
end
context 'and has one associated object' do
setup do
@wotsit = @widget.create_wotsit :name => 'John'

View file

@ -1,43 +1,37 @@
require 'rubygems'
require 'test/unit'
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}
end
require 'shoulda'
require 'paper_trail'
require 'active_record'
require 'action_controller'
require 'action_controller/test_process'
require 'active_support'
require 'active_support/test_case'
require 'lib/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'
if db_adapter.nil?
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])
ActiveRecord::Base.establish_connection(
:adapter => "sqlite3",
:database => ":memory:"
)
ActiveRecord::Migration.verbose = false
end
def load_schema
connect_to_database
load(File.dirname(__FILE__) + "/schema.rb")
require File.dirname(__FILE__) + '/../rails/init.rb'
load File.dirname(__FILE__) + '/schema.rb'
end
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
load_schema