Skip to content

Commit d510a7d

Browse files
committed
added render_pings helper test
1 parent c4e18f1 commit d510a7d

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

test/helpers/comments_helper_test.rb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
require 'test_helper'
22

33
class CommentsHelperTest < ActionView::TestCase
4+
include ApplicationHelper
5+
include UsersHelper
46
include Devise::Test::ControllerHelpers
57

68
test '[help center] and [help] substitution' do
@@ -108,4 +110,20 @@ class CommentsHelperTest < ActionView::TestCase
108110
assert_nil limit_message
109111
end
110112
end
113+
114+
test 'render_pings should correctly render comment pings' do
115+
std = users(:standard_user)
116+
mod = users(:moderator)
117+
118+
sign_in std
119+
120+
host = RequestContext.community.host
121+
122+
rendered = render_pings("this is not correct, @##{std.id}. @##{mod.id}'s answer is better. @#123, thoughs?",
123+
host: host)
124+
125+
assert Regexp.new("http:\\/\\/#{Regexp.escape(host)}\\/users\\/#{std.id}").match?(rendered)
126+
assert Regexp.new("http:\\/\\/#{Regexp.escape(host)}\\/users\\/#{mod.id}").match?(rendered)
127+
assert(/@#123/.match?(rendered))
128+
end
111129
end

0 commit comments

Comments
 (0)