comparison .svn/pristine/e8/e8f5719ac8290bf42290de6a5ad4ab322d08803d.svn-base @ 1464:261b3d9a4903 redmine-2.4

Update to Redmine 2.4 branch rev 12663
author Chris Cannam
date Tue, 14 Jan 2014 14:37:42 +0000
parents
children
comparison
equal deleted inserted replaced
1296:038ba2d95de8 1464:261b3d9a4903
1 # encoding: utf-8
2 #
3 # Redmine - project management software
4 # Copyright (C) 2006-2013 Jean-Philippe Lang
5 #
6 # This program is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU General Public License
8 # as published by the Free Software Foundation; either version 2
9 # of the License, or (at your option) any later version.
10 #
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19
20 require File.expand_path('../../../test_helper', __FILE__)
21
22 class SearchHelperTest < ActionView::TestCase
23 include SearchHelper
24 include Redmine::I18n
25 include ERB::Util
26
27 def test_highlight_single_token
28 assert_equal 'This is a <span class="highlight token-0">token</span>.',
29 highlight_tokens('This is a token.', %w(token))
30 end
31
32 def test_highlight_multiple_tokens
33 assert_equal 'This is a <span class="highlight token-0">token</span> and <span class="highlight token-1">another</span> <span class="highlight token-0">token</span>.',
34 highlight_tokens('This is a token and another token.', %w(token another))
35 end
36
37 def test_highlight_should_not_exceed_maximum_length
38 s = (('1234567890' * 100) + ' token ') * 100
39 r = highlight_tokens(s, %w(token))
40 assert r.include?('<span class="highlight token-0">token</span>')
41 assert r.length <= 1300
42 end
43
44 def test_highlight_multibyte
45 s = ('й' * 200) + ' token ' + ('й' * 200)
46 r = highlight_tokens(s, %w(token))
47 assert_equal ('й' * 45) + ' ... ' + ('й' * 44) + ' <span class="highlight token-0">token</span> ' + ('й' * 44) + ' ... ' + ('й' * 45), r
48 end
49 end