Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
O
OHR Support
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
97
Issues
97
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
OHR Support
Commits
13de4cc4
Commit
13de4cc4
authored
May 06, 2011
by
Eric Davis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[#383] Fixed failing tests due to a helper method name conflict (to_utf8)
Introduced in
1eee7312
parent
d2931534
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
26 additions
and
26 deletions
+26
-26
attachments_helper.rb
app/helpers/attachments_helper.rb
+1
-1
repositories_helper.rb
app/helpers/repositories_helper.rb
+1
-1
timelog_helper.rb
app/helpers/timelog_helper.rb
+3
-3
_diff.rhtml
app/views/common/_diff.rhtml
+2
-2
_file.rhtml
app/views/common/_file.rhtml
+1
-1
annotate.rhtml
app/views/repositories/annotate.rhtml
+1
-1
repository_helper_test.rb
test/unit/helpers/repository_helper_test.rb
+17
-17
No files found.
app/helpers/attachments_helper.rb
View file @
13de4cc4
...
...
@@ -28,7 +28,7 @@ module AttachmentsHelper
end
end
def
to_utf8
(
str
)
def
to_utf8
_for_attachments
(
str
)
if
str
.
respond_to?
(
:force_encoding
)
str
.
force_encoding
(
'UTF-8'
)
return
str
if
str
.
valid_encoding?
...
...
app/helpers/repositories_helper.rb
View file @
13de4cc4
...
...
@@ -116,7 +116,7 @@ module RepositoriesHelper
output
end
def
to_utf8
(
str
)
def
to_utf8
_for_repositories
(
str
)
return
str
if
str
.
nil?
str
=
to_utf8_internal
(
str
)
if
str
.
respond_to?
(
:force_encoding
)
...
...
app/helpers/timelog_helper.rb
View file @
13de4cc4
...
...
@@ -144,7 +144,7 @@ module TimelogHelper
headers
=
criterias
.
collect
{
|
criteria
|
l
(
@available_criterias
[
criteria
][
:label
])
}
headers
+=
periods
headers
<<
l
(
:label_total
)
csv
<<
headers
.
collect
{
|
c
|
to_utf8
(
c
)
}
csv
<<
headers
.
collect
{
|
c
|
to_utf8
_for_timelogs
(
c
)
}
# Content
report_criteria_to_csv
(
csv
,
criterias
,
periods
,
hours
)
# Total row
...
...
@@ -166,7 +166,7 @@ module TimelogHelper
hours_for_value
=
select_hours
(
hours
,
criterias
[
level
],
value
)
next
if
hours_for_value
.
empty?
row
=
[
''
]
*
level
row
<<
to_utf8
(
format_criteria_value
(
criterias
[
level
],
value
))
row
<<
to_utf8
_for_timelogs
(
format_criteria_value
(
criterias
[
level
],
value
))
row
+=
[
''
]
*
(
criterias
.
length
-
level
-
1
)
total
=
0
periods
.
each
do
|
period
|
...
...
@@ -183,7 +183,7 @@ module TimelogHelper
end
end
def
to_utf8
(
s
)
def
to_utf8
_for_timelogs
(
s
)
@ic
||=
Iconv
.
new
(
l
(
:general_csv_encoding
),
'UTF-8'
)
begin
;
@ic
.
iconv
(
s
.
to_s
);
rescue
;
s
.
to_s
;
end
end
...
...
app/views/common/_diff.rhtml
View file @
13de4cc4
...
...
@@ -31,7 +31,7 @@
<%
else
-%>
<table
class=
"filecontent"
>
<thead>
<tr><th
colspan=
"3"
class=
"filename"
>
<%=
to_utf8
table_file
.
file_name
%>
</th></tr>
<tr><th
colspan=
"3"
class=
"filename"
>
<%=
to_utf8
_for_attachments
table_file
.
file_name
%>
</th></tr>
</thead>
<tbody>
<%
table_file
.
each_line
do
|
spacing
,
line
|
%>
...
...
@@ -44,7 +44,7 @@
<th
class=
"line-num"
>
<%=
line
.
nb_line_left
%>
</th>
<th
class=
"line-num"
>
<%=
line
.
nb_line_right
%>
</th>
<td
class=
"line-code
<%=
line
.
type_diff
%>
"
>
<pre>
<%=
to_utf8
line
.
html_line
%>
</pre>
<pre>
<%=
to_utf8
_for_attachments
line
.
html_line
%>
</pre>
</td>
</tr>
<%
end
-%>
...
...
app/views/common/_file.rhtml
View file @
13de4cc4
...
...
@@ -2,7 +2,7 @@
<table
class=
"filecontent syntaxhl"
>
<tbody>
<%
line_num
=
1
%>
<%
syntax_highlight
(
filename
,
to_utf8
(
content
)).
each_line
do
|
line
|
%>
<%
syntax_highlight
(
filename
,
to_utf8
_for_attachments
(
content
)).
each_line
do
|
line
|
%>
<tr><th
class=
"line-num"
id=
"L
<%=
line_num
%>
"
><a
href=
"#L
<%=
line_num
%>
"
>
<%=
line_num
%>
</a></th><td
class=
"line-code"
><pre>
<%=
line
%>
</pre></td></tr>
<%
line_num
+=
1
%>
<%
end
%>
...
...
app/views/repositories/annotate.rhtml
View file @
13de4cc4
...
...
@@ -14,7 +14,7 @@
<table
class=
"filecontent annotate syntaxhl"
>
<tbody>
<%
line_num
=
1
%>
<%
syntax_highlight
(
@path
,
to_utf8
(
@annotate
.
content
)).
each_line
do
|
line
|
%>
<%
syntax_highlight
(
@path
,
to_utf8
_for_repositories
(
@annotate
.
content
)).
each_line
do
|
line
|
%>
<%
revision
=
@annotate
.
revisions
[
line_num
-
1
]
%>
<tr
class=
"bloc-
<%=
revision
.
nil?
?
0
:
colors
[
revision
.
identifier
||
revision
.
revision
]
%>
"
>
<th
class=
"line-num"
id=
"L
<%=
line_num
%>
"
><a
href=
"#L
<%=
line_num
%>
"
>
<%=
line_num
%>
</a></th>
...
...
test/unit/helpers/repository_helper_test.rb
View file @
13de4cc4
...
...
@@ -20,7 +20,7 @@ require File.expand_path('../../../test_helper', __FILE__)
class
RepositoryHelperTest
<
HelperTestCase
include
RepositoriesHelper
def
test_from_latin1_to_utf8
def
test_from_latin1_to_utf8
_for_repositories
with_settings
:repositories_encodings
=>
'UTF-8,ISO-8859-1'
do
s1
=
"Texte encod
\xc3\xa9
"
s2
=
"Texte encod
\xe9
"
...
...
@@ -30,12 +30,12 @@ class RepositoryHelperTest < HelperTestCase
s2
.
force_encoding
(
"ASCII-8BIT"
)
s3
.
force_encoding
(
"UTF-8"
)
end
assert_equal
s1
,
to_utf8
(
s2
)
assert_equal
s1
,
to_utf8
(
s3
)
assert_equal
s1
,
to_utf8
_for_repositories
(
s2
)
assert_equal
s1
,
to_utf8
_for_repositories
(
s3
)
end
end
def
test_from_euc_jp_to_utf8
def
test_from_euc_jp_to_utf8
_for_repositories
with_settings
:repositories_encodings
=>
'UTF-8,EUC-JP'
do
s1
=
"
\xe3\x83\xac\xe3\x83\x83\xe3\x83\x89\xe3\x83\x9e\xe3\x82\xa4\xe3\x83\xb3
"
s2
=
"
\xa5\xec\xa5\xc3\xa5\xc9\xa5\xde\xa5\xa4\xa5\xf3
"
...
...
@@ -45,12 +45,12 @@ class RepositoryHelperTest < HelperTestCase
s2
.
force_encoding
(
"ASCII-8BIT"
)
s3
.
force_encoding
(
"UTF-8"
)
end
assert_equal
s1
,
to_utf8
(
s2
)
assert_equal
s1
,
to_utf8
(
s3
)
assert_equal
s1
,
to_utf8
_for_repositories
(
s2
)
assert_equal
s1
,
to_utf8
_for_repositories
(
s3
)
end
end
def
test_to_utf8_should_be_converted_all_latin1_to_utf8
def
test_to_utf8_
for_repositories_
should_be_converted_all_latin1_to_utf8
with_settings
:repositories_encodings
=>
'ISO-8859-1'
do
s1
=
"
\xc3\x82\xc2\x80
"
s2
=
"
\xC2\x80
"
...
...
@@ -60,25 +60,25 @@ class RepositoryHelperTest < HelperTestCase
s2
.
force_encoding
(
"ASCII-8BIT"
)
s3
.
force_encoding
(
"UTF-8"
)
end
assert_equal
s1
,
to_utf8
(
s2
)
assert_equal
s1
,
to_utf8
(
s3
)
assert_equal
s1
,
to_utf8
_for_repositories
(
s2
)
assert_equal
s1
,
to_utf8
_for_repositories
(
s3
)
end
end
def
test_to_utf8_blank_string
assert_equal
""
,
to_utf8
(
""
)
assert_equal
nil
,
to_utf8
(
nil
)
def
test_to_utf8_
for_repositories_
blank_string
assert_equal
""
,
to_utf8
_for_repositories
(
""
)
assert_equal
nil
,
to_utf8
_for_repositories
(
nil
)
end
def
test_to_utf8_returns_ascii_as_utf8
def
test_to_utf8_
for_repositories_
returns_ascii_as_utf8
s1
=
"ASCII"
s2
=
s1
.
dup
if
s1
.
respond_to?
(
:force_encoding
)
s1
.
force_encoding
(
"UTF-8"
)
s2
.
force_encoding
(
"ISO-8859-1"
)
end
str1
=
to_utf8
(
s1
)
str2
=
to_utf8
(
s2
)
str1
=
to_utf8
_for_repositories
(
s1
)
str2
=
to_utf8
_for_repositories
(
s2
)
assert_equal
s1
,
str1
assert_equal
s1
,
str2
if
s1
.
respond_to?
(
:force_encoding
)
...
...
@@ -87,10 +87,10 @@ class RepositoryHelperTest < HelperTestCase
end
end
def
test_to_utf8_invalid_utf8_sequences_should_be_stripped
def
test_to_utf8_
for_repositories_
invalid_utf8_sequences_should_be_stripped
with_settings
:repositories_encodings
=>
''
do
s1
=
File
.
read
(
"
#{
RAILS_ROOT
}
/test/fixtures/encoding/iso-8859-1.txt"
)
str
=
to_utf8
(
s1
)
str
=
to_utf8
_for_repositories
(
s1
)
if
str
.
respond_to?
(
:force_encoding
)
assert_equal
"Texte encod? en ISO-8859-1."
,
str
assert
str
.
valid_encoding?
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment