comparison .svn/pristine/54/549732f3fd96b4524d8aa62cc5177f9b0ad9d268.svn-base @ 909:cbb26bc654de redmine-1.3

Update to Redmine 1.3-stable branch (Redmine SVN rev 8964)
author Chris Cannam
date Fri, 24 Feb 2012 19:09:32 +0000
parents
children
comparison
equal deleted inserted replaced
908:c6c2cbd0afee 909:cbb26bc654de
1 # encoding: utf-8
2 #
3 # Redmine - project management software
4 # Copyright (C) 2006-2011 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
25 def test_highlight_single_token
26 assert_equal 'This is a <span class="highlight token-0">token</span>.',
27 highlight_tokens('This is a token.', %w(token))
28 end
29
30 def test_highlight_multiple_tokens
31 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>.',
32 highlight_tokens('This is a token and another token.', %w(token another))
33 end
34
35 def test_highlight_should_not_exceed_maximum_length
36 s = (('1234567890' * 100) + ' token ') * 100
37 r = highlight_tokens(s, %w(token))
38 assert r.include?('<span class="highlight token-0">token</span>')
39 assert r.length <= 1300
40 end
41
42 def test_highlight_multibyte
43 s = ('й' * 200) + ' token ' + ('й' * 200)
44 r = highlight_tokens(s, %w(token))
45 assert_equal ('й' * 45) + ' ... ' + ('й' * 44) + ' <span class="highlight token-0">token</span> ' + ('й' * 44) + ' ... ' + ('й' * 45), r
46 end
47 end