From: Harry Wood Date: Fri, 6 May 2022 11:38:17 +0000 (+0100) Subject: Add some basic testing of issue_comment model X-Git-Tag: live~1736^2~1 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/e204e1d178242c450ca0db46724dc9d7e5e11665 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. --- 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