Fixed 1.8.7 compatible issue

This commit is contained in:
blmarket
2012-05-31 21:23:58 +09:00
parent 150a019b8d
commit eaa7a61f71
2 changed files with 20 additions and 12 deletions
+12 -8
View File
@@ -1,6 +1,10 @@
# ~*~ encoding: utf-8 ~*~
require File.expand_path(File.join(File.dirname(__FILE__), "helper"))
def utf8(str)
str.respond_to?(:force_encoding) ? str.force_encoding('utf-8') : str
end
context "Unicode Support" do
setup do
@path = cloned_testpath("examples/revert.git")
@@ -16,7 +20,7 @@ context "Unicode Support" do
page = @wiki.page("한글 test")
assert_equal Gollum::Page, page.class
assert_equal "# 한글", page.raw_data.force_encoding('utf-8')
assert_equal "# 한글", utf8(page.raw_data)
end
test "unicode with existing format rules" do
@@ -57,27 +61,27 @@ context "Frontend Unicode support" do
assert last_response.ok?
page = @wiki.page('한글')
assert_equal '한글 text', page.raw_data.force_encoding('utf-8')
assert_equal '한글 text', utf8(page.raw_data)
assert_equal 'def', page.version.message
end
test "heavy use 1" do
post "/create", :content => '한글 text'.force_encoding('ascii-8bit'), :page => "PG",
post "/create", :content => '한글 text', :page => "PG",
:format => 'markdown', :message => 'def'
follow_redirect!
assert last_response.ok?
@wiki.update_page(@wiki.page('PG'), nil, nil, '다른 text', {})
page = @wiki.page('PG')
assert_equal '다른 text', page.raw_data.force_encoding('utf-8')
assert_equal '다른 text', utf8(page.raw_data)
post '/edit/PG', :content => '바뀐 text'.force_encoding('ascii-8bit'), :message => 'ghi'
post '/edit/PG', :content => '바뀐 text', :message => 'ghi'
follow_redirect!
assert last_response.ok?
@wiki = Gollum::Wiki.new(@path)
page = @wiki.page('PG')
assert_equal '바뀐 text', page.raw_data.force_encoding('utf-8')
assert_equal '바뀐 text', utf8(page.raw_data)
assert_equal 'ghi', page.version.message
end
@@ -90,7 +94,7 @@ context "Frontend Unicode support" do
@wiki.update_page(@wiki.page('한글'), nil, nil, '다른 text', {})
@wiki = Gollum::Wiki.new(@path)
page = @wiki.page('한글')
assert_equal '다른 text', page.raw_data.force_encoding('utf-8')
assert_equal '다른 text', utf8(page.raw_data)
post '/edit/' + CGI.escape('한글'), :content => '바뀐 text',
:format => 'markdown', :message => 'ghi'
@@ -99,7 +103,7 @@ context "Frontend Unicode support" do
@wiki = Gollum::Wiki.new(@path)
page = @wiki.page('한글')
assert_equal '바뀐 text', page.raw_data.force_encoding('utf-8')
assert_equal '바뀐 text', utf8(page.raw_data)
assert_equal 'ghi', page.version.message
end