Commit 322a5d33f165de88489d6df0903028e312772175
1 parent
d14479dd
Exists in
master
and in
29 other branches
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,18 +79,29 @@ class ArticleTest < Test::Unit::TestCase | ||
79 | end | 79 | end |
80 | 80 | ||
81 | should 'not accept articles with same slug under the same level' do | 81 | should 'not accept articles with same slug under the same level' do |
82 | + | ||
83 | + # top level articles first | ||
82 | profile = create_user('testinguser').person | 84 | profile = create_user('testinguser').person |
83 | a1 = profile.articles.build(:name => 'test') | 85 | a1 = profile.articles.build(:name => 'test') |
84 | a1.save! | 86 | a1.save! |
85 | 87 | ||
88 | + # cannot add another top level article with same slug | ||
86 | a2 = profile.articles.build(:name => 'test') | 89 | a2 = profile.articles.build(:name => 'test') |
87 | a2.valid? | 90 | a2.valid? |
88 | assert a2.errors.invalid?(:slug) | 91 | assert a2.errors.invalid?(:slug) |
89 | 92 | ||
93 | + # now create a child of a1 | ||
90 | a3 = profile.articles.build(:name => 'test') | 94 | a3 = profile.articles.build(:name => 'test') |
91 | a3.parent = a1 | 95 | a3.parent = a1 |
92 | a3.valid? | 96 | a3.valid? |
93 | assert !a3.errors.invalid?(:slug) | 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 | end | 105 | end |
95 | 106 | ||
96 | end | 107 | end |