Get all the tests passing under ruby 1.9
This commit is contained in:
parent
df02008ee9
commit
9813d9f1e4
14 changed files with 61 additions and 44 deletions
4
Gemfile
4
Gemfile
|
@ -4,6 +4,9 @@ source 'http://rubygems.org'
|
|||
# Require rails
|
||||
gem 'rails', '3.2.3'
|
||||
|
||||
# Require things which have moved to gems in ruby 1.9
|
||||
gem 'bigdecimal', :platforms => :ruby_19
|
||||
|
||||
# Require the postgres database driver
|
||||
gem 'pg'
|
||||
|
||||
|
@ -47,6 +50,7 @@ gem 'memcached', '>= 1.4.1'
|
|||
# Gems needed for running tests
|
||||
group :test do
|
||||
gem 'timecop'
|
||||
gem 'minitest', :platforms => :ruby_19
|
||||
end
|
||||
|
||||
# Gems needed for compiling assets
|
||||
|
|
|
@ -30,6 +30,7 @@ GEM
|
|||
i18n (~> 0.6)
|
||||
multi_json (~> 1.0)
|
||||
arel (3.0.2)
|
||||
bigdecimal (1.1.0)
|
||||
builder (3.0.0)
|
||||
cocaine (0.2.1)
|
||||
coffee-rails (3.2.2)
|
||||
|
@ -68,6 +69,7 @@ GEM
|
|||
treetop (~> 1.4.8)
|
||||
memcached (1.4.1)
|
||||
mime-types (1.18)
|
||||
minitest (3.0.1)
|
||||
multi_json (1.3.4)
|
||||
multipart-post (1.1.5)
|
||||
nokogiri (1.5.2)
|
||||
|
@ -154,6 +156,7 @@ PLATFORMS
|
|||
|
||||
DEPENDENCIES
|
||||
SystemTimer (>= 1.1.3)
|
||||
bigdecimal
|
||||
coffee-rails (~> 3.2.1)
|
||||
composite_primary_keys (>= 5.0.0)
|
||||
deadlock_retry (>= 1.2.0)
|
||||
|
@ -165,6 +168,7 @@ DEPENDENCIES
|
|||
jquery-rails
|
||||
libxml-ruby (>= 2.0.5)
|
||||
memcached (>= 1.4.1)
|
||||
minitest
|
||||
open_id_authentication (>= 1.1.0)
|
||||
openstreetmap-oauth-plugin (>= 0.4.0.1)
|
||||
paperclip (~> 2.0)
|
||||
|
|
|
@ -423,7 +423,7 @@ class AmfController < ApplicationController
|
|||
# Remove any elements where 2 seconds doesn't elapse before next one
|
||||
revdates.delete_if { |d| revdates.include?(d+1) or revdates.include?(d+2) }
|
||||
# Collect all in one nested array
|
||||
revdates.collect! {|d| [d.succ.strftime("%d %b %Y, %H:%M:%S")] + revusers[d.to_i] }
|
||||
revdates.collect! {|d| [(d + 1).strftime("%d %b %Y, %H:%M:%S")] + revusers[d.to_i] }
|
||||
revdates.uniq!
|
||||
|
||||
return ['way', wayid, revdates]
|
||||
|
@ -437,7 +437,7 @@ class AmfController < ApplicationController
|
|||
def getnode_history(nodeid) #:doc:
|
||||
begin
|
||||
history = Node.find(nodeid).old_nodes.unredacted.reverse.collect do |old_node|
|
||||
[old_node.timestamp.succ.strftime("%d %b %Y, %H:%M:%S")] + change_user(old_node)
|
||||
[(old_node.timestamp + 1).strftime("%d %b %Y, %H:%M:%S")] + change_user(old_node)
|
||||
end
|
||||
return ['node', nodeid, history]
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
|
|
|
@ -400,7 +400,7 @@ en:
|
|||
post: Post
|
||||
when: When
|
||||
comment: Comment
|
||||
ago: %{ago} ago
|
||||
ago: "%{ago} ago"
|
||||
newer_comments: "Newer Comments"
|
||||
older_comments: "Older Comments"
|
||||
export:
|
||||
|
|
|
@ -8,18 +8,20 @@ module Potlatch
|
|||
|
||||
# Return two-byte integer
|
||||
def self.getint(s)
|
||||
s.getc*256+s.getc
|
||||
s.getbyte*256+s.getbyte
|
||||
end
|
||||
|
||||
# Return four-byte long
|
||||
def self.getlong(s)
|
||||
((s.getc*256+s.getc)*256+s.getc)*256+s.getc
|
||||
((s.getbyte*256+s.getbyte)*256+s.getbyte)*256+s.getbyte
|
||||
end
|
||||
|
||||
# Return string with two-byte length
|
||||
def self.getstring(s)
|
||||
len=s.getc*256+s.getc
|
||||
s.read(len)
|
||||
len=s.getbyte*256+s.getbyte
|
||||
str=s.read(len)
|
||||
str.force_encoding("UTF-8") if str.respond_to?("force_encoding")
|
||||
str
|
||||
end
|
||||
|
||||
# Return eight-byte double-precision float
|
||||
|
@ -45,23 +47,23 @@ module Potlatch
|
|||
if (key=='') then break end
|
||||
arr[key]=getvalue(s)
|
||||
end
|
||||
s.getc # skip the 9 'end of object' value
|
||||
s.getbyte # skip the 9 'end of object' value
|
||||
arr
|
||||
end
|
||||
|
||||
# Parse and get value
|
||||
def self.getvalue(s)
|
||||
case s.getc
|
||||
case s.getbyte
|
||||
when 0; return getdouble(s) # number
|
||||
when 1; return s.getc # boolean
|
||||
when 1; return s.getbyte # boolean
|
||||
when 2; return getstring(s) # string
|
||||
when 3; return getobject(s) # object/hash
|
||||
when 5; return nil # null
|
||||
when 6; return nil # undefined
|
||||
when 8; s.read(4) # mixedArray
|
||||
return getobject(s) # |
|
||||
when 10;return getarray(s) # array
|
||||
else; return nil # error
|
||||
when 5; return nil # null
|
||||
when 6; return nil # undefined
|
||||
when 8; s.read(4) # mixedArray
|
||||
return getobject(s) # |
|
||||
when 10; return getarray(s) # array
|
||||
else; return nil # error
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -134,7 +136,7 @@ module Potlatch
|
|||
# Skip headers
|
||||
AMF.getint(@request).times do # Read number of headers and loop
|
||||
AMF.getstring(@request) # | skip name
|
||||
req.getc # | skip boolean
|
||||
req.getbyte # | skip boolean
|
||||
AMF.getvalue(@request) # | skip value
|
||||
end
|
||||
|
||||
|
|
23
lib/utf8.rb
23
lib/utf8.rb
|
@ -1,16 +1,21 @@
|
|||
require 'iconv'
|
||||
|
||||
module UTF8
|
||||
##
|
||||
# Checks that a string is valid UTF-8 by trying to convert it to UTF-8
|
||||
# using the iconv library, which is in the standard library.
|
||||
def self.valid?(str)
|
||||
return true if str.nil?
|
||||
Iconv.conv("UTF-8", "UTF-8", str)
|
||||
return true
|
||||
if String.new.respond_to?("valid_encoding?")
|
||||
def self.valid?(str)
|
||||
return true if str.nil?
|
||||
return str.valid_encoding?
|
||||
end
|
||||
else
|
||||
require 'iconv'
|
||||
|
||||
rescue
|
||||
return false
|
||||
def self.valid?(str)
|
||||
return true if str.nil?
|
||||
Iconv.conv("UTF-8", "UTF-8", str)
|
||||
return true
|
||||
rescue
|
||||
return false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -295,11 +295,10 @@ class AmfControllerTest < ActionController::TestCase
|
|||
assert_equal latest.id, history[1]
|
||||
# We use dates rather than version numbers here, because you might
|
||||
# have moved a node within a way (i.e. way version not incremented).
|
||||
# The timestamp is +1 (timestamp.succ) because we say "give me the
|
||||
# revision of 15:33:02", but that might actually include changes at
|
||||
# 15:33:02.457.
|
||||
assert_equal latest.timestamp.succ.strftime("%d %b %Y, %H:%M:%S"), history[2].first[0]
|
||||
assert_equal oldest.timestamp.succ.strftime("%d %b %Y, %H:%M:%S"), history[2].last[0]
|
||||
# The timestamp is +1 because we say "give me the revision of 15:33:02",
|
||||
# but that might actually include changes at 15:33:02.457.
|
||||
assert_equal (latest.timestamp + 1).strftime("%d %b %Y, %H:%M:%S"), history[2].first[0]
|
||||
assert_equal (oldest.timestamp + 1).strftime("%d %b %Y, %H:%M:%S"), history[2].last[0]
|
||||
end
|
||||
|
||||
def test_getway_history_nonexistent
|
||||
|
@ -331,10 +330,10 @@ class AmfControllerTest < ActionController::TestCase
|
|||
assert_equal history[1], latest.id,
|
||||
'second element should be the input node ID'
|
||||
assert_equal history[2].first[0],
|
||||
latest.timestamp.succ.strftime("%d %b %Y, %H:%M:%S"),
|
||||
(latest.timestamp + 1).strftime("%d %b %Y, %H:%M:%S"),
|
||||
'first element in third element (array) should be the latest version'
|
||||
assert_equal history[2].last[0],
|
||||
nodes(:node_with_versions_v1).timestamp.succ.strftime("%d %b %Y, %H:%M:%S"),
|
||||
(nodes(:node_with_versions_v1).timestamp + 1).strftime("%d %b %Y, %H:%M:%S"),
|
||||
'last element in third element (array) should be the initial version'
|
||||
end
|
||||
|
||||
|
|
|
@ -104,7 +104,7 @@ class DiaryEntryControllerTest < ActionController::TestCase
|
|||
end
|
||||
assert_select "body", :count => 1 do
|
||||
assert_select "div#content", :count => 1 do
|
||||
assert_select "h1", "New Diary Entry", :count => 1
|
||||
assert_select "h1", :text => "New Diary Entry", :count => 1
|
||||
# We don't care about the layout, we just care about the form fields
|
||||
# that are available
|
||||
assert_select "form[action='/diary/new']", :count => 1 do
|
||||
|
|
|
@ -212,7 +212,7 @@ class UserControllerTest < ActionController::TestCase
|
|||
register_email = ActionMailer::Base.deliveries.first
|
||||
|
||||
assert_equal register_email.to[0], new_email
|
||||
assert_match /#{@url}/, register_email.body
|
||||
assert_match /#{@url}/, register_email.body.to_s
|
||||
|
||||
# Check the page
|
||||
assert_redirected_to :action => 'login', :referer => nil
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
require File.dirname(__FILE__) + '/../test_helper'
|
||||
|
||||
class OAuthTest < ActionController::IntegrationTest
|
||||
fixtures :users, :client_applications
|
||||
fixtures :users, :client_applications, :gpx_files
|
||||
|
||||
include OAuth::Helper
|
||||
|
||||
|
|
|
@ -71,7 +71,7 @@ class UserCreationTest < ActionController::IntegrationTest
|
|||
|
||||
assert_equal register_email.to[0], new_email
|
||||
# Check that the confirm account url is correct
|
||||
assert_match /#{@url}/, register_email.body
|
||||
assert_match /#{@url}/, register_email.body.to_s
|
||||
|
||||
# Check the page
|
||||
assert_response :success
|
||||
|
@ -114,7 +114,7 @@ class UserCreationTest < ActionController::IntegrationTest
|
|||
# Check that the confirm account url is correct
|
||||
confirm_regex = Regexp.new("/user/redirect_tester/confirm\\?confirm_string=([a-zA-Z0-9]*)")
|
||||
register_email.parts.each do |part|
|
||||
assert_match(confirm_regex, part.body)
|
||||
assert_match confirm_regex, part.body.to_s
|
||||
end
|
||||
confirm_string = register_email.parts[0].body.match(confirm_regex)[1]
|
||||
|
||||
|
@ -211,7 +211,7 @@ class UserCreationTest < ActionController::IntegrationTest
|
|||
# Check that the confirm account url is correct
|
||||
confirm_regex = Regexp.new("/user/redirect_tester_openid/confirm\\?confirm_string=([a-zA-Z0-9]*)")
|
||||
register_email.parts.each do |part|
|
||||
assert_match(confirm_regex, part.body)
|
||||
assert_match confirm_regex, part.body.to_s
|
||||
end
|
||||
confirm_string = register_email.parts[0].body.match(confirm_regex)[1]
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ class ActiveSupport::TestCase
|
|||
# Load standard fixtures needed to test API methods
|
||||
def self.api_fixtures
|
||||
#print "setting up the api_fixtures"
|
||||
fixtures :users, :changesets, :changeset_tags
|
||||
fixtures :users, :user_roles, :changesets, :changeset_tags
|
||||
|
||||
fixtures :current_nodes, :nodes
|
||||
set_fixture_class :current_nodes => 'Node'
|
||||
|
|
|
@ -19,7 +19,7 @@ class MessageTest < ActiveSupport::TestCase
|
|||
assert message.errors[:title].any?
|
||||
assert message.errors[:body].any?
|
||||
assert message.errors[:sent_on].any?
|
||||
assert true, message.message_read
|
||||
assert !message.message_read
|
||||
end
|
||||
|
||||
def test_validating_msgs
|
||||
|
@ -76,6 +76,9 @@ class MessageTest < ActiveSupport::TestCase
|
|||
db_msg = msg.class.find(msg.id)
|
||||
assert_equal char, db_msg.title, "Database silently truncated message title"
|
||||
|
||||
rescue ArgumentError => ex
|
||||
assert_equal ex.to_s, "invalid byte sequence in UTF-8"
|
||||
|
||||
rescue ActiveRecord::RecordInvalid
|
||||
# because we only test invalid sequences it is OK to barf on them
|
||||
end
|
||||
|
|
|
@ -52,7 +52,7 @@ class UserTest < ActiveSupport::TestCase
|
|||
ok.each do |name|
|
||||
user = users(:normal_user)
|
||||
user.email = name
|
||||
assert user.valid?(:save), user.errors.full_messages
|
||||
assert user.valid?(:save), user.errors.full_messages.join(",")
|
||||
end
|
||||
|
||||
bad.each do |name|
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue