summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2006-12-10 18:35:48 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2006-12-10 18:35:48 +0000
commit55ed70529aefdb3029f5ab72169b2f7909b2f2a3 (patch)
tree1f1dbf48685483905949c121cafe36e26c7efc7c /test
parent28c6aa4e6dfe7b4261cd4b4feb50eda62ace0572 (diff)
downloadredmine-55ed70529aefdb3029f5ab72169b2f7909b2f2a3.tar.gz
redmine-55ed70529aefdb3029f5ab72169b2f7909b2f2a3.zip
added model Comment.
comments can now be added on news. git-svn-id: http://redmine.rubyforge.org/svn/trunk@81 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test')
-rw-r--r--test/fixtures/comments.yml10
-rw-r--r--test/fixtures/news.yml2
-rw-r--r--test/unit/comment_test.rb30
3 files changed, 42 insertions, 0 deletions
diff --git a/test/fixtures/comments.yml b/test/fixtures/comments.yml
new file mode 100644
index 000000000..24a4546aa
--- /dev/null
+++ b/test/fixtures/comments.yml
@@ -0,0 +1,10 @@
+# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
+comments_001:
+ commented_type: News
+ commented_id: 1
+ id: 1
+ author_id: 1
+ comment: my first comment
+ created_on: 2006-12-10 18:10:10 +01:00
+ updated_on: 2006-12-10 18:10:10 +01:00
+ \ No newline at end of file
diff --git a/test/fixtures/news.yml b/test/fixtures/news.yml
index 1bef9184e..2c2e2c134 100644
--- a/test/fixtures/news.yml
+++ b/test/fixtures/news.yml
@@ -10,6 +10,7 @@ news_001:
Visit http://ecookbook.somenet.foo/
summary: First version was released...
author_id: 2
+ comments_count: 1
news_002:
created_on: 2006-07-19 22:42:58 +02:00
project_id: 1
@@ -18,3 +19,4 @@ news_002:
description: eCookbook 1.0 have downloaded 100,000 times
summary: eCookbook 1.0 have downloaded 100,000 times
author_id: 2
+ comments_count: 0
diff --git a/test/unit/comment_test.rb b/test/unit/comment_test.rb
new file mode 100644
index 000000000..4435f0a7f
--- /dev/null
+++ b/test/unit/comment_test.rb
@@ -0,0 +1,30 @@
+require File.dirname(__FILE__) + '/../test_helper'
+
+class CommentTest < Test::Unit::TestCase
+ fixtures :users, :news, :comments
+
+ def setup
+ @jsmith = User.find(2)
+ @news = News.find(1)
+ end
+
+ def test_create
+ comment = Comment.new(:commented => @news, :author => @jsmith, :comment => "my comment")
+ assert comment.save
+ @news.reload
+ assert_equal 2, @news.comments_count
+ end
+
+ def test_validate
+ comment = Comment.new(:commented => @news)
+ assert !comment.save
+ assert_equal 2, comment.errors.length
+ end
+
+ def test_destroy
+ comment = Comment.find(1)
+ assert comment.destroy
+ @news.reload
+ assert_equal 0, @news.comments_count
+ end
+end