Skip to content

Commit 6e6d1a3

Browse files
committed
added tests for the Comment#pings method
1 parent 6d2ad87 commit 6e6d1a3

3 files changed

Lines changed: 27 additions & 0 deletions

File tree

test/fixtures/comment_threads.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,9 @@ new_user_on_own_post:
6868
reply_count: 0
6969
post: new_user_question
7070
community: sample
71+
72+
with_user_pings:
73+
title: Pings for @#-1 and @#<%= ActiveRecord::FixtureSet.identify :standard_user %> users
74+
reply_count: 1
75+
post: question_one
76+
community: sample

test/fixtures/comments.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,14 @@ new_user_on_own_post:
7070
comment_thread: new_user_on_own_post
7171
created_at: 2020-01-01T00:00:00.000000Z
7272
updated_at: 2021-01-01T00:00:00.000000Z
73+
74+
with_user_pings:
75+
user: standard_user
76+
post: question_one
77+
content: >
78+
special ping for @#-1 user (system)
79+
and for @#<%= ActiveRecord::FixtureSet.identify :standard_user %> (user)
80+
community: sample
81+
comment_thread: with_user_pings
82+
created_at: 2020-01-01T00:00:00.000000Z
83+
updated_at: 2021-01-01T00:00:00.000000Z

test/models/comment_test.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,14 @@ class CommentTest < ActiveSupport::TestCase
3333
assert_not Comment::USER_PING_REG_EXP.match?(mention)
3434
end
3535
end
36+
37+
test 'pings should correctly' do
38+
std_user = users(:standard_user)
39+
with_pings = comments(:with_user_pings)
40+
41+
pings = with_pings.pings
42+
43+
assert pings.include?(std_user.id)
44+
assert_not pings.include?(User.system.id)
45+
end
3646
end

0 commit comments

Comments
 (0)