Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Clean up test helper.

  • Loading branch information...
commit b88af809162091de554acf9579120ae341a7d8a8 1 parent bc22f9c
@airblade airblade authored
View
2  init.rb
@@ -1 +1 @@
-# Include hook code here
+require 'paper_trail'
View
8 paper_trail.gemspec
@@ -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
1  rails/init.rb
@@ -1 +0,0 @@
-require 'paper_trail'
View
18 test/database.yml
@@ -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
9 test/paper_trail_controller_test.rb
@@ -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 @@ def destroy
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
6 test/paper_trail_model_test.rb
@@ -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
54 test/test_helper.rb
@@ -1,43 +1,37 @@
-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
+require 'rubygems'
- %w(action_pack action_controller active_record active_support initializer).each {|f| require f}
-end
+require 'test/unit'
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?
- raise "No DB Adapter selected. Pass the DB= option to pick one, or install Sqlite or Sqlite3."
- end
+require 'lib/paper_trail'
- ActiveRecord::Base.establish_connection(config[db_adapter])
+def connect_to_database
+ 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
Please sign in to comment.
Something went wrong with that request. Please try again.