From e204e1d178242c450ca0db46724dc9d7e5e11665 Mon Sep 17 00:00:00 2001 From: Harry Wood Date: Fri, 6 May 2022 12:38:17 +0100 Subject: [PATCH] Add some basic testing of issue_comment model A factory and a basic test of validation for the issue_comment model, similar to what we have for diary_comment. --- test/factories/issue_comment.rb | 8 ++++++++ test/models/issue_comment_test.rb | 8 +++++--- 2 files changed, 13 insertions(+), 3 deletions(-) create mode 100644 test/factories/issue_comment.rb diff --git a/test/factories/issue_comment.rb b/test/factories/issue_comment.rb new file mode 100644 index 000000000..52316954d --- /dev/null +++ b/test/factories/issue_comment.rb @@ -0,0 +1,8 @@ +FactoryBot.define do + factory :issue_comment do + sequence(:body) { |n| "This is issue comment #{n}" } + + issue + user + end +end diff --git a/test/models/issue_comment_test.rb b/test/models/issue_comment_test.rb index 53ba35889..27fa9d66d 100644 --- a/test/models/issue_comment_test.rb +++ b/test/models/issue_comment_test.rb @@ -1,7 +1,9 @@ require "test_helper" class IssueCommentTest < ActiveSupport::TestCase - # test "the truth" do - # assert true - # end + test "body must be present" do + comment = build(:issue_comment, :body => "") + assert_not comment.valid? + assert_not_nil comment.errors[:body] + end end -- 2.39.5