Fix rubocop lint issues
This commit is contained in:
parent
ef7f3d800c
commit
baf10cd392
40 changed files with 105 additions and 150 deletions
|
@ -18,52 +18,14 @@ Lint/AmbiguousRegexpLiteral:
|
||||||
Lint/AssignmentInCondition:
|
Lint/AssignmentInCondition:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
|
||||||
# Offense count: 1
|
|
||||||
# Configuration parameters: AlignWith, SupportedStyles.
|
|
||||||
Lint/DefEndAlignment:
|
|
||||||
Enabled: false
|
|
||||||
|
|
||||||
# Offense count: 2
|
|
||||||
Lint/DuplicateMethods:
|
|
||||||
Enabled: false
|
|
||||||
|
|
||||||
# Offense count: 5
|
# Offense count: 5
|
||||||
# Configuration parameters: AlignWith, SupportedStyles.
|
|
||||||
Lint/EndAlignment:
|
|
||||||
Enabled: false
|
|
||||||
|
|
||||||
# Offense count: 8
|
|
||||||
Lint/HandleExceptions:
|
Lint/HandleExceptions:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
|
||||||
# Offense count: 1
|
|
||||||
Lint/LiteralInCondition:
|
|
||||||
Enabled: false
|
|
||||||
|
|
||||||
# Offense count: 8
|
# Offense count: 8
|
||||||
Lint/ParenthesesAsGroupedExpression:
|
Lint/ParenthesesAsGroupedExpression:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
|
||||||
# Offense count: 18
|
|
||||||
Lint/RescueException:
|
|
||||||
Enabled: false
|
|
||||||
|
|
||||||
# Offense count: 3
|
|
||||||
Lint/ShadowingOuterLocalVariable:
|
|
||||||
Enabled: false
|
|
||||||
|
|
||||||
# Offense count: 2
|
|
||||||
Lint/UselessAccessModifier:
|
|
||||||
Enabled: false
|
|
||||||
|
|
||||||
# Offense count: 48
|
|
||||||
Lint/UselessAssignment:
|
|
||||||
Enabled: false
|
|
||||||
|
|
||||||
# Offense count: 2
|
|
||||||
Lint/Void:
|
|
||||||
Enabled: false
|
|
||||||
|
|
||||||
# Offense count: 546
|
# Offense count: 546
|
||||||
Metrics/AbcSize:
|
Metrics/AbcSize:
|
||||||
Max: 194
|
Max: 194
|
||||||
|
|
|
@ -114,7 +114,7 @@ class AmfController < ApplicationController
|
||||||
return [-2, "Sorry - I can't get the map for that area. The server said: #{ex}"]
|
return [-2, "Sorry - I can't get the map for that area. The server said: #{ex}"]
|
||||||
rescue OSM::APIError => ex
|
rescue OSM::APIError => ex
|
||||||
return [-1, ex.to_s]
|
return [-1, ex.to_s]
|
||||||
rescue Exception => ex
|
rescue StandardError => ex
|
||||||
return [-2, "An unusual error happened (in #{call}). The server said: #{ex}"]
|
return [-2, "An unusual error happened (in #{call}). The server said: #{ex}"]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -375,6 +375,7 @@ class AmfController < ApplicationController
|
||||||
rescue ArgumentError
|
rescue ArgumentError
|
||||||
# thrown by date parsing method. leave old_way as nil for
|
# thrown by date parsing method. leave old_way as nil for
|
||||||
# the error handler below.
|
# the error handler below.
|
||||||
|
old_way = nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -691,7 +692,7 @@ class AmfController < ApplicationController
|
||||||
new_node.id = id.to_i
|
new_node.id = id.to_i
|
||||||
begin
|
begin
|
||||||
node.delete_with_history!(new_node, user)
|
node.delete_with_history!(new_node, user)
|
||||||
rescue OSM::APIPreconditionFailedError => ex
|
rescue OSM::APIPreconditionFailedError
|
||||||
# We don't do anything here as the node is being used elsewhere
|
# We don't do anything here as the node is being used elsewhere
|
||||||
# and we don't want to delete it
|
# and we don't want to delete it
|
||||||
end
|
end
|
||||||
|
@ -827,7 +828,7 @@ class AmfController < ApplicationController
|
||||||
begin
|
begin
|
||||||
node.delete_with_history!(new_node, user)
|
node.delete_with_history!(new_node, user)
|
||||||
nodeversions[node.id] = node.version
|
nodeversions[node.id] = node.version
|
||||||
rescue OSM::APIPreconditionFailedError => ex
|
rescue OSM::APIPreconditionFailedError
|
||||||
# We don't do anything with the exception as the node is in use
|
# We don't do anything with the exception as the node is in use
|
||||||
# elsewhere and we don't want to delete it
|
# elsewhere and we don't want to delete it
|
||||||
end
|
end
|
||||||
|
|
|
@ -25,7 +25,7 @@ class ApiController < ApplicationController
|
||||||
bbox = BoundingBox.from_bbox_params(params)
|
bbox = BoundingBox.from_bbox_params(params)
|
||||||
bbox.check_boundaries
|
bbox.check_boundaries
|
||||||
bbox.check_size
|
bbox.check_size
|
||||||
rescue Exception => err
|
rescue StandardError => err
|
||||||
report_error(err.message)
|
report_error(err.message)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
@ -121,7 +121,7 @@ class ApiController < ApplicationController
|
||||||
bbox = BoundingBox.from_bbox_params(params)
|
bbox = BoundingBox.from_bbox_params(params)
|
||||||
bbox.check_boundaries
|
bbox.check_boundaries
|
||||||
bbox.check_size
|
bbox.check_size
|
||||||
rescue Exception => err
|
rescue StandardError => err
|
||||||
report_error(err.message)
|
report_error(err.message)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
|
@ -24,13 +24,13 @@ class ApplicationController < ActionController::Base
|
||||||
else
|
else
|
||||||
redirect_to :controller => "user", :action => "terms", :referer => request.fullpath
|
redirect_to :controller => "user", :action => "terms", :referer => request.fullpath
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
elsif session[:token]
|
elsif session[:token]
|
||||||
if @user = User.authenticate(:token => session[:token])
|
if @user = User.authenticate(:token => session[:token])
|
||||||
session[:user] = @user.id
|
session[:user] = @user.id
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
rescue Exception => ex
|
rescue StandardError => ex
|
||||||
logger.info("Exception authorizing user: #{ex}")
|
logger.info("Exception authorizing user: #{ex}")
|
||||||
reset_session
|
reset_session
|
||||||
@user = nil
|
@user = nil
|
||||||
|
@ -345,7 +345,7 @@ class ApplicationController < ActionController::Base
|
||||||
report_error ex.message, ex.status
|
report_error ex.message, ex.status
|
||||||
rescue AbstractController::ActionNotFound => ex
|
rescue AbstractController::ActionNotFound => ex
|
||||||
raise
|
raise
|
||||||
rescue Exception => ex
|
rescue StandardError => ex
|
||||||
logger.info("API threw unexpected #{ex.class} exception: #{ex.message}")
|
logger.info("API threw unexpected #{ex.class} exception: #{ex.message}")
|
||||||
ex.backtrace.each { |l| logger.info(l) }
|
ex.backtrace.each { |l| logger.info(l) }
|
||||||
report_error "#{ex.class}: #{ex.message}", :internal_server_error
|
report_error "#{ex.class}: #{ex.message}", :internal_server_error
|
||||||
|
@ -441,7 +441,7 @@ class ApplicationController < ActionController::Base
|
||||||
@user.preferred_editor
|
@user.preferred_editor
|
||||||
else
|
else
|
||||||
DEFAULT_EDITOR
|
DEFAULT_EDITOR
|
||||||
end
|
end
|
||||||
|
|
||||||
if request.env['HTTP_USER_AGENT'] =~ /MSIE|Trident/ && editor == 'id'
|
if request.env['HTTP_USER_AGENT'] =~ /MSIE|Trident/ && editor == 'id'
|
||||||
editor = 'potlatch2'
|
editor = 'potlatch2'
|
||||||
|
|
|
@ -73,7 +73,7 @@ class GeocoderController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
render :action => "results"
|
render :action => "results"
|
||||||
rescue Exception => ex
|
rescue StandardError => ex
|
||||||
@error = "Error contacting rpc.geocoder.us: #{ex}"
|
@error = "Error contacting rpc.geocoder.us: #{ex}"
|
||||||
render :action => "error"
|
render :action => "error"
|
||||||
end
|
end
|
||||||
|
@ -99,7 +99,7 @@ class GeocoderController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
render :action => "results"
|
render :action => "results"
|
||||||
rescue Exception => ex
|
rescue StandardError => ex
|
||||||
@error = "Error contacting www.npemap.org.uk: #{ex}"
|
@error = "Error contacting www.npemap.org.uk: #{ex}"
|
||||||
render :action => "error"
|
render :action => "error"
|
||||||
end
|
end
|
||||||
|
@ -121,7 +121,7 @@ class GeocoderController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
render :action => "results"
|
render :action => "results"
|
||||||
rescue Exception => ex
|
rescue StandardError => ex
|
||||||
@error = "Error contacting geocoder.ca: #{ex}"
|
@error = "Error contacting geocoder.ca: #{ex}"
|
||||||
render :action => "error"
|
render :action => "error"
|
||||||
end
|
end
|
||||||
|
@ -188,7 +188,7 @@ class GeocoderController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
render :action => "results"
|
render :action => "results"
|
||||||
# rescue Exception => ex
|
# rescue StandardError => ex
|
||||||
# @error = "Error contacting nominatim.openstreetmap.org: #{ex.to_s}"
|
# @error = "Error contacting nominatim.openstreetmap.org: #{ex.to_s}"
|
||||||
# render :action => "error"
|
# render :action => "error"
|
||||||
end
|
end
|
||||||
|
@ -219,7 +219,7 @@ class GeocoderController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
render :action => "results"
|
render :action => "results"
|
||||||
rescue Exception => ex
|
rescue StandardError => ex
|
||||||
@error = "Error contacting ws.geonames.org: #{ex}"
|
@error = "Error contacting ws.geonames.org: #{ex}"
|
||||||
render :action => "error"
|
render :action => "error"
|
||||||
end
|
end
|
||||||
|
@ -251,7 +251,7 @@ class GeocoderController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
render :action => "results"
|
render :action => "results"
|
||||||
rescue Exception => ex
|
rescue StandardError => ex
|
||||||
@error = "Error contacting nominatim.openstreetmap.org: #{ex}"
|
@error = "Error contacting nominatim.openstreetmap.org: #{ex}"
|
||||||
render :action => "error"
|
render :action => "error"
|
||||||
end
|
end
|
||||||
|
@ -281,7 +281,7 @@ class GeocoderController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
render :action => "results"
|
render :action => "results"
|
||||||
rescue Exception => ex
|
rescue StandardError => ex
|
||||||
@error = "Error contacting ws.geonames.org: #{ex}"
|
@error = "Error contacting ws.geonames.org: #{ex}"
|
||||||
render :action => "error"
|
render :action => "error"
|
||||||
end
|
end
|
||||||
|
|
|
@ -102,10 +102,10 @@ class SwfController < ApplicationController
|
||||||
# Line-drawing
|
# Line-drawing
|
||||||
|
|
||||||
def startShape
|
def startShape
|
||||||
s = 0.chr # No fill styles
|
s = 0.chr # No fill styles
|
||||||
s += 2.chr # Two line styles
|
s += 2.chr # Two line styles
|
||||||
s += packUI16(0) + 0.chr + 255.chr + 255.chr # Width 5, RGB #00FFFF
|
s += packUI16(0) + 0.chr + 255.chr + 255.chr # Width 5, RGB #00FFFF
|
||||||
s += packUI16(0) + 255.chr + 0.chr + 255.chr # Width 5, RGB #FF00FF
|
s += packUI16(0) + 255.chr + 0.chr + 255.chr # Width 5, RGB #FF00FF
|
||||||
s += 34.chr # 2 fill, 2 line index bits
|
s += 34.chr # 2 fill, 2 line index bits
|
||||||
s
|
s
|
||||||
end
|
end
|
||||||
|
@ -115,10 +115,11 @@ class SwfController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def startAndMove(x, y, col)
|
def startAndMove(x, y, col)
|
||||||
d = '001001' # Line style change, moveTo
|
d = '001001' # Line style change, moveTo
|
||||||
l = [lengthSB(x), lengthSB(y)].max
|
l = [lengthSB(x), lengthSB(y)].max
|
||||||
d += sprintf("%05b%0#{l}b%0#{l}b", l, x, y)
|
d += sprintf("%05b%0#{l}b%0#{l}b", l, x, y)
|
||||||
d += col # Select line style
|
d += col # Select line style
|
||||||
|
d
|
||||||
end
|
end
|
||||||
|
|
||||||
def drawTo(absx, absy, x, y)
|
def drawTo(absx, absy, x, y)
|
||||||
|
@ -131,7 +132,7 @@ class SwfController < ApplicationController
|
||||||
xstep = dx / mstep
|
xstep = dx / mstep
|
||||||
ystep = dy / mstep
|
ystep = dy / mstep
|
||||||
d = ''
|
d = ''
|
||||||
for i in (1..mstep)
|
1.upto(mstep).each do
|
||||||
d += drawSection(x, y, x + xstep, y + ystep)
|
d += drawSection(x, y, x + xstep, y + ystep)
|
||||||
x += xstep
|
x += xstep
|
||||||
y += ystep
|
y += ystep
|
||||||
|
@ -147,6 +148,7 @@ class SwfController < ApplicationController
|
||||||
d += sprintf("%04b", l - 2)
|
d += sprintf("%04b", l - 2)
|
||||||
d += '1' # GeneralLine
|
d += '1' # GeneralLine
|
||||||
d += sprintf("%0#{l}b%0#{l}b", dx, dy)
|
d += sprintf("%0#{l}b%0#{l}b", dx, dy)
|
||||||
|
d
|
||||||
end
|
end
|
||||||
|
|
||||||
# -----------------------------------------------------------------------
|
# -----------------------------------------------------------------------
|
||||||
|
|
|
@ -372,7 +372,7 @@ class TraceController < ApplicationController
|
||||||
|
|
||||||
# Rename the temporary file to the final name
|
# Rename the temporary file to the final name
|
||||||
FileUtils.mv(filename, @trace.trace_name)
|
FileUtils.mv(filename, @trace.trace_name)
|
||||||
rescue Exception => ex
|
rescue StandardError
|
||||||
# Remove the file as we have failed to update the database
|
# Remove the file as we have failed to update the database
|
||||||
FileUtils.rm_f(filename)
|
FileUtils.rm_f(filename)
|
||||||
|
|
||||||
|
@ -384,7 +384,7 @@ class TraceController < ApplicationController
|
||||||
# Clear the inserted flag to make the import daemon load the trace
|
# Clear the inserted flag to make the import daemon load the trace
|
||||||
@trace.inserted = false
|
@trace.inserted = false
|
||||||
@trace.save!
|
@trace.save!
|
||||||
rescue Exception => ex
|
rescue StandardError
|
||||||
# Remove the file as we have failed to update the database
|
# Remove the file as we have failed to update the database
|
||||||
FileUtils.rm_f(@trace.trace_name)
|
FileUtils.rm_f(@trace.trace_name)
|
||||||
|
|
||||||
|
|
|
@ -64,7 +64,7 @@ module UserHelper
|
||||||
size = options[:size] || 100
|
size = options[:size] || 100
|
||||||
hash = Digest::MD5.hexdigest(user.email.downcase)
|
hash = Digest::MD5.hexdigest(user.email.downcase)
|
||||||
default_image_url = image_url("users/images/large.png")
|
default_image_url = image_url("users/images/large.png")
|
||||||
url = "#{request.protocol}www.gravatar.com/avatar/#{hash}.jpg?s=#{size}&d=#{u(default_image_url)}"
|
"#{request.protocol}www.gravatar.com/avatar/#{hash}.jpg?s=#{size}&d=#{u(default_image_url)}"
|
||||||
end
|
end
|
||||||
|
|
||||||
def user_gravatar_tag(user, options = {})
|
def user_gravatar_tag(user, options = {})
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
class Acl < ActiveRecord::Base
|
class Acl < ActiveRecord::Base
|
||||||
def self.match(address, domain = nil)
|
def self.match(address, domain = nil)
|
||||||
if domain
|
if domain
|
||||||
condition = Acl.where("address >>= ? OR domain = ?", address, domain)
|
Acl.where("address >>= ? OR domain = ?", address, domain)
|
||||||
else
|
else
|
||||||
condition = Acl.where("address >>= ?", address)
|
Acl.where("address >>= ?", address)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@ class ClientApplication < ActiveRecord::Base
|
||||||
return false unless OauthNonce.remember(signature.request.nonce, signature.request.timestamp)
|
return false unless OauthNonce.remember(signature.request.nonce, signature.request.timestamp)
|
||||||
value = signature.verify
|
value = signature.verify
|
||||||
value
|
value
|
||||||
rescue OAuth::Signature::UnknownSignatureMethod => e
|
rescue OAuth::Signature::UnknownSignatureMethod
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@ class Message < ActiveRecord::Base
|
||||||
body = mail.decoded
|
body = mail.decoded
|
||||||
end
|
end
|
||||||
|
|
||||||
message = Message.new(
|
Message.new(
|
||||||
:sender => from,
|
:sender => from,
|
||||||
:recipient => to,
|
:recipient => to,
|
||||||
:sent_on => mail.date.new_offset(0),
|
:sent_on => mail.date.new_offset(0),
|
||||||
|
|
|
@ -129,7 +129,7 @@ class Relation < ActiveRecord::Base
|
||||||
member_el['ref'] = member.member_id.to_s
|
member_el['ref'] = member.member_id.to_s
|
||||||
member_el['role'] = member.member_role
|
member_el['role'] = member.member_role
|
||||||
el << member_el
|
el << member_el
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
add_tags_to_xml_node(el, relation_tags)
|
add_tags_to_xml_node(el, relation_tags)
|
||||||
|
|
|
@ -138,7 +138,6 @@ class User < ActiveRecord::Base
|
||||||
def nearby(radius = NEARBY_RADIUS, num = NEARBY_USERS)
|
def nearby(radius = NEARBY_RADIUS, num = NEARBY_USERS)
|
||||||
if home_lon && home_lat
|
if home_lon && home_lat
|
||||||
gc = OSM::GreatCircle.new(home_lat, home_lon)
|
gc = OSM::GreatCircle.new(home_lat, home_lon)
|
||||||
bounds = gc.bounds(radius)
|
|
||||||
sql_for_distance = gc.sql_for_distance("home_lat", "home_lon")
|
sql_for_distance = gc.sql_for_distance("home_lat", "home_lon")
|
||||||
nearby = User.where("id != ? AND status IN (\'active\', \'confirmed\') AND data_public = ? AND #{sql_for_distance} <= ?", id, true, radius).order(sql_for_distance).limit(num)
|
nearby = User.where("id != ? AND status IN (\'active\', \'confirmed\') AND data_public = ? AND #{sql_for_distance} <= ?", id, true, radius).order(sql_for_distance).limit(num)
|
||||||
else
|
else
|
||||||
|
@ -212,8 +211,8 @@ class User < ActiveRecord::Base
|
||||||
def spam_score
|
def spam_score
|
||||||
changeset_score = changesets.size * 50
|
changeset_score = changesets.size * 50
|
||||||
trace_score = traces.size * 50
|
trace_score = traces.size * 50
|
||||||
diary_entry_score = diary_entries.inject(0) { |s, e| s += e.body.spam_score }
|
diary_entry_score = diary_entries.inject(0) { |s, e| s + e.body.spam_score }
|
||||||
diary_comment_score = diary_comments.inject(0) { |s, c| s += c.body.spam_score }
|
diary_comment_score = diary_comments.inject(0) { |s, c| s + c.body.spam_score }
|
||||||
|
|
||||||
score = description.spam_score / 4.0
|
score = description.spam_score / 4.0
|
||||||
score += diary_entries.where("created_at > ?", 1.day.ago).count * 10
|
score += diary_entries.where("created_at > ?", 1.day.ago).count * 10
|
||||||
|
|
|
@ -86,9 +86,9 @@ class Way < ActiveRecord::Base
|
||||||
|
|
||||||
# You can't pull in all the tags too unless we put a sequence_id on the way_tags table and have a multipart key
|
# You can't pull in all the tags too unless we put a sequence_id on the way_tags table and have a multipart key
|
||||||
def self.find_eager(id)
|
def self.find_eager(id)
|
||||||
way = Way.find(id, :include => { :way_nodes => :node })
|
Way.find(id, :include => { :way_nodes => :node })
|
||||||
# If waytag had a multipart key that was real, you could do this:
|
# If waytag had a multipart key that was real, you could do this:
|
||||||
# way = Way.find(id, :include => [:way_tags, {:way_nodes => :node}])
|
# Way.find(id, :include => [:way_tags, {:way_nodes => :node}])
|
||||||
end
|
end
|
||||||
|
|
||||||
# Find a way given it's ID, and in a single SQL call also grab its nodes and tags
|
# Find a way given it's ID, and in a single SQL call also grab its nodes and tags
|
||||||
|
|
|
@ -48,6 +48,7 @@ class PopulateNodeTagsAndRemove < ActiveRecord::Migration
|
||||||
if have_nodes
|
if have_nodes
|
||||||
execute "LOAD DATA INFILE '#{nodes}' INTO TABLE nodes #{csvopts} (id, latitude, longitude, user_id, visible, timestamp, tile, version)"
|
execute "LOAD DATA INFILE '#{nodes}' INTO TABLE nodes #{csvopts} (id, latitude, longitude, user_id, visible, timestamp, tile, version)"
|
||||||
execute "LOAD DATA INFILE '#{node_tags}' INTO TABLE node_tags #{csvopts} (id, version, k, v)"
|
execute "LOAD DATA INFILE '#{node_tags}' INTO TABLE node_tags #{csvopts} (id, version, k, v)"
|
||||||
|
execute "LOAD DATA INFILE '#{current_nodes}' INTO TABLE current_nodes #{csvopts} (id, latitude, longitude, user_id, visible, timestamp, tile)"
|
||||||
execute "LOAD DATA INFILE '#{current_node_tags}' INTO TABLE current_node_tags #{csvopts} (id, k, v)"
|
execute "LOAD DATA INFILE '#{current_node_tags}' INTO TABLE current_node_tags #{csvopts} (id, k, v)"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
class BoundingBox
|
class BoundingBox
|
||||||
attr_reader :min_lon, :min_lat, :max_lon, :max_lat
|
attr_reader :min_lon, :min_lat, :max_lon, :max_lat
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
LON_LIMIT = 180.0
|
LON_LIMIT = 180.0
|
||||||
LAT_LIMIT = 90.0
|
LAT_LIMIT = 90.0
|
||||||
SCALED_LON_LIMIT = LON_LIMIT * GeoRecord::SCALE
|
SCALED_LON_LIMIT = LON_LIMIT * GeoRecord::SCALE
|
||||||
|
|
|
@ -13,8 +13,6 @@ class Country
|
||||||
countries[code]
|
countries[code]
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
def self.countries
|
def self.countries
|
||||||
@@countries ||= load_countries
|
@@countries ||= load_countries
|
||||||
end
|
end
|
||||||
|
|
|
@ -26,7 +26,7 @@ loop do
|
||||||
Notifier.gpx_failure(trace, '0 points parsed ok. Do they all have lat,lng,alt,timestamp?').deliver
|
Notifier.gpx_failure(trace, '0 points parsed ok. Do they all have lat,lng,alt,timestamp?').deliver
|
||||||
trace.destroy
|
trace.destroy
|
||||||
end
|
end
|
||||||
rescue Exception => ex
|
rescue StandardError => ex
|
||||||
logger.info ex.to_s
|
logger.info ex.to_s
|
||||||
ex.backtrace.each { |l| logger.info l }
|
ex.backtrace.each { |l| logger.info l }
|
||||||
Notifier.gpx_failure(trace, ex.to_s + "\n" + ex.backtrace.join("\n")).deliver
|
Notifier.gpx_failure(trace, ex.to_s + "\n" + ex.backtrace.join("\n")).deliver
|
||||||
|
@ -45,7 +45,7 @@ loop do
|
||||||
|
|
||||||
begin
|
begin
|
||||||
trace.destroy
|
trace.destroy
|
||||||
rescue Exception => ex
|
rescue StandardError => ex
|
||||||
logger.info ex.to_s
|
logger.info ex.to_s
|
||||||
ex.backtrace.each { |l| logger.info l }
|
ex.backtrace.each { |l| logger.info l }
|
||||||
end
|
end
|
||||||
|
|
|
@ -238,7 +238,7 @@ class DiffReader
|
||||||
if action_attributes["if-unused"]
|
if action_attributes["if-unused"]
|
||||||
begin
|
begin
|
||||||
old.delete_with_history!(new, @changeset.user)
|
old.delete_with_history!(new, @changeset.user)
|
||||||
rescue OSM::APIAlreadyDeletedError, OSM::APIPreconditionFailedError => ex
|
rescue OSM::APIAlreadyDeletedError, OSM::APIPreconditionFailedError
|
||||||
xml_result["new_id"] = old.id.to_s
|
xml_result["new_id"] = old.id.to_s
|
||||||
xml_result["new_version"] = old.version.to_s
|
xml_result["new_version"] = old.version.to_s
|
||||||
end
|
end
|
||||||
|
|
16
lib/gpx.rb
16
lib/gpx.rb
|
@ -63,22 +63,16 @@ module GPX
|
||||||
highlightgc.stroke('#000000')
|
highlightgc.stroke('#000000')
|
||||||
highlightgc.fill('#000000')
|
highlightgc.fill('#000000')
|
||||||
|
|
||||||
images = []
|
images = frames.times.collect do
|
||||||
|
Magick::Image.new(width, height) do |image|
|
||||||
frames.times do
|
|
||||||
image = Magick::Image.new(width, height) do |image|
|
|
||||||
image.background_color = 'white'
|
image.background_color = 'white'
|
||||||
image.format = 'GIF'
|
image.format = 'GIF'
|
||||||
end
|
end
|
||||||
|
|
||||||
images << image
|
|
||||||
end
|
end
|
||||||
|
|
||||||
oldpx = 0.0
|
oldpx = 0.0
|
||||||
oldpy = 0.0
|
oldpy = 0.0
|
||||||
|
|
||||||
first = true
|
|
||||||
|
|
||||||
m = 0
|
m = 0
|
||||||
mm = 0
|
mm = 0
|
||||||
points do |p|
|
points do |p|
|
||||||
|
@ -131,9 +125,9 @@ module GPX
|
||||||
gc.stroke('#000000')
|
gc.stroke('#000000')
|
||||||
gc.fill('#000000')
|
gc.fill('#000000')
|
||||||
|
|
||||||
image = Magick::Image.new(width, height) do |image|
|
image = Magick::Image.new(width, height) do |i|
|
||||||
image.background_color = 'white'
|
i.background_color = 'white'
|
||||||
image.format = 'GIF'
|
i.format = 'GIF'
|
||||||
end
|
end
|
||||||
|
|
||||||
oldpx = 0.0
|
oldpx = 0.0
|
||||||
|
|
|
@ -12,7 +12,7 @@ module Nominatim
|
||||||
response = OSM::Timer.timeout(4) do
|
response = OSM::Timer.timeout(4) do
|
||||||
REXML::Document.new(Net::HTTP.get(URI.parse(url)))
|
REXML::Document.new(Net::HTTP.get(URI.parse(url)))
|
||||||
end
|
end
|
||||||
rescue Exception
|
rescue StandardError
|
||||||
response = nil
|
response = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -510,7 +510,7 @@ module OSM
|
||||||
end
|
end
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
rescue Exception
|
rescue StandardError
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -71,6 +71,7 @@ module Potlatch
|
||||||
d += encodestring("null")
|
d += encodestring("null")
|
||||||
d += [-1].pack("N")
|
d += [-1].pack("N")
|
||||||
d += encodevalue(n)
|
d += encodevalue(n)
|
||||||
|
d
|
||||||
end
|
end
|
||||||
|
|
||||||
# Pack variables as AMF
|
# Pack variables as AMF
|
||||||
|
@ -154,7 +155,7 @@ module Potlatch
|
||||||
bodies.times do # Read each body
|
bodies.times do # Read each body
|
||||||
name = AMF.getstring(@request) # | get message name
|
name = AMF.getstring(@request) # | get message name
|
||||||
index = AMF.getstring(@request) # | get index in response sequence
|
index = AMF.getstring(@request) # | get index in response sequence
|
||||||
bytes = AMF.getlong(@request) # | get total size in bytes
|
AMF.getlong(@request) # | get total size in bytes
|
||||||
args = AMF.getvalue(@request) # | get response (probably an array)
|
args = AMF.getvalue(@request) # | get response (probably an array)
|
||||||
|
|
||||||
result = @dispatch.call(name, *args)
|
result = @dispatch.call(name, *args)
|
||||||
|
@ -247,8 +248,11 @@ module Potlatch
|
||||||
t = line.chomp
|
t = line.chomp
|
||||||
if t =~ /^([\w:]+)\/(\w+)\s+(.+)$/
|
if t =~ /^([\w:]+)\/(\w+)\s+(.+)$/
|
||||||
tag = $1; type = $2; values = $3
|
tag = $1; type = $2; values = $3
|
||||||
if values == '-' then autotags[type][tag] = []
|
if values == '-'
|
||||||
else autotags[type][tag] = values.split(',').sort.reverse end
|
autotags[type][tag] = []
|
||||||
|
else
|
||||||
|
autotags[type][tag] = values.split(',').sort.reverse
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -16,7 +16,6 @@ LOCALE_DIR = File.dirname(__FILE__) + '/../../config/locales/'
|
||||||
EN = YAML.load_file(LOCALE_DIR + 'en.yml')
|
EN = YAML.load_file(LOCALE_DIR + 'en.yml')
|
||||||
|
|
||||||
def iterate(hash, fhash = {}, path = '', outfile = $stdout)
|
def iterate(hash, fhash = {}, path = '', outfile = $stdout)
|
||||||
postr = ''
|
|
||||||
hash.each do |key, val|
|
hash.each do |key, val|
|
||||||
fhash[key] = {} unless fhash.key? key
|
fhash[key] = {} unless fhash.key? key
|
||||||
if val.is_a? Hash
|
if val.is_a? Hash
|
||||||
|
@ -32,7 +31,6 @@ end
|
||||||
|
|
||||||
def lang2po(lang, outfile = $stdout)
|
def lang2po(lang, outfile = $stdout)
|
||||||
puts lang
|
puts lang
|
||||||
oth = {}
|
|
||||||
infile = LOCALE_DIR + lang + '.yml'
|
infile = LOCALE_DIR + lang + '.yml'
|
||||||
if File.exist? infile
|
if File.exist? infile
|
||||||
oth = YAML.load_file(infile)
|
oth = YAML.load_file(infile)
|
||||||
|
|
|
@ -82,7 +82,7 @@ begin
|
||||||
|
|
||||||
puts "</table>"
|
puts "</table>"
|
||||||
end
|
end
|
||||||
rescue Exception => e
|
rescue StandardError => e
|
||||||
puts "<p><em>Exception: #{e}</em><br />#{e.backtrace.join('<br />')}</p>"
|
puts "<p><em>Exception: #{e}</em><br />#{e.backtrace.join('<br />')}</p>"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -446,7 +446,7 @@ class AmfControllerTest < ActionController::TestCase
|
||||||
# Using similar method for the node controller test
|
# Using similar method for the node controller test
|
||||||
def test_putpoi_create_valid
|
def test_putpoi_create_valid
|
||||||
# This node has no tags
|
# This node has no tags
|
||||||
nd = Node.new
|
|
||||||
# create a node with random lat/lon
|
# create a node with random lat/lon
|
||||||
lat = rand(100) - 50 + rand
|
lat = rand(100) - 50 + rand
|
||||||
lon = rand(100) - 50 + rand
|
lon = rand(100) - 50 + rand
|
||||||
|
@ -485,7 +485,7 @@ class AmfControllerTest < ActionController::TestCase
|
||||||
|
|
||||||
####
|
####
|
||||||
# This node has some tags
|
# This node has some tags
|
||||||
tnd = Node.new
|
|
||||||
# create a node with random lat/lon
|
# create a node with random lat/lon
|
||||||
lat = rand(100) - 50 + rand
|
lat = rand(100) - 50 + rand
|
||||||
lon = rand(100) - 50 + rand
|
lon = rand(100) - 50 + rand
|
||||||
|
@ -528,7 +528,7 @@ class AmfControllerTest < ActionController::TestCase
|
||||||
# try creating a POI with rubbish in the tags
|
# try creating a POI with rubbish in the tags
|
||||||
def test_putpoi_create_with_control_chars
|
def test_putpoi_create_with_control_chars
|
||||||
# This node has no tags
|
# This node has no tags
|
||||||
nd = Node.new
|
|
||||||
# create a node with random lat/lon
|
# create a node with random lat/lon
|
||||||
lat = rand(100) - 50 + rand
|
lat = rand(100) - 50 + rand
|
||||||
lon = rand(100) - 50 + rand
|
lon = rand(100) - 50 + rand
|
||||||
|
@ -563,7 +563,7 @@ class AmfControllerTest < ActionController::TestCase
|
||||||
# try creating a POI with rubbish in the tags
|
# try creating a POI with rubbish in the tags
|
||||||
def test_putpoi_create_with_invalid_utf8
|
def test_putpoi_create_with_invalid_utf8
|
||||||
# This node has no tags
|
# This node has no tags
|
||||||
nd = Node.new
|
|
||||||
# create a node with random lat/lon
|
# create a node with random lat/lon
|
||||||
lat = rand(100) - 50 + rand
|
lat = rand(100) - 50 + rand
|
||||||
lon = rand(100) - 50 + rand
|
lon = rand(100) - 50 + rand
|
||||||
|
@ -649,21 +649,21 @@ class AmfControllerTest < ActionController::TestCase
|
||||||
req.read(2) # version
|
req.read(2) # version
|
||||||
|
|
||||||
# parse through any headers
|
# parse through any headers
|
||||||
headers = AMF.getint(req) # Read number of headers
|
headers = AMF.getint(req) # Read number of headers
|
||||||
headers.times do # Read each header
|
headers.times do # Read each header
|
||||||
name = AMF.getstring(req) # |
|
AMF.getstring(req) # |
|
||||||
req.getc # | skip boolean
|
req.getc # | skip boolean
|
||||||
value = AMF.getvalue(req) # |
|
AMF.getvalue(req) # |
|
||||||
end
|
end
|
||||||
|
|
||||||
# parse through responses
|
# parse through responses
|
||||||
results = {}
|
results = {}
|
||||||
bodies = AMF.getint(req) # Read number of bodies
|
bodies = AMF.getint(req) # Read number of bodies
|
||||||
bodies.times do # Read each body
|
bodies.times do # Read each body
|
||||||
message = AMF.getstring(req) # | get message name
|
message = AMF.getstring(req) # | get message name
|
||||||
index = AMF.getstring(req) # | get index in response sequence
|
AMF.getstring(req) # | get index in response sequence
|
||||||
bytes = AMF.getlong(req) # | get total size in bytes
|
AMF.getlong(req) # | get total size in bytes
|
||||||
args = AMF.getvalue(req) # | get response (probably an array)
|
args = AMF.getvalue(req) # | get response (probably an array)
|
||||||
results[message] = args
|
results[message] = args
|
||||||
end
|
end
|
||||||
@amf_result = results
|
@amf_result = results
|
||||||
|
|
|
@ -521,7 +521,6 @@ EOF
|
||||||
put :create
|
put :create
|
||||||
end
|
end
|
||||||
assert_response :success
|
assert_response :success
|
||||||
changeset_id = @response.body.to_i
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -778,6 +777,7 @@ EOF
|
||||||
# check that objects are unmodified
|
# check that objects are unmodified
|
||||||
assert_nodes_are_equal(node, Node.find(1))
|
assert_nodes_are_equal(node, Node.find(1))
|
||||||
assert_ways_are_equal(way, Way.find(1))
|
assert_ways_are_equal(way, Way.find(1))
|
||||||
|
assert_relations_are_equal(rel, Relation.find(1))
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
|
|
|
@ -194,14 +194,12 @@ class NodeControllerTest < ActionController::TestCase
|
||||||
# in a way...
|
# in a way...
|
||||||
content(nodes(:used_node_1).to_xml)
|
content(nodes(:used_node_1).to_xml)
|
||||||
delete :delete, :id => current_nodes(:used_node_1).id
|
delete :delete, :id => current_nodes(:used_node_1).id
|
||||||
assert_require_public_data
|
assert_require_public_data "shouldn't be able to delete a node used in a way (#{@response.body})"
|
||||||
"shouldn't be able to delete a node used in a way (#{@response.body})"
|
|
||||||
|
|
||||||
# in a relation...
|
# in a relation...
|
||||||
content(nodes(:node_used_by_relationship).to_xml)
|
content(nodes(:node_used_by_relationship).to_xml)
|
||||||
delete :delete, :id => current_nodes(:node_used_by_relationship).id
|
delete :delete, :id => current_nodes(:node_used_by_relationship).id
|
||||||
assert_require_public_data
|
assert_require_public_data "shouldn't be able to delete a node used in a relation (#{@response.body})"
|
||||||
"shouldn't be able to delete a node used in a relation (#{@response.body})"
|
|
||||||
|
|
||||||
## now set auth for the public data user
|
## now set auth for the public data user
|
||||||
basic_authorization(users(:public_user).email, "test")
|
basic_authorization(users(:public_user).email, "test")
|
||||||
|
|
|
@ -35,7 +35,6 @@ class OldNodeControllerTest < ActionController::TestCase
|
||||||
def test_version
|
def test_version
|
||||||
## First try this with a non-public user
|
## First try this with a non-public user
|
||||||
basic_authorization(users(:normal_user).email, "test")
|
basic_authorization(users(:normal_user).email, "test")
|
||||||
changeset_id = changesets(:normal_user_first_change).id
|
|
||||||
|
|
||||||
# setup a simple XML node
|
# setup a simple XML node
|
||||||
xml_doc = current_nodes(:visible_node).to_xml
|
xml_doc = current_nodes(:visible_node).to_xml
|
||||||
|
@ -85,7 +84,6 @@ class OldNodeControllerTest < ActionController::TestCase
|
||||||
|
|
||||||
## Now do it with the public user
|
## Now do it with the public user
|
||||||
basic_authorization(users(:public_user).email, "test")
|
basic_authorization(users(:public_user).email, "test")
|
||||||
changeset_id = changesets(:public_user_first_change).id
|
|
||||||
|
|
||||||
# setup a simple XML node
|
# setup a simple XML node
|
||||||
xml_doc = current_nodes(:node_with_versions).to_xml
|
xml_doc = current_nodes(:node_with_versions).to_xml
|
||||||
|
|
|
@ -681,7 +681,7 @@ OSM
|
||||||
content doc
|
content doc
|
||||||
put :update, :id => relation_id
|
put :update, :id => relation_id
|
||||||
assert_response :success, "can't update relation: #{@response.body}"
|
assert_response :success, "can't update relation: #{@response.body}"
|
||||||
new_version = @response.body.to_i
|
assert_equal 2, @response.body.to_i
|
||||||
|
|
||||||
# get it back again and check the ordering again
|
# get it back again and check the ordering again
|
||||||
get :read, :id => relation_id
|
get :read, :id => relation_id
|
||||||
|
|
|
@ -124,11 +124,9 @@ class WayControllerTest < ActionController::TestCase
|
||||||
"<nd ref='#{nid1}'/><nd ref='#{nid2}'/>" +
|
"<nd ref='#{nid1}'/><nd ref='#{nid2}'/>" +
|
||||||
"<tag k='test' v='yes' /></way></osm>"
|
"<tag k='test' v='yes' /></way></osm>"
|
||||||
put :create
|
put :create
|
||||||
# hope for success
|
# hope for failure
|
||||||
assert_response :forbidden,
|
assert_response :forbidden,
|
||||||
"way upload did not return success status"
|
"way upload did not return forbidden status"
|
||||||
# read id of created way and search for it
|
|
||||||
wayid = @response.body
|
|
||||||
|
|
||||||
## Now use a public user
|
## Now use a public user
|
||||||
nid1 = current_nodes(:used_node_1).id
|
nid1 = current_nodes(:used_node_1).id
|
||||||
|
|
|
@ -7,10 +7,6 @@ class ApplicationHelperTest < ActionView::TestCase
|
||||||
I18n.locale = "en"
|
I18n.locale = "en"
|
||||||
end
|
end
|
||||||
|
|
||||||
def setup
|
|
||||||
I18n.locale = "en"
|
|
||||||
end
|
|
||||||
|
|
||||||
def test_linkify
|
def test_linkify
|
||||||
%w(http://example.com/test ftp://example.com/test https://example.com/test).each do |link|
|
%w(http://example.com/test ftp://example.com/test https://example.com/test).each do |link|
|
||||||
text = "Test #{link} is made into a link"
|
text = "Test #{link} is made into a link"
|
||||||
|
|
|
@ -171,7 +171,6 @@ class UserCreationTest < ActionDispatch::IntegrationTest
|
||||||
def test_user_create_openid_failure
|
def test_user_create_openid_failure
|
||||||
new_email = "newtester-openid2@osm.org"
|
new_email = "newtester-openid2@osm.org"
|
||||||
display_name = "new_tester-openid2"
|
display_name = "new_tester-openid2"
|
||||||
password = "testtest2"
|
|
||||||
assert_difference('User.count', 0) do
|
assert_difference('User.count', 0) do
|
||||||
assert_difference('ActionMailer::Base.deliveries.size', 0) do
|
assert_difference('ActionMailer::Base.deliveries.size', 0) do
|
||||||
post "/user/new",
|
post "/user/new",
|
||||||
|
@ -190,7 +189,6 @@ class UserCreationTest < ActionDispatch::IntegrationTest
|
||||||
def test_user_create_openid_redirect
|
def test_user_create_openid_redirect
|
||||||
new_email = "redirect_tester_openid@osm.org"
|
new_email = "redirect_tester_openid@osm.org"
|
||||||
display_name = "redirect_tester_openid"
|
display_name = "redirect_tester_openid"
|
||||||
password = ""
|
|
||||||
# nothing special about this page, just need a protected page to redirect back to.
|
# nothing special about this page, just need a protected page to redirect back to.
|
||||||
referer = "/traces/mine"
|
referer = "/traces/mine"
|
||||||
assert_difference('User.count') do
|
assert_difference('User.count') do
|
||||||
|
|
|
@ -292,8 +292,7 @@ class UserLoginTest < ActionDispatch::IntegrationTest
|
||||||
post '/login', 'openid_url' => "http://localhost:1123/john.doe?openid.success=true", :referer => "/history"
|
post '/login', 'openid_url' => "http://localhost:1123/john.doe?openid.success=true", :referer => "/history"
|
||||||
assert_response :redirect
|
assert_response :redirect
|
||||||
|
|
||||||
res = openid_request(@response.redirect_url)
|
post '/login', openid_request(@response.redirect_url)
|
||||||
res2 = post '/login', res
|
|
||||||
|
|
||||||
assert_response :redirect
|
assert_response :redirect
|
||||||
follow_redirect!
|
follow_redirect!
|
||||||
|
@ -311,8 +310,7 @@ class UserLoginTest < ActionDispatch::IntegrationTest
|
||||||
post '/login', 'openid_url' => "http://localhost:1123/john.doe", :referer => "/diary"
|
post '/login', 'openid_url' => "http://localhost:1123/john.doe", :referer => "/diary"
|
||||||
assert_response :redirect
|
assert_response :redirect
|
||||||
|
|
||||||
res = openid_request(@response.redirect_url)
|
post '/login', openid_request(@response.redirect_url)
|
||||||
post '/login', res
|
|
||||||
|
|
||||||
assert_response :redirect
|
assert_response :redirect
|
||||||
follow_redirect!
|
follow_redirect!
|
||||||
|
@ -361,7 +359,7 @@ class UserLoginTest < ActionDispatch::IntegrationTest
|
||||||
assert_response :redirect
|
assert_response :redirect
|
||||||
|
|
||||||
res = openid_request(@response.redirect_url)
|
res = openid_request(@response.redirect_url)
|
||||||
res2 = post '/login', res
|
post '/login', res
|
||||||
|
|
||||||
assert_response :redirect
|
assert_response :redirect
|
||||||
follow_redirect!
|
follow_redirect!
|
||||||
|
|
|
@ -144,7 +144,6 @@ class BoundingBoxTest < ActiveSupport::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_expand_max_lat_with_margin
|
def test_expand_max_lat_with_margin
|
||||||
bbox = @bbox_expand
|
|
||||||
@expand_max_lat_array.each_with_index do |array_string, index|
|
@expand_max_lat_array.each_with_index do |array_string, index|
|
||||||
check_expand(@bbox_expand_minus_two, array_string, 1, @expand_max_lat_margin_response[index])
|
check_expand(@bbox_expand_minus_two, array_string, 1, @expand_max_lat_margin_response[index])
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,7 +3,7 @@ require 'test_helper'
|
||||||
class I18nTest < ActiveSupport::TestCase
|
class I18nTest < ActiveSupport::TestCase
|
||||||
I18n.available_locales.each do |locale|
|
I18n.available_locales.each do |locale|
|
||||||
define_method("test_#{locale.to_s.underscore}".to_sym) do
|
define_method("test_#{locale.to_s.underscore}".to_sym) do
|
||||||
plural_keys = plural_keys(locale)
|
# plural_keys = plural_keys(locale)
|
||||||
|
|
||||||
translation_keys.each do |key|
|
translation_keys.each do |key|
|
||||||
variables = []
|
variables = []
|
||||||
|
@ -32,7 +32,7 @@ class I18nTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
if value.is_a?(Hash)
|
if value.is_a?(Hash)
|
||||||
value.each do |subkey, subvalue|
|
value.each do |subkey, subvalue|
|
||||||
# assert plural_keys.include?(subkey), "#{key}.#{subkey} is not a valid plural key"
|
# assert plural_keys.include?(subkey), "#{key}.#{subkey} is not a valid plural key"
|
||||||
|
|
||||||
unless subvalue.nil?
|
unless subvalue.nil?
|
||||||
subvalue.scan(/%\{(\w+)\}/) do
|
subvalue.scan(/%\{(\w+)\}/) do
|
||||||
|
|
|
@ -40,7 +40,7 @@ class ChangesetTest < ActiveSupport::TestCase
|
||||||
message_update = assert_raise(OSM::APIBadXMLError) do
|
message_update = assert_raise(OSM::APIBadXMLError) do
|
||||||
Changeset.from_xml(nokv, false)
|
Changeset.from_xml(nokv, false)
|
||||||
end
|
end
|
||||||
assert_match /tag is missing key/, message_create.message
|
assert_match /tag is missing key/, message_update.message
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_from_xml_no_v
|
def test_from_xml_no_v
|
||||||
|
|
|
@ -25,7 +25,7 @@ class MessageTest < ActiveSupport::TestCase
|
||||||
def test_validating_msgs
|
def test_validating_msgs
|
||||||
message = messages(:unread_message)
|
message = messages(:unread_message)
|
||||||
assert message.valid?
|
assert message.valid?
|
||||||
massage = messages(:read_message)
|
message = messages(:read_message)
|
||||||
assert message.valid?
|
assert message.valid?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -79,8 +79,6 @@ class MessageTest < ActiveSupport::TestCase
|
||||||
rescue ArgumentError => ex
|
rescue ArgumentError => ex
|
||||||
assert_equal ex.to_s, "invalid byte sequence in UTF-8"
|
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
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -30,7 +30,7 @@ class NoteTest < ActiveSupport::TestCase
|
||||||
assert_not_nil note.closed_at
|
assert_not_nil note.closed_at
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_close
|
def test_reopen
|
||||||
note = notes(:closed_note_with_comment)
|
note = notes(:closed_note_with_comment)
|
||||||
assert_equal "closed", note.status
|
assert_equal "closed", note.status
|
||||||
assert_not_nil note.closed_at
|
assert_not_nil note.closed_at
|
||||||
|
|
|
@ -71,6 +71,20 @@ class ActiveSupport::TestCase
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
##
|
||||||
|
# for some reason assert_equal a, b fails when the relations are
|
||||||
|
# actually equal, so this method manually checks the fields...
|
||||||
|
def assert_relations_are_equal(a, b)
|
||||||
|
assert_not_nil a, "first relation is not allowed to be nil"
|
||||||
|
assert_not_nil b, "second relation #{a.id} is not allowed to be nil"
|
||||||
|
assert_equal a.id, b.id, "relation IDs"
|
||||||
|
assert_equal a.changeset_id, b.changeset_id, "changeset ID on relation #{a.id}"
|
||||||
|
assert_equal a.visible, b.visible, "visible on relation #{a.id}, #{a.visible.inspect} != #{b.visible.inspect}"
|
||||||
|
assert_equal a.version, b.version, "version on relation #{a.id}"
|
||||||
|
assert_equal a.tags, b.tags, "tags on relation #{a.id}"
|
||||||
|
assert_equal a.members, b.members, "member references on relation #{a.id}"
|
||||||
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
# for some reason assert_equal a, b fails when the ways are actually
|
# for some reason assert_equal a, b fails when the ways are actually
|
||||||
# equal, so this method manually checks the fields...
|
# equal, so this method manually checks the fields...
|
||||||
|
@ -130,20 +144,21 @@ class ActiveSupport::TestCase
|
||||||
|
|
||||||
# Set things up for OpenID testing
|
# Set things up for OpenID testing
|
||||||
def openid_setup
|
def openid_setup
|
||||||
rots_response = Net::HTTP.get_response(URI.parse("http://localhost:1123/"))
|
Net::HTTP.get_response(URI.parse("http://localhost:1123/"))
|
||||||
rescue
|
rescue
|
||||||
# It isn't, so start a new instance.
|
# It isn't, so start a new instance.
|
||||||
rots = IO.popen("#{Rails.root}/vendor/gems/rots-0.2.1/bin/rots --silent")
|
rots = IO.popen("#{Rails.root}/vendor/gems/rots-0.2.1/bin/rots --silent")
|
||||||
|
|
||||||
# Wait for up to 30 seconds for the server to start and respond before continuing
|
# Wait for up to 30 seconds for the server to start and respond before continuing
|
||||||
for i in (1..30)
|
1.upto(30).each do
|
||||||
begin
|
begin
|
||||||
sleep 1
|
sleep 1
|
||||||
rots_response = Net::HTTP.get_response(URI.parse("http://localhost:1123/"))
|
Net::HTTP.get_response(URI.parse("http://localhost:1123/"))
|
||||||
# If the rescue block doesn't fire, ROTS is up and running and we can continue
|
# If the rescue block doesn't fire, ROTS is up and running and we can continue
|
||||||
break
|
break
|
||||||
rescue
|
rescue
|
||||||
# If the connection failed, do nothing and repeat the loop
|
# If the connection failed, do nothing and repeat the loop
|
||||||
|
next
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue