DRY supported_languages
This commit is contained in:
@@ -1,29 +1,41 @@
|
||||
require "test_helper"
|
||||
|
||||
class CommentTest < ActiveSupport::TestCase
|
||||
test "should be valid with a user, body, and commentable" do
|
||||
user = users(:admin_user)
|
||||
test "should be valid with a user, body, commentable, and language code" do
|
||||
user = users(:contributor_user)
|
||||
entry = entries(:one)
|
||||
comment = Comment.new(user: user, body: "This is a comment.", commentable: entry)
|
||||
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(:admin_user)
|
||||
user = users(:contributor_user)
|
||||
entry = entries(:one)
|
||||
comment = Comment.new(user: user, commentable: entry)
|
||||
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)
|
||||
comment = Comment.new(body: "This is a comment.", commentable: entry)
|
||||
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(:admin_user)
|
||||
comment = Comment.new(user: user, body: "This is a comment.")
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user