# 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'
# Gems needed for running tests
group :test do
gem 'timecop'
+ gem 'minitest', :platforms => :ruby_19
end
# Gems needed for compiling assets
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)
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)
DEPENDENCIES
SystemTimer (>= 1.1.3)
+ bigdecimal
coffee-rails (~> 3.2.1)
composite_primary_keys (>= 5.0.0)
deadlock_retry (>= 1.2.0)
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)
# 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]
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
post: Post
when: When
comment: Comment
- ago: %{ago} ago
+ ago: "%{ago} ago"
newer_comments: "Newer Comments"
older_comments: "Older Comments"
export:
# 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
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
# 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
-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
-
- rescue
- return false
- end
-end
+ if String.new.respond_to?("valid_encoding?")
+ def self.valid?(str)
+ return true if str.nil?
+ return str.valid_encoding?
+ end
+ else
+ require 'iconv'
+ def self.valid?(str)
+ return true if str.nil?
+ Iconv.conv("UTF-8", "UTF-8", str)
+ return true
+ rescue
+ return false
+ end
+ end
+end
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
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
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
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
require File.dirname(__FILE__) + '/../test_helper'
class OAuthTest < ActionController::IntegrationTest
- fixtures :users, :client_applications
+ fixtures :users, :client_applications, :gpx_files
include OAuth::Helper
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
# 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]
# 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]
# 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'
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
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
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|