require 'test/unit' require 'active_record' require 'lib/paranoia' DB_FILE = 'tmp/test_db' FileUtils.mkdir_p File.dirname(DB_FILE) FileUtils.rm_f DB_FILE ActiveRecord::Base.establish_connection :adapter => 'sqlite3', :database => DB_FILE ActiveRecord::Base.connection.execute 'CREATE TABLE paranoid_models (id INTEGER NOT NULL PRIMARY KEY)' ActiveRecord::Base.connection.execute 'CREATE TABLE plain_models (id INTEGER NOT NULL PRIMARY KEY)' class ParanoiaTest < Test::Unit::TestCase def test_plain_model_class_is_not_paranoid assert_equal false, PlainModel.paranoid? end def test_paranoid_model_class_is_paranoid assert_equal true, ParanoidModel.paranoid? end def test_plain_models_are_not_paranoid assert_equal false, PlainModel.new.paranoid? end def test_paranoid_models_are_paranoid assert_equal true, ParanoidModel.new.paranoid? end end # Helper classes class ParanoidModel < ActiveRecord::Base acts_as_paranoid end class PlainModel < ActiveRecord::Base end