diff --git a/init.rb b/init.rb index 3c19a743..2ff49202 100644 --- a/init.rb +++ b/init.rb @@ -1 +1 @@ -# Include hook code here +require 'paper_trail' diff --git a/paper_trail.gemspec b/paper_trail.gemspec index 73510ebd..f6cdb4d9 100644 --- a/paper_trail.gemspec +++ b/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", diff --git a/rails/init.rb b/rails/init.rb deleted file mode 100644 index 2ff49202..00000000 --- a/rails/init.rb +++ /dev/null @@ -1 +0,0 @@ -require 'paper_trail' diff --git a/test/database.yml b/test/database.yml deleted file mode 100644 index cc050eec..00000000 --- a/test/database.yml +++ /dev/null @@ -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 diff --git a/test/paper_trail_controller_test.rb b/test/paper_trail_controller_test.rb index 33fba031..c6202e21 100644 --- a/test/paper_trail_controller_test.rb +++ b/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 @@ 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 diff --git a/test/paper_trail_model_test.rb b/test/paper_trail_model_test.rb index ac8f0040..758e589e 100644 --- a/test/paper_trail_model_test.rb +++ b/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' diff --git a/test/test_helper.rb b/test/test_helper.rb index 1dbc7961..849866bd 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -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