Revision 441:cbce1fd3b1b7 test/unit/helpers/.svn
| test/unit/helpers/.svn/all-wcprops | ||
|---|---|---|
| 1 | 1 |
K 25 |
| 2 | 2 |
svn:wc:ra_dav:version-url |
| 3 |
V 42
|
|
| 4 |
/svn/!svn/ver/4982/trunk/test/unit/helpers
|
|
| 3 |
V 56
|
|
| 4 |
/svn/!svn/ver/5878/branches/1.2-stable/test/unit/helpers
|
|
| 5 | 5 |
END |
| 6 |
repository_helper_test.rb |
|
| 7 |
K 25 |
|
| 8 |
svn:wc:ra_dav:version-url |
|
| 9 |
V 68 |
|
| 10 |
/svn/!svn/ver/4932/trunk/test/unit/helpers/repository_helper_test.rb |
|
| 11 |
END |
|
| 12 |
custom_fields_helper_test.rb |
|
| 13 |
K 25 |
|
| 14 |
svn:wc:ra_dav:version-url |
|
| 15 |
V 71 |
|
| 16 |
/svn/!svn/ver/4509/trunk/test/unit/helpers/custom_fields_helper_test.rb |
|
| 17 |
END |
|
| 18 |
timelog_helper_test.rb |
|
| 19 |
K 25 |
|
| 20 |
svn:wc:ra_dav:version-url |
|
| 21 |
V 65 |
|
| 22 |
/svn/!svn/ver/4509/trunk/test/unit/helpers/timelog_helper_test.rb |
|
| 23 |
END |
|
| 24 |
issue_moves_helper_test.rb |
|
| 25 |
K 25 |
|
| 26 |
svn:wc:ra_dav:version-url |
|
| 27 |
V 69 |
|
| 28 |
/svn/!svn/ver/3936/trunk/test/unit/helpers/issue_moves_helper_test.rb |
|
| 29 |
END |
|
| 30 |
application_helper_test.rb |
|
| 31 |
K 25 |
|
| 32 |
svn:wc:ra_dav:version-url |
|
| 33 |
V 69 |
|
| 34 |
/svn/!svn/ver/4982/trunk/test/unit/helpers/application_helper_test.rb |
|
| 35 |
END |
|
| 36 |
search_helper_test.rb |
|
| 37 |
K 25 |
|
| 38 |
svn:wc:ra_dav:version-url |
|
| 39 |
V 64 |
|
| 40 |
/svn/!svn/ver/4509/trunk/test/unit/helpers/search_helper_test.rb |
|
| 41 |
END |
|
| 42 |
sort_helper_test.rb |
|
| 43 |
K 25 |
|
| 44 |
svn:wc:ra_dav:version-url |
|
| 45 |
V 62 |
|
| 46 |
/svn/!svn/ver/4509/trunk/test/unit/helpers/sort_helper_test.rb |
|
| 47 |
END |
|
| 48 |
projects_helper_test.rb |
|
| 49 |
K 25 |
|
| 50 |
svn:wc:ra_dav:version-url |
|
| 51 |
V 66 |
|
| 52 |
/svn/!svn/ver/4509/trunk/test/unit/helpers/projects_helper_test.rb |
|
| 53 |
END |
|
| 54 |
issues_helper_test.rb |
|
| 55 |
K 25 |
|
| 56 |
svn:wc:ra_dav:version-url |
|
| 57 |
V 64 |
|
| 58 |
/svn/!svn/ver/4509/trunk/test/unit/helpers/issues_helper_test.rb |
|
| 59 |
END |
|
| test/unit/helpers/.svn/entries | ||
|---|---|---|
| 1 | 1 |
10 |
| 2 | 2 |
|
| 3 | 3 |
dir |
| 4 |
4993
|
|
| 5 |
http://redmine.rubyforge.org/svn/trunk/test/unit/helpers
|
|
| 4 |
6000
|
|
| 5 |
http://redmine.rubyforge.org/svn/branches/1.2-stable/test/unit/helpers
|
|
| 6 | 6 |
http://redmine.rubyforge.org/svn |
| 7 | 7 |
|
| 8 | 8 |
|
| 9 | 9 |
|
| 10 |
2011-03-01T10:27:30.170724Z
|
|
| 11 |
4982
|
|
| 10 |
2011-05-18T02:46:50.087237Z
|
|
| 11 |
5833
|
|
| 12 | 12 |
tmaruyama |
| 13 | 13 |
|
| 14 | 14 |
|
| ... | ... | |
| 32 | 32 |
|
| 33 | 33 |
|
| 34 | 34 |
|
| 35 |
2011-03-03T11:40:17.000000Z
|
|
| 36 |
657e0f9ae00af3978571139525631dcc
|
|
| 37 |
2011-02-23T07:04:52.071012Z
|
|
| 38 |
4932
|
|
| 35 |
2011-06-06T13:17:45.000000Z
|
|
| 36 |
de5d924549645540d359a120c9236ea3
|
|
| 37 |
2011-04-12T05:04:45.936482Z
|
|
| 38 |
5428
|
|
| 39 | 39 |
tmaruyama |
| 40 | 40 |
|
| 41 | 41 |
|
| ... | ... | |
| 58 | 58 |
|
| 59 | 59 |
|
| 60 | 60 |
|
| 61 |
2288
|
|
| 61 |
3834
|
|
| 62 | 62 |
|
| 63 | 63 |
custom_fields_helper_test.rb |
| 64 | 64 |
file |
| ... | ... | |
| 66 | 66 |
|
| 67 | 67 |
|
| 68 | 68 |
|
| 69 |
2011-03-03T11:05:08.000000Z
|
|
| 70 |
0091346b4a944910faf5733e2ed88a76
|
|
| 71 |
2010-12-12T23:24:34.194336Z
|
|
| 72 |
4509
|
|
| 73 |
jbbarth
|
|
| 69 |
2011-06-06T13:17:45.000000Z
|
|
| 70 |
d9a56bd73de482d38a0ed098b11f0f49
|
|
| 71 |
2011-03-24T18:24:30.045951Z
|
|
| 72 |
5214
|
|
| 73 |
jplang
|
|
| 74 | 74 |
has-props |
| 75 | 75 |
|
| 76 | 76 |
|
| ... | ... | |
| 92 | 92 |
|
| 93 | 93 |
|
| 94 | 94 |
|
| 95 |
1123
|
|
| 95 |
1828
|
|
| 96 | 96 |
|
| 97 | 97 |
timelog_helper_test.rb |
| 98 | 98 |
file |
| ... | ... | |
| 100 | 100 |
|
| 101 | 101 |
|
| 102 | 102 |
|
| 103 |
2011-03-03T11:05:08.000000Z
|
|
| 103 |
2011-06-06T13:15:00.000000Z
|
|
| 104 | 104 |
ac087c4ae8e6354c77ef7189351ce220 |
| 105 | 105 |
2010-12-12T23:24:34.194336Z |
| 106 | 106 |
4509 |
| ... | ... | |
| 134 | 134 |
|
| 135 | 135 |
|
| 136 | 136 |
|
| 137 |
2011-03-03T11:05:08.000000Z
|
|
| 137 |
2011-06-06T13:15:00.000000Z
|
|
| 138 | 138 |
2c72db60f744a7dec4600df692c40766 |
| 139 | 139 |
2010-08-11T14:42:10.119704Z |
| 140 | 140 |
3936 |
| ... | ... | |
| 168 | 168 |
|
| 169 | 169 |
|
| 170 | 170 |
|
| 171 |
2011-03-03T11:40:17.000000Z
|
|
| 172 |
1f311492ce81d8708bef3193e684f98d
|
|
| 173 |
2011-03-01T10:27:30.170724Z
|
|
| 174 |
4982
|
|
| 171 |
2011-06-06T13:17:45.000000Z
|
|
| 172 |
3833a7b3d44df2dea7f55a5c4f3a13d9
|
|
| 173 |
2011-05-18T02:46:50.087237Z
|
|
| 174 |
5833
|
|
| 175 | 175 |
tmaruyama |
| 176 | 176 |
has-props |
| 177 | 177 |
|
| ... | ... | |
| 194 | 194 |
|
| 195 | 195 |
|
| 196 | 196 |
|
| 197 |
35024
|
|
| 197 |
32490
|
|
| 198 | 198 |
|
| 199 | 199 |
search_helper_test.rb |
| 200 | 200 |
file |
| ... | ... | |
| 202 | 202 |
|
| 203 | 203 |
|
| 204 | 204 |
|
| 205 |
2011-03-03T11:05:08.000000Z
|
|
| 205 |
2011-06-06T13:15:00.000000Z
|
|
| 206 | 206 |
9eb29557d249537fed237c15e1b1b65b |
| 207 | 207 |
2010-12-12T23:24:34.194336Z |
| 208 | 208 |
4509 |
| ... | ... | |
| 236 | 236 |
|
| 237 | 237 |
|
| 238 | 238 |
|
| 239 |
2011-03-03T11:05:08.000000Z
|
|
| 239 |
2011-06-06T13:15:00.000000Z
|
|
| 240 | 240 |
fd65c7c018eb59b2d8697ebeb6b7ba71 |
| 241 | 241 |
2010-12-12T23:24:34.194336Z |
| 242 | 242 |
4509 |
| ... | ... | |
| 270 | 270 |
|
| 271 | 271 |
|
| 272 | 272 |
|
| 273 |
2011-03-03T11:05:08.000000Z
|
|
| 273 |
2011-06-06T13:15:00.000000Z
|
|
| 274 | 274 |
93f6f6ca679f5c32988254776b6d09ae |
| 275 | 275 |
2010-12-12T23:24:34.194336Z |
| 276 | 276 |
4509 |
| ... | ... | |
| 304 | 304 |
|
| 305 | 305 |
|
| 306 | 306 |
|
| 307 |
2011-03-03T11:05:08.000000Z
|
|
| 308 |
b26d2e82551d9f01c0394400ffd85136
|
|
| 309 |
2010-12-12T23:24:34.194336Z
|
|
| 310 |
4509
|
|
| 311 |
jbbarth
|
|
| 307 |
2011-06-06T13:17:45.000000Z
|
|
| 308 |
d4c94f0c0516cba361aaaee5bacba498
|
|
| 309 |
2011-05-16T22:56:46.854254Z
|
|
| 310 |
5804
|
|
| 311 |
tmaruyama
|
|
| 312 | 312 |
|
| 313 | 313 |
|
| 314 | 314 |
|
| ... | ... | |
| 330 | 330 |
|
| 331 | 331 |
|
| 332 | 332 |
|
| 333 |
5782
|
|
| 333 |
6813
|
|
| 334 | 334 |
|
| test/unit/helpers/.svn/text-base/application_helper_test.rb.svn-base | ||
|---|---|---|
| 1 | 1 |
# Redmine - project management software |
| 2 |
# Copyright (C) 2006-2010 Jean-Philippe Lang
|
|
| 2 |
# Copyright (C) 2006-2011 Jean-Philippe Lang
|
|
| 3 | 3 |
# |
| 4 | 4 |
# This program is free software; you can redistribute it and/or |
| 5 | 5 |
# modify it under the terms of the GNU General Public License |
| 6 | 6 |
# as published by the Free Software Foundation; either version 2 |
| 7 | 7 |
# of the License, or (at your option) any later version. |
| 8 |
#
|
|
| 8 |
# |
|
| 9 | 9 |
# This program is distributed in the hope that it will be useful, |
| 10 | 10 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | 11 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | 12 |
# GNU General Public License for more details. |
| 13 |
#
|
|
| 13 |
# |
|
| 14 | 14 |
# You should have received a copy of the GNU General Public License |
| 15 | 15 |
# along with this program; if not, write to the Free Software |
| 16 | 16 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| ... | ... | |
| 18 | 18 |
require File.expand_path('../../../test_helper', __FILE__)
|
| 19 | 19 |
|
| 20 | 20 |
class ApplicationHelperTest < ActionView::TestCase |
| 21 |
|
|
| 21 |
|
|
| 22 | 22 |
fixtures :projects, :roles, :enabled_modules, :users, |
| 23 |
:repositories, :changesets,
|
|
| 23 |
:repositories, :changesets, |
|
| 24 | 24 |
:trackers, :issue_statuses, :issues, :versions, :documents, |
| 25 | 25 |
:wikis, :wiki_pages, :wiki_contents, |
| 26 | 26 |
:boards, :messages, |
| ... | ... | |
| 35 | 35 |
context "authorized user" do |
| 36 | 36 |
should "be tested" |
| 37 | 37 |
end |
| 38 |
|
|
| 38 |
|
|
| 39 | 39 |
context "unauthorized user" do |
| 40 | 40 |
should "be tested" |
| 41 | 41 |
end |
| 42 |
|
|
| 42 |
|
|
| 43 | 43 |
should "allow using the :controller and :action for the target link" do |
| 44 | 44 |
User.current = User.find_by_login('admin')
|
| 45 | 45 |
|
| ... | ... | |
| 48 | 48 |
{:controller => 'issues', :action => 'edit', :id => Issue.first.id})
|
| 49 | 49 |
assert_match /href/, response |
| 50 | 50 |
end |
| 51 |
|
|
| 51 |
|
|
| 52 | 52 |
end |
| 53 |
|
|
| 53 |
|
|
| 54 | 54 |
def test_auto_links |
| 55 | 55 |
to_test = {
|
| 56 | 56 |
'http://foo.bar' => '<a class="external" href="http://foo.bar">http://foo.bar</a>', |
| ... | ... | |
| 84 | 84 |
} |
| 85 | 85 |
to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text) }
|
| 86 | 86 |
end |
| 87 |
|
|
| 87 |
|
|
| 88 | 88 |
def test_auto_mailto |
| 89 |
assert_equal '<p><a class="email" href="mailto:test@foo.bar">test@foo.bar</a></p>',
|
|
| 89 |
assert_equal '<p><a class="email" href="mailto:test@foo.bar">test@foo.bar</a></p>', |
|
| 90 | 90 |
textilizable('test@foo.bar')
|
| 91 | 91 |
end |
| 92 |
|
|
| 92 |
|
|
| 93 | 93 |
def test_inline_images |
| 94 | 94 |
to_test = {
|
| 95 | 95 |
'!http://foo.bar/image.jpg!' => '<img src="http://foo.bar/image.jpg" alt="" />', |
| ... | ... | |
| 102 | 102 |
} |
| 103 | 103 |
to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text) }
|
| 104 | 104 |
end |
| 105 |
|
|
| 105 |
|
|
| 106 | 106 |
def test_inline_images_inside_tags |
| 107 | 107 |
raw = <<-RAW |
| 108 | 108 |
h1. !foo.png! Heading |
| ... | ... | |
| 115 | 115 |
assert textilizable(raw).include?('<img src="foo.png" alt="" />')
|
| 116 | 116 |
assert textilizable(raw).include?('<img src="bar.gif" alt="" />')
|
| 117 | 117 |
end |
| 118 |
|
|
| 118 |
|
|
| 119 | 119 |
def test_attached_images |
| 120 | 120 |
to_test = {
|
| 121 | 121 |
'Inline image: !logo.gif!' => 'Inline image: <img src="/attachments/download/3" title="This is a logo" alt="This is a logo" />', |
| ... | ... | |
| 128 | 128 |
attachments = Attachment.find(:all) |
| 129 | 129 |
to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text, :attachments => attachments) }
|
| 130 | 130 |
end |
| 131 |
|
|
| 131 |
|
|
| 132 | 132 |
def test_textile_external_links |
| 133 | 133 |
to_test = {
|
| 134 | 134 |
'This is a "link":http://foo.bar' => 'This is a <a href="http://foo.bar" class="external">link</a>', |
| ... | ... | |
| 149 | 149 |
end |
| 150 | 150 |
|
| 151 | 151 |
def test_redmine_links |
| 152 |
issue_link = link_to('#3', {:controller => 'issues', :action => 'show', :id => 3},
|
|
| 152 |
issue_link = link_to('#3', {:controller => 'issues', :action => 'show', :id => 3},
|
|
| 153 | 153 |
:class => 'issue status-1 priority-1 overdue', :title => 'Error 281 when updating a recipe (New)') |
| 154 |
|
|
| 154 |
|
|
| 155 | 155 |
changeset_link = link_to('r1', {:controller => 'repositories', :action => 'revision', :id => 'ecookbook', :rev => 1},
|
| 156 | 156 |
:class => 'changeset', :title => 'My very first commit') |
| 157 | 157 |
changeset_link2 = link_to('r2', {:controller => 'repositories', :action => 'revision', :id => 'ecookbook', :rev => 2},
|
| 158 | 158 |
:class => 'changeset', :title => 'This commit fixes #1, #2 and references #1 & #3') |
| 159 |
|
|
| 159 |
|
|
| 160 | 160 |
document_link = link_to('Test document', {:controller => 'documents', :action => 'show', :id => 1},
|
| 161 | 161 |
:class => 'document') |
| 162 |
|
|
| 162 |
|
|
| 163 | 163 |
version_link = link_to('1.0', {:controller => 'versions', :action => 'show', :id => 2},
|
| 164 | 164 |
:class => 'version') |
| 165 | 165 |
|
| 166 | 166 |
message_url = {:controller => 'messages', :action => 'show', :board_id => 1, :id => 4}
|
| 167 |
|
|
| 167 |
|
|
| 168 | 168 |
project_url = {:controller => 'projects', :action => 'show', :id => 'subproject1'}
|
| 169 |
|
|
| 169 |
|
|
| 170 | 170 |
source_url = {:controller => 'repositories', :action => 'entry', :id => 'ecookbook', :path => ['some', 'file']}
|
| 171 | 171 |
source_url_with_ext = {:controller => 'repositories', :action => 'entry', :id => 'ecookbook', :path => ['some', 'file.ext']}
|
| 172 |
|
|
| 172 |
|
|
| 173 | 173 |
to_test = {
|
| 174 | 174 |
# tickets |
| 175 | 175 |
'#3, [#3], (#3) and #3.' => "#{issue_link}, [#{issue_link}], (#{issue_link}) and #{issue_link}.",
|
| ... | ... | |
| 224 | 224 |
@project = Project.find(1) |
| 225 | 225 |
to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text), "#{text} failed" }
|
| 226 | 226 |
end |
| 227 |
|
|
| 227 |
|
|
| 228 | 228 |
def test_cross_project_redmine_links |
| 229 | 229 |
source_link = link_to('ecookbook:source:/some/file', {:controller => 'repositories', :action => 'entry', :id => 'ecookbook', :path => ['some', 'file']},
|
| 230 | 230 |
:class => 'source') |
| 231 |
|
|
| 231 |
|
|
| 232 | 232 |
changeset_link = link_to('ecookbook:r2', {:controller => 'repositories', :action => 'revision', :id => 'ecookbook', :rev => 2},
|
| 233 | 233 |
:class => 'changeset', :title => 'This commit fixes #1, #2 and references #1 & #3') |
| 234 |
|
|
| 234 |
|
|
| 235 | 235 |
to_test = {
|
| 236 | 236 |
# documents |
| 237 | 237 |
'document:"Test document"' => 'document:"Test document"', |
| ... | ... | |
| 345 | 345 |
} |
| 346 | 346 |
to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text, :attachments => Issue.find(3).attachments), "#{text} failed" }
|
| 347 | 347 |
end |
| 348 |
|
|
| 348 |
|
|
| 349 | 349 |
def test_wiki_links |
| 350 | 350 |
to_test = {
|
| 351 | 351 |
'[[CookBook documentation]]' => '<a href="/projects/ecookbook/wiki/CookBook_documentation" class="wiki-page">CookBook documentation</a>', |
| ... | ... | |
| 374 | 374 |
@project = Project.find(1) |
| 375 | 375 |
to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text) }
|
| 376 | 376 |
end |
| 377 |
|
|
| 377 |
|
|
| 378 | 378 |
def test_html_tags |
| 379 | 379 |
to_test = {
|
| 380 | 380 |
"<div>content</div>" => "<p><div>content</div></p>", |
| ... | ... | |
| 398 | 398 |
} |
| 399 | 399 |
to_test.each { |text, result| assert_equal result, textilizable(text) }
|
| 400 | 400 |
end |
| 401 |
|
|
| 401 |
|
|
| 402 | 402 |
def test_allowed_html_tags |
| 403 | 403 |
to_test = {
|
| 404 | 404 |
"<pre>preformatted text</pre>" => "<pre>preformatted text</pre>", |
| ... | ... | |
| 407 | 407 |
} |
| 408 | 408 |
to_test.each { |text, result| assert_equal result, textilizable(text) }
|
| 409 | 409 |
end |
| 410 |
|
|
| 410 |
|
|
| 411 | 411 |
def test_pre_tags |
| 412 | 412 |
raw = <<-RAW |
| 413 | 413 |
Before |
| ... | ... | |
| 426 | 426 |
</pre> |
| 427 | 427 |
<p>After</p> |
| 428 | 428 |
EXPECTED |
| 429 |
|
|
| 429 |
|
|
| 430 | 430 |
assert_equal expected.gsub(%r{[\r\n\t]}, ''), textilizable(raw).gsub(%r{[\r\n\t]}, '')
|
| 431 | 431 |
end |
| 432 |
|
|
| 432 |
|
|
| 433 | 433 |
def test_pre_content_should_not_parse_wiki_and_redmine_links |
| 434 | 434 |
raw = <<-RAW |
| 435 | 435 |
[[CookBook documentation]] |
| ... | ... | |
| 452 | 452 |
#1 |
| 453 | 453 |
</pre> |
| 454 | 454 |
EXPECTED |
| 455 |
|
|
| 455 |
|
|
| 456 | 456 |
@project = Project.find(1) |
| 457 | 457 |
assert_equal expected.gsub(%r{[\r\n\t]}, ''), textilizable(raw).gsub(%r{[\r\n\t]}, '')
|
| 458 | 458 |
end |
| 459 |
|
|
| 459 |
|
|
| 460 | 460 |
def test_non_closing_pre_blocks_should_be_closed |
| 461 | 461 |
raw = <<-RAW |
| 462 | 462 |
<pre><code> |
| ... | ... | |
| 466 | 466 |
<pre><code> |
| 467 | 467 |
</code></pre> |
| 468 | 468 |
EXPECTED |
| 469 |
|
|
| 469 |
|
|
| 470 | 470 |
@project = Project.find(1) |
| 471 | 471 |
assert_equal expected.gsub(%r{[\r\n\t]}, ''), textilizable(raw).gsub(%r{[\r\n\t]}, '')
|
| 472 | 472 |
end |
| 473 |
|
|
| 473 |
|
|
| 474 | 474 |
def test_syntax_highlight |
| 475 | 475 |
raw = <<-RAW |
| 476 | 476 |
<pre><code class="ruby"> |
| ... | ... | |
| 485 | 485 |
|
| 486 | 486 |
assert_equal expected.gsub(%r{[\r\n\t]}, ''), textilizable(raw).gsub(%r{[\r\n\t]}, '')
|
| 487 | 487 |
end |
| 488 |
|
|
| 488 |
|
|
| 489 | 489 |
def test_wiki_links_in_tables |
| 490 | 490 |
to_test = {"|[[Page|Link title]]|[[Other Page|Other title]]|\n|Cell 21|[[Last page]]|" =>
|
| 491 | 491 |
'<tr><td><a href="/projects/ecookbook/wiki/Page" class="wiki-page new">Link title</a></td>' + |
| ... | ... | |
| 495 | 495 |
@project = Project.find(1) |
| 496 | 496 |
to_test.each { |text, result| assert_equal "<table>#{result}</table>", textilizable(text).gsub(/[\t\n]/, '') }
|
| 497 | 497 |
end |
| 498 |
|
|
| 498 |
|
|
| 499 | 499 |
def test_text_formatting |
| 500 | 500 |
to_test = {'*_+bold, italic and underline+_*' => '<strong><em><ins>bold, italic and underline</ins></em></strong>',
|
| 501 | 501 |
'(_text within parentheses_)' => '(<em>text within parentheses</em>)', |
| ... | ... | |
| 505 | 505 |
} |
| 506 | 506 |
to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text) }
|
| 507 | 507 |
end |
| 508 |
|
|
| 508 |
|
|
| 509 | 509 |
def test_wiki_horizontal_rule |
| 510 | 510 |
assert_equal '<hr />', textilizable('---')
|
| 511 | 511 |
assert_equal '<p>Dashes: ---</p>', textilizable('Dashes: ---')
|
| 512 | 512 |
end |
| 513 |
|
|
| 513 |
|
|
| 514 | 514 |
def test_footnotes |
| 515 | 515 |
raw = <<-RAW |
| 516 | 516 |
This is some text[1]. |
| ... | ... | |
| 525 | 525 |
|
| 526 | 526 |
assert_equal expected.gsub(%r{[\r\n\t]}, ''), textilizable(raw).gsub(%r{[\r\n\t]}, '')
|
| 527 | 527 |
end |
| 528 |
|
|
| 528 |
|
|
| 529 |
def test_headings |
|
| 530 |
raw = 'h1. Some heading' |
|
| 531 |
expected = %|<a name="Some-heading"></a>\n<h1 >Some heading<a href="#Some-heading" class="wiki-anchor">¶</a></h1>| |
|
| 532 |
|
|
| 533 |
assert_equal expected, textilizable(raw) |
|
| 534 |
end |
|
| 535 |
|
|
| 529 | 536 |
def test_table_of_content |
| 530 | 537 |
raw = <<-RAW |
| 531 | 538 |
{{toc}}
|
| ... | ... | |
| 559 | 566 |
expected = '<ul class="toc">' + |
| 560 | 567 |
'<li><a href="#Title">Title</a>' + |
| 561 | 568 |
'<ul>' + |
| 562 |
'<li><a href="#Subtitle-with-a-Wiki-link">Subtitle with a Wiki link</a></li>' +
|
|
| 563 |
'<li><a href="#Subtitle-with-another-Wiki-link">Subtitle with another Wiki link</a></li>' +
|
|
| 569 |
'<li><a href="#Subtitle-with-a-Wiki-link">Subtitle with a Wiki link</a></li>' + |
|
| 570 |
'<li><a href="#Subtitle-with-another-Wiki-link">Subtitle with another Wiki link</a></li>' + |
|
| 564 | 571 |
'<li><a href="#Subtitle-with-red-text">Subtitle with red text</a>' + |
| 565 | 572 |
'<ul>' + |
| 566 | 573 |
'<li><a href="#Subtitle-with-some-modifiers">Subtitle with some modifiers</a></li>' + |
| ... | ... | |
| 583 | 590 |
@project = Project.find(1) |
| 584 | 591 |
assert textilizable(raw).gsub("\n", "").include?(expected), textilizable(raw)
|
| 585 | 592 |
end |
| 586 |
|
|
| 593 |
|
|
| 587 | 594 |
def test_table_of_content_should_contain_included_page_headings |
| 588 | 595 |
raw = <<-RAW |
| 589 | 596 |
{{toc}}
|
| ... | ... | |
| 595 | 602 |
|
| 596 | 603 |
expected = '<ul class="toc">' + |
| 597 | 604 |
'<li><a href="#Included">Included</a></li>' + |
| 598 |
'<li><a href="#Child-page-1">Child page 1</a></li>' +
|
|
| 605 |
'<li><a href="#Child-page-1">Child page 1</a></li>' + |
|
| 599 | 606 |
'</ul>' |
| 600 | 607 |
|
| 601 | 608 |
@project = Project.find(1) |
| 602 | 609 |
assert textilizable(raw).gsub("\n", "").include?(expected)
|
| 603 | 610 |
end |
| 604 |
|
|
| 605 |
def test_blockquote |
|
| 606 |
# orig raw text |
|
| 607 |
raw = <<-RAW |
|
| 608 |
John said: |
|
| 609 |
> Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas sed libero. |
|
| 610 |
> Nullam commodo metus accumsan nulla. Curabitur lobortis dui id dolor. |
|
| 611 |
> * Donec odio lorem, |
|
| 612 |
> * sagittis ac, |
|
| 613 |
> * malesuada in, |
|
| 614 |
> * adipiscing eu, dolor. |
|
| 615 |
> |
|
| 616 |
> >Nulla varius pulvinar diam. Proin id arcu id lorem scelerisque condimentum. Proin vehicula turpis vitae lacus. |
|
| 617 |
> Proin a tellus. Nam vel neque. |
|
| 618 | 611 |
|
| 619 |
He's right. |
|
| 620 |
RAW |
|
| 621 |
|
|
| 622 |
# expected html |
|
| 623 |
expected = <<-EXPECTED |
|
| 624 |
<p>John said:</p> |
|
| 625 |
<blockquote> |
|
| 626 |
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas sed libero. |
|
| 627 |
Nullam commodo metus accumsan nulla. Curabitur lobortis dui id dolor. |
|
| 628 |
<ul> |
|
| 629 |
<li>Donec odio lorem,</li> |
|
| 630 |
<li>sagittis ac,</li> |
|
| 631 |
<li>malesuada in,</li> |
|
| 632 |
<li>adipiscing eu, dolor.</li> |
|
| 633 |
</ul> |
|
| 634 |
<blockquote> |
|
| 635 |
<p>Nulla varius pulvinar diam. Proin id arcu id lorem scelerisque condimentum. Proin vehicula turpis vitae lacus.</p> |
|
| 636 |
</blockquote> |
|
| 637 |
<p>Proin a tellus. Nam vel neque.</p> |
|
| 638 |
</blockquote> |
|
| 639 |
<p>He's right.</p> |
|
| 640 |
EXPECTED |
|
| 641 |
|
|
| 642 |
assert_equal expected.gsub(%r{\s+}, ''), textilizable(raw).gsub(%r{\s+}, '')
|
|
| 643 |
end |
|
| 644 |
|
|
| 645 |
def test_table |
|
| 646 |
raw = <<-RAW |
|
| 647 |
This is a table with empty cells: |
|
| 648 |
|
|
| 649 |
|cell11|cell12|| |
|
| 650 |
|cell21||cell23| |
|
| 651 |
|cell31|cell32|cell33| |
|
| 652 |
RAW |
|
| 653 |
|
|
| 654 |
expected = <<-EXPECTED |
|
| 655 |
<p>This is a table with empty cells:</p> |
|
| 656 |
|
|
| 657 |
<table> |
|
| 658 |
<tr><td>cell11</td><td>cell12</td><td></td></tr> |
|
| 659 |
<tr><td>cell21</td><td></td><td>cell23</td></tr> |
|
| 660 |
<tr><td>cell31</td><td>cell32</td><td>cell33</td></tr> |
|
| 661 |
</table> |
|
| 662 |
EXPECTED |
|
| 663 |
|
|
| 664 |
assert_equal expected.gsub(%r{\s+}, ''), textilizable(raw).gsub(%r{\s+}, '')
|
|
| 665 |
end |
|
| 666 |
|
|
| 667 |
def test_table_with_line_breaks |
|
| 668 |
raw = <<-RAW |
|
| 669 |
This is a table with line breaks: |
|
| 670 |
|
|
| 671 |
|cell11 |
|
| 672 |
continued|cell12|| |
|
| 673 |
|-cell21-||cell23 |
|
| 674 |
cell23 line2 |
|
| 675 |
cell23 *line3*| |
|
| 676 |
|cell31|cell32 |
|
| 677 |
cell32 line2|cell33| |
|
| 678 |
|
|
| 679 |
RAW |
|
| 680 |
|
|
| 681 |
expected = <<-EXPECTED |
|
| 682 |
<p>This is a table with line breaks:</p> |
|
| 683 |
|
|
| 684 |
<table> |
|
| 685 |
<tr> |
|
| 686 |
<td>cell11<br />continued</td> |
|
| 687 |
<td>cell12</td> |
|
| 688 |
<td></td> |
|
| 689 |
</tr> |
|
| 690 |
<tr> |
|
| 691 |
<td><del>cell21</del></td> |
|
| 692 |
<td></td> |
|
| 693 |
<td>cell23<br/>cell23 line2<br/>cell23 <strong>line3</strong></td> |
|
| 694 |
</tr> |
|
| 695 |
<tr> |
|
| 696 |
<td>cell31</td> |
|
| 697 |
<td>cell32<br/>cell32 line2</td> |
|
| 698 |
<td>cell33</td> |
|
| 699 |
</tr> |
|
| 700 |
</table> |
|
| 701 |
EXPECTED |
|
| 702 |
|
|
| 703 |
assert_equal expected.gsub(%r{\s+}, ''), textilizable(raw).gsub(%r{\s+}, '')
|
|
| 704 |
end |
|
| 705 |
|
|
| 706 |
def test_textile_should_not_mangle_brackets |
|
| 707 |
assert_equal '<p>[msg1][msg2]</p>', textilizable('[msg1][msg2]')
|
|
| 708 |
end |
|
| 709 |
|
|
| 710 | 612 |
def test_default_formatter |
| 711 | 613 |
Setting.text_formatting = 'unknown' |
| 712 | 614 |
text = 'a *link*: http://www.example.net/' |
| 713 | 615 |
assert_equal '<p>a *link*: <a href="http://www.example.net/">http://www.example.net/</a></p>', textilizable(text) |
| 714 | 616 |
Setting.text_formatting = 'textile' |
| 715 | 617 |
end |
| 716 |
|
|
| 618 |
|
|
| 717 | 619 |
def test_due_date_distance_in_words |
| 718 | 620 |
to_test = { Date.today => 'Due in 0 days',
|
| 719 | 621 |
Date.today + 1 => 'Due in 1 day', |
| ... | ... | |
| 728 | 630 |
assert_equal expected, due_date_distance_in_words(date) |
| 729 | 631 |
end |
| 730 | 632 |
end |
| 731 |
|
|
| 633 |
|
|
| 732 | 634 |
def test_avatar |
| 733 | 635 |
# turn on avatars |
| 734 | 636 |
Setting.gravatar_enabled = '1' |
| ... | ... | |
| 736 | 638 |
assert avatar('jsmith <jsmith@somenet.foo>').include?(Digest::MD5.hexdigest('jsmith@somenet.foo'))
|
| 737 | 639 |
assert_nil avatar('jsmith')
|
| 738 | 640 |
assert_nil avatar(nil) |
| 739 |
|
|
| 641 |
|
|
| 740 | 642 |
# turn off avatars |
| 741 | 643 |
Setting.gravatar_enabled = '0' |
| 742 | 644 |
assert_equal '', avatar(User.find_by_mail('jsmith@somenet.foo'))
|
| 743 | 645 |
end |
| 744 |
|
|
| 646 |
|
|
| 745 | 647 |
def test_link_to_user |
| 746 | 648 |
user = User.find(2) |
| 747 | 649 |
t = link_to_user(user) |
| 748 | 650 |
assert_equal "<a href=\"/users/2\">#{ user.name }</a>", t
|
| 749 | 651 |
end |
| 750 |
|
|
| 652 |
|
|
| 751 | 653 |
def test_link_to_user_should_not_link_to_locked_user |
| 752 | 654 |
user = User.find(5) |
| 753 | 655 |
assert user.locked? |
| 754 | 656 |
t = link_to_user(user) |
| 755 | 657 |
assert_equal user.name, t |
| 756 | 658 |
end |
| 757 |
|
|
| 659 |
|
|
| 758 | 660 |
def test_link_to_user_should_not_link_to_anonymous |
| 759 | 661 |
user = User.anonymous |
| 760 | 662 |
assert user.anonymous? |
| test/unit/helpers/.svn/text-base/custom_fields_helper_test.rb.svn-base | ||
|---|---|---|
| 1 | 1 |
# Redmine - project management software |
| 2 |
# Copyright (C) 2006-2009 Jean-Philippe Lang
|
|
| 2 |
# Copyright (C) 2006-2011 Jean-Philippe Lang
|
|
| 3 | 3 |
# |
| 4 | 4 |
# This program is free software; you can redistribute it and/or |
| 5 | 5 |
# modify it under the terms of the GNU General Public License |
| ... | ... | |
| 26 | 26 |
assert_equal 'Yes', format_value('1', 'bool')
|
| 27 | 27 |
assert_equal 'No', format_value('0', 'bool')
|
| 28 | 28 |
end |
| 29 |
|
|
| 30 |
def test_unknow_field_format_should_be_edited_as_string |
|
| 31 |
field = CustomField.new(:field_format => 'foo') |
|
| 32 |
value = CustomValue.new(:value => 'bar', :custom_field => field) |
|
| 33 |
field.id = 52 |
|
| 34 |
|
|
| 35 |
assert_equal '<input id="object_custom_field_values_52" name="object[custom_field_values][52]" type="text" value="bar" />', |
|
| 36 |
custom_field_tag('object', value)
|
|
| 37 |
end |
|
| 38 |
|
|
| 39 |
def test_unknow_field_format_should_be_bulk_edited_as_string |
|
| 40 |
field = CustomField.new(:field_format => 'foo') |
|
| 41 |
field.id = 52 |
|
| 42 |
|
|
| 43 |
assert_equal '<input id="object_custom_field_values_52" name="object[custom_field_values][52]" type="text" value="" />', |
|
| 44 |
custom_field_tag_for_bulk_edit('object', field)
|
|
| 45 |
end |
|
| 29 | 46 |
end |
| test/unit/helpers/.svn/text-base/issues_helper_test.rb.svn-base | ||
|---|---|---|
| 1 | 1 |
# Redmine - project management software |
| 2 |
# Copyright (C) 2006-2010 Jean-Philippe Lang
|
|
| 2 |
# Copyright (C) 2006-2011 Jean-Philippe Lang
|
|
| 3 | 3 |
# |
| 4 | 4 |
# This program is free software; you can redistribute it and/or |
| 5 | 5 |
# modify it under the terms of the GNU General Public License |
| 6 | 6 |
# as published by the Free Software Foundation; either version 2 |
| 7 | 7 |
# of the License, or (at your option) any later version. |
| 8 |
#
|
|
| 8 |
# |
|
| 9 | 9 |
# This program is distributed in the hope that it will be useful, |
| 10 | 10 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | 11 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | 12 |
# GNU General Public License for more details. |
| 13 |
#
|
|
| 13 |
# |
|
| 14 | 14 |
# You should have received a copy of the GNU General Public License |
| 15 | 15 |
# along with this program; if not, write to the Free Software |
| 16 | 16 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| ... | ... | |
| 44 | 44 |
@request ||= ActionController::TestRequest.new |
| 45 | 45 |
end |
| 46 | 46 |
|
| 47 |
def test_issue_heading |
|
| 48 |
assert_equal "Bug #1", issue_heading(Issue.find(1)) |
|
| 49 |
end |
|
| 50 |
|
|
| 51 |
def test_issues_destroy_confirmation_message_with_one_root_issue |
|
| 52 |
assert_equal l(:text_issues_destroy_confirmation), issues_destroy_confirmation_message(Issue.find(1)) |
|
| 53 |
end |
|
| 54 |
|
|
| 55 |
def test_issues_destroy_confirmation_message_with_an_arrayt_of_root_issues |
|
| 56 |
assert_equal l(:text_issues_destroy_confirmation), issues_destroy_confirmation_message(Issue.find([1, 2])) |
|
| 57 |
end |
|
| 58 |
|
|
| 59 |
def test_issues_destroy_confirmation_message_with_one_parent_issue |
|
| 60 |
Issue.find(2).update_attribute :parent_issue_id, 1 |
|
| 61 |
assert_equal l(:text_issues_destroy_confirmation) + "\n" + l(:text_issues_destroy_descendants_confirmation, :count => 1), |
|
| 62 |
issues_destroy_confirmation_message(Issue.find(1)) |
|
| 63 |
end |
|
| 64 |
|
|
| 65 |
def test_issues_destroy_confirmation_message_with_one_parent_issue_and_its_child |
|
| 66 |
Issue.find(2).update_attribute :parent_issue_id, 1 |
|
| 67 |
assert_equal l(:text_issues_destroy_confirmation), issues_destroy_confirmation_message(Issue.find([1, 2])) |
|
| 68 |
end |
|
| 69 |
|
|
| 47 | 70 |
context "IssuesHelper#show_detail" do |
| 48 | 71 |
context "with no_html" do |
| 49 | 72 |
should 'show a changing attribute' do |
| test/unit/helpers/.svn/text-base/repository_helper_test.rb.svn-base | ||
|---|---|---|
| 24 | 24 |
with_settings :repositories_encodings => 'UTF-8,ISO-8859-1' do |
| 25 | 25 |
s1 = "Texte encod\xc3\xa9" |
| 26 | 26 |
s2 = "Texte encod\xe9" |
| 27 |
s3 = s2 |
|
| 27 |
s3 = s2.dup
|
|
| 28 | 28 |
if s1.respond_to?(:force_encoding) |
| 29 | 29 |
s1.force_encoding("UTF-8")
|
| 30 | 30 |
s2.force_encoding("ASCII-8BIT")
|
| ... | ... | |
| 39 | 39 |
with_settings :repositories_encodings => 'UTF-8,EUC-JP' do |
| 40 | 40 |
s1 = "\xe3\x83\xac\xe3\x83\x83\xe3\x83\x89\xe3\x83\x9e\xe3\x82\xa4\xe3\x83\xb3" |
| 41 | 41 |
s2 = "\xa5\xec\xa5\xc3\xa5\xc9\xa5\xde\xa5\xa4\xa5\xf3" |
| 42 |
s3 = s2 |
|
| 42 |
s3 = s2.dup
|
|
| 43 | 43 |
if s1.respond_to?(:force_encoding) |
| 44 | 44 |
s1.force_encoding("UTF-8")
|
| 45 | 45 |
s2.force_encoding("ASCII-8BIT")
|
| ... | ... | |
| 54 | 54 |
with_settings :repositories_encodings => 'ISO-8859-1' do |
| 55 | 55 |
s1 = "\xc3\x82\xc2\x80" |
| 56 | 56 |
s2 = "\xC2\x80" |
| 57 |
s3 = s2 |
|
| 57 |
s3 = s2.dup
|
|
| 58 | 58 |
if s1.respond_to?(:force_encoding) |
| 59 | 59 |
s1.force_encoding("UTF-8")
|
| 60 | 60 |
s2.force_encoding("ASCII-8BIT")
|
| ... | ... | |
| 64 | 64 |
assert_equal s1, to_utf8(s3) |
| 65 | 65 |
end |
| 66 | 66 |
end |
| 67 |
|
|
| 68 |
def test_to_utf8_blank_string |
|
| 69 |
assert_equal "", to_utf8("")
|
|
| 70 |
assert_equal nil, to_utf8(nil) |
|
| 71 |
end |
|
| 72 |
|
|
| 73 |
def test_to_utf8_returns_ascii_as_utf8 |
|
| 74 |
s1 = "ASCII" |
|
| 75 |
s2 = s1.dup |
|
| 76 |
if s1.respond_to?(:force_encoding) |
|
| 77 |
s1.force_encoding("UTF-8")
|
|
| 78 |
s2.force_encoding("ISO-8859-1")
|
|
| 79 |
end |
|
| 80 |
str1 = to_utf8(s1) |
|
| 81 |
str2 = to_utf8(s2) |
|
| 82 |
assert_equal s1, str1 |
|
| 83 |
assert_equal s1, str2 |
|
| 84 |
if s1.respond_to?(:force_encoding) |
|
| 85 |
assert_equal "UTF-8", str1.encoding.to_s |
|
| 86 |
assert_equal "UTF-8", str2.encoding.to_s |
|
| 87 |
end |
|
| 88 |
end |
|
| 89 |
|
|
| 90 |
def test_to_utf8_invalid_utf8_sequences_should_be_stripped |
|
| 91 |
with_settings :repositories_encodings => '' do |
|
| 92 |
# s1 = File.read("#{RAILS_ROOT}/test/fixtures/encoding/iso-8859-1.txt")
|
|
| 93 |
s1 = "Texte encod\xe9 en ISO-8859-1." |
|
| 94 |
s1.force_encoding("ASCII-8BIT") if s1.respond_to?(:force_encoding)
|
|
| 95 |
str = to_utf8(s1) |
|
| 96 |
if str.respond_to?(:force_encoding) |
|
| 97 |
assert str.valid_encoding? |
|
| 98 |
assert_equal "UTF-8", str.encoding.to_s |
|
| 99 |
end |
|
| 100 |
assert_equal "Texte encod? en ISO-8859-1.", str |
|
| 101 |
end |
|
| 102 |
end |
|
| 103 |
|
|
| 104 |
def test_to_utf8_invalid_utf8_sequences_should_be_stripped_ja_jis |
|
| 105 |
with_settings :repositories_encodings => 'ISO-2022-JP' do |
|
| 106 |
s1 = "test\xb5\xfetest\xb5\xfe" |
|
| 107 |
s1.force_encoding("ASCII-8BIT") if s1.respond_to?(:force_encoding)
|
|
| 108 |
str = to_utf8(s1) |
|
| 109 |
if str.respond_to?(:force_encoding) |
|
| 110 |
assert str.valid_encoding? |
|
| 111 |
assert_equal "UTF-8", str.encoding.to_s |
|
| 112 |
end |
|
| 113 |
assert_equal "test??test??", str |
|
| 114 |
end |
|
| 115 |
end |
|
| 67 | 116 |
end |
| 68 |
|
|
Also available in: Unified diff