Permalink
Browse files

added tests that dont interfere with original tests

  • Loading branch information...
1 parent 17b33f0 commit e7b2b1421fecf1da9082965b173a7f064de089d8 @ooochie ooochie committed Nov 19, 2008
Showing with 2,496 additions and 17 deletions.
  1. +2,460 −0 test/debug.log
  2. +0 −5 test/fixtures/categories.yml
  3. +7 −0 test/fixtures/people.yml
  4. +7 −0 test/fixtures/places.yml
  5. +0 −4 test/fixtures/widgets.yml
  6. +12 −7 test/paranoid_test.rb
  7. +9 −0 test/schema.rb
  8. +1 −1 test/test_helper.rb
View

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -16,9 +16,4 @@ category_4:
id: 4
widget_id: 2
title: 'category 4'
- deleted_at: '2005-01-01 00:00:00'
-category_5:
- id: 4
- widget_id: 2
- title: 'category 1'
deleted_at: '2005-01-01 00:00:00'
View
@@ -0,0 +1,7 @@
+person_1:
+ id: 1
+ name: Lindsay
+person_2:
+ id: 2
+ name: Lindsay
+ deleted_at: '2008-01-01 00:00:00'
View
@@ -0,0 +1,7 @@
+place_1:
+ id: 1
+ location: America
+place_2:
+ id: 2
+ location: New Zealand
+ deleted_at: '2008-01-01 00:00:00'
@@ -6,7 +6,3 @@ widget_2:
title: 'deleted widget 2'
deleted_at: '2005-01-01 00:00:00'
category_id: 3
-widget_3:
- id: 3
- title: 'widget 1'
- deleted_at: '2005-01-01 00:00:00'
View
@@ -2,7 +2,6 @@
class Widget < ActiveRecord::Base
acts_as_paranoid
- validates_uniqueness_of :title
has_many :categories, :dependent => :destroy
has_and_belongs_to_many :habtm_categories, :class_name => 'Category'
has_one :category
@@ -13,7 +12,6 @@ class Widget < ActiveRecord::Base
end
class Category < ActiveRecord::Base
- validates_uniqueness_of :title, :without_deleted => true
belongs_to :widget
belongs_to :any_widget, :class_name => 'Widget', :foreign_key => 'widget_id', :with_deleted => true
acts_as_paranoid
@@ -38,17 +36,24 @@ class Tagging < ActiveRecord::Base
acts_as_paranoid
end
+class Person < ActiveRecord::Base
+ validates_uniqueness_of :name #include deleted items
+end
+class Place < ActiveRecord::Base
+ validates_uniqueness_of :location, :without_deleted => true #ignores deleted items
+end
+
class NonParanoidAndroid < ActiveRecord::Base
end
class ValidatesUniquenessTest < Test::Unit::TestCase
- fixtures :widgets, :categories, :categories_widgets, :tags, :taggings
+ fixtures :people, :places
def test_should_recognize_without_deleted_option
- #validates_uniqueness_of :title
- assert_equal widgets(:widget_1).valid?, false
- # validates_uniqueness_of :title, :without_deleted => true
- assert_equal categories(:category_1).valid?, true
+ #validates_uniqueness_of :title #include deleted items
+ assert_equal people(:person_1).valid?, false
+ #validates_uniqueness_of :title, :without_deleted => true #ignores deleted items
+ assert_equal places(:place_1).valid?, true
end
end
View
@@ -26,5 +26,14 @@
t.column :widget_id, :integer
t.column :deleted_at, :timestamp
end
+
+ create_table :places, :force => true do |t|
+ t.column :location, :string
+ t.column :deleted_at, :timestamp
+ end
+ create_table :people, :force => true do |t|
+ t.column :name, :string
+ t.column :deleted_at, :timestamp
+ end
end
View
@@ -7,7 +7,7 @@
config = YAML::load(IO.read(File.dirname(__FILE__) + '/database.yml'))
ActiveRecord::Base.logger = Logger.new(File.dirname(__FILE__) + "/debug.log")
-ActiveRecord::Base.establish_connection(config[ENV['DB'] || 'sqlite'])
+ActiveRecord::Base.establish_connection(config[ENV['DB'] || 'sqlite3'])
load(File.dirname(__FILE__) + "/schema.rb")

0 comments on commit e7b2b14

Please sign in to comment.