mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-12-30 20:23:14 +08:00
39 lines
1.2 KiB
Ruby
39 lines
1.2 KiB
Ruby
require 'test_helper'
|
|
|
|
class ProjectCommentTest < ActiveSupport::TestCase
|
|
def setup
|
|
@project_comment = project_comments(:test)
|
|
@project = @project_comment.project
|
|
@comment = @project_comment.comment
|
|
end
|
|
|
|
test "should validate with correct data" do
|
|
assert @project_comment.valid?
|
|
end
|
|
|
|
test "should not validate with non existent comment id" do
|
|
@project_comment.comment_id = 2343434
|
|
assert_not @project_comment.valid?
|
|
@project_comment.comment = nil
|
|
assert_not @project_comment.valid?
|
|
end
|
|
|
|
test "should not validate with non existent project id" do
|
|
@project_comment.project_id = 1223232323
|
|
assert_not @project_comment.valid?
|
|
@project_comment.project = nil
|
|
assert_not @project_comment.valid?
|
|
end
|
|
|
|
test "should validate for project/comment uniqueness" do
|
|
project_comment = ProjectComment.new(
|
|
project: @project, comment: @comment)
|
|
assert_not project_comment.save
|
|
end
|
|
|
|
test "should have association project -> comment" do
|
|
project = projects(:dummy)
|
|
project.comments << @comment
|
|
assert_equal @comment, Project.find(project.id).comments.first, "There is no association between project -> comment."
|
|
end
|
|
end
|