add tests

This commit is contained in:
2026-01-22 15:54:43 +01:00
parent 5674e6b21a
commit 0de8e1ad14
10 changed files with 220 additions and 47 deletions
+25 -3
View File
@@ -1,7 +1,29 @@
require "test_helper"
class CommentTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
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