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
This commit is contained in:
Vendored
+10
@@ -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
|
||||
|
||||
Vendored
+2
@@ -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
|
||||
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user