Commit 322a5d33f165de88489d6df0903028e312772175

Authored by AntonioTerceiro
1 parent d14479dd

ActionItem21: hardening the test



git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@973 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing 1 changed file with 11 additions and 0 deletions   Show diff stats
test/unit/article_test.rb
... ... @@ -79,18 +79,29 @@ class ArticleTest < Test::Unit::TestCase
79 79 end
80 80  
81 81 should 'not accept articles with same slug under the same level' do
  82 +
  83 + # top level articles first
82 84 profile = create_user('testinguser').person
83 85 a1 = profile.articles.build(:name => 'test')
84 86 a1.save!
85 87  
  88 + # cannot add another top level article with same slug
86 89 a2 = profile.articles.build(:name => 'test')
87 90 a2.valid?
88 91 assert a2.errors.invalid?(:slug)
89 92  
  93 + # now create a child of a1
90 94 a3 = profile.articles.build(:name => 'test')
91 95 a3.parent = a1
92 96 a3.valid?
93 97 assert !a3.errors.invalid?(:slug)
  98 + a3.save!
  99 +
  100 + # cannot add another child of a1 with same slug
  101 + a4 = profile.articles.build(:name => 'test')
  102 + a4.parent = a1
  103 + a4.valid?
  104 + assert a4.errors.invalid?(:slug)
94 105 end
95 106  
96 107 end
... ...