30 lines
850 B
Ruby
30 lines
850 B
Ruby
require "test_helper"
|
|
|
|
class CommentTest < ActiveSupport::TestCase
|
|
test "should be valid with a user, body, and commentable" do
|
|
user = users(:one)
|
|
entry = entries(:one)
|
|
comment = Comment.new(user: user, body: "This is a comment.", commentable: entry)
|
|
assert comment.valid?
|
|
end
|
|
|
|
test "should be invalid without a body" do
|
|
user = users(:one)
|
|
entry = entries(:one)
|
|
comment = Comment.new(user: user, commentable: entry)
|
|
assert_not comment.valid?
|
|
end
|
|
|
|
test "should be invalid without a user" do
|
|
entry = entries(:one)
|
|
comment = Comment.new(body: "This is a comment.", commentable: entry)
|
|
assert_not comment.valid?
|
|
end
|
|
|
|
test "should be invalid without a commentable" do
|
|
user = users(:one)
|
|
comment = Comment.new(user: user, body: "This is a comment.")
|
|
assert_not comment.valid?
|
|
end
|
|
end
|