42 lines
1.4 KiB
Ruby
42 lines
1.4 KiB
Ruby
require "test_helper"
|
|
|
|
class CommentTest < ActiveSupport::TestCase
|
|
test "should be valid with a user, body, commentable, and language code" do
|
|
user = users(:contributor_user)
|
|
entry = entries(:one)
|
|
language = supported_languages(:one)
|
|
comment = Comment.new(user: user, body: "This is a comment.", commentable: entry, language: language)
|
|
assert comment.valid?
|
|
end
|
|
|
|
test "should be valid without a language code" do
|
|
user = users(:contributor_user)
|
|
entry = entries(:one)
|
|
comment = Comment.new(user: user, body: "General note.", commentable: entry, language_code: nil)
|
|
assert comment.valid?
|
|
end
|
|
|
|
test "should be invalid without a body" do
|
|
user = users(:contributor_user)
|
|
entry = entries(:one)
|
|
language = supported_languages(:one)
|
|
comment = Comment.new(user: user, commentable: entry, language: language)
|
|
assert_not comment.valid?
|
|
end
|
|
|
|
test "should be invalid without a user" do
|
|
entry = entries(:one)
|
|
language = supported_languages(:one)
|
|
comment = Comment.new(body: "This is a comment.", commentable: entry, language: language)
|
|
assert_not comment.valid?
|
|
end
|
|
|
|
test "should be invalid without a commentable" do
|
|
user = users(:contributor_user)
|
|
language = supported_languages(:one)
|
|
comment = Comment.new(user: user, body: "This is a comment.", language: language)
|
|
assert_not comment.valid?
|
|
end
|
|
|
|
end
|