Layout/ExtraSpacing:
AllowForAlignment: true
-Style/BracesAroundHashParameters:
- EnforcedStyle: context_dependent
+Lint/PercentStringArray:
+ Exclude:
+ - 'config/initializers/secure_headers.rb'
+ - 'app/controllers/site_controller.rb'
-Style/FileName:
+Naming/FileName:
Exclude:
- 'script/deliver-message'
- 'script/locale/reload-languages'
- 'script/update-spam-blocks'
+Rails/ApplicationRecord:
+ Enabled: false
+
+Rails/HasManyOrHasOneDependent:
+ Enabled: false
+
+Rails/HttpPositionalArguments:
+ Enabled: false
+
+Rails/SkipsModelValidations:
+ Exclude:
+ - 'db/migrate/*.rb'
+ - 'app/controllers/user_controller.rb'
+
+Style/BracesAroundHashParameters:
+ EnforcedStyle: context_dependent
+
Style/FormatStringToken:
EnforcedStyle: template
Style/SymbolArray:
EnforcedStyle: brackets
-
-Rails/ApplicationRecord:
- Enabled: false
-
-Rails/HttpPositionalArguments:
- Enabled: false
-
-Rails/SkipsModelValidations:
- Exclude:
- - 'db/migrate/*.rb'
- - 'app/controllers/user_controller.rb'
-
-Lint/PercentStringArray:
- Exclude:
- - 'config/initializers/secure_headers.rb'
- - 'app/controllers/site_controller.rb'
# This configuration was generated by
# `rubocop --auto-gen-config`
-# on 2016-10-20 21:45:27 +0100 using RuboCop version 0.44.1.
+# on 2017-10-05 10:04:24 +0100 using RuboCop version 0.50.0.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.
+# Offense count: 1
+# Cop supports --auto-correct.
+# Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth.
+# SupportedStyles: aligned, indented
+Layout/MultilineOperationIndentation:
+ Exclude:
+ - 'lib/bounding_box.rb'
+
# Offense count: 34
Lint/AmbiguousOperator:
Exclude:
- 'test/lib/bounding_box_test.rb'
- 'test/lib/country_test.rb'
-# Offense count: 117
+# Offense count: 124
Lint/AmbiguousRegexpLiteral:
Enabled: false
-# Offense count: 30
+# Offense count: 32
# Configuration parameters: AllowSafeAssignment.
Lint/AssignmentInCondition:
Exclude:
- 'lib/osm.rb'
- 'script/deliver-message'
-# Offense count: 5
+# Offense count: 4
Lint/HandleExceptions:
Exclude:
- 'app/controllers/amf_controller.rb'
- 'app/controllers/user_controller.rb'
- - 'config/initializers/session.rb'
+
+# Offense count: 3
+Lint/InterpolationCheck:
+ Exclude:
+ - 'test/controllers/node_controller_test.rb'
+
+# Offense count: 2
+Lint/RescueWithoutErrorClass:
+ Exclude:
+ - 'app/helpers/browse_helper.rb'
# Offense count: 2
Lint/ShadowingOuterLocalVariable:
Exclude:
- 'app/views/changeset/list.atom.builder'
-# Offense count: 630
+# Offense count: 666
Metrics/AbcSize:
Max: 280
-# Offense count: 35
-# Configuration parameters: CountComments.
+# Offense count: 41
+# Configuration parameters: CountComments, ExcludedMethods.
Metrics/BlockLength:
- Max: 295
+ Max: 240
# Offense count: 12
+# Configuration parameters: CountBlocks.
Metrics/BlockNesting:
Max: 5
-# Offense count: 62
+# Offense count: 63
# Configuration parameters: CountComments.
Metrics/ClassLength:
Max: 1790
-# Offense count: 69
+# Offense count: 71
Metrics/CyclomaticComplexity:
Max: 20
-# Offense count: 2826
-# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives.
+# Offense count: 3004
+# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
# URISchemes: http, https
Metrics/LineLength:
- Max: 1072
+ Max: 1073
-# Offense count: 612
+# Offense count: 675
# Configuration parameters: CountComments.
Metrics/MethodLength:
Max: 179
-# Offense count: 1
+# Offense count: 2
# Configuration parameters: CountComments.
Metrics/ModuleLength:
Max: 147
Metrics/PerceivedComplexity:
Max: 23
+# Offense count: 5
+Naming/AccessorMethodName:
+ Exclude:
+ - 'app/controllers/application_controller.rb'
+ - 'app/helpers/title_helper.rb'
+ - 'app/models/old_way.rb'
+ - 'lib/osm.rb'
+ - 'lib/potlatch.rb'
+
+# Offense count: 8
+# Configuration parameters: NamePrefix, NamePrefixBlacklist, NameWhitelist.
+# NamePrefix: is_, has_, have_
+# NamePrefixBlacklist: is_, has_, have_
+# NameWhitelist: is_a?
+Naming/PredicateName:
+ Exclude:
+ - 'spec/**/*'
+ - 'app/models/changeset.rb'
+ - 'app/models/old_node.rb'
+ - 'app/models/old_relation.rb'
+ - 'app/models/old_way.rb'
+ - 'app/models/user.rb'
+ - 'lib/classic_pagination/pagination.rb'
+
# Offense count: 2
# Configuration parameters: Include.
# Include: app/**/*.rb, config/**/*.rb, lib/**/*.rb
- 'db/migrate/025_add_end_time_to_changesets.rb'
- 'db/migrate/20120404205604_add_user_and_description_to_redaction.rb'
-# Offense count: 17
+# Offense count: 20
Rails/OutputSafety:
Exclude:
- 'app/controllers/user_controller.rb'
- 'lib/rich_text.rb'
- 'test/helpers/application_helper_test.rb'
-# Offense count: 74
+# Offense count: 86
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: strict, flexible
Rails/TimeZone:
Enabled: false
-# Offense count: 5
-Style/AccessorMethodName:
- Exclude:
- - 'app/controllers/application_controller.rb'
- - 'app/helpers/title_helper.rb'
- - 'app/models/old_way.rb'
- - 'lib/osm.rb'
- - 'lib/potlatch.rb'
-
# Offense count: 1
Style/AsciiComments:
Exclude:
- 'test/models/message_test.rb'
-# Offense count: 220
+# Offense count: 219
Style/Documentation:
Enabled: false
- 'test/controllers/relation_controller_test.rb'
- 'test/controllers/way_controller_test.rb'
-# Offense count: 71
+# Offense count: 75
# Cop supports --auto-correct.
+# Configuration parameters: Strict.
Style/NumericLiterals:
MinDigits: 11
-# Offense count: 8
-# Configuration parameters: NamePrefix, NamePrefixBlacklist, NameWhitelist.
-# NamePrefix: is_, has_, have_
-# NamePrefixBlacklist: is_, has_, have_
-# NameWhitelist: is_a?
-Style/PredicateName:
- Exclude:
- - 'spec/**/*'
- - 'app/models/changeset.rb'
- - 'app/models/old_node.rb'
- - 'app/models/old_relation.rb'
- - 'app/models/old_way.rb'
- - 'app/models/user.rb'
- - 'lib/classic_pagination/pagination.rb'
-
-# Offense count: 97
+# Offense count: 95
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: compact, exploded
cs = Changeset.find(closeid.to_i)
cs.set_closed_time_now
if cs.user_id != user.id
- raise OSM::APIUserChangesetMismatchError.new
+ raise OSM::APIUserChangesetMismatchError
elsif closecomment.empty?
cs.save!
else
begin
other = YAML.safe_load(File.open(Rails.root.join("config", "potlatch", "locales", "#{lang}.yml")))[lang]
loaded_lang = lang
- rescue
+ rescue StandardError
other = en
end
# Alternative SQL queries for getway/whichways
def sql_find_ways_in_area(bbox)
- sql = <<-EOF
+ sql = <<-SQL
SELECT DISTINCT current_ways.id AS wayid,current_ways.version AS version
FROM current_way_nodes
INNER JOIN current_nodes ON current_nodes.id=current_way_nodes.node_id
WHERE current_nodes.visible=TRUE
AND current_ways.visible=TRUE
AND #{OSM.sql_for_area(bbox, 'current_nodes.')}
- EOF
+ SQL
ActiveRecord::Base.connection.select_all(sql).collect { |a| [a["wayid"].to_i, a["version"].to_i] }
end
def sql_find_pois_in_area(bbox)
pois = []
- sql = <<-EOF
+ sql = <<-SQL
SELECT current_nodes.id,current_nodes.latitude*0.0000001 AS lat,current_nodes.longitude*0.0000001 AS lon,current_nodes.version
FROM current_nodes
LEFT OUTER JOIN current_way_nodes cwn ON cwn.node_id=current_nodes.id
WHERE current_nodes.visible=TRUE
AND cwn.id IS NULL
AND #{OSM.sql_for_area(bbox, 'current_nodes.')}
- EOF
+ SQL
ActiveRecord::Base.connection.select_all(sql).each do |row|
poitags = {}
ActiveRecord::Base.connection.select_all("SELECT k,v FROM current_node_tags WHERE id=#{row['id']}").each do |n|
def sql_find_relations_in_area_and_ways(bbox, way_ids)
# ** It would be more Potlatchy to get relations for nodes within ways
# during 'getway', not here
- sql = <<-EOF
+ sql = <<-SQL
SELECT DISTINCT cr.id AS relid,cr.version AS version
FROM current_relations cr
INNER JOIN current_relation_members crm ON crm.id=cr.id
INNER JOIN current_nodes cn ON crm.member_id=cn.id AND crm.member_type='Node'
WHERE #{OSM.sql_for_area(bbox, 'cn.')}
- EOF
+ SQL
unless way_ids.empty?
- sql += <<-EOF
+ sql += <<-SQL
UNION
SELECT DISTINCT cr.id AS relid,cr.version AS version
FROM current_relations cr
INNER JOIN current_relation_members crm ON crm.id=cr.id
WHERE crm.member_type='Way'
AND crm.member_id IN (#{way_ids.join(',')})
- EOF
+ SQL
end
ActiveRecord::Base.connection.select_all(sql).collect { |a| [a["relid"].to_i, a["version"].to_i] }
end
def sql_get_nodes_in_way(wayid)
points = []
- sql = <<-EOF
+ sql = <<-SQL
SELECT latitude*0.0000001 AS lat,longitude*0.0000001 AS lon,current_nodes.id,current_nodes.version
FROM current_way_nodes,current_nodes
WHERE current_way_nodes.id=#{wayid.to_i}
AND current_way_nodes.node_id=current_nodes.id
AND current_nodes.visible=TRUE
ORDER BY sequence_id
- EOF
+ SQL
ActiveRecord::Base.connection.select_all(sql).each do |row|
nodetags = {}
ActiveRecord::Base.connection.select_all("SELECT k,v FROM current_node_tags WHERE id=#{row['id']}").each do |n|
# or raises a suitable error. +method+ should be a symbol, e.g: :put or :get.
def assert_method(method)
ok = request.send((method.to_s.downcase + "?").to_sym)
- raise OSM::APIBadMethodError.new(method) unless ok
+ raise OSM::APIBadMethodError, method unless ok
end
##
# Add a comment to a changeset
def comment
# Check the arguments are sane
- raise OSM::APIBadUserInput.new("No id was given") unless params[:id]
- raise OSM::APIBadUserInput.new("No text was given") if params[:text].blank?
+ raise OSM::APIBadUserInput, "No id was given" unless params[:id]
+ raise OSM::APIBadUserInput, "No text was given" if params[:text].blank?
# Extract the arguments
id = params[:id].to_i
# Find the changeset and check it is valid
changeset = Changeset.find(id)
- raise OSM::APIChangesetNotYetClosedError.new(changeset) if changeset.is_open?
+ raise OSM::APIChangesetNotYetClosedError, changeset if changeset.is_open?
# Add a comment to the changeset
comment = changeset.comments.create(:changeset => changeset,
# Adds a subscriber to the changeset
def subscribe
# Check the arguments are sane
- raise OSM::APIBadUserInput.new("No id was given") unless params[:id]
+ raise OSM::APIBadUserInput, "No id was given" unless params[:id]
# Extract the arguments
id = params[:id].to_i
# Find the changeset and check it is valid
changeset = Changeset.find(id)
- raise OSM::APIChangesetNotYetClosedError.new(changeset) if changeset.is_open?
- raise OSM::APIChangesetAlreadySubscribedError.new(changeset) if changeset.subscribers.exists?(current_user.id)
+ raise OSM::APIChangesetNotYetClosedError, changeset if changeset.is_open?
+ raise OSM::APIChangesetAlreadySubscribedError, changeset if changeset.subscribers.exists?(current_user.id)
# Add the subscriber
changeset.subscribers << current_user
# Removes a subscriber from the changeset
def unsubscribe
# Check the arguments are sane
- raise OSM::APIBadUserInput.new("No id was given") unless params[:id]
+ raise OSM::APIBadUserInput, "No id was given" unless params[:id]
# Extract the arguments
id = params[:id].to_i
# Find the changeset and check it is valid
changeset = Changeset.find(id)
- raise OSM::APIChangesetNotYetClosedError.new(changeset) if changeset.is_open?
- raise OSM::APIChangesetNotSubscribedError.new(changeset) unless changeset.subscribers.exists?(current_user.id)
+ raise OSM::APIChangesetNotYetClosedError, changeset if changeset.is_open?
+ raise OSM::APIChangesetNotSubscribedError, changeset unless changeset.subscribers.exists?(current_user.id)
# Remove the subscriber
changeset.subscribers.delete(current_user)
# Sets visible flag on comment to false
def hide_comment
# Check the arguments are sane
- raise OSM::APIBadUserInput.new("No id was given") unless params[:id]
+ raise OSM::APIBadUserInput, "No id was given" unless params[:id]
# Extract the arguments
id = params[:id].to_i
# Sets visible flag on comment to true
def unhide_comment
# Check the arguments are sane
- raise OSM::APIBadUserInput.new("No id was given") unless params[:id]
+ raise OSM::APIBadUserInput, "No id was given" unless params[:id]
# Extract the arguments
id = params[:id].to_i
@comments = changeset.comments.includes(:author, :changeset).limit(comments_limit)
else
# Return comments
- @comments = ChangesetComment.includes(:author, :changeset).where(:visible => :true).order("created_at DESC").limit(comments_limit).preload(:changeset)
+ @comments = ChangesetComment.includes(:author, :changeset).where(:visible => true).order("created_at DESC").limit(comments_limit).preload(:changeset)
end
# Render the result
changesets
else
# shouldn't provide both name and UID
- raise OSM::APIBadUserInput.new("provide either the user ID or display name, but not both") if user && name
+ raise OSM::APIBadUserInput, "provide either the user ID or display name, but not both" if user && name
# use either the name or the UID to find the user which we're selecting on.
u = if name.nil?
# user input checking, we don't have any UIDs < 1
- raise OSM::APIBadUserInput.new("invalid user ID") if user.to_i < 1
+ raise OSM::APIBadUserInput, "invalid user ID" if user.to_i < 1
u = User.find(user.to_i)
else
u = User.find_by(:display_name => name)
end
# make sure we found a user
- raise OSM::APINotFoundError.new if u.nil?
+ raise OSM::APINotFoundError if u.nil?
# should be able to get changesets of public users only, or
# our own changesets regardless of public-ness.
# check that we actually have 2 elements in the array
times = time.split(/,/)
- raise OSM::APIBadUserInput.new("bad time range") if times.size != 2
+ raise OSM::APIBadUserInput, "bad time range" if times.size != 2
from, to = times.collect { |t| DateTime.parse(t) }
return changesets.where("closed_at >= ? and created_at <= ?", from, to)
# stupid DateTime seems to throw both of these for bad parsing, so
# we have to catch both and ensure the correct code path is taken.
rescue ArgumentError => ex
- raise OSM::APIBadUserInput.new(ex.message.to_s)
+ raise OSM::APIBadUserInput, ex.message.to_s
rescue RuntimeError => ex
- raise OSM::APIBadUserInput.new(ex.message.to_s)
+ raise OSM::APIBadUserInput, ex.message.to_s
end
##
if ids.nil?
changesets
elsif ids.empty?
- raise OSM::APIBadUserInput.new("No changesets were given to search for")
+ raise OSM::APIBadUserInput, "No changesets were given to search for"
else
ids = ids.split(",").collect(&:to_i)
changesets.where(:id => ids)
if params[:limit].to_i > 0 && params[:limit].to_i <= 10000
params[:limit].to_i
else
- raise OSM::APIBadUserInput.new("Comments limit must be between 1 and 10000")
+ raise OSM::APIBadUserInput, "Comments limit must be between 1 and 10000"
end
else
100
-# coding: utf-8
-
class GeocoderController < ApplicationController
require "cgi"
require "uri"
end
def escape_query(query)
- URI.escape(query, Regexp.new("[^#{URI::PATTERN::UNRESERVED}]", false, "N"))
+ CGI.escape(query)
end
def normalize_params
Float(captures[0])
lat = !captures[2].casecmp("s").zero? ? captures[0].to_f : -captures[0].to_f
lon = !captures[5].casecmp("w").zero? ? captures[3].to_f : -captures[3].to_f
- rescue
+ rescue StandardError
lat = !captures[0].casecmp("s").zero? ? captures[1].to_f : -captures[1].to_f
lon = !captures[3].casecmp("w").zero? ? captures[4].to_f : -captures[4].to_f
end
Float(captures[0])
lat = !captures[3].casecmp("s").zero? ? captures[0].to_f + captures[1].to_f / 60 : -(captures[0].to_f + captures[1].to_f / 60)
lon = !captures[7].casecmp("w").zero? ? captures[4].to_f + captures[5].to_f / 60 : -(captures[4].to_f + captures[5].to_f / 60)
- rescue
+ rescue StandardError
lat = !captures[0].casecmp("s").zero? ? captures[1].to_f + captures[2].to_f / 60 : -(captures[1].to_f + captures[2].to_f / 60)
lon = !captures[4].casecmp("w").zero? ? captures[5].to_f + captures[6].to_f / 60 : -(captures[5].to_f + captures[6].to_f / 60)
end
Float(captures[0])
lat = !captures[4].casecmp("s").zero? ? captures[0].to_f + (captures[1].to_f + captures[2].to_f / 60) / 60 : -(captures[0].to_f + (captures[1].to_f + captures[2].to_f / 60) / 60)
lon = !captures[9].casecmp("w").zero? ? captures[5].to_f + (captures[6].to_f + captures[7].to_f / 60) / 60 : -(captures[5].to_f + (captures[6].to_f + captures[7].to_f / 60) / 60)
- rescue
+ rescue StandardError
lat = !captures[0].casecmp("s").zero? ? captures[1].to_f + (captures[2].to_f + captures[3].to_f / 60) / 60 : -(captures[1].to_f + (captures[2].to_f + captures[3].to_f / 60) / 60)
lon = !captures[5].casecmp("w").zero? ? captures[6].to_f + (captures[7].to_f + captures[8].to_f / 60) / 60 : -(captures[6].to_f + (captures[7].to_f + captures[8].to_f / 60) / 60)
end
new_node = Node.from_xml(request.raw_post)
unless new_node && new_node.id == node.id
- raise OSM::APIBadUserInput.new("The id in the url (#{node.id}) is not the same as provided in the xml (#{new_node.id})")
+ raise OSM::APIBadUserInput, "The id in the url (#{node.id}) is not the same as provided in the xml (#{new_node.id})"
end
node.update_from(new_node, current_user)
new_node = Node.from_xml(request.raw_post)
unless new_node && new_node.id == node.id
- raise OSM::APIBadUserInput.new("The id in the url (#{node.id}) is not the same as provided in the xml (#{new_node.id})")
+ raise OSM::APIBadUserInput, "The id in the url (#{node.id}) is not the same as provided in the xml (#{new_node.id})"
end
node.delete_with_history!(new_node, current_user)
render :plain => node.version.to_s
# Dump the details on many nodes whose ids are given in the "nodes" parameter.
def nodes
unless params["nodes"]
- raise OSM::APIBadUserInput.new("The parameter nodes is required, and must be of the form nodes=id[,id[,id...]]")
+ raise OSM::APIBadUserInput, "The parameter nodes is required, and must be of the form nodes=id[,id[,id...]]"
end
ids = params["nodes"].split(",").collect(&:to_i)
if ids.empty?
- raise OSM::APIBadUserInput.new("No nodes were given to search for")
+ raise OSM::APIBadUserInput, "No nodes were given to search for"
end
doc = OSM::API.new.get_xml_doc
if params[:bbox]
bbox = BoundingBox.from_bbox_params(params)
else
- raise OSM::APIBadUserInput.new("No l was given") unless params[:l]
- raise OSM::APIBadUserInput.new("No r was given") unless params[:r]
- raise OSM::APIBadUserInput.new("No b was given") unless params[:b]
- raise OSM::APIBadUserInput.new("No t was given") unless params[:t]
+ raise OSM::APIBadUserInput, "No l was given" unless params[:l]
+ raise OSM::APIBadUserInput, "No r was given" unless params[:r]
+ raise OSM::APIBadUserInput, "No b was given" unless params[:b]
+ raise OSM::APIBadUserInput, "No t was given" unless params[:t]
bbox = BoundingBox.from_lrbt_params(params)
end
raise OSM::APIAccessDenied if Acl.no_note_comment(request.remote_ip)
# Check the arguments are sane
- raise OSM::APIBadUserInput.new("No lat was given") unless params[:lat]
- raise OSM::APIBadUserInput.new("No lon was given") unless params[:lon]
- raise OSM::APIBadUserInput.new("No text was given") if params[:text].blank?
+ raise OSM::APIBadUserInput, "No lat was given" unless params[:lat]
+ raise OSM::APIBadUserInput, "No lon was given" unless params[:lon]
+ raise OSM::APIBadUserInput, "No text was given" if params[:text].blank?
# Extract the arguments
lon = OSM.parse_float(params[:lon], OSM::APIBadUserInput, "lon was not a number")
Note.transaction do
# Create the note
@note = Note.create(:lat => lat, :lon => lon)
- raise OSM::APIBadUserInput.new("The note is outside this world") unless @note.in_world?
+ raise OSM::APIBadUserInput, "The note is outside this world" unless @note.in_world?
# Save the note
@note.save!
raise OSM::APIAccessDenied if Acl.no_note_comment(request.remote_ip)
# Check the arguments are sane
- raise OSM::APIBadUserInput.new("No id was given") unless params[:id]
- raise OSM::APIBadUserInput.new("No text was given") if params[:text].blank?
+ raise OSM::APIBadUserInput, "No id was given" unless params[:id]
+ raise OSM::APIBadUserInput, "No text was given" if params[:text].blank?
# Extract the arguments
id = params[:id].to_i
@note = Note.find(id)
raise OSM::APINotFoundError unless @note
raise OSM::APIAlreadyDeletedError.new("note", @note.id) unless @note.visible?
- raise OSM::APINoteAlreadyClosedError.new(@note) if @note.closed?
+ raise OSM::APINoteAlreadyClosedError, @note if @note.closed?
# Add a comment to the note
Note.transaction do
# Close a note
def close
# Check the arguments are sane
- raise OSM::APIBadUserInput.new("No id was given") unless params[:id]
+ raise OSM::APIBadUserInput, "No id was given" unless params[:id]
# Extract the arguments
id = params[:id].to_i
@note = Note.find_by(:id => id)
raise OSM::APINotFoundError unless @note
raise OSM::APIAlreadyDeletedError.new("note", @note.id) unless @note.visible?
- raise OSM::APINoteAlreadyClosedError.new(@note) if @note.closed?
+ raise OSM::APINoteAlreadyClosedError, @note if @note.closed?
# Close the note and add a comment
Note.transaction do
# Reopen a note
def reopen
# Check the arguments are sane
- raise OSM::APIBadUserInput.new("No id was given") unless params[:id]
+ raise OSM::APIBadUserInput, "No id was given" unless params[:id]
# Extract the arguments
id = params[:id].to_i
@note = Note.find_by(:id => id)
raise OSM::APINotFoundError unless @note
raise OSM::APIAlreadyDeletedError.new("note", @note.id) unless @note.visible? || current_user.moderator?
- raise OSM::APINoteAlreadyOpenError.new(@note) unless @note.closed? || !@note.visible?
+ raise OSM::APINoteAlreadyOpenError, @note unless @note.closed? || !@note.visible?
# Reopen the note and add a comment
Note.transaction do
# Read a note
def show
# Check the arguments are sane
- raise OSM::APIBadUserInput.new("No id was given") unless params[:id]
+ raise OSM::APIBadUserInput, "No id was given" unless params[:id]
# Find the note and check it is valid
@note = Note.find(params[:id])
# Delete (hide) a note
def destroy
# Check the arguments are sane
- raise OSM::APIBadUserInput.new("No id was given") unless params[:id]
+ raise OSM::APIBadUserInput, "No id was given" unless params[:id]
# Extract the arguments
id = params[:id].to_i
# Return a list of notes matching a given string
def search
# Check the arguments are sane
- raise OSM::APIBadUserInput.new("No query string was given") unless params[:q]
+ raise OSM::APIBadUserInput, "No query string was given" unless params[:q]
# Get any conditions that need to be applied
@notes = closed_condition(Note.all)
if params[:limit].to_i > 0 && params[:limit].to_i <= 10000
params[:limit].to_i
else
- raise OSM::APIBadUserInput.new("Note limit must be between 1 and 10000")
+ raise OSM::APIBadUserInput, "Note limit must be between 1 and 10000"
end
else
100
# the .where() method used in the lookup_old_element_versions
# call won't throw an error if no records are found, so we have
# to do that ourselves.
- raise OSM::APINotFoundError.new if @elements.empty?
+ raise OSM::APINotFoundError if @elements.empty?
doc = OSM::API.new.get_xml_doc
new_relation = Relation.from_xml(request.raw_post)
unless new_relation && new_relation.id == relation.id
- raise OSM::APIBadUserInput.new("The id in the url (#{relation.id}) is not the same as provided in the xml (#{new_relation.id})")
+ raise OSM::APIBadUserInput, "The id in the url (#{relation.id}) is not the same as provided in the xml (#{new_relation.id})"
end
relation.update_from new_relation, current_user
def relations
unless params["relations"]
- raise OSM::APIBadUserInput.new("The parameter relations is required, and must be of the form relations=id[,id[,id...]]")
+ raise OSM::APIBadUserInput, "The parameter relations is required, and must be of the form relations=id[,id[,id...]]"
end
ids = params["relations"].split(",").collect(&:to_i)
if ids.empty?
- raise OSM::APIBadUserInput.new("No relations were given to search for")
+ raise OSM::APIBadUserInput, "No relations were given to search for"
end
doc = OSM::API.new.get_xml_doc
begin
do_create(params[:trace][:gpx_file], params[:trace][:tagstring],
params[:trace][:description], params[:trace][:visibility])
- rescue => ex
+ rescue StandardError => ex
logger.debug ex
end
"lat" => m[2],
"lon" => m[3] }.merge(editor))
end
- rescue
+ rescue StandardError
# Use default
end
begin
Notifier.email_confirm(user, user.tokens.create).deliver_now
- rescue
+ rescue StandardError
# Ignore errors sending email
end
else
if preference = old_preferences.delete(pt["k"])
preference.v = pt["v"]
elsif new_preferences.include?(pt["k"])
- raise OSM::APIDuplicatePreferenceError.new(pt["k"])
+ raise OSM::APIDuplicatePreferenceError, pt["k"]
else
preference = current_user.preferences.build(:k => pt["k"], :v => pt["v"])
end
new_way = Way.from_xml(request.raw_post)
unless new_way && new_way.id == way.id
- raise OSM::APIBadUserInput.new("The id in the url (#{way.id}) is not the same as provided in the xml (#{new_way.id})")
+ raise OSM::APIBadUserInput, "The id in the url (#{way.id}) is not the same as provided in the xml (#{new_way.id})"
end
way.update_from(new_way, current_user)
def ways
unless params["ways"]
- raise OSM::APIBadUserInput.new("The parameter ways is required, and must be of the form ways=id[,id[,id...]]")
+ raise OSM::APIBadUserInput, "The parameter ways is required, and must be of the form ways=id[,id[,id...]]"
end
ids = params["ways"].split(",").collect(&:to_i)
- if ids.empty?
- raise OSM::APIBadUserInput.new("No ways were given to search for")
- end
+ raise OSM::APIBadUserInput, "No ways were given to search for" if ids.empty?
doc = OSM::API.new.get_xml_doc
enddate = v[:enddate]
begin
parsed = enddate && Date.parse(enddate)
- rescue
+ rescue StandardError
parsed = nil
end
!parsed.is_a?(Date) || (parsed.is_a?(Date) && parsed.past?)
-require "uri"
+require "cgi"
module BrowseHelper
def printable_name(object, version = false)
# the correct page.
lookup_us = lookup.tr(" ", "_")
- if page = WIKI_PAGES[locale][type][lookup_us] rescue nil
+ if page = begin
+ WIKI_PAGES[locale][type][lookup_us]
+ rescue
+ nil
+ end
url = "http://wiki.openstreetmap.org/wiki/#{page}?uselang=#{locale}"
- elsif page = WIKI_PAGES["en"][type][lookup_us] rescue nil
+ elsif page = begin
+ WIKI_PAGES["en"][type][lookup_us]
+ rescue
+ nil
+ end
url = "http://wiki.openstreetmap.org/wiki/#{page}?uselang=#{locale}"
end
# Must break it up to correctly build the url
value = Regexp.last_match(1)
section = "#" + Regexp.last_match(2)
- encoded_section = "#" + URI.encode(Regexp.last_match(2).gsub(/ +/, "_"), /[^A-Za-z0-9:_]/).tr("%", ".")
+ encoded_section = "#" + CGI.escape(Regexp.last_match(2).gsub(/ +/, "_")).tr("%", ".")
else
section = ""
encoded_section = ""
def set_title(title = nil)
if title
@title = TitleHelper.coder.decode(title.gsub("<bdi>", "\u202a").gsub("</bdi>", "\u202c"))
- response.headers["X-Page-Title"] = URI.escape(t("layouts.project_name.title") + " | " + @title)
+ response.headers["X-Page-Title"] = ERB::Util.u(t("layouts.project_name.title") + " | " + @title)
else
@title = title
- response.headers["X-Page-Title"] = URI.escape(t("layouts.project_name.title"))
+ response.headers["X-Page-Title"] = ERB::Util.u(t("layouts.project_name.title"))
end
end
end
attr_writer :tags
def add_tag_keyval(k, v)
- @tags = {} unless @tags
+ @tags ||= {}
# duplicate tags are now forbidden, so we can't allow values
# in the hash to be overwritten.
# bounding box, only the tags of the changeset.
def update_from(other, user)
# ensure that only the user who opened the changeset may modify it.
- raise OSM::APIUserChangesetMismatchError.new unless user.id == user_id
+ raise OSM::APIUserChangesetMismatchError unless user.id == user_id
# can't change a closed changeset
- raise OSM::APIChangesetAlreadyClosedError.new(self) unless is_open?
+ raise OSM::APIChangesetAlreadyClosedError, self unless is_open?
# copy the other's tags
self.tags = other.tags
raise OSM::APIBadXMLError.new("node", pt, "Changeset id is missing") if pt["changeset"].nil?
node.changeset_id = pt["changeset"].to_i
- raise OSM::APIBadUserInput.new("The node is outside this world") unless node.in_world?
+ raise OSM::APIBadUserInput, "The node is outside this world" unless node.in_world?
# version must be present unless creating
raise OSM::APIBadXMLError.new("node", pt, "Version is required when updating") unless create || !pt["version"].nil?
node.id = pt["id"].to_i
# .to_i will return 0 if there is no number that can be parsed.
# We want to make sure that there is no id with zero anyway
- raise OSM::APIBadUserInput.new("ID of node cannot be zero when updating.") if node.id.zero?
+ raise OSM::APIBadUserInput, "ID of node cannot be zero when updating." if node.id.zero?
end
# We don't care about the time, as it is explicitly set on create/update/delete
lock!
check_consistency(self, new_node, user)
ways = Way.joins(:way_nodes).where(:visible => true, :current_way_nodes => { :node_id => id }).order(:id)
- raise OSM::APIPreconditionFailedError.new("Node #{id} is still used by ways #{ways.collect(&:id).join(',')}.") unless ways.empty?
+ raise OSM::APIPreconditionFailedError, "Node #{id} is still used by ways #{ways.collect(&:id).join(',')}." unless ways.empty?
rels = Relation.joins(:relation_members).where(:visible => true, :current_relation_members => { :member_type => "Node", :member_id => id }).order(:id)
- raise OSM::APIPreconditionFailedError.new("Node #{id} is still used by relations #{rels.collect(&:id).join(',')}.") unless rels.empty?
+ raise OSM::APIPreconditionFailedError, "Node #{id} is still used by relations #{rels.collect(&:id).join(',')}." unless rels.empty?
self.changeset_id = new_node.changeset_id
self.tags = {}
attr_writer :tags
def add_tag_key_val(k, v)
- @tags = {} unless @tags
+ @tags ||= {}
# duplicate tags are now forbidden, so we can't allow values
# in the hash to be overwritten.
def to_query
q = "access_token=#{token}&token_type=bearer"
- q << "&state=#{URI.escape(state)}" if @state
+ q << "&state=#{CGI.escape(state)}" if @state
q << "&expires_in=#{expires_in}" if expires_at
- q << "&scope=#{URI.escape(scope)}" if scope
+ q << "&scope=#{CGI.escape(scope)}" if scope
q
end
def to_query
q = "code=#{token}"
- q << "&state=#{URI.escape(state)}" if @state
+ q << "&state=#{CGI.escape(state)}" if @state
q
end
relation.id = pt["id"].to_i
# .to_i will return 0 if there is no number that can be parsed.
# We want to make sure that there is no id with zero anyway
- raise OSM::APIBadUserInput.new("ID of relation cannot be zero when updating.") if relation.id.zero?
+ raise OSM::APIBadUserInput, "ID of relation cannot be zero when updating." if relation.id.zero?
end
# We don't care about the timestamp nor the visibility as these are either
member["role"] ||= "" # Allow the upload to not include this, in which case we default to an empty string.
relation.add_member(member["type"].classify, member["ref"], member["role"])
end
- raise OSM::APIBadUserInput.new("Some bad xml in relation") if relation.nil?
+ raise OSM::APIBadUserInput, "Some bad xml in relation" if relation.nil?
relation
end
end
def add_tag_keyval(k, v)
- @tags = {} unless @tags
+ @tags ||= {}
# duplicate tags are now forbidden, so we can't allow values
# in the hash to be overwritten.
check_consistency(self, new_relation, user)
# This will check to see if this relation is used by another relation
rel = RelationMember.joins(:relation).find_by("visible = ? AND member_type = 'Relation' and member_id = ? ", true, id)
- raise OSM::APIPreconditionFailedError.new("The relation #{new_relation.id} is used in relation #{rel.relation.id}.") unless rel.nil?
+ raise OSM::APIPreconditionFailedError, "The relation #{new_relation.id} is used in relation #{rel.relation.id}." unless rel.nil?
self.changeset_id = new_relation.changeset_id
self.tags = {}
lock!
check_consistency(self, new_relation, user)
unless new_relation.preconditions_ok?(members)
- raise OSM::APIPreconditionFailedError.new("Cannot update relation #{id}: data or member data is invalid.")
+ raise OSM::APIPreconditionFailedError, "Cannot update relation #{id}: data or member data is invalid."
end
self.changeset_id = new_relation.changeset_id
self.changeset = new_relation.changeset
def create_with_history(user)
check_create_consistency(self, user)
unless preconditions_ok?
- raise OSM::APIPreconditionFailedError.new("Cannot create relation: data or member data is invalid.")
+ raise OSM::APIPreconditionFailedError, "Cannot create relation: data or member data is invalid."
end
self.version = 0
self.visible = true
# and check that it is OK to use.
unless element && element.visible? && element.preconditions_ok?
- raise OSM::APIPreconditionFailedError.new("Relation with id #{id} cannot be saved due to #{m[0]} with id #{m[1]}")
+ raise OSM::APIPreconditionFailedError, "Relation with id #{id} cannot be saved due to #{m[0]} with id #{m[1]}"
end
hash[m[1]] = true
end
old_id = id.to_i
if old_id < 0
new_id = id_map[type.downcase.to_sym][old_id]
- raise OSM::APIBadUserInput.new("Placeholder #{type} not found for reference #{old_id} in relation #{self.id.nil? ? placeholder_id : self.id}.") if new_id.nil?
+ raise OSM::APIBadUserInput, "Placeholder #{type} not found for reference #{old_id} in relation #{self.id.nil? ? placeholder_id : self.id}." if new_id.nil?
[type, new_id, role]
else
[type, id, role]
id = pt["id"].to_i
# .to_i will return 0 if there is no number that can be parsed.
# We want to make sure that there is no id with zero anyway
- raise OSM::APIBadUserInput.new("ID of trace cannot be zero when updating.") if id.zero?
- raise OSM::APIBadUserInput.new("The id in the url (#{self.id}) is not the same as provided in the xml (#{id})") unless self.id == id
+ raise OSM::APIBadUserInput, "ID of trace cannot be zero when updating." if id.zero?
+ raise OSM::APIBadUserInput, "The id in the url (#{self.id}) is not the same as provided in the xml (#{id})" unless self.id == id
end
# We don't care about the time, as it is explicitly set on create/update/delete
way.id = pt["id"].to_i
# .to_i will return 0 if there is no number that can be parsed.
# We want to make sure that there is no id with zero anyway
- raise OSM::APIBadUserInput.new("ID of way cannot be zero when updating.") if way.id.zero?
+ raise OSM::APIBadUserInput, "ID of way cannot be zero when updating." if way.id.zero?
end
# We don't care about the timestamp nor the visibility as these are either
attr_writer :tags
def add_nd_num(n)
- @nds = [] unless @nds
+ @nds ||= []
@nds << n.to_i
end
def add_tag_keyval(k, v)
- @tags = {} unless @tags
+ @tags ||= {}
# duplicate tags are now forbidden, so we can't allow values
# in the hash to be overwritten.
lock!
check_consistency(self, new_way, user)
unless new_way.preconditions_ok?(nds)
- raise OSM::APIPreconditionFailedError.new("Cannot update way #{id}: data is invalid.")
+ raise OSM::APIPreconditionFailedError, "Cannot update way #{id}: data is invalid."
end
self.changeset_id = new_way.changeset_id
def create_with_history(user)
check_create_consistency(self, user)
unless preconditions_ok?
- raise OSM::APIPreconditionFailedError.new("Cannot create way: data is invalid.")
+ raise OSM::APIPreconditionFailedError, "Cannot create way: data is invalid."
end
self.version = 0
self.visible = true
if db_nds.length < new_nds.length
missing = new_nds - db_nds.collect(&:id)
- raise OSM::APIPreconditionFailedError.new("Way #{id} requires the nodes with id in (#{missing.join(',')}), which either do not exist, or are not visible.")
+ raise OSM::APIPreconditionFailedError, "Way #{id} requires the nodes with id in (#{missing.join(',')}), which either do not exist, or are not visible."
end
end
lock!
check_consistency(self, new_way, user)
rels = Relation.joins(:relation_members).where(:visible => true, :current_relation_members => { :member_type => "Way", :member_id => id }).order(:id)
- raise OSM::APIPreconditionFailedError.new("Way #{id} is still used by relations #{rels.collect(&:id).join(',')}.") unless rels.empty?
+ raise OSM::APIPreconditionFailedError, "Way #{id} is still used by relations #{rels.collect(&:id).join(',')}." unless rels.empty?
self.changeset_id = new_way.changeset_id
self.changeset = new_way.changeset
nds.map! do |node_id|
if node_id < 0
new_id = id_map[:node][node_id]
- raise OSM::APIBadUserInput.new("Placeholder node not found for reference #{node_id} in way #{id.nil? ? placeholder_id : id}") if new_id.nil?
+ raise OSM::APIBadUserInput, "Placeholder node not found for reference #{node_id} in way #{id.nil? ? placeholder_id : id}" if new_id.nil?
new_id
else
node_id
begin
BANNERS = YAML.load_file(Rails.root.join("config", "banners.yml")).deep_symbolize_keys
-rescue
+rescue StandardError
BANNERS = {}.freeze
end
class TileNodes < ActiveRecord::Migration
def self.upgrade_table(from_table, to_table, model)
if ENV["USE_DB_FUNCTIONS"]
- execute <<-END_SQL
+ execute <<-SQL
INSERT INTO #{to_table} (id, latitude, longitude, user_id, visible, tags, timestamp, tile)
SELECT id, ROUND(latitude * 10000000), ROUND(longitude * 10000000),
user_id, visible, tags, timestamp,
tile_for_point(CAST(ROUND(latitude * 10000000) AS INTEGER),
CAST(ROUND(longitude * 10000000) AS INTEGER))
FROM #{from_table}
- END_SQL
+ SQL
else
- execute <<-END_SQL
+ execute <<-SQL
INSERT INTO #{to_table} (id, latitude, longitude, user_id, visible, tags, timestamp, tile)
SELECT id, ROUND(latitude * 10000000), ROUND(longitude * 10000000),
user_id, visible, tags, timestamp, 0
FROM #{from_table}
- END_SQL
+ SQL
model.all.each(&:save!)
end
end
def self.downgrade_table(from_table, to_table)
- execute <<-END_SQL
+ execute <<-SQL
INSERT INTO #{to_table} (id, latitude, longitude, user_id, visible, tags, timestamp)
SELECT id, latitude / 10000000, longitude / 10000000,
user_id, visible, tags, timestamp
FROM #{from_table}
- END_SQL
+ SQL
end
def self.up
cmd = "db/migrate/008_remove_segments_helper"
src = "#{cmd}.cc"
if !File.exist?(cmd) || File.mtime(cmd) < File.mtime(src)
- system("c++ -O3 -Wall `mysql_config --cflags --libs` " +
+ system("c++ -O3 -Wall `mysql_config --cflags --libs` " \
"#{src} -o #{cmd}") || raise
end
cmd = "db/migrate/020_populate_node_tags_and_remove_helper"
src = "#{cmd}.c"
if !File.exist?(cmd) || File.mtime(cmd) < File.mtime(src)
- system("cc -O3 -Wall `mysql_config --cflags --libs` " +
+ system("cc -O3 -Wall `mysql_config --cflags --libs` " \
"#{src} -o #{cmd}") || raise
end
# all edits up to the API change,
# all the changesets will have the id of the user that made them.
# We need to generate a changeset for each user in the database
- execute "INSERT INTO changesets (id, user_id, created_at, open)" +
+ execute "INSERT INTO changesets (id, user_id, created_at, open)" \
"SELECT id, id, creation_time, false from users;"
@conv_user_tables.each do |tbl|
def check_boundaries
# check the bbox is sane
if min_lon > max_lon
- raise OSM::APIBadBoundingBox.new(
- "The minimum longitude must be less than the maximum longitude, but it wasn't"
- )
+ raise OSM::APIBadBoundingBox, "The minimum longitude must be less than the maximum longitude, but it wasn't"
end
if min_lat > max_lat
- raise OSM::APIBadBoundingBox.new(
- "The minimum latitude must be less than the maximum latitude, but it wasn't"
- )
+ raise OSM::APIBadBoundingBox, "The minimum latitude must be less than the maximum latitude, but it wasn't"
end
if min_lon < -LON_LIMIT || min_lat < -LAT_LIMIT || max_lon > +LON_LIMIT || max_lat > +LAT_LIMIT
- raise OSM::APIBadBoundingBox.new("The latitudes must be between #{-LAT_LIMIT} and #{LAT_LIMIT}," +
- " and longitudes between #{-LON_LIMIT} and #{LON_LIMIT}")
+ raise OSM::APIBadBoundingBox, "The latitudes must be between #{-LAT_LIMIT} and #{LAT_LIMIT}," \
+ " and longitudes between #{-LON_LIMIT} and #{LON_LIMIT}"
end
self
end
def check_size(max_area = MAX_REQUEST_AREA)
# check the bbox isn't too large
if area > max_area
- raise OSM::APIBadBoundingBox.new("The maximum bbox size is " + max_area.to_s +
- ", and your request was too large. Either request a smaller area, or use planet.osm")
+ raise OSM::APIBadBoundingBox, "The maximum bbox size is " + max_area.to_s +
+ ", and your request was too large. Either request a smaller area, or use planet.osm"
end
self
end
def from_bbox_array(bbox_array)
unless bbox_array
- raise OSM::APIBadUserInput.new(
- "The parameter bbox is required, and must be of the form min_lon,min_lat,max_lon,max_lat"
- )
+ raise OSM::APIBadUserInput, "The parameter bbox is required, and must be of the form min_lon,min_lat,max_lon,max_lat"
end
# Take an array of length 4, create a bounding box with min_lon, min_lat, max_lon and
# max_lat within their respective boundaries.
# This will throw an exception if there is an inconsistency
def check_consistency(old, new, user)
if new.id != old.id || new.id.nil? || old.id.nil?
- raise OSM::APIPreconditionFailedError.new("New and old IDs don't match on #{new.class}. #{new.id} != #{old.id}.")
+ raise OSM::APIPreconditionFailedError, "New and old IDs don't match on #{new.class}. #{new.id} != #{old.id}."
elsif new.version != old.version
raise OSM::APIVersionMismatchError.new(new.id, new.class.to_s, new.version, old.version)
elsif new.changeset.nil?
- raise OSM::APIChangesetMissingError.new
+ raise OSM::APIChangesetMissingError
elsif new.changeset.user_id != user.id
- raise OSM::APIUserChangesetMismatchError.new
+ raise OSM::APIUserChangesetMismatchError
elsif !new.changeset.is_open?
- raise OSM::APIChangesetAlreadyClosedError.new(new.changeset)
+ raise OSM::APIChangesetAlreadyClosedError, new.changeset
end
end
# This is similar to above, just some validations don't apply
def check_create_consistency(new, user)
if new.changeset.nil?
- raise OSM::APIChangesetMissingError.new
+ raise OSM::APIChangesetMissingError
elsif new.changeset.user_id != user.id
- raise OSM::APIUserChangesetMismatchError.new
+ raise OSM::APIUserChangesetMismatchError
elsif !new.changeset.is_open?
- raise OSM::APIChangesetAlreadyClosedError.new(new.changeset)
+ raise OSM::APIChangesetAlreadyClosedError, new.changeset
end
end
# check user credentials - only the user who opened a changeset
# may alter it.
if changeset.nil?
- raise OSM::APIChangesetMissingError.new
+ raise OSM::APIChangesetMissingError
elsif user.id != changeset.user_id
- raise OSM::APIUserChangesetMismatchError.new
+ raise OSM::APIUserChangesetMismatchError
elsif !changeset.is_open?
- raise OSM::APIChangesetAlreadyClosedError.new(changeset)
+ raise OSM::APIChangesetAlreadyClosedError, changeset
end
end
end
class Hash
def with_symbols!
- keys.each { |key| self[key.to_s.to_sym] = self[key] }
+ each_key { |key| self[key.to_s.to_sym] = self[key] }
self
end
end
with_element do |model_name, _model_attributes|
model = MODELS[model_name]
if model.nil?
- raise OSM::APIBadUserInput.new("Unexpected element type #{model_name}, " +
- "expected node, way or relation.")
+ raise OSM::APIBadUserInput, "Unexpected element type #{model_name}, " \
+ "expected node, way or relation."
end
# new in libxml-ruby >= 2, expand returns an element not associated
# with a document. this means that there's no encoding parameter,
# take the first element and check that it is an osmChange element
@reader.read
- raise OSM::APIBadUserInput.new("Document element should be 'osmChange'.") if @reader.name != "osmChange"
+ raise OSM::APIBadUserInput, "Document element should be 'osmChange'." if @reader.name != "osmChange"
result = OSM::API.new.get_xml_doc
result.root.name = "diffResult"
# check if the placeholder ID has been given before and throw
# an exception if it has - we can't create the same element twice.
model_sym = model.to_s.downcase.to_sym
- raise OSM::APIBadUserInput.new("Placeholder IDs must be unique for created elements.") if ids[model_sym].include? placeholder_id
+ raise OSM::APIBadUserInput, "Placeholder IDs must be unique for created elements." if ids[model_sym].include? placeholder_id
# some elements may have placeholders for other elements in the
# diff, so we must fix these before saving the element.
else
# no other actions to choose from, so it must be the users fault!
- raise OSM::APIChangesetActionInvalid.new(action_name)
+ raise OSM::APIChangesetActionInvalid, action_name
end
end
end
def redact!(_r)
- raise OSM::APICannotRedactError.new
+ raise OSM::APICannotRedactError
end
end
# Parse a float, raising a specified exception on failure
def self.parse_float(str, klass, *args)
Float(str)
- rescue
+ rescue StandardError
raise klass.new(*args)
end
tilesql = QuadTile.sql_for_area(bbox, prefix)
bbox = bbox.to_scaled
- "#{tilesql} AND #{prefix}latitude BETWEEN #{bbox.min_lat} AND #{bbox.max_lat} " +
+ "#{tilesql} AND #{prefix}latitude BETWEEN #{bbox.min_lat} AND #{bbox.max_lat} " \
"AND #{prefix}longitude BETWEEN #{bbox.min_lon} AND #{bbox.max_lon}"
end
def redact!(redaction)
# check that this version isn't the current version
- raise OSM::APICannotRedactError.new if is_latest_version?
+ raise OSM::APICannotRedactError if is_latest_version?
# make the change
self.redaction = redaction
if session[session_persistence_key]
request.session_options[:expire_after] = session[session_persistence_key]
end
- rescue
+ rescue StandardError
reset_session
end
end
def test_create
basic_authorization create(:user, :data_public => false).email, "test"
# Create the first user's changeset
- content "<osm><changeset>" +
- "<tag k='created_by' v='osm test suite checking changesets'/>" +
+ content "<osm><changeset>" \
+ "<tag k='created_by' v='osm test suite checking changesets'/>" \
"</changeset></osm>"
put :create
assert_require_public_data
basic_authorization create(:user).email, "test"
# Create the first user's changeset
- content "<osm><changeset>" +
- "<tag k='created_by' v='osm test suite checking changesets'/>" +
+ content "<osm><changeset>" \
+ "<tag k='created_by' v='osm test suite checking changesets'/>" \
"</changeset></osm>"
put :create
# simple diff to change a node, way and relation by removing
# their tags
- diff = <<EOF.strip_heredoc
+ diff = <<CHANGESET.strip_heredoc
<osmChange>
<modify>
<node id='#{node.id}' lon='0' lat='0' changeset='#{changeset_id}' version='1'/>
</relation>
</modify>
</osmChange>
-EOF
+CHANGESET
# upload it
content diff
# simple diff to change a node, way and relation by removing
# their tags
- diff = <<EOF.strip_heredoc
+ diff = <<CHANGESET.strip_heredoc
<osmChange>
<modify>
<node id='#{node.id}' lon='0' lat='0' changeset='#{changeset_id}' version='1'/>
</relation>
</modify>
</osmChange>
-EOF
+CHANGESET
# upload it
content diff
# simple diff to change a node, way and relation by removing
# their tags
- diff = <<EOF.strip_heredoc
+ diff = <<CHANGESET.strip_heredoc
<osmChange>
<modify>
<node id='#{node.id}' lon='0' lat='0' changeset='#{changeset_id}' version='1'/>
</relation>
</modify>
</osmChange>
-EOF
+CHANGESET
# upload it
content diff
basic_authorization user.email, "test"
# simple diff to create a node way and relation using placeholders
- diff = <<EOF.strip_heredoc
+ diff = <<CHANGESET.strip_heredoc
<osmChange>
<create>
<node id='-1' lon='0' lat='0' changeset='#{changeset.id}'>
</relation>
</create>
</osmChange>
-EOF
+CHANGESET
# upload it
content diff
basic_authorization create(:user).email, "test"
# create a temporary changeset
- content "<osm><changeset>" +
- "<tag k='created_by' v='osm test suite checking changesets'/>" +
+ content "<osm><changeset>" \
+ "<tag k='created_by' v='osm test suite checking changesets'/>" \
"</changeset></osm>"
assert_difference "Changeset.count", 1 do
put :create
# upload some widely-spaced nodes, spiralling positive and negative to cause
# largest bbox over-expansion possible.
- diff = <<EOF.strip_heredoc
+ diff = <<CHANGESET.strip_heredoc
<osmChange>
<create>
<node id='-1' lon='-20' lat='-10' changeset='#{changeset_id}'/>
<node id='-18' lon='179.9' lat='89.9' changeset='#{changeset_id}'/>
</create>
</osmChange>
-EOF
+CHANGESET
# upload it, which used to cause an error like "PGError: ERROR:
# integer out of range" (bug #2152). but shouldn't any more.
basic_authorization changeset.user.email, "test"
# simple diff to create a node way and relation using placeholders
- diff = <<EOF.strip_heredoc
+ diff = <<CHANGESET.strip_heredoc
<osmChange>
<create>
<node id='-1' lon='0' lat='0' changeset='#{changeset.id}'>
</node>
</create>
</osmChange>
-EOF
+CHANGESET
# upload it
content diff
basic_authorization changeset.user.email, "test"
# simple diff to create a node way and relation using placeholders
- diff = <<EOF.strip_heredoc
+ diff = <<CHANGESET.strip_heredoc
<osmChange>
<create>
<node id='-1' lon='0' lat='0' changeset='#{changeset.id}'>
</relation>
</modify>
</osmChange>
-EOF
+CHANGESET
# upload it
content diff
basic_authorization changeset.user.email, "test"
# simple diff to create a node way and relation using placeholders
- diff = <<EOF.strip_heredoc
+ diff = <<CHANGESET.strip_heredoc
<osmChange>
<modify>
<node id='#{node.id}' lon='0' lat='0' changeset='#{changeset.id}' version='1'/>
</node>
</create>
</osmChange>
-EOF
+CHANGESET
# upload it
content diff
# change the location of a node multiple times, each time referencing
# the last version. doesn't this depend on version numbers being
# sequential?
- diff = <<EOF.strip_heredoc
+ diff = <<CHANGESET.strip_heredoc
<osmChange>
<modify>
<node id='#{node.id}' lon='0' lat='0' changeset='#{changeset.id}' version='1'/>
<node id='#{node.id}' lon='9' lat='9' changeset='#{changeset.id}' version='8'/>
</modify>
</osmChange>
-EOF
+CHANGESET
# upload it
content diff
basic_authorization changeset.user.email, "test"
- diff = <<EOF.strip_heredoc
+ diff = <<CHANGESET.strip_heredoc
<osmChange>
<modify>
<node id='#{node.id}' lon='0' lat='0' changeset='#{changeset.id}' version='1'/>
<node id='#{node.id}' lon='1' lat='1' changeset='#{changeset.id}' version='1'/>
</modify>
</osmChange>
-EOF
+CHANGESET
# upload it
content diff
basic_authorization changeset.user.email, "test"
- diff = <<EOF.strip_heredoc
+ diff = <<CHANGESET.strip_heredoc
<osmChange>
<modify>
<node id='1' lon='1' lat='1' changeset='#{changeset.id}'/>
</modify>
</osmChange>
-EOF
+CHANGESET
# upload it
content diff
basic_authorization changeset.user.email, "test"
- diff = <<EOF.strip_heredoc
+ diff = <<CHANGESET.strip_heredoc
<osmChange>
<ping>
<node id='1' lon='1' lat='1' changeset='#{changeset.id}' />
</ping>
</osmChange>
-EOF
+CHANGESET
content diff
post :upload, :params => { :id => changeset.id }
assert_response :bad_request, "Shouldn't be able to upload a diff with the action ping"
basic_authorization changeset.user.email, "test"
- diff = <<EOF.strip_heredoc
+ diff = <<CHANGESET.strip_heredoc
<osmChange>
<modify><node id='#{node.id}' lon='0' lat='0' changeset='#{changeset.id}'
version='1'></node>
<member type='relation' role='some' ref='#{other_relation.id}'/>
</relation>
</modify></osmChange>
-EOF
+CHANGESET
# upload it
content diff
basic_authorization changeset.user.email, "test"
- diff = <<EOF.strip_heredoc
+ diff = <<CHANGESET.strip_heredoc
<osmChange>
<create>
<node id='-1' lon='0' lat='0' changeset='#{changeset.id}'>
<node id='-1' lon='2' lat='2' changeset='#{changeset.id}' version='2'/>
</delete>
</osmChange>
-EOF
+CHANGESET
# upload it
content diff
basic_authorization changeset.user.email, "test"
- diff = <<EOF.strip_heredoc
+ diff = <<CHANGESET.strip_heredoc
<osmChange>
<create>
<node id='-1' lon='0' lat='0' changeset='#{changeset.id}' version='1'/>
<node id='-1' lon='2' lat='2' changeset='#{changeset.id}' version='2'/>
</create>
</osmChange>
-EOF
+CHANGESET
# upload it
content diff
basic_authorization changeset.user.email, "test"
- diff = <<EOF.strip_heredoc
+ diff = <<CHANGESET.strip_heredoc
<osmChange>
<create>
<node id="-1" lon="0" lat="0" changeset="#{changeset.id}" version="1"/>
</way>
</create>
</osmChange>
-EOF
+CHANGESET
# upload it
content diff
assert_equal "Placeholder node not found for reference -4 in way -1", @response.body
# the same again, but this time use an existing way
- diff = <<EOF.strip_heredoc
+ diff = <<CHANGESET.strip_heredoc
<osmChange>
<create>
<node id="-1" lon="0" lat="0" changeset="#{changeset.id}" version="1"/>
</way>
</create>
</osmChange>
-EOF
+CHANGESET
# upload it
content diff
basic_authorization changeset.user.email, "test"
- diff = <<EOF.strip_heredoc
+ diff = <<CHANGESET.strip_heredoc
<osmChange>
<create>
<node id="-1" lon="0" lat="0" changeset="#{changeset.id}" version="1"/>
</relation>
</create>
</osmChange>
-EOF
+CHANGESET
# upload it
content diff
assert_equal "Placeholder Node not found for reference -4 in relation -1.", @response.body
# the same again, but this time use an existing relation
- diff = <<EOF.strip_heredoc
+ diff = <<CHANGESET.strip_heredoc
<osmChange>
<create>
<node id="-1" lon="0" lat="0" changeset="#{changeset.id}" version="1"/>
</relation>
</create>
</osmChange>
-EOF
+CHANGESET
# upload it
content diff
def test_upload_node_move
basic_authorization create(:user).email, "test"
- content "<osm><changeset>" +
- "<tag k='created_by' v='osm test suite checking changesets'/>" +
+ content "<osm><changeset>" \
+ "<tag k='created_by' v='osm test suite checking changesets'/>" \
"</changeset></osm>"
put :create
assert_response :success
def test_upload_way_extend
basic_authorization create(:user).email, "test"
- content "<osm><changeset>" +
- "<tag k='created_by' v='osm test suite checking changesets'/>" +
+ content "<osm><changeset>" \
+ "<tag k='created_by' v='osm test suite checking changesets'/>" \
"</changeset></osm>"
put :create
assert_response :success
# upload it
content diff
post :upload, :params => { :id => changeset.id }
- assert_response(:success, "should be able to upload " +
+ assert_response(:success, "should be able to upload " \
"empty changeset: " + diff)
end
end
basic_authorization create(:user, :data_public => false).email, "test"
# create a temporary changeset
- content "<osm><changeset>" +
- "<tag k='created_by' v='osm test suite checking changesets'/>" +
+ content "<osm><changeset>" \
+ "<tag k='created_by' v='osm test suite checking changesets'/>" \
"</changeset></osm>"
put :create
assert_response :forbidden
basic_authorization create(:user).email, "test"
# create a temporary changeset
- content "<osm><changeset>" +
- "<tag k='created_by' v='osm test suite checking changesets'/>" +
+ content "<osm><changeset>" \
+ "<tag k='created_by' v='osm test suite checking changesets'/>" \
"</changeset></osm>"
put :create
assert_response :success
changeset_id = @response.body.to_i
# add a diff to it
- diff = <<EOF.strip_heredoc
+ diff = <<CHANGESET.strip_heredoc
<osmChange>
<modify>
<node id='#{node.id}' lon='0' lat='0' changeset='#{changeset_id}' version='1'/>
<node id='#{node.id}' lon='9' lat='9' changeset='#{changeset_id}' version='8'/>
</modify>
</osmChange>
-EOF
+CHANGESET
# upload it
content diff
basic_authorization create(:user).email, "test"
# create a temporary changeset
- content "<osm><changeset>" +
- "<tag k='created_by' v='osm test suite checking changesets'/>" +
+ content "<osm><changeset>" \
+ "<tag k='created_by' v='osm test suite checking changesets'/>" \
"</changeset></osm>"
put :create
assert_response :success
basic_authorization create(:user).email, "test"
# create a temporary changeset
- content "<osm><changeset>" +
- "<tag k='created_by' v='osm test suite checking changesets'/>" +
+ content "<osm><changeset>" \
+ "<tag k='created_by' v='osm test suite checking changesets'/>" \
"</changeset></osm>"
put :create
assert_response :success
changeset_id = @response.body.to_i
# add a diff to it
- diff = <<EOF.strip_heredoc
+ diff = <<CHANGESET.strip_heredoc
<osmChange>
<delete>
<node id='#{node.id}' lon='0' lat='0' changeset='#{changeset_id}' version='1'/>
</way>
</modify>
</osmChange>
-EOF
+CHANGESET
# upload it
content diff
# check that the changeset is now closed as well
assert(!changeset.is_open?,
- "changeset should have been auto-closed by exceeding " +
+ "changeset should have been auto-closed by exceeding " \
"element limit.")
end
get :edit,
:params => { :display_name => entry.user.display_name, :id => entry.id }
assert_response :redirect
- assert_redirected_to :controller => :user, :action => :login, :referer => "/user/#{URI.encode(entry.user.display_name)}/diary/#{entry.id}/edit"
+ assert_redirected_to :controller => :user, :action => :login, :referer => "/user/#{ERB::Util.u(entry.user.display_name)}/diary/#{entry.id}/edit"
# Verify that you get a not found error, when you pass a bogus id
get :edit,
assert_select "h1", :text => /Edit diary entry/, :count => 1
end
assert_select "div#content", :count => 1 do
- assert_select "form[action='/user/#{URI.encode(entry.user.display_name)}/diary/#{entry.id}/edit'][method=post]", :count => 1 do
+ assert_select "form[action='/user/#{ERB::Util.u(entry.user.display_name)}/diary/#{entry.id}/edit'][method=post]", :count => 1 do
assert_select "input#diary_entry_title[name='diary_entry[title]'][value='#{entry.title}']", :count => 1
assert_select "textarea#diary_entry_body[name='diary_entry[body]']", :text => entry.body, :count => 1
assert_select "select#diary_entry_language_code", :count => 1
assert_select "abbr[class='geo'][title='#{number_with_precision(new_latitude, :precision => 4)}; #{number_with_precision(new_longitude, :precision => 4)}']", :count => 1
# As we're not logged in, check that you cannot edit
# print @response.body
- assert_select "a[href='/user/#{URI.encode(entry.user.display_name)}/diary/#{entry.id}/edit']", :text => "Edit this entry", :count => 1
+ assert_select "a[href='/user/#{ERB::Util.u(entry.user.display_name)}/diary/#{entry.id}/edit']", :text => "Edit this entry", :count => 1
end
# and when not logged in as the user who wrote the entry
assert_select "abbr[class=geo][title='#{number_with_precision(new_latitude, :precision => 4)}; #{number_with_precision(new_longitude, :precision => 4)}']", :count => 1
# As we're not logged in, check that you cannot edit
assert_select "li[class='hidden show_if_user_#{entry.user.id}']", :count => 1 do
- assert_select "a[href='/user/#{URI.encode(entry.user.display_name)}/diary/#{entry.id}/edit']", :text => "Edit this entry", :count => 1
+ assert_select "a[href='/user/#{ERB::Util.u(entry.user.display_name)}/diary/#{entry.id}/edit']", :text => "Edit this entry", :count => 1
end
end
end
assert_response :success
assert_select ".diary-comment", :count => 1 do
assert_select "#comment#{comment.id}", :count => 1 do
- assert_select "a[href='/user/#{URI.encode(other_user.display_name)}']", :text => other_user.display_name, :count => 1
+ assert_select "a[href='/user/#{ERB::Util.u(other_user.display_name)}']", :text => other_user.display_name, :count => 1
end
assert_select ".richtext", :text => /New comment/, :count => 1
end
assert_select "div.diary_post", entries.count
entries.each do |entry|
- assert_select "a[href=?]", "/user/#{URI.encode(entry.user.display_name)}/diary/#{entry.id}"
+ assert_select "a[href=?]", "/user/#{ERB::Util.u(entry.user.display_name)}/diary/#{entry.id}"
end
end
end
-# coding: utf-8
require "test_helper"
require "geocoder_controller"
# try and put something into a string that the API might
# use unquoted and therefore allow code injection...
- content "<osm><node lat='0' lon='0' changeset='#{private_changeset.id}'>" +
- '<tag k="#{@user.inspect}" v="0"/>' +
+ content "<osm><node lat='0' lon='0' changeset='#{private_changeset.id}'>" \
+ '<tag k="#{@user.inspect}" v="0"/>' \
"</node></osm>"
put :create
assert_require_public_data "Shouldn't be able to create with non-public user"
# try and put something into a string that the API might
# use unquoted and therefore allow code injection...
- content "<osm><node lat='0' lon='0' changeset='#{changeset.id}'>" +
- '<tag k="#{@user.inspect}" v="0"/>' +
+ content "<osm><node lat='0' lon='0' changeset='#{changeset.id}'>" \
+ '<tag k="#{@user.inspect}" v="0"/>' \
"</node></osm>"
put :create
assert_response :success
end
# check all the versions
- versions.keys.each do |key|
+ versions.each_key do |key|
get :version, :params => { :id => nodeid, :version => key.to_i }
assert_response :success,
###
# create an relation with a node as member
# This time try with a role attribute in the relation
- content "<osm><relation changeset='#{private_changeset.id}'>" +
- "<member ref='#{node.id}' type='node' role='some'/>" +
+ content "<osm><relation changeset='#{private_changeset.id}'>" \
+ "<member ref='#{node.id}' type='node' role='some'/>" \
"<tag k='test' v='yes' /></relation></osm>"
put :create
# hope for forbidden due to user
###
# create an relation with a node as member, this time test that we don't
# need a role attribute to be included
- content "<osm><relation changeset='#{private_changeset.id}'>" +
+ content "<osm><relation changeset='#{private_changeset.id}'>" \
"<member ref='#{node.id}' type='node'/>" + "<tag k='test' v='yes' /></relation></osm>"
put :create
# hope for forbidden due to user
###
# create an relation with a way and a node as members
- content "<osm><relation changeset='#{private_changeset.id}'>" +
- "<member type='node' ref='#{node.id}' role='some'/>" +
- "<member type='way' ref='#{way.id}' role='other'/>" +
+ content "<osm><relation changeset='#{private_changeset.id}'>" \
+ "<member type='node' ref='#{node.id}' role='some'/>" \
+ "<member type='way' ref='#{way.id}' role='other'/>" \
"<tag k='test' v='yes' /></relation></osm>"
put :create
# hope for forbidden, due to user
###
# create an relation with a node as member
# This time try with a role attribute in the relation
- content "<osm><relation changeset='#{changeset.id}'>" +
- "<member ref='#{node.id}' type='node' role='some'/>" +
+ content "<osm><relation changeset='#{changeset.id}'>" \
+ "<member ref='#{node.id}' type='node' role='some'/>" \
"<tag k='test' v='yes' /></relation></osm>"
put :create
# hope for success
###
# create an relation with a node as member, this time test that we don't
# need a role attribute to be included
- content "<osm><relation changeset='#{changeset.id}'>" +
+ content "<osm><relation changeset='#{changeset.id}'>" \
"<member ref='#{node.id}' type='node'/>" + "<tag k='test' v='yes' /></relation></osm>"
put :create
# hope for success
###
# create an relation with a way and a node as members
- content "<osm><relation changeset='#{changeset.id}'>" +
- "<member type='node' ref='#{node.id}' role='some'/>" +
- "<member type='way' ref='#{way.id}' role='other'/>" +
+ content "<osm><relation changeset='#{changeset.id}'>" \
+ "<member type='node' ref='#{node.id}' role='some'/>" \
+ "<member type='way' ref='#{way.id}' role='other'/>" \
"<tag k='test' v='yes' /></relation></osm>"
put :create
# hope for success
basic_authorization user.email, "test"
# create a relation with non-existing node as member
- content "<osm><relation changeset='#{changeset.id}'>" +
- "<member type='node' ref='0'/><tag k='test' v='yes' />" +
+ content "<osm><relation changeset='#{changeset.id}'>" \
+ "<member type='node' ref='0'/><tag k='test' v='yes' />" \
"</relation></osm>"
put :create
# expect failure
basic_authorization user.email, "test"
# create some xml that should return an error
- content "<osm><relation changeset='#{changeset.id}'>" +
- "<member type='type' ref='#{node.id}' role=''/>" +
+ content "<osm><relation changeset='#{changeset.id}'>" \
+ "<member type='type' ref='#{node.id}' role=''/>" \
"<tag k='tester' v='yep'/></relation></osm>"
put :create
# expect failure
assert_equal a_tags.keys, b_tags.keys, "Tag keys should be identical."
a_tags.each do |k, v|
assert_equal v, b_tags[k],
- "Tags which were not altered should be the same. " +
+ "Tags which were not altered should be the same. " \
"#{a_tags.inspect} != #{b_tags.inspect}"
end
end
# you are not logged in
get :account, :params => { :display_name => user.display_name }
assert_response :redirect
- assert_redirected_to :controller => :user, :action => "login", :referer => "/user/#{URI.encode(user.display_name)}/account"
+ assert_redirected_to :controller => :user, :action => "login", :referer => "/user/#{ERB::Util.u(user.display_name)}/account"
# Make sure that you are blocked when not logged in as the right user
get :account, :params => { :display_name => user.display_name }, :session => { :user => create(:user) }
assert_select "form#accountForm" do |form|
assert_equal "post", form.attr("method").to_s
assert_select "input[name='_method']", false
- assert_equal "/user/#{URI.encode(user.display_name)}/account", form.attr("action").to_s
+ assert_equal "/user/#{ERB::Util.u(user.display_name)}/account", form.attr("action").to_s
end
# Updating the description should work
# Adding external authentication should redirect to the auth provider
post :account, :params => { :display_name => user.display_name, :user => user.attributes.merge(:auth_provider => "openid", :auth_uid => "gmail.com") }, :session => { :user => user }
assert_response :redirect
- assert_redirected_to auth_path(:provider => "openid", :openid_url => "https://www.google.com/accounts/o8/id", :origin => "/user/#{URI.encode(user.display_name)}/account")
+ assert_redirected_to auth_path(:provider => "openid", :openid_url => "https://www.google.com/accounts/o8/id", :origin => "/user/#{ERB::Util.u(user.display_name)}/account")
# Changing name to one that exists should fail
new_attributes = user.attributes.dup.merge(:display_name => create(:user).display_name)
get :view, :params => { :display_name => user.display_name }
assert_response :success
assert_select "div#userinformation" do
- assert_select "a[href^='/user/#{URI.encode(user.display_name)}/history']", 1
- assert_select "a[href='/user/#{URI.encode(user.display_name)}/traces']", 1
- assert_select "a[href='/user/#{URI.encode(user.display_name)}/diary']", 1
- assert_select "a[href='/user/#{URI.encode(user.display_name)}/diary/comments']", 1
- assert_select "a[href='/user/#{URI.encode(user.display_name)}/account']", 0
- assert_select "a[href='/user/#{URI.encode(user.display_name)}/blocks']", 0
- assert_select "a[href='/user/#{URI.encode(user.display_name)}/blocks_by']", 0
- assert_select "a[href='/blocks/new/#{URI.encode(user.display_name)}']", 0
+ assert_select "a[href^='/user/#{ERB::Util.u(user.display_name)}/history']", 1
+ assert_select "a[href='/user/#{ERB::Util.u(user.display_name)}/traces']", 1
+ assert_select "a[href='/user/#{ERB::Util.u(user.display_name)}/diary']", 1
+ assert_select "a[href='/user/#{ERB::Util.u(user.display_name)}/diary/comments']", 1
+ assert_select "a[href='/user/#{ERB::Util.u(user.display_name)}/account']", 0
+ assert_select "a[href='/user/#{ERB::Util.u(user.display_name)}/blocks']", 0
+ assert_select "a[href='/user/#{ERB::Util.u(user.display_name)}/blocks_by']", 0
+ assert_select "a[href='/blocks/new/#{ERB::Util.u(user.display_name)}']", 0
end
# Test a user who has been blocked
get :view, :params => { :display_name => blocked_user.display_name }
assert_response :success
assert_select "div#userinformation" do
- assert_select "a[href^='/user/#{URI.encode(blocked_user.display_name)}/history']", 1
- assert_select "a[href='/user/#{URI.encode(blocked_user.display_name)}/traces']", 1
- assert_select "a[href='/user/#{URI.encode(blocked_user.display_name)}/diary']", 1
- assert_select "a[href='/user/#{URI.encode(blocked_user.display_name)}/diary/comments']", 1
- assert_select "a[href='/user/#{URI.encode(blocked_user.display_name)}/account']", 0
- assert_select "a[href='/user/#{URI.encode(blocked_user.display_name)}/blocks']", 1
- assert_select "a[href='/user/#{URI.encode(blocked_user.display_name)}/blocks_by']", 0
- assert_select "a[href='/blocks/new/#{URI.encode(blocked_user.display_name)}']", 0
+ assert_select "a[href^='/user/#{ERB::Util.u(blocked_user.display_name)}/history']", 1
+ assert_select "a[href='/user/#{ERB::Util.u(blocked_user.display_name)}/traces']", 1
+ assert_select "a[href='/user/#{ERB::Util.u(blocked_user.display_name)}/diary']", 1
+ assert_select "a[href='/user/#{ERB::Util.u(blocked_user.display_name)}/diary/comments']", 1
+ assert_select "a[href='/user/#{ERB::Util.u(blocked_user.display_name)}/account']", 0
+ assert_select "a[href='/user/#{ERB::Util.u(blocked_user.display_name)}/blocks']", 1
+ assert_select "a[href='/user/#{ERB::Util.u(blocked_user.display_name)}/blocks_by']", 0
+ assert_select "a[href='/blocks/new/#{ERB::Util.u(blocked_user.display_name)}']", 0
end
# Test a moderator who has applied blocks
get :view, :params => { :display_name => moderator_user.display_name }
assert_response :success
assert_select "div#userinformation" do
- assert_select "a[href^='/user/#{URI.encode(moderator_user.display_name)}/history']", 1
- assert_select "a[href='/user/#{URI.encode(moderator_user.display_name)}/traces']", 1
- assert_select "a[href='/user/#{URI.encode(moderator_user.display_name)}/diary']", 1
- assert_select "a[href='/user/#{URI.encode(moderator_user.display_name)}/diary/comments']", 1
- assert_select "a[href='/user/#{URI.encode(moderator_user.display_name)}/account']", 0
- assert_select "a[href='/user/#{URI.encode(moderator_user.display_name)}/blocks']", 0
- assert_select "a[href='/user/#{URI.encode(moderator_user.display_name)}/blocks_by']", 1
- assert_select "a[href='/blocks/new/#{URI.encode(moderator_user.display_name)}']", 0
+ assert_select "a[href^='/user/#{ERB::Util.u(moderator_user.display_name)}/history']", 1
+ assert_select "a[href='/user/#{ERB::Util.u(moderator_user.display_name)}/traces']", 1
+ assert_select "a[href='/user/#{ERB::Util.u(moderator_user.display_name)}/diary']", 1
+ assert_select "a[href='/user/#{ERB::Util.u(moderator_user.display_name)}/diary/comments']", 1
+ assert_select "a[href='/user/#{ERB::Util.u(moderator_user.display_name)}/account']", 0
+ assert_select "a[href='/user/#{ERB::Util.u(moderator_user.display_name)}/blocks']", 0
+ assert_select "a[href='/user/#{ERB::Util.u(moderator_user.display_name)}/blocks_by']", 1
+ assert_select "a[href='/blocks/new/#{ERB::Util.u(moderator_user.display_name)}']", 0
end
# Login as a normal user
get :view, :params => { :display_name => user.display_name }
assert_response :success
assert_select "div#userinformation" do
- assert_select "a[href^='/user/#{URI.encode(user.display_name)}/history']", 1
+ assert_select "a[href^='/user/#{ERB::Util.u(user.display_name)}/history']", 1
assert_select "a[href='/traces/mine']", 1
- assert_select "a[href='/user/#{URI.encode(user.display_name)}/diary']", 1
- assert_select "a[href='/user/#{URI.encode(user.display_name)}/diary/comments']", 1
- assert_select "a[href='/user/#{URI.encode(user.display_name)}/account']", 1
- assert_select "a[href='/user/#{URI.encode(user.display_name)}/blocks']", 0
- assert_select "a[href='/user/#{URI.encode(user.display_name)}/blocks_by']", 0
- assert_select "a[href='/blocks/new/#{URI.encode(user.display_name)}']", 0
+ assert_select "a[href='/user/#{ERB::Util.u(user.display_name)}/diary']", 1
+ assert_select "a[href='/user/#{ERB::Util.u(user.display_name)}/diary/comments']", 1
+ assert_select "a[href='/user/#{ERB::Util.u(user.display_name)}/account']", 1
+ assert_select "a[href='/user/#{ERB::Util.u(user.display_name)}/blocks']", 0
+ assert_select "a[href='/user/#{ERB::Util.u(user.display_name)}/blocks_by']", 0
+ assert_select "a[href='/blocks/new/#{ERB::Util.u(user.display_name)}']", 0
end
# Login as a moderator
get :view, :params => { :display_name => user.display_name }
assert_response :success
assert_select "div#userinformation" do
- assert_select "a[href^='/user/#{URI.encode(user.display_name)}/history']", 1
- assert_select "a[href='/user/#{URI.encode(user.display_name)}/traces']", 1
- assert_select "a[href='/user/#{URI.encode(user.display_name)}/diary']", 1
- assert_select "a[href='/user/#{URI.encode(user.display_name)}/diary/comments']", 1
- assert_select "a[href='/user/#{URI.encode(user.display_name)}/account']", 0
- assert_select "a[href='/user/#{URI.encode(user.display_name)}/blocks']", 0
- assert_select "a[href='/user/#{URI.encode(user.display_name)}/blocks_by']", 0
- assert_select "a[href='/blocks/new/#{URI.encode(user.display_name)}']", 1
+ assert_select "a[href^='/user/#{ERB::Util.u(user.display_name)}/history']", 1
+ assert_select "a[href='/user/#{ERB::Util.u(user.display_name)}/traces']", 1
+ assert_select "a[href='/user/#{ERB::Util.u(user.display_name)}/diary']", 1
+ assert_select "a[href='/user/#{ERB::Util.u(user.display_name)}/diary/comments']", 1
+ assert_select "a[href='/user/#{ERB::Util.u(user.display_name)}/account']", 0
+ assert_select "a[href='/user/#{ERB::Util.u(user.display_name)}/blocks']", 0
+ assert_select "a[href='/user/#{ERB::Util.u(user.display_name)}/blocks_by']", 0
+ assert_select "a[href='/blocks/new/#{ERB::Util.u(user.display_name)}']", 1
end
end
changeset_id = private_changeset.id
# create a way with pre-existing nodes
- content "<osm><way changeset='#{changeset_id}'>" +
- "<nd ref='#{node1.id}'/><nd ref='#{node2.id}'/>" +
+ content "<osm><way changeset='#{changeset_id}'>" \
+ "<nd ref='#{node1.id}'/><nd ref='#{node2.id}'/>" \
"<tag k='test' v='yes' /></way></osm>"
put :create
# hope for failure
changeset_id = changeset.id
# create a way with pre-existing nodes
- content "<osm><way changeset='#{changeset_id}'>" +
- "<nd ref='#{node1.id}'/><nd ref='#{node2.id}'/>" +
+ content "<osm><way changeset='#{changeset_id}'>" \
+ "<nd ref='#{node1.id}'/><nd ref='#{node2.id}'/>" \
"<tag k='test' v='yes' /></way></osm>"
put :create
# hope for success
# use the first user's open changeset
# create a way with non-existing node
- content "<osm><way changeset='#{private_open_changeset.id}'>" +
+ content "<osm><way changeset='#{private_open_changeset.id}'>" \
"<nd ref='0'/><tag k='test' v='yes' /></way></osm>"
put :create
# expect failure
"way upload with invalid node using a private user did not return 'forbidden'"
# create a way with no nodes
- content "<osm><way changeset='#{private_open_changeset.id}'>" +
+ content "<osm><way changeset='#{private_open_changeset.id}'>" \
"<tag k='test' v='yes' /></way></osm>"
put :create
# expect failure
"way upload with no node using a private userdid not return 'forbidden'"
# create a way inside a closed changeset
- content "<osm><way changeset='#{private_closed_changeset.id}'>" +
+ content "<osm><way changeset='#{private_closed_changeset.id}'>" \
"<nd ref='#{node.id}'/></way></osm>"
put :create
# expect failure
# use the first user's open changeset
# create a way with non-existing node
- content "<osm><way changeset='#{open_changeset.id}'>" +
+ content "<osm><way changeset='#{open_changeset.id}'>" \
"<nd ref='0'/><tag k='test' v='yes' /></way></osm>"
put :create
# expect failure
assert_equal "Precondition failed: Way requires the nodes with id in (0), which either do not exist, or are not visible.", @response.body
# create a way with no nodes
- content "<osm><way changeset='#{open_changeset.id}'>" +
+ content "<osm><way changeset='#{open_changeset.id}'>" \
"<tag k='test' v='yes' /></way></osm>"
put :create
# expect failure
assert_equal "Precondition failed: Cannot create way: data is invalid.", @response.body
# create a way inside a closed changeset
- content "<osm><way changeset='#{closed_changeset.id}'>" +
+ content "<osm><way changeset='#{closed_changeset.id}'>" \
"<nd ref='#{node.id}'/></way></osm>"
put :create
# expect failure
"way upload to closed changeset did not return 'conflict'"
# create a way with a tag which is too long
- content "<osm><way changeset='#{open_changeset.id}'>" +
- "<nd ref='#{node.id}'/>" +
- "<tag k='foo' v='#{'x' * 256}'/>" +
+ content "<osm><way changeset='#{open_changeset.id}'>" \
+ "<nd ref='#{node.id}'/>" \
+ "<tag k='foo' v='#{'x' * 256}'/>" \
"</way></osm>"
put :create
# expect failure
class ChangesetHelperTest < ActionView::TestCase
def test_changeset_user_link
changeset = create(:changeset)
- assert_equal %(<a href="/user/#{URI.encode(changeset.user.display_name)}">#{changeset.user.display_name}</a>), changeset_user_link(changeset)
+ assert_equal %(<a href="/user/#{ERB::Util.u(changeset.user.display_name)}">#{changeset.user.display_name}</a>), changeset_user_link(changeset)
changeset = create(:changeset, :user => create(:user, :data_public => false))
assert_equal "anonymous", changeset_user_link(changeset)
assert_match %r{^Created <abbr title='Mon, 01 Jan 2007 00:00:00 \+0000'>.*</abbr> by anonymous$}, changeset_details(changeset)
changeset = create(:changeset, :created_at => Time.utc(2007, 1, 1, 0, 0, 0), :closed_at => Time.utc(2007, 1, 2, 0, 0, 0))
- user_link = %(<a href="/user/#{URI.encode(changeset.user.display_name)}">#{changeset.user.display_name}</a>)
+ user_link = %(<a href="/user/#{ERB::Util.u(changeset.user.display_name)}">#{changeset.user.display_name}</a>)
assert_match %r{^Closed <abbr title='Created: Mon, 01 Jan 2007 00:00:00 \+0000 Closed: Tue, 02 Jan 2007 00:00:00 \+0000'>.*</abbr> by #{user_link}$}, changeset_details(changeset)
end
user = create(:user)
assert_match %r{^Created by anonymous <abbr title='Wed, 05 Mar 2014 21:37:45 \+0000'><span title=" 5 March 2014 at 21:37">.*</span> ago</abbr>$}, note_event("open", date, nil)
- assert_match %r{^Resolved by <a href="/user/#{URI.encode(user.display_name)}">#{user.display_name}</a> <abbr title='Wed, 05 Mar 2014 21:37:45 \+0000'><span title=" 5 March 2014 at 21:37">.*</span> ago</abbr>$}, note_event("closed", date, user)
+ assert_match %r{^Resolved by <a href="/user/#{ERB::Util.u(user.display_name)}">#{user.display_name}</a> <abbr title='Wed, 05 Mar 2014 21:37:45 \+0000'><span title=" 5 March 2014 at 21:37">.*</span> ago</abbr>$}, note_event("closed", date, user)
end
def test_note_author
assert_equal "", note_author(nil)
assert_equal "deleted", note_author(deleted_user)
- assert_equal "<a href=\"/user/#{URI.encode(user.display_name)}\">#{user.display_name}</a>", note_author(user)
- assert_equal "<a href=\"http://test.host/user/#{URI.encode(user.display_name)}\">#{user.display_name}</a>", note_author(user, :only_path => false)
+ assert_equal "<a href=\"/user/#{ERB::Util.u(user.display_name)}\">#{user.display_name}</a>", note_author(user)
+ assert_equal "<a href=\"http://test.host/user/#{ERB::Util.u(user.display_name)}\">#{user.display_name}</a>", note_author(user, :only_path => false)
end
end
-# coding: utf-8
require "test_helper"
assert_equal "Test Title", @title
set_title("Test & Title")
- assert_equal "OpenStreetMap%20%7C%20Test%20&%20Title", response.header["X-Page-Title"]
+ assert_equal "OpenStreetMap%20%7C%20Test%20%26%20Title", response.header["X-Page-Title"]
assert_equal "Test & Title", @title
set_title("Tést & Tïtlè")
- assert_equal "OpenStreetMap%20%7C%20T%C3%A9st%20&%20T%C3%AFtl%C3%A8", response.header["X-Page-Title"]
+ assert_equal "OpenStreetMap%20%7C%20T%C3%A9st%20%26%20T%C3%AFtl%C3%A8", response.header["X-Page-Title"]
assert_equal "Tést & Tïtlè", @title
end
end
user = create(:user)
icon = role_icon(user, "moderator")
- assert_dom_equal %(<a confirm="Are you sure you want to grant the role `moderator' to the user `#{user.display_name}'?" rel="nofollow" data-method="post" href="/user/#{URI.encode(user.display_name)}/role/moderator/grant"><picture><source srcset="/images/roles/blank_moderator.svg" type="image/svg+xml" /><img srcset="/images/roles/blank_moderator.svg" border="0" alt="Grant moderator access" title="Grant moderator access" src="/images/roles/blank_moderator.png" width="20" height="20" /></picture></a>), icon
+ assert_dom_equal %(<a confirm="Are you sure you want to grant the role `moderator' to the user `#{user.display_name}'?" rel="nofollow" data-method="post" href="/user/#{ERB::Util.u(user.display_name)}/role/moderator/grant"><picture><source srcset="/images/roles/blank_moderator.svg" type="image/svg+xml" /><img srcset="/images/roles/blank_moderator.svg" border="0" alt="Grant moderator access" title="Grant moderator access" src="/images/roles/blank_moderator.png" width="20" height="20" /></picture></a>), icon
moderator_user = create(:moderator_user)
icon = role_icon(moderator_user, "moderator")
- assert_dom_equal %(<a confirm="Are you sure you want to revoke the role `moderator' from the user `#{moderator_user.display_name}'?" rel="nofollow" data-method="post" href="/user/#{URI.encode(moderator_user.display_name)}/role/moderator/revoke"><picture><source srcset="/images/roles/moderator.svg" type="image/svg+xml" /><img srcset="/images/roles/moderator.svg" border="0" alt="Revoke moderator access" title="Revoke moderator access" src="/images/roles/moderator.png" width="20" height="20" /></picture></a>), icon
+ assert_dom_equal %(<a confirm="Are you sure you want to revoke the role `moderator' from the user `#{moderator_user.display_name}'?" rel="nofollow" data-method="post" href="/user/#{ERB::Util.u(moderator_user.display_name)}/role/moderator/revoke"><picture><source srcset="/images/roles/moderator.svg" type="image/svg+xml" /><img srcset="/images/roles/moderator.svg" border="0" alt="Revoke moderator access" title="Revoke moderator access" src="/images/roles/moderator.png" width="20" height="20" /></picture></a>), icon
end
def test_role_icons_normal
user = create(:user)
icons = role_icons(user)
- assert_dom_equal %( <a confirm="Are you sure you want to grant the role `administrator' to the user `#{user.display_name}'?" rel="nofollow" data-method="post" href="/user/#{URI.encode(user.display_name)}/role/administrator/grant"><picture><source srcset="/images/roles/blank_administrator.svg" type="image/svg+xml" /><img srcset="/images/roles/blank_administrator.svg" border="0" alt="Grant administrator access" title="Grant administrator access" src="/images/roles/blank_administrator.png" width="20" height="20" /></picture></a> <a confirm="Are you sure you want to grant the role `moderator' to the user `#{user.display_name}'?" rel="nofollow" data-method="post" href="/user/#{URI.encode(user.display_name)}/role/moderator/grant"><picture><source srcset="/images/roles/blank_moderator.svg" type="image/svg+xml" /><img srcset="/images/roles/blank_moderator.svg" border="0" alt="Grant moderator access" title="Grant moderator access" src="/images/roles/blank_moderator.png" width="20" height="20" /></picture></a>), icons
+ assert_dom_equal %( <a confirm="Are you sure you want to grant the role `administrator' to the user `#{user.display_name}'?" rel="nofollow" data-method="post" href="/user/#{ERB::Util.u(user.display_name)}/role/administrator/grant"><picture><source srcset="/images/roles/blank_administrator.svg" type="image/svg+xml" /><img srcset="/images/roles/blank_administrator.svg" border="0" alt="Grant administrator access" title="Grant administrator access" src="/images/roles/blank_administrator.png" width="20" height="20" /></picture></a> <a confirm="Are you sure you want to grant the role `moderator' to the user `#{user.display_name}'?" rel="nofollow" data-method="post" href="/user/#{ERB::Util.u(user.display_name)}/role/moderator/grant"><picture><source srcset="/images/roles/blank_moderator.svg" type="image/svg+xml" /><img srcset="/images/roles/blank_moderator.svg" border="0" alt="Grant moderator access" title="Grant moderator access" src="/images/roles/blank_moderator.png" width="20" height="20" /></picture></a>), icons
moderator_user = create(:moderator_user)
icons = role_icons(moderator_user)
- assert_dom_equal %( <a confirm="Are you sure you want to grant the role `administrator' to the user `#{moderator_user.display_name}'?" rel="nofollow" data-method="post" href="/user/#{URI.encode(moderator_user.display_name)}/role/administrator/grant"><picture><source srcset="/images/roles/blank_administrator.svg" type="image/svg+xml" /><img srcset="/images/roles/blank_administrator.svg" border="0" alt="Grant administrator access" title="Grant administrator access" src="/images/roles/blank_administrator.png" width="20" height="20" /></picture></a> <a confirm="Are you sure you want to revoke the role `moderator' from the user `#{moderator_user.display_name}'?" rel="nofollow" data-method="post" href="/user/#{URI.encode(moderator_user.display_name)}/role/moderator/revoke"><picture><source srcset="/images/roles/moderator.svg" type="image/svg+xml" /><img srcset="/images/roles/moderator.svg" border="0" alt="Revoke moderator access" title="Revoke moderator access" src="/images/roles/moderator.png" width="20" height="20" /></picture></a>), icons
+ assert_dom_equal %( <a confirm="Are you sure you want to grant the role `administrator' to the user `#{moderator_user.display_name}'?" rel="nofollow" data-method="post" href="/user/#{ERB::Util.u(moderator_user.display_name)}/role/administrator/grant"><picture><source srcset="/images/roles/blank_administrator.svg" type="image/svg+xml" /><img srcset="/images/roles/blank_administrator.svg" border="0" alt="Grant administrator access" title="Grant administrator access" src="/images/roles/blank_administrator.png" width="20" height="20" /></picture></a> <a confirm="Are you sure you want to revoke the role `moderator' from the user `#{moderator_user.display_name}'?" rel="nofollow" data-method="post" href="/user/#{ERB::Util.u(moderator_user.display_name)}/role/moderator/revoke"><picture><source srcset="/images/roles/moderator.svg" type="image/svg+xml" /><img srcset="/images/roles/moderator.svg" border="0" alt="Revoke moderator access" title="Revoke moderator access" src="/images/roles/moderator.png" width="20" height="20" /></picture></a>), icons
super_user = create(:super_user)
icons = role_icons(super_user)
- assert_dom_equal %( <a confirm="Are you sure you want to revoke the role `administrator' from the user `#{super_user.display_name}'?" rel="nofollow" data-method="post" href="/user/#{URI.encode(super_user.display_name)}/role/administrator/revoke"><picture><source srcset="/images/roles/administrator.svg" type="image/svg+xml" /><img srcset="/images/roles/administrator.svg" border="0" alt="Revoke administrator access" title="Revoke administrator access" src="/images/roles/administrator.png" width="20" height="20" /></picture></a> <a confirm="Are you sure you want to revoke the role `moderator' from the user `#{super_user.display_name}'?" rel="nofollow" data-method="post" href="/user/#{URI.encode(super_user.display_name)}/role/moderator/revoke"><picture><source srcset="/images/roles/moderator.svg" type="image/svg+xml" /><img srcset="/images/roles/moderator.svg" border="0" alt="Revoke moderator access" title="Revoke moderator access" src="/images/roles/moderator.png" width="20" height="20" /></picture></a>), icons
+ assert_dom_equal %( <a confirm="Are you sure you want to revoke the role `administrator' from the user `#{super_user.display_name}'?" rel="nofollow" data-method="post" href="/user/#{ERB::Util.u(super_user.display_name)}/role/administrator/revoke"><picture><source srcset="/images/roles/administrator.svg" type="image/svg+xml" /><img srcset="/images/roles/administrator.svg" border="0" alt="Revoke administrator access" title="Revoke administrator access" src="/images/roles/administrator.png" width="20" height="20" /></picture></a> <a confirm="Are you sure you want to revoke the role `moderator' from the user `#{super_user.display_name}'?" rel="nofollow" data-method="post" href="/user/#{ERB::Util.u(super_user.display_name)}/role/moderator/revoke"><picture><source srcset="/images/roles/moderator.svg" type="image/svg+xml" /><img srcset="/images/roles/moderator.svg" border="0" alt="Revoke moderator access" title="Revoke moderator access" src="/images/roles/moderator.png" width="20" height="20" /></picture></a>), icons
end
end
assert_redirected_to "controller" => "user", "action" => "login", "cookie_test" => "true"
follow_redirect!
assert_response :success
- post "/login", :params => { "username" => user.email, "password" => "test", :referer => "/user/#{URI.encode(user.display_name)}" }
+ post "/login", :params => { "username" => user.email, "password" => "test", :referer => "/user/#{ERB::Util.u(user.display_name)}" }
assert_response :redirect
follow_redirect!
assert_response :success
assert_template "user/view"
- get "/user/#{URI.encode(user.display_name)}/account"
+ get "/user/#{ERB::Util.u(user.display_name)}/account"
assert_response :success
assert_template "user/account"
# check that the form to allow new client application creations exists
assert_in_heading do
- assert_select "ul.secondary-actions li a[href='/user/#{URI.encode(user.display_name)}/oauth_clients']"
+ assert_select "ul.secondary-actions li a[href='/user/#{ERB::Util.u(user.display_name)}/oauth_clients']"
end
# now we follow the link to the oauth client list
- get "/user/#{URI.encode(user.display_name)}/oauth_clients"
+ get "/user/#{ERB::Util.u(user.display_name)}/oauth_clients"
assert_response :success
assert_in_body do
- assert_select "a[href='/user/#{URI.encode(user.display_name)}/oauth_clients/new']"
+ assert_select "a[href='/user/#{ERB::Util.u(user.display_name)}/oauth_clients/new']"
end
# now we follow the link to the new oauth client page
- get "/user/#{URI.encode(user.display_name)}/oauth_clients/new"
+ get "/user/#{ERB::Util.u(user.display_name)}/oauth_clients/new"
assert_response :success
assert_in_heading do
assert_select "h1", "Register a new application"
end
assert_in_body do
- assert_select "form[action='/user/#{URI.encode(user.display_name)}/oauth_clients']" do
+ assert_select "form[action='/user/#{ERB::Util.u(user.display_name)}/oauth_clients']" do
[:name, :url, :callback_url, :support_url].each do |inp|
assert_select "input[name=?]", "client_application[#{inp}]"
end
end
end
- post "/user/#{URI.encode(user.display_name)}/oauth_clients",
+ post "/user/#{ERB::Util.u(user.display_name)}/oauth_clients",
:params => { "client_application[name]" => "My New App",
"client_application[url]" => "http://my.new.app.org/",
"client_application[callback_url]" => "http://my.new.app.org/callback",
assert_equal "Registered the information successfully", flash[:notice]
# now go back to the account page and check its listed under this user
- get "/user/#{URI.encode(user.display_name)}/oauth_clients"
+ get "/user/#{ERB::Util.u(user.display_name)}/oauth_clients"
assert_response :success
assert_template "oauth_clients/index"
assert_in_body { assert_select "div>a", "My New App" }
assert_response :success
target_user = create(:user)
- post "/user/#{URI.encode(target_user.display_name)}/role/#{role}/#{action}"
+ post "/user/#{ERB::Util.u(target_user.display_name)}/role/#{role}/#{action}"
assert_redirected_to :controller => "user", :action => "view", :display_name => target_user.display_name
reset!
assert_response :success
target_user = create(:user)
- post "/user/#{URI.encode(target_user.display_name)}/role/#{role}/#{action}"
+ post "/user/#{ERB::Util.u(target_user.display_name)}/role/#{role}/#{action}"
assert_redirected_to :controller => "user", :action => "view", :display_name => target_user.display_name
reset!
def check_expand(bbox, array_string, margin = 0, result = nil)
array = array_string.split(",").collect(&:to_f)
- result = array unless result
+ result ||= array
bbox.expand!(BoundingBox.new(array[0], array[1], array[2], array[3]), margin)
check_bbox(bbox, result)
end
if default_value.is_a?(Hash)
variables.push("count")
- default_value.each do |_subkey, subvalue|
+ default_value.each_value do |subvalue|
subvalue.scan(/%\{(\w+)\}/) do
variables.push(Regexp.last_match(1))
end
-# coding: utf-8
-
require "test_helper"
class LanguageTest < ActiveSupport::TestCase