Commit 7a7d4ce0d262d49c651cce8fdf0a955baabd1c1b
1 parent
ea404739
Exists in
master
and in
29 other branches
Fix ExtendedTag unit test
Showing
2 changed files
with
8 additions
and
3 deletions
Show diff stats
lib/extended_tag.rb
1 | class Tag | 1 | class Tag |
2 | + | ||
3 | + attr_accessible :name, :parent_id, :pending | ||
4 | + | ||
5 | + has_many :children, :class_name => 'Tag', :foreign_key => 'parent_id', :dependent => :destroy | ||
6 | + | ||
2 | 7 | ||
3 | @@original_find = self.method(:find) | 8 | @@original_find = self.method(:find) |
4 | # Rename the find method to find_with_pendings that includes all tags in the search regardless if its pending or not | 9 | # Rename the find method to find_with_pendings that includes all tags in the search regardless if its pending or not |
test/unit/extended_tag_test.rb
@@ -19,15 +19,15 @@ class UserTest < ActiveSupport::TestCase | @@ -19,15 +19,15 @@ class UserTest < ActiveSupport::TestCase | ||
19 | 19 | ||
20 | def test_parent_candidates | 20 | def test_parent_candidates |
21 | tag1 = Tag.create(:name => 'parent_tag') | 21 | tag1 = Tag.create(:name => 'parent_tag') |
22 | - tag2 = Tag.create(:name => 'child_tag', :parent => tag1) | 22 | + tag2 = Tag.create(:name => 'child_tag', :parent_id => tag1.id) |
23 | assert ( not tag1.parent_candidates.include?(tag2) ) | 23 | assert ( not tag1.parent_candidates.include?(tag2) ) |
24 | assert tag2.parent_candidates.include?(tag1) | 24 | assert tag2.parent_candidates.include?(tag1) |
25 | end | 25 | end |
26 | 26 | ||
27 | def test_descendents | 27 | def test_descendents |
28 | tag1 = Tag.create(:name => 'parent_tag') | 28 | tag1 = Tag.create(:name => 'parent_tag') |
29 | - tag2 = Tag.create(:name => 'child_tag', :parent => tag1) | ||
30 | - tag3 = Tag.create(:name => 'grand_tag', :parent => tag2) | 29 | + tag2 = Tag.create(:name => 'child_tag', :parent_id => tag1.id) |
30 | + tag3 = Tag.create(:name => 'grand_tag', :parent_id => tag2.id) | ||
31 | assert (not tag2.descendents.include?(tag1)) | 31 | assert (not tag2.descendents.include?(tag1)) |
32 | assert (not tag1.descendents.include?(tag1)) | 32 | assert (not tag1.descendents.include?(tag1)) |
33 | assert tag1.descendents.include?(tag2) | 33 | assert tag1.descendents.include?(tag2) |