1
|
# redMine - project management software
|
2
|
# Copyright (C) 2008 Karl Heinz Marbaise
|
3
|
#
|
4
|
# This program is free software; you can redistribute it and/or
|
5
|
# modify it under the terms of the GNU General Public License
|
6
|
# as published by the Free Software Foundation; either version 2
|
7
|
# of the License, or (at your option) any later version.
|
8
|
#
|
9
|
# This program is distributed in the hope that it will be useful,
|
10
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
12
|
# GNU General Public License for more details.
|
13
|
#
|
14
|
# You should have received a copy of the GNU General Public License
|
15
|
# along with this program; if not, write to the Free Software
|
16
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
17
|
|
18
|
require 'test/unit'
|
19
|
require File.dirname(__FILE__) + '/../../../../lib/tasks/trac/trac_migration'
|
20
|
|
21
|
class TracMigrationTest < Test::Unit::TestCase
|
22
|
|
23
|
# def setup
|
24
|
# @trac = TracMigrate::TracWiki.new()
|
25
|
# end
|
26
|
|
27
|
# The following three test cases are related to issue #2023
|
28
|
# The construct {{{XYZ}}} is not supported by trac.
|
29
|
# so the result should be simply the same as the input.
|
30
|
def test_activity_code_tags_10
|
31
|
assert_equal("{{{XYZ}}}", TracMigrate::TracWiki.wiki("{{{XYZ}}}"))
|
32
|
end
|
33
|
|
34
|
# This construct is valid and would produce the expected output in trac.
|
35
|
# The {{{ must be on a separate line and }}} as well.
|
36
|
def test_activity_code_tags_20
|
37
|
assert_equal("<pre>\nXYZ\n</pre>", TracMigrate::TracWiki.wiki("{{{\nXYZ\n}}}"))
|
38
|
end
|
39
|
|
40
|
def test_activity_code_tags_30
|
41
|
assert_equal("<pre>\n<code class=\"java\">\npublic class test\n</code></pre>", TracMigrate::TracWiki.wiki("{{{\n#!java\npublic class test\n}}}"))
|
42
|
end
|
43
|
|
44
|
# manual break
|
45
|
# The official guide in trac says this is the only way.
|
46
|
def test_activity_br_10
|
47
|
assert_equal("\n", TracMigrate::TracWiki.wiki("[[BR]]"))
|
48
|
end
|
49
|
|
50
|
# but the lower case variant is working too.
|
51
|
def test_activity_br_11
|
52
|
assert_equal("\n", TracMigrate::TracWiki.wiki("[[br]]"))
|
53
|
end
|
54
|
|
55
|
## ------------------
|
56
|
## Code Highlightings
|
57
|
## ------------------
|
58
|
def test_activity_highlighting_10
|
59
|
assert_equal("_*HighlightingText*_", TracMigrate::TracWiki.wiki("'''''HighlightingText'''''"))
|
60
|
end
|
61
|
|
62
|
def test_activity_highlighting_20
|
63
|
assert_equal("*HighlightingText*", TracMigrate::TracWiki.wiki("'''HighlightingText'''"))
|
64
|
end
|
65
|
|
66
|
def test_activity_highlighting_30
|
67
|
assert_equal("_HighlightingText_", TracMigrate::TracWiki.wiki("''HighlightingText''"))
|
68
|
end
|
69
|
|
70
|
def test_activity_highlighting_40
|
71
|
assert_equal("+HighlightingText+", TracMigrate::TracWiki.wiki("__HighlightingText__"))
|
72
|
end
|
73
|
|
74
|
# Milestones
|
75
|
# The following test cases are related to issue #2052
|
76
|
def test_activity_milestone_10
|
77
|
assert_equal("version:1.0.0", TracMigrate::TracWiki.wiki("milestone:1.0.0"))
|
78
|
end
|
79
|
|
80
|
def test_activity_milestone_20
|
81
|
assert_equal('version:"1.0.0"', TracMigrate::TracWiki.wiki('milestone:"1.0.0"'))
|
82
|
end
|
83
|
|
84
|
def test_activity_milestone_30
|
85
|
assert_equal('version:"0.1.0 Mercury"', TracMigrate::TracWiki.wiki('[milestone:"0.1.0 Mercury" Milestone 0.1.0 (Mercury)]'))
|
86
|
end
|
87
|
|
88
|
def test_activity_milestone_40
|
89
|
assert_equal('version:"Test Milestone X"', TracMigrate::TracWiki.wiki('[milestone:"Test Milestone X"]'))
|
90
|
end
|
91
|
|
92
|
# Tickets (issue #2053)
|
93
|
def test_activity_ticket_10
|
94
|
assert_equal('#123', TracMigrate::TracWiki.wiki('ticket:123'))
|
95
|
end
|
96
|
|
97
|
def test_activity_ticket_11
|
98
|
assert_equal('#123', TracMigrate::TracWiki.wiki('#123'))
|
99
|
end
|
100
|
|
101
|
def test_activity_ticket_20
|
102
|
assert_equal('#123', TracMigrate::TracWiki.wiki('[ticket:123]'))
|
103
|
end
|
104
|
|
105
|
def test_activity_ticket_30
|
106
|
assert_equal('"this":/issues/show/123', TracMigrate::TracWiki.wiki('[ticket:123 this]'))
|
107
|
end
|
108
|
|
109
|
# Tables (issue #2054)
|
110
|
def test_activity_tables_10
|
111
|
assert_equal(
|
112
|
'|Column1|Column2|Column3|',
|
113
|
TracMigrate::TracWiki.wiki('||Column1||Column2||Column3||')
|
114
|
)
|
115
|
end
|
116
|
|
117
|
# Tables (issue #2089)
|
118
|
def test_activity_mailto_10
|
119
|
assert_equal('user@test.de', TracMigrate::TracWiki.wiki('[mailto:user@test.de]'))
|
120
|
end
|
121
|
def test_activity_mailto_20
|
122
|
assert_equal(
|
123
|
'"The new text":mailto:user@test.de',
|
124
|
TracMigrate::TracWiki.wiki('[mailto:user@test.de The new text]')
|
125
|
)
|
126
|
end
|
127
|
|
128
|
#source - tag (issue #2068)
|
129
|
def test_activity_source_10
|
130
|
assert_equal(
|
131
|
'source:/tags/JAGOSI-0.0.10/jagosiapi/src/main/java/com/soebes/jagosi/api/JaGoSI.java@HEAD#L143',
|
132
|
TracMigrate::TracWiki.wiki('[source:/tags/JAGOSI-0.0.10/jagosiapi/src/main/java/com/soebes/jagosi/api/JaGoSI.java@latest#L143 Line 143]')
|
133
|
)
|
134
|
end
|
135
|
|
136
|
def test_activity_wiki_10
|
137
|
assert_equal(
|
138
|
'[[RepositoryQuestions|Have you ever put such questions to your repository]]',
|
139
|
TracMigrate::TracWiki.wiki('[wiki:RepositoryQuestions Have you ever put such questions to your repository?]')
|
140
|
)
|
141
|
end
|
142
|
|
143
|
def test_activity_wiki_20
|
144
|
assert_equal(
|
145
|
'* -Scan a whole repository-',
|
146
|
TracMigrate::TracWiki.wiki(' * ~~Scan a whole repository~~')
|
147
|
)
|
148
|
end
|
149
|
|
150
|
def test_activity_wiki_30
|
151
|
assert_equal(
|
152
|
'* -[[Configuration|Cron like automation]] to scan repositories-.',
|
153
|
TracMigrate::TracWiki.wiki(' * ~~[wiki:Configuration Cron like automation] to scan repositories~~.')
|
154
|
)
|
155
|
end
|
156
|
|
157
|
def test_activity_changeset_10
|
158
|
assert_equal('r123', TracMigrate::TracWiki.wiki('r123'))
|
159
|
end
|
160
|
def test_activity_changeset_20
|
161
|
assert_equal('r123', TracMigrate::TracWiki.wiki('[123]'))
|
162
|
end
|
163
|
def test_activity_changeset_30
|
164
|
assert_equal('r123', TracMigrate::TracWiki.wiki('changeset:123'))
|
165
|
end
|
166
|
|
167
|
|
168
|
def test_activity_integration_10
|
169
|
assert_equal(
|
170
|
'version:"XXX"+Test+version:"Test Milestone X"',
|
171
|
TracMigrate::TracWiki.wiki('[milestone:"XXX"]__Test__[milestone:"Test Milestone X"]')
|
172
|
)
|
173
|
end
|
174
|
end
|
175
|
|