]> git.openstreetmap.org Git - rails.git/commitdiff
Add some basic testing of issue_comment model
authorHarry Wood <github@harrywood.co.uk>
Fri, 6 May 2022 11:38:17 +0000 (12:38 +0100)
committerHarry Wood <github@harrywood.co.uk>
Fri, 6 May 2022 11:38:17 +0000 (12:38 +0100)
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 [new file with mode: 0644]
test/models/issue_comment_test.rb

diff --git a/test/factories/issue_comment.rb b/test/factories/issue_comment.rb
new file mode 100644 (file)
index 0000000..5231695
--- /dev/null
@@ -0,0 +1,8 @@
+FactoryBot.define do
+  factory :issue_comment do
+    sequence(:body) { |n| "This is issue comment #{n}" }
+
+    issue
+    user
+  end
+end
index 53ba358895999bb54b3eff1e71a27d6c22a143f9..27fa9d66d878bbfeeee918ee6a3a6edd9c14196d 100644 (file)
@@ -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