Mercurial > hg > soundsoftware-site
comparison .svn/pristine/f0/f055e63882b13e8e39249356c308c679bd2aad29.svn-base @ 1296:038ba2d95de8 redmine-2.2
Fix redmine-2.2 branch update (add missing svn files)
author | Chris Cannam |
---|---|
date | Fri, 14 Jun 2013 09:05:06 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
1294:3e4c3460b6ca | 1296:038ba2d95de8 |
---|---|
1 # encoding: utf-8 | |
2 # | |
3 # Redmine - project management software | |
4 # Copyright (C) 2006-2012 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 ERB::Util | |
25 | |
26 def test_highlight_single_token | |
27 assert_equal 'This is a <span class="highlight token-0">token</span>.', | |
28 highlight_tokens('This is a token.', %w(token)) | |
29 end | |
30 | |
31 def test_highlight_multiple_tokens | |
32 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>.', | |
33 highlight_tokens('This is a token and another token.', %w(token another)) | |
34 end | |
35 | |
36 def test_highlight_should_not_exceed_maximum_length | |
37 s = (('1234567890' * 100) + ' token ') * 100 | |
38 r = highlight_tokens(s, %w(token)) | |
39 assert r.include?('<span class="highlight token-0">token</span>') | |
40 assert r.length <= 1300 | |
41 end | |
42 | |
43 def test_highlight_multibyte | |
44 s = ('й' * 200) + ' token ' + ('й' * 200) | |
45 r = highlight_tokens(s, %w(token)) | |
46 assert_equal ('й' * 45) + ' ... ' + ('й' * 44) + ' <span class="highlight token-0">token</span> ' + ('й' * 44) + ' ... ' + ('й' * 45), r | |
47 end | |
48 end |