From: Tom Hughes Date: Fri, 20 Feb 2015 19:42:44 +0000 (+0000) Subject: Standardise on double quoted strings X-Git-Tag: live~4778 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/dc2a2c8ebd1a11e4a64555fda22c6859a51defff?ds=inline;hp=--cc Standardise on double quoted strings --- dc2a2c8ebd1a11e4a64555fda22c6859a51defff diff --git a/.rubocop.yml b/.rubocop.yml index c05a1ca79..555d76d36 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -8,3 +8,6 @@ Style/FileName: - 'script/deliver-message' - 'script/locale/reload-languages' - 'script/update-spam-blocks' + +Style/StringLiterals: + EnforcedStyle: double_quotes diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 2817faea4..f43d2ac8c 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -141,12 +141,6 @@ Style/RegexpLiteral: Style/RescueModifier: Enabled: false -# Offense count: 6639 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -Style/StringLiterals: - Enabled: false - # Offense count: 8 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, SupportedStyles. diff --git a/Gemfile b/Gemfile index e59705dad..b8657bae1 100644 --- a/Gemfile +++ b/Gemfile @@ -1,97 +1,97 @@ -source 'https://rubygems.org' +source "https://rubygems.org" # Require rails -gem 'rails', '4.2.0' +gem "rails", "4.2.0" # Require things which have moved to gems in ruby 1.9 -gem 'bigdecimal', "~> 1.1.0", :platforms => :ruby_19 +gem "bigdecimal", "~> 1.1.0", :platforms => :ruby_19 # Require things which have moved to gems in ruby 2.0 -gem 'psych', :platforms => :ruby_20 +gem "psych", :platforms => :ruby_20 # Require json for multi_json -gem 'json' +gem "json" # Use postgres as the database -gem 'pg' +gem "pg" # Use SCSS for stylesheets -gem 'sass-rails', '~> 5.0' +gem "sass-rails", "~> 5.0" # Use Uglifier as compressor for JavaScript assets -gem 'uglifier', '>= 1.3.0' +gem "uglifier", ">= 1.3.0" # Use CoffeeScript for .js.coffee assets and views -gem 'coffee-rails', '~> 4.1.0' +gem "coffee-rails", "~> 4.1.0" # Use jquery as the JavaScript library -gem 'jquery-rails' +gem "jquery-rails" # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder # gem 'jbuilder', '~> 2.0' -gem 'jsonify-rails' +gem "jsonify-rails" # Use R2 for RTL conversion -gem 'r2' +gem "r2" # Use autoprefixer to generate CSS prefixes -gem 'autoprefixer-rails' +gem "autoprefixer-rails" # Load rails plugins -gem 'rails-i18n', "~> 4.0.0" -gem 'dynamic_form' -gem 'rinku', '>= 1.2.2', :require => 'rails_rinku' -gem 'oauth-plugin', '>= 0.5.1' -gem 'open_id_authentication', '>= 1.1.0' -gem 'validates_email_format_of', '>= 1.5.1' -gem 'composite_primary_keys', '~> 8.0.0' -gem 'http_accept_language', '~> 2.0.0' -gem 'paperclip', '~> 4.0' -gem 'deadlock_retry', '>= 1.2.0' -gem 'openstreetmap-i18n-js', '>= 3.0.0.rc5.3', :require => 'i18n-js' -gem 'rack-cors' -gem 'actionpack-page_caching' +gem "rails-i18n", "~> 4.0.0" +gem "dynamic_form" +gem "rinku", ">= 1.2.2", :require => "rails_rinku" +gem "oauth-plugin", ">= 0.5.1" +gem "open_id_authentication", ">= 1.1.0" +gem "validates_email_format_of", ">= 1.5.1" +gem "composite_primary_keys", "~> 8.0.0" +gem "http_accept_language", "~> 2.0.0" +gem "paperclip", "~> 4.0" +gem "deadlock_retry", ">= 1.2.0" +gem "openstreetmap-i18n-js", ">= 3.0.0.rc5.3", :require => "i18n-js" +gem "rack-cors" +gem "actionpack-page_caching" # We need ruby-openid 2.2.0 or later for ruby 1.9 support -gem 'ruby-openid', '>= 2.2.0' +gem "ruby-openid", ">= 2.2.0" # Markdown formatting support -gem 'redcarpet' +gem "redcarpet" # Character conversion support for ruby 1.8 -gem 'iconv', '= 0.1', :platforms => :ruby_18 +gem "iconv", "= 0.1", :platforms => :ruby_18 # Load libxml support for XML parsing and generation -gem 'libxml-ruby', '>= 2.0.5', :require => 'libxml' +gem "libxml-ruby", ">= 2.0.5", :require => "libxml" # Use for HTML sanitisation -gem 'sanitize' -gem 'htmlentities' +gem "sanitize" +gem "htmlentities" # Load SystemTimer for implementing request timeouts -gem 'SystemTimer', '>= 1.1.3', :require => 'system_timer', :platforms => :ruby_18 +gem "SystemTimer", ">= 1.1.3", :require => "system_timer", :platforms => :ruby_18 # Load httpclient and soap4r for SOAP support for Quova GeoIP queries -gem 'httpclient' -gem 'soap4r-ruby1.9' +gem "httpclient" +gem "soap4r-ruby1.9" # Load memcache client in case we are using it -gem 'dalli' -gem 'kgio' +gem "dalli" +gem "kgio" # Gems useful for development group :development do - gem 'vendorer' + gem "vendorer" end # Gems needed for running tests group :test do - gem 'timecop' - gem 'minitest', '~> 5.1', :platforms => [:ruby_19, :ruby_20] + gem "timecop" + gem "minitest", "~> 5.1", :platforms => [:ruby_19, :ruby_20] end # Needed in development as well so rake can see konacha tasks group :development, :test do - gem 'konacha' - gem 'poltergeist' + gem "konacha" + gem "poltergeist" end diff --git a/Rakefile b/Rakefile index 28fdc4c57..39f9f3564 100644 --- a/Rakefile +++ b/Rakefile @@ -1,6 +1,6 @@ # Add your own tasks in files placed in lib/tasks ending in .rake, # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. -require File.expand_path('../config/application', __FILE__) +require File.expand_path("../config/application", __FILE__) OpenStreetMap::Application.load_tasks diff --git a/app/controllers/amf_controller.rb b/app/controllers/amf_controller.rb index 6f84313be..6860056e7 100644 --- a/app/controllers/amf_controller.rb +++ b/app/controllers/amf_controller.rb @@ -51,17 +51,17 @@ class AmfController < ApplicationController logger.info("Executing AMF #{message}(#{args.join(',')})") case message - when 'getpresets' then result = getpresets(*args) - when 'whichways' then result = whichways(*args) - when 'whichways_deleted' then result = whichways_deleted(*args) - when 'getway' then result = getway(args[0].to_i) - when 'getrelation' then result = getrelation(args[0].to_i) - when 'getway_old' then result = getway_old(args[0].to_i, args[1]) - when 'getway_history' then result = getway_history(args[0].to_i) - when 'getnode_history' then result = getnode_history(args[0].to_i) - when 'findgpx' then result = findgpx(*args) - when 'findrelations' then result = findrelations(*args) - when 'getpoi' then result = getpoi(*args) + when "getpresets" then result = getpresets(*args) + when "whichways" then result = whichways(*args) + when "whichways_deleted" then result = whichways_deleted(*args) + when "getway" then result = getway(args[0].to_i) + when "getrelation" then result = getrelation(args[0].to_i) + when "getway_old" then result = getway_old(args[0].to_i, args[1]) + when "getway_history" then result = getway_history(args[0].to_i) + when "getnode_history" then result = getnode_history(args[0].to_i) + when "findgpx" then result = findgpx(*args) + when "findrelations" then result = findrelations(*args) + when "getpoi" then result = getpoi(*args) end result @@ -82,19 +82,19 @@ class AmfController < ApplicationController result = [-5, nil] else case message - when 'putway' then + when "putway" then orn = renumberednodes.dup result = putway(renumberednodes, *args) result[4] = renumberednodes.reject { |k, _v| orn.key?(k) } if result[0] == 0 && result[2] != result[3] then renumberedways[result[2]] = result[3] end - when 'putrelation' then + when "putrelation" then result = putrelation(renumberednodes, renumberedways, *args) - when 'deleteway' then + when "deleteway" then result = deleteway(*args) - when 'putpoi' then + when "putpoi" then result = putpoi(*args) if result[0] == 0 && result[2] != result[3] then renumberednodes[result[2]] = result[3] end - when 'startchangeset' then + when "startchangeset" then result = startchangeset(*args) end @@ -138,7 +138,7 @@ class AmfController < ApplicationController amf_handle_error("'startchangeset'", nil, nil) do user = getuser(usertoken) unless user then return -1, "You are not logged in, so Potlatch can't write any changes to the database." end - if user.blocks.active.exists? then return -1, t('application.setup_user_auth.blocked') end + if user.blocks.active.exists? then return -1, t("application.setup_user_auth.blocked") end if REQUIRE_TERMS_AGREED && user.terms_agreed.nil? then return -1, "You must accept the contributor terms before you can edit." end if cstags @@ -155,7 +155,7 @@ class AmfController < ApplicationController elsif closecomment.empty? cs.save! else - cs.tags['comment'] = closecomment + cs.tags["comment"] = closecomment # in case closecomment has chars not allowed in xml cs.tags = strip_non_xml_chars cs.tags cs.save_with_tags! @@ -168,7 +168,7 @@ class AmfController < ApplicationController cs.tags = cstags cs.user_id = user.id unless closecomment.empty? - cs.tags['comment'] = closecomment + cs.tags["comment"] = closecomment # in case closecomment has chars not allowed in xml cs.tags = strip_non_xml_chars cs.tags end @@ -176,9 +176,9 @@ class AmfController < ApplicationController cs.created_at = Time.now.getutc cs.closed_at = cs.created_at + Changeset::IDLE_TIMEOUT cs.save_with_tags! - return [0, '', cs.id] + return [0, "", cs.id] else - return [0, '', nil] + return [0, "", nil] end end end @@ -215,12 +215,12 @@ class AmfController < ApplicationController def getlocalized(lang) # What we end up actually using. Reported in Potlatch's created_by=* string - loaded_lang = 'en' + loaded_lang = "en" # Load English defaults en = YAML.load(File.open("#{Rails.root}/config/potlatch/locales/en.yml"))["en"] - if lang == 'en' + if lang == "en" return [loaded_lang, en] else # Use English as a fallback @@ -288,7 +288,7 @@ class AmfController < ApplicationController relations = relations.collect { |relation| [relation.id, relation.version] }.uniq end - [0, '', ways, points, relations] + [0, "", ways, points, relations] end end @@ -312,7 +312,7 @@ class AmfController < ApplicationController nodes_in_area = Node.bbox(bbox).joins(:ways_via_history).where(:current_ways => { :visible => false }) way_ids = nodes_in_area.collect { |node| node.ways_via_history.invisible.collect(&:id) }.flatten.uniq - [0, '', way_ids] + [0, "", way_ids] end end @@ -320,7 +320,7 @@ class AmfController < ApplicationController # Returns the way id, a Potlatch-style array of points, a hash of tags, the version number, and the user ID. def getway(wayid) #:doc: - amf_handle_error_with_timeout("'getway' #{wayid}", 'way', wayid) do + amf_handle_error_with_timeout("'getway' #{wayid}", "way", wayid) do if POTLATCH_USE_SQL points = sql_get_nodes_in_way(wayid) tags = sql_get_tags_in_way(wayid) @@ -333,11 +333,11 @@ class AmfController < ApplicationController way = Way.where(:id => wayid).first # check case where way has been deleted or doesn't exist - return [-4, 'way', wayid] if way.nil? || !way.visible + return [-4, "way", wayid] if way.nil? || !way.visible points = way.nodes.preload(:node_tags).collect do |node| nodetags = node.tags - nodetags.delete('created_by') + nodetags.delete("created_by") [node.lon, node.lat, node.id, nodetags, node.version] end tags = way.tags @@ -345,7 +345,7 @@ class AmfController < ApplicationController uid = way.changeset.user.id end - [0, '', wayid, points, tags, version, uid] + [0, "", wayid, points, tags, version, uid] end end @@ -365,8 +365,8 @@ class AmfController < ApplicationController # 5. is this the current, visible version? (boolean) def getway_old(id, timestamp) #:doc: - amf_handle_error_with_timeout("'getway_old' #{id}, #{timestamp}", 'way', id) do - if timestamp == '' + amf_handle_error_with_timeout("'getway_old' #{id}, #{timestamp}", "way", id) do + if timestamp == "" # undelete old_way = OldWay.where(:visible => true, :way_id => id).unredacted.order("version DESC").first points = old_way.get_nodes_undelete unless old_way.nil? @@ -392,8 +392,8 @@ class AmfController < ApplicationController return [-1, "Sorry, the server could not find a way at that time.", id] else curway = Way.find(id) - old_way.tags['history'] = "Retrieved from v#{old_way.version}" - return [0, '', id, points, old_way.tags, curway.version, (curway.version == old_way.version && curway.visible)] + old_way.tags["history"] = "Retrieved from v#{old_way.version}" + return [0, "", id, points, old_way.tags, curway.version, (curway.version == old_way.version && curway.visible)] end end end @@ -434,9 +434,9 @@ class AmfController < ApplicationController revdates.collect! { |d| [(d + 1).strftime("%d %b %Y, %H:%M:%S")] + revusers[d.to_i] } revdates.uniq! - return ['way', wayid, revdates] + return ["way", wayid, revdates] rescue ActiveRecord::RecordNotFound - return ['way', wayid, []] + return ["way", wayid, []] end # Find history of a node. Returns 'node', id, and an array of previous versions as above. @@ -445,14 +445,14 @@ class AmfController < ApplicationController history = Node.find(nodeid).old_nodes.unredacted.reverse.collect do |old_node| [(old_node.timestamp + 1).strftime("%d %b %Y, %H:%M:%S")] + change_user(old_node) end - return ['node', nodeid, history] + return ["node", nodeid, history] rescue ActiveRecord::RecordNotFound - return ['node', nodeid, []] + return ["node", nodeid, []] end def change_user(obj) user_object = obj.changeset.user - user = user_object.data_public? ? user_object.display_name : 'anonymous' + user = user_object.data_public? ? user_object.display_name : "anonymous" uid = user_object.data_public? ? user_object.id : 0 [user, uid] end @@ -465,7 +465,7 @@ class AmfController < ApplicationController user = getuser(usertoken) return -1, "You must be logged in to search for GPX traces." unless user - return -1, t('application.setup_user_auth.blocked') if user.blocks.active.exists? + return -1, t("application.setup_user_auth.blocked") if user.blocks.active.exists? query = Trace.visible_to(user) if searchterm.to_i > 0 @@ -476,7 +476,7 @@ class AmfController < ApplicationController gpxs = query.collect do |gpx| [gpx.id, gpx.name, gpx.description] end - [0, '', gpxs] + [0, "", gpxs] end end @@ -490,11 +490,11 @@ class AmfController < ApplicationController # 5. version. def getrelation(relid) #:doc: - amf_handle_error("'getrelation' #{relid}", 'relation', relid) do + amf_handle_error("'getrelation' #{relid}", "relation", relid) do rel = Relation.where(:id => relid).first - return [-4, 'relation', relid] if rel.nil? || !rel.visible - [0, '', relid, rel.tags, rel.members, rel.version] + return [-4, "relation", relid] if rel.nil? || !rel.visible + [0, "", relid, rel.tags, rel.members, rel.version] end end @@ -526,10 +526,10 @@ class AmfController < ApplicationController # 3. version. def putrelation(renumberednodes, renumberedways, usertoken, changeset_id, version, relid, tags, members, visible) #:doc: - amf_handle_error("'putrelation' #{relid}", 'relation', relid) do + amf_handle_error("'putrelation' #{relid}", "relation", relid) do user = getuser(usertoken) unless user then return -1, "You are not logged in, so the relation could not be saved." end - if user.blocks.active.exists? then return -1, t('application.setup_user_auth.blocked') end + if user.blocks.active.exists? then return -1, t("application.setup_user_auth.blocked") end if REQUIRE_TERMS_AGREED && user.terms_agreed.nil? then return -1, "You must accept the contributor terms before you can edit." end unless tags_ok(tags) then return -1, "One of the tags is invalid. Linux users may need to upgrade to Flash Player 10.1." end @@ -551,8 +551,8 @@ class AmfController < ApplicationController members.each do |m| mid = m[1].to_i if mid < 0 - mid = renumberednodes[mid] if m[0] == 'Node' - mid = renumberedways[mid] if m[0] == 'Way' + mid = renumberednodes[mid] if m[0] == "Node" + mid = renumberedways[mid] if m[0] == "Way" end if mid typedmembers << [m[0], mid, m[2].delete("\000-\037\ufffe\uffff", "^\011\012\015")] @@ -581,9 +581,9 @@ class AmfController < ApplicationController end # transaction if relid <= 0 - return [0, '', relid, new_relation.id, new_relation.version] + return [0, "", relid, new_relation.id, new_relation.version] else - return [0, '', relid, relid, relation.version] + return [0, "", relid, relid, relation.version] end end end @@ -612,12 +612,12 @@ class AmfController < ApplicationController # 6. hash of node versions (node=>version) def putway(renumberednodes, usertoken, changeset_id, wayversion, originalway, pointlist, attributes, nodes, deletednodes) #:doc: - amf_handle_error("'putway' #{originalway}", 'way', originalway) do + amf_handle_error("'putway' #{originalway}", "way", originalway) do # -- Initialise user = getuser(usertoken) unless user then return -1, "You are not logged in, so the way could not be saved." end - if user.blocks.active.exists? then return -1, t('application.setup_user_auth.blocked') end + if user.blocks.active.exists? then return -1, t("application.setup_user_auth.blocked") end if REQUIRE_TERMS_AGREED && user.terms_agreed.nil? then return -1, "You must accept the contributor terms before you can edit." end if pointlist.length < 2 then return -2, "Server error - way is only #{points.length} points long." end @@ -654,7 +654,7 @@ class AmfController < ApplicationController unless tags_ok(node.tags) then return -1, "One of the tags is invalid. Linux users may need to upgrade to Flash Player 10.1." end node.tags = strip_non_xml_chars node.tags - node.tags.delete('created_by') + node.tags.delete("created_by") node.version = version if id <= 0 # We're creating the node @@ -708,7 +708,7 @@ class AmfController < ApplicationController end end # transaction - [0, '', originalway, way.id, renumberednodes, way.version, nodeversions, deletednodes] + [0, "", originalway, way.id, renumberednodes, way.version, nodeversions, deletednodes] end end @@ -722,10 +722,10 @@ class AmfController < ApplicationController # 4. version. def putpoi(usertoken, changeset_id, version, id, lon, lat, tags, visible) #:doc: - amf_handle_error("'putpoi' #{id}", 'node', id) do + amf_handle_error("'putpoi' #{id}", "node", id) do user = getuser(usertoken) unless user then return -1, "You are not logged in, so the point could not be saved." end - if user.blocks.active.exists? then return -1, t('application.setup_user_auth.blocked') end + if user.blocks.active.exists? then return -1, t("application.setup_user_auth.blocked") end if REQUIRE_TERMS_AGREED && user.terms_agreed.nil? then return -1, "You must accept the contributor terms before you can edit." end unless tags_ok(tags) then return -1, "One of the tags is invalid. Linux users may need to upgrade to Flash Player 10.1." end @@ -766,9 +766,9 @@ class AmfController < ApplicationController end # transaction if id <= 0 - return [0, '', id, new_node.id, new_node.version] + return [0, "", id, new_node.id, new_node.version] else - return [0, '', id, node.id, node.version] + return [0, "", id, node.id, node.version] end end end @@ -779,18 +779,18 @@ class AmfController < ApplicationController # Returns array of id, long, lat, hash of tags, (current) version. def getpoi(id, timestamp) #:doc: - amf_handle_error("'getpoi' #{id}", 'node', id) do + amf_handle_error("'getpoi' #{id}", "node", id) do id = id.to_i n = Node.find(id) v = n.version - unless timestamp == '' + unless timestamp == "" n = OldNode.where("node_id = ? AND timestamp <= ?", id, timestamp).unredacted.order("timestamp DESC").first end if n - return [0, '', n.id, n.lon, n.lat, n.tags, v] + return [0, "", n.id, n.lon, n.lat, n.tags, v] else - return [-4, 'node', id] + return [-4, "node", id] end end end @@ -806,10 +806,10 @@ class AmfController < ApplicationController # Returns 0 (success), unchanged way id, new way version, new node versions. def deleteway(usertoken, changeset_id, way_id, way_version, deletednodes) #:doc: - amf_handle_error("'deleteway' #{way_id}", 'way', way_id) do + amf_handle_error("'deleteway' #{way_id}", "way", way_id) do user = getuser(usertoken) unless user then return -1, "You are not logged in, so the way could not be deleted." end - if user.blocks.active.exists? then return -1, t('application.setup_user_auth.blocked') end + if user.blocks.active.exists? then return -1, t("application.setup_user_auth.blocked") end if REQUIRE_TERMS_AGREED && user.terms_agreed.nil? then return -1, "You must accept the contributor terms before you can edit." end way_id = way_id.to_i @@ -843,7 +843,7 @@ class AmfController < ApplicationController end end end # transaction - [0, '', way_id, old_way.version, nodeversions] + [0, "", way_id, old_way.version, nodeversions] end end @@ -906,7 +906,7 @@ class AmfController < ApplicationController AND current_ways.visible=TRUE AND #{OSM.sql_for_area(bbox, "current_nodes.")} EOF - ActiveRecord::Base.connection.select_all(sql).collect { |a| [a['wayid'].to_i, a['version'].to_i] } + ActiveRecord::Base.connection.select_all(sql).collect { |a| [a["wayid"].to_i, a["version"].to_i] } end def sql_find_pois_in_area(bbox) @@ -922,9 +922,9 @@ class AmfController < ApplicationController 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| - poitags[n['k']] = n['v'] + poitags[n["k"]] = n["v"] end - pois << [row['id'].to_i, row['lon'].to_f, row['lat'].to_f, poitags, row['version'].to_i] + pois << [row["id"].to_i, row["lon"].to_f, row["lat"].to_f, poitags, row["version"].to_i] end pois end @@ -949,7 +949,7 @@ class AmfController < ApplicationController AND crm.member_id IN (#{way_ids.join(',')}) EOF end - ActiveRecord::Base.connection.select_all(sql).collect { |a| [a['relid'].to_i, a['version'].to_i] } + ActiveRecord::Base.connection.select_all(sql).collect { |a| [a["relid"].to_i, a["version"].to_i] } end def sql_get_nodes_in_way(wayid) @@ -965,10 +965,10 @@ class AmfController < ApplicationController 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| - nodetags[n['k']] = n['v'] + nodetags[n["k"]] = n["v"] end - nodetags.delete('created_by') - points << [row['lon'].to_f, row['lat'].to_f, row['id'].to_i, nodetags, row['version'].to_i] + nodetags.delete("created_by") + points << [row["lon"].to_f, row["lat"].to_f, row["id"].to_i, nodetags, row["version"].to_i] end points end @@ -976,16 +976,16 @@ class AmfController < ApplicationController def sql_get_tags_in_way(wayid) tags = {} ActiveRecord::Base.connection.select_all("SELECT k,v FROM current_way_tags WHERE id=#{wayid.to_i}").each do |row| - tags[row['k']] = row['v'] + tags[row["k"]] = row["v"] end tags end def sql_get_way_version(wayid) - ActiveRecord::Base.connection.select_one("SELECT version FROM current_ways WHERE id=#{wayid.to_i}")['version'] + ActiveRecord::Base.connection.select_one("SELECT version FROM current_ways WHERE id=#{wayid.to_i}")["version"] end def sql_get_way_user(wayid) - ActiveRecord::Base.connection.select_one("SELECT user FROM current_ways,changesets WHERE current_ways.id=#{wayid.to_i} AND current_ways.changeset=changesets.id")['user'] + ActiveRecord::Base.connection.select_one("SELECT user FROM current_ways,changesets WHERE current_ways.id=#{wayid.to_i} AND current_ways.changeset=changesets.id")["user"] end end diff --git a/app/controllers/api_controller.rb b/app/controllers/api_controller.rb index 659d35477..6bbbee1ce 100644 --- a/app/controllers/api_controller.rb +++ b/app/controllers/api_controller.rb @@ -9,7 +9,7 @@ class ApiController < ApplicationController # within the specified bounding box, and in the specified page. def trackpoints # retrieve the page number - page = params['page'].to_s.to_i + page = params["page"].to_s.to_i unless page >= 0 report_error("Page number must be greater than or equal to 0") @@ -35,10 +35,10 @@ class ApiController < ApplicationController doc = XML::Document.new doc.encoding = XML::Encoding::UTF_8 - root = XML::Node.new 'gpx' - root['version'] = '1.0' - root['creator'] = 'OpenStreetMap.org' - root['xmlns'] = "http://www.topografix.com/GPX/1/0" + root = XML::Node.new "gpx" + root["version"] = "1.0" + root["creator"] = "OpenStreetMap.org" + root["xmlns"] = "http://www.topografix.com/GPX/1/0" doc.root = root @@ -61,21 +61,21 @@ class ApiController < ApplicationController gpx_file = Trace.find(gpx_id) if gpx_file.trackable? - track = XML::Node.new 'trk' + track = XML::Node.new "trk" doc.root << track timestamps = true if gpx_file.identifiable? track << (XML::Node.new("name") << gpx_file.name) track << (XML::Node.new("desc") << gpx_file.description) - track << (XML::Node.new("url") << url_for(:controller => 'trace', :action => 'view', :display_name => gpx_file.user.display_name, :id => gpx_file.id)) + track << (XML::Node.new("url") << url_for(:controller => "trace", :action => "view", :display_name => gpx_file.user.display_name, :id => gpx_file.id)) end else # use the anonymous track segment if the user hasn't allowed # their GPX points to be tracked. timestamps = false if anon_track.nil? - anon_track = XML::Node.new 'trk' + anon_track = XML::Node.new "trk" doc.root << anon_track end track = anon_track @@ -84,12 +84,12 @@ class ApiController < ApplicationController if trackid != point.trackid if gpx_file.trackable? - trkseg = XML::Node.new 'trkseg' + trkseg = XML::Node.new "trkseg" track << trkseg trackid = point.trackid else if anon_trkseg.nil? - anon_trkseg = XML::Node.new 'trkseg' + anon_trkseg = XML::Node.new "trkseg" anon_track << anon_trkseg end trkseg = anon_trkseg @@ -141,7 +141,7 @@ class ApiController < ApplicationController doc = OSM::API.new.get_xml_doc # add bounds - doc.root << bbox.add_bounds_to(XML::Node.new 'bounds') + doc.root << bbox.add_bounds_to(XML::Node.new "bounds") # get ways # find which ways are needed @@ -210,13 +210,13 @@ class ApiController < ApplicationController # Get a list of the tiles that have changed within a specified time # period def changes - zoom = (params[:zoom] || '12').to_i + zoom = (params[:zoom] || "12").to_i if params.include?(:start) && params.include?(:end) starttime = Time.parse(params[:start]) endtime = Time.parse(params[:end]) else - hours = (params[:hours] || '1').to_i.hours + hours = (params[:hours] || "1").to_i.hours endtime = Time.now.getutc starttime = endtime - hours end @@ -228,7 +228,7 @@ class ApiController < ApplicationController tiles = Node.where(:timestamp => starttime..endtime).group("maptile_for_point(latitude, longitude, #{zoom})").count doc = OSM::API.new.get_xml_doc - changes = XML::Node.new 'changes' + changes = XML::Node.new "changes" changes["starttime"] = starttime.xmlschema changes["endtime"] = endtime.xmlschema @@ -236,7 +236,7 @@ class ApiController < ApplicationController x = (tile.to_i >> zoom) & mask y = tile.to_i & mask - t = XML::Node.new 'tile' + t = XML::Node.new "tile" t["x"] = x.to_s t["y"] = y.to_s t["z"] = zoom.to_s @@ -261,37 +261,37 @@ class ApiController < ApplicationController def capabilities doc = OSM::API.new.get_xml_doc - api = XML::Node.new 'api' - version = XML::Node.new 'version' - version['minimum'] = "#{API_VERSION}" - version['maximum'] = "#{API_VERSION}" + api = XML::Node.new "api" + version = XML::Node.new "version" + version["minimum"] = "#{API_VERSION}" + version["maximum"] = "#{API_VERSION}" api << version - area = XML::Node.new 'area' - area['maximum'] = MAX_REQUEST_AREA.to_s + area = XML::Node.new "area" + area["maximum"] = MAX_REQUEST_AREA.to_s api << area - tracepoints = XML::Node.new 'tracepoints' - tracepoints['per_page'] = TRACEPOINTS_PER_PAGE.to_s + tracepoints = XML::Node.new "tracepoints" + tracepoints["per_page"] = TRACEPOINTS_PER_PAGE.to_s api << tracepoints - waynodes = XML::Node.new 'waynodes' - waynodes['maximum'] = MAX_NUMBER_OF_WAY_NODES.to_s + waynodes = XML::Node.new "waynodes" + waynodes["maximum"] = MAX_NUMBER_OF_WAY_NODES.to_s api << waynodes - changesets = XML::Node.new 'changesets' - changesets['maximum_elements'] = Changeset::MAX_ELEMENTS.to_s + changesets = XML::Node.new "changesets" + changesets["maximum_elements"] = Changeset::MAX_ELEMENTS.to_s api << changesets - timeout = XML::Node.new 'timeout' - timeout['seconds'] = API_TIMEOUT.to_s + timeout = XML::Node.new "timeout" + timeout["seconds"] = API_TIMEOUT.to_s api << timeout - status = XML::Node.new 'status' - status['database'] = database_status.to_s - status['api'] = api_status.to_s - status['gpx'] = gpx_status.to_s + status = XML::Node.new "status" + status["database"] = database_status.to_s + status["api"] = api_status.to_s + status["gpx"] = gpx_status.to_s api << status doc.root << api - policy = XML::Node.new 'policy' - blacklist = XML::Node.new 'imagery' + policy = XML::Node.new "policy" + blacklist = XML::Node.new "imagery" IMAGERY_BLACKLIST.each do |url_regex| - xnd = XML::Node.new 'blacklist' - xnd['regex'] = url_regex.to_s + xnd = XML::Node.new "blacklist" + xnd["regex"] = url_regex.to_s blacklist << xnd end policy << blacklist diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 3b706966a..43afdf74f 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -18,7 +18,7 @@ class ApplicationController < ActionController::Base # don't allow access to any auth-requiring part of the site unless # the new CTs have been seen (and accept/decline chosen). elsif !@user.terms_seen && flash[:skip_terms].nil? - flash[:notice] = t 'user.terms.you need to accept or decline' + flash[:notice] = t "user.terms.you need to accept or decline" if params[:referer] redirect_to :controller => "user", :action => "terms", :referer => params[:referer] else @@ -39,7 +39,7 @@ class ApplicationController < ActionController::Base def require_user unless @user if request.get? - redirect_to :controller => 'user', :action => 'login', :referer => request.fullpath + redirect_to :controller => "user", :action => "login", :referer => request.fullpath else render :text => "", :status => :forbidden end @@ -76,7 +76,7 @@ class ApplicationController < ActionController::Base redirect_to Hash[params].merge(:cookie_test => "true") return false else - flash.now[:warning] = t 'application.require_cookies.cookies_needed' + flash.now[:warning] = t "application.require_cookies.cookies_needed" end else session.delete(:cookie_test) @@ -123,8 +123,8 @@ class ApplicationController < ActionController::Base def require_moderator unless @user.moderator? if request.get? - flash[:error] = t('application.require_moderator.not_a_moderator') - redirect_to :action => 'index' + flash[:error] = t("application.require_moderator.not_a_moderator") + redirect_to :action => "index" else render :text => "", :status => :forbidden end @@ -142,7 +142,7 @@ class ApplicationController < ActionController::Base # authenticate per-scheme if username.nil? @user = nil # no authentication provided - perhaps first connect (client should retry after 401) - elsif username == 'token' + elsif username == "token" @user = User.authenticate(:token => passwd) # preferred - random token for user from db, passed in basic auth else @user = User.authenticate(:username => username, :password => passwd) # basic auth @@ -154,7 +154,7 @@ class ApplicationController < ActionController::Base # check if the user has been banned if @user.blocks.active.exists? # NOTE: need slightly more helpful message than this. - report_error t('application.setup_user_auth.blocked'), :forbidden + report_error t("application.setup_user_auth.blocked"), :forbidden end # if the user hasn't seen the contributor terms then don't @@ -162,12 +162,12 @@ class ApplicationController < ActionController::Base # (but can decline) the CTs to continue. if REQUIRE_TERMS_SEEN && !@user.terms_seen && flash[:skip_terms].nil? set_locale - report_error t('application.setup_user_auth.need_to_see_terms'), :forbidden + report_error t("application.setup_user_auth.need_to_see_terms"), :forbidden end end end - def authorize(realm = 'Web Password', errormessage = "Couldn't authenticate you") + def authorize(realm = "Web Password", errormessage = "Couldn't authenticate you") # make the @user object from any auth sources we have setup_user_auth @@ -201,7 +201,7 @@ class ApplicationController < ActionController::Base if request.xhr? report_error "Database offline for maintenance", :service_unavailable else - redirect_to :controller => 'site', :action => 'offline' + redirect_to :controller => "site", :action => "offline" end end end @@ -212,7 +212,7 @@ class ApplicationController < ActionController::Base if request.xhr? report_error "Database offline for maintenance", :service_unavailable else - redirect_to :controller => 'site', :action => 'offline' + redirect_to :controller => "site", :action => "offline" end end end @@ -273,10 +273,10 @@ class ApplicationController < ActionController::Base # message. For now, rails won't let us) def report_error(message, status = :bad_request) # Todo: some sort of escaping of problem characters in the message - response.headers['Error'] = message + response.headers["Error"] = message - if request.headers['X-Error-Format'] && - request.headers['X-Error-Format'].downcase == "xml" + if request.headers["X-Error-Format"] && + request.headers["X-Error-Format"].downcase == "xml" result = OSM::API.new.get_xml_doc result.root.name = "osmError" result.root << (XML::Node.new("status") << "#{Rack::Utils.status_code(status)} #{Rack::Utils::HTTP_STATUS_CODES[status]}") @@ -289,11 +289,11 @@ class ApplicationController < ActionController::Base end def set_locale - response.header['Vary'] = 'Accept-Language' + response.header["Vary"] = "Accept-Language" if @user && !@user.languages.empty? http_accept_language.user_preferred_languages = @user.languages - response.header['Vary'] = '*' + response.header["Vary"] = "*" end I18n.locale = select_locale @@ -303,7 +303,7 @@ class ApplicationController < ActionController::Base @user.save end - response.headers['Content-Language'] = I18n.locale.to_s + response.headers["Content-Language"] = I18n.locale.to_s end def select_locale(locales = I18n.available_locales) @@ -429,7 +429,7 @@ class ApplicationController < ActionController::Base end def map_layout - request.xhr? ? 'xhr' : 'map' + request.xhr? ? "xhr" : "map" end def preferred_editor @@ -441,8 +441,8 @@ class ApplicationController < ActionController::Base DEFAULT_EDITOR end - if request.env['HTTP_USER_AGENT'] =~ /MSIE|Trident/ && editor == 'id' - editor = 'potlatch2' + if request.env["HTTP_USER_AGENT"] =~ /MSIE|Trident/ && editor == "id" + editor = "potlatch2" end editor @@ -454,16 +454,16 @@ class ApplicationController < ActionController::Base # extract authorisation credentials from headers, returns user = nil if none def get_auth_data - if request.env.key? 'X-HTTP_AUTHORIZATION' # where mod_rewrite might have put it - authdata = request.env['X-HTTP_AUTHORIZATION'].to_s.split - elsif request.env.key? 'REDIRECT_X_HTTP_AUTHORIZATION' # mod_fcgi - authdata = request.env['REDIRECT_X_HTTP_AUTHORIZATION'].to_s.split - elsif request.env.key? 'HTTP_AUTHORIZATION' # regular location - authdata = request.env['HTTP_AUTHORIZATION'].to_s.split + if request.env.key? "X-HTTP_AUTHORIZATION" # where mod_rewrite might have put it + authdata = request.env["X-HTTP_AUTHORIZATION"].to_s.split + elsif request.env.key? "REDIRECT_X_HTTP_AUTHORIZATION" # mod_fcgi + authdata = request.env["REDIRECT_X_HTTP_AUTHORIZATION"].to_s.split + elsif request.env.key? "HTTP_AUTHORIZATION" # regular location + authdata = request.env["HTTP_AUTHORIZATION"].to_s.split end # only basic authentication supported - if authdata && authdata[0] == 'Basic' - user, pass = Base64.decode64(authdata[1]).split(':', 2) + if authdata && authdata[0] == "Basic" + user, pass = Base64.decode64(authdata[1]).split(":", 2) end [user, pass] end diff --git a/app/controllers/browse_controller.rb b/app/controllers/browse_controller.rb index 3dfcd18e6..a529b393e 100644 --- a/app/controllers/browse_controller.rb +++ b/app/controllers/browse_controller.rb @@ -10,7 +10,7 @@ class BrowseController < ApplicationController def relation @type = "relation" @feature = Relation.find(params[:id]) - render 'feature' + render "feature" rescue ActiveRecord::RecordNotFound render :action => "not_found", :status => :not_found end @@ -18,7 +18,7 @@ class BrowseController < ApplicationController def relation_history @type = "relation" @feature = Relation.find(params[:id]) - render 'history' + render "history" rescue ActiveRecord::RecordNotFound render :action => "not_found", :status => :not_found end @@ -26,7 +26,7 @@ class BrowseController < ApplicationController def way @type = "way" @feature = Way.preload(:way_tags, :containing_relation_members, :changeset => :user, :nodes => [:node_tags, :ways => :way_tags]).find(params[:id]) - render 'feature' + render "feature" rescue ActiveRecord::RecordNotFound render :action => "not_found", :status => :not_found end @@ -34,7 +34,7 @@ class BrowseController < ApplicationController def way_history @type = "way" @feature = Way.preload(:way_tags, :old_ways => { :changeset => :user }).find(params[:id]) - render 'history' + render "history" rescue ActiveRecord::RecordNotFound render :action => "not_found", :status => :not_found end @@ -42,7 +42,7 @@ class BrowseController < ApplicationController def node @type = "node" @feature = Node.find(params[:id]) - render 'feature' + render "feature" rescue ActiveRecord::RecordNotFound render :action => "not_found", :status => :not_found end @@ -50,7 +50,7 @@ class BrowseController < ApplicationController def node_history @type = "node" @feature = Node.find(params[:id]) - render 'history' + render "history" rescue ActiveRecord::RecordNotFound render :action => "not_found", :status => :not_found end @@ -63,9 +63,9 @@ class BrowseController < ApplicationController else @comments = @changeset.comments.includes(:author) end - @node_pages, @nodes = paginate(:old_nodes, :conditions => { :changeset_id => @changeset.id }, :per_page => 20, :parameter => 'node_page') - @way_pages, @ways = paginate(:old_ways, :conditions => { :changeset_id => @changeset.id }, :per_page => 20, :parameter => 'way_page') - @relation_pages, @relations = paginate(:old_relations, :conditions => { :changeset_id => @changeset.id }, :per_page => 20, :parameter => 'relation_page') + @node_pages, @nodes = paginate(:old_nodes, :conditions => { :changeset_id => @changeset.id }, :per_page => 20, :parameter => "node_page") + @way_pages, @ways = paginate(:old_ways, :conditions => { :changeset_id => @changeset.id }, :per_page => 20, :parameter => "way_page") + @relation_pages, @relations = paginate(:old_relations, :conditions => { :changeset_id => @changeset.id }, :per_page => 20, :parameter => "relation_page") if @changeset.user.data_public? @next_by_user = @changeset.user.changesets.where("id > ?", @changeset.id).reorder(:id => :asc).first @prev_by_user = @changeset.user.changesets.where("id < ?", @changeset.id).reorder(:id => :desc).first diff --git a/app/controllers/changeset_controller.rb b/app/controllers/changeset_controller.rb index 941e752f9..eefe5b55f 100644 --- a/app/controllers/changeset_controller.rb +++ b/app/controllers/changeset_controller.rb @@ -1,8 +1,8 @@ # The ChangesetController is the RESTful interface to Changeset objects class ChangesetController < ApplicationController - layout 'site' - require 'xml/libxml' + layout "site" + require "xml/libxml" skip_before_filter :verify_authenticity_token, :except => [:list] before_filter :authorize_web, :only => [:list, :feed, :comments_feed] @@ -85,8 +85,8 @@ class ChangesetController < ApplicationController # abuse, maybe should change to some other format? doc = XML::Parser.string(request.raw_post).parse doc.find("//osm/node").each do |n| - lon << n['lon'].to_f * GeoRecord::SCALE - lat << n['lat'].to_f * GeoRecord::SCALE + lon << n["lon"].to_f * GeoRecord::SCALE + lat << n["lat"].to_f * GeoRecord::SCALE end # add the existing bounding box to the lon-lat array @@ -204,17 +204,17 @@ class ChangesetController < ApplicationController # query changesets by bounding box, time, user or open/closed status. def query # find any bounding box - bbox = BoundingBox.from_bbox_params(params) if params['bbox'] + bbox = BoundingBox.from_bbox_params(params) if params["bbox"] # create the conditions that the user asked for. some or all of # these may be nil. changesets = Changeset.all changesets = conditions_bbox(changesets, bbox) - changesets = conditions_user(changesets, params['user'], params['display_name']) - changesets = conditions_time(changesets, params['time']) - changesets = conditions_open(changesets, params['open']) - changesets = conditions_closed(changesets, params['closed']) - changesets = conditions_ids(changesets, params['changesets']) + changesets = conditions_user(changesets, params["user"], params["display_name"]) + changesets = conditions_time(changesets, params["time"]) + changesets = conditions_open(changesets, params["open"]) + changesets = conditions_closed(changesets, params["closed"]) + changesets = conditions_ids(changesets, params["changesets"]) # create the results document results = OSM::API.new.get_xml_doc @@ -509,7 +509,7 @@ class ChangesetController < ApplicationController else # if there is a range, i.e: comma separated, then the first is # low, second is high - same as with bounding boxes. - if time.count(',') == 1 + if time.count(",") == 1 # check that we actually have 2 elements in the array times = time.split(/,/) fail OSM::APIBadUserInput.new("bad time range") if times.size != 2 @@ -564,7 +564,7 @@ class ChangesetController < ApplicationController elsif ids.empty? fail OSM::APIBadUserInput.new("No changesets were given to search for") else - ids = ids.split(',').collect(&:to_i) + ids = ids.split(",").collect(&:to_i) return changesets.where(:id => ids) end end diff --git a/app/controllers/diary_entry_controller.rb b/app/controllers/diary_entry_controller.rb index 5129963f8..7c38e58a8 100644 --- a/app/controllers/diary_entry_controller.rb +++ b/app/controllers/diary_entry_controller.rb @@ -1,5 +1,5 @@ class DiaryEntryController < ApplicationController - layout 'site', :except => :rss + layout "site", :except => :rss before_filter :authorize_web before_filter :set_locale @@ -10,7 +10,7 @@ class DiaryEntryController < ApplicationController before_filter :require_administrator, :only => [:hide, :hidecomment] def new - @title = t 'diary_entry.new.title' + @title = t "diary_entry.new.title" if params[:diary_entry] @diary_entry = DiaryEntry.new(entry_params) @@ -24,27 +24,27 @@ class DiaryEntryController < ApplicationController else @user.preferences.create(:k => "diary.default_language", :v => @diary_entry.language_code) end - redirect_to :controller => 'diary_entry', :action => 'list', :display_name => @user.display_name + redirect_to :controller => "diary_entry", :action => "list", :display_name => @user.display_name else - render :action => 'edit' + render :action => "edit" end else default_lang = @user.preferences.where(:k => "diary.default_language").first lang_code = default_lang ? default_lang.v : @user.preferred_language @diary_entry = DiaryEntry.new(:language_code => lang_code) set_map_location - render :action => 'edit' + render :action => "edit" end end def edit - @title = t 'diary_entry.edit.title' + @title = t "diary_entry.edit.title" @diary_entry = DiaryEntry.find(params[:id]) if @user != @diary_entry.user - redirect_to :controller => 'diary_entry', :action => 'view', :id => params[:id] + redirect_to :controller => "diary_entry", :action => "view", :id => params[:id] elsif params[:diary_entry] && @diary_entry.update_attributes(entry_params) - redirect_to :controller => 'diary_entry', :action => 'view', :id => params[:id] + redirect_to :controller => "diary_entry", :action => "view", :id => params[:id] end set_map_location @@ -61,9 +61,9 @@ class DiaryEntryController < ApplicationController Notifier.diary_comment_notification(@diary_comment).deliver_now end - redirect_to :controller => 'diary_entry', :action => 'view', :display_name => @entry.user.display_name, :id => @entry.id + redirect_to :controller => "diary_entry", :action => "view", :display_name => @entry.user.display_name, :id => @entry.id else - render :action => 'view' + render :action => "view" end rescue ActiveRecord::RecordNotFound render :action => "no_such_entry", :status => :not_found @@ -74,7 +74,7 @@ class DiaryEntryController < ApplicationController @this_user = User.active.find_by_display_name(params[:display_name]) if @this_user - @title = t 'diary_entry.list.user_title', :user => @this_user.display_name + @title = t "diary_entry.list.user_title", :user => @this_user.display_name @entries = @this_user.diary_entries else render_unknown_user params[:display_name] @@ -82,7 +82,7 @@ class DiaryEntryController < ApplicationController end elsif params[:friends] if @user - @title = t 'diary_entry.list.title_friends' + @title = t "diary_entry.list.title_friends" @entries = DiaryEntry.where(:user_id => @user.friend_users) else require_user @@ -90,7 +90,7 @@ class DiaryEntryController < ApplicationController end elsif params[:nearby] if @user - @title = t 'diary_entry.list.title_nearby' + @title = t "diary_entry.list.title_nearby" @entries = DiaryEntry.where(:user_id => @user.nearby) else require_user @@ -100,10 +100,10 @@ class DiaryEntryController < ApplicationController @entries = DiaryEntry.joins(:user).where(:users => { :status => %w(active confirmed) }) if params[:language] - @title = t 'diary_entry.list.in_language_title', :language => Language.find(params[:language]).english_name + @title = t "diary_entry.list.in_language_title", :language => Language.find(params[:language]).english_name @entries = @entries.where(:language_code => params[:language]) else - @title = t 'diary_entry.list.title' + @title = t "diary_entry.list.title" end end @@ -123,8 +123,8 @@ class DiaryEntryController < ApplicationController if user @entries = user.diary_entries - @title = I18n.t('diary_entry.feed.user.title', :user => user.display_name) - @description = I18n.t('diary_entry.feed.user.description', :user => user.display_name) + @title = I18n.t("diary_entry.feed.user.title", :user => user.display_name) + @description = I18n.t("diary_entry.feed.user.description", :user => user.display_name) @link = "http://#{SERVER_URL}/user/#{user.display_name}/diary" else render :text => "", :status => :not_found @@ -135,12 +135,12 @@ class DiaryEntryController < ApplicationController if params[:language] @entries = @entries.where(:language_code => params[:language]) - @title = I18n.t('diary_entry.feed.language.title', :language_name => Language.find(params[:language]).english_name) - @description = I18n.t('diary_entry.feed.language.description', :language_name => Language.find(params[:language]).english_name) + @title = I18n.t("diary_entry.feed.language.title", :language_name => Language.find(params[:language]).english_name) + @description = I18n.t("diary_entry.feed.language.description", :language_name => Language.find(params[:language]).english_name) @link = "http://#{SERVER_URL}/diary/#{params[:language]}" else - @title = I18n.t('diary_entry.feed.all.title') - @description = I18n.t('diary_entry.feed.all.description') + @title = I18n.t("diary_entry.feed.all.title") + @description = I18n.t("diary_entry.feed.all.description") @link = "http://#{SERVER_URL}/diary" end end @@ -151,10 +151,10 @@ class DiaryEntryController < ApplicationController def view @entry = @this_user.diary_entries.visible.where(:id => params[:id]).first if @entry - @title = t 'diary_entry.view.title', :user => params[:display_name], :title => @entry.title + @title = t "diary_entry.view.title", :user => params[:display_name], :title => @entry.title else - @title = t 'diary_entry.no_such_entry.title', :id => params[:id] - render :action => 'no_such_entry', :status => :not_found + @title = t "diary_entry.no_such_entry.title", :id => params[:id] + render :action => "no_such_entry", :status => :not_found end end @@ -176,7 +176,7 @@ class DiaryEntryController < ApplicationController :user_id => @this_user, :visible => true }, - :order => 'created_at DESC', + :order => "created_at DESC", :per_page => 20) @page = (params[:page] || 1).to_i end @@ -200,8 +200,8 @@ class DiaryEntryController < ApplicationController # and return them to the user page. def require_administrator unless @user.administrator? - flash[:error] = t('user.filter.not_an_administrator') - redirect_to :controller => 'diary_entry', :action => 'view' + flash[:error] = t("user.filter.not_an_administrator") + redirect_to :controller => "diary_entry", :action => "view" end end diff --git a/app/controllers/geocoder_controller.rb b/app/controllers/geocoder_controller.rb index 37cdc6557..e889228f3 100644 --- a/app/controllers/geocoder_controller.rb +++ b/app/controllers/geocoder_controller.rb @@ -1,10 +1,10 @@ # coding: utf-8 class GeocoderController < ApplicationController - require 'cgi' - require 'uri' - require 'net/http' - require 'rexml/document' + require "cgi" + require "uri" + require "net/http" + require "rexml/document" before_filter :authorize_web before_filter :set_locale @@ -170,7 +170,7 @@ class GeocoderController < ApplicationController else prefix_name = t "geocoder.search_osm_nominatim.prefix.#{klass}.#{type}", :default => type.gsub("_", " ").capitalize end - if klass == 'boundary' && type == 'administrative' + if klass == "boundary" && type == "administrative" rank = (place.attributes["place_rank"].to_i + 1) / 2 prefix_name = t "geocoder.search_osm_nominatim.admin_levels.level#{rank}", :default => prefix_name end @@ -324,7 +324,7 @@ class GeocoderController < ApplicationController end def escape_query(query) - URI.escape(query, Regexp.new("[^#{URI::PATTERN::UNRESERVED}]", false, 'N')) + URI.escape(query, Regexp.new("[^#{URI::PATTERN::UNRESERVED}]", false, "N")) end def normalize_params @@ -356,11 +356,11 @@ class GeocoderController < ApplicationController def nsew_to_decdeg(captures) begin Float(captures[0]) - captures[2].downcase != 's' ? lat = captures[0].to_f : lat = -(captures[0].to_f) - captures[5].downcase != 'w' ? lon = captures[3].to_f : lon = -(captures[3].to_f) + captures[2].downcase != "s" ? lat = captures[0].to_f : lat = -(captures[0].to_f) + captures[5].downcase != "w" ? lon = captures[3].to_f : lon = -(captures[3].to_f) rescue - captures[0].downcase != 's' ? lat = captures[1].to_f : lat = -(captures[1].to_f) - captures[3].downcase != 'w' ? lon = captures[4].to_f : lon = -(captures[4].to_f) + captures[0].downcase != "s" ? lat = captures[1].to_f : lat = -(captures[1].to_f) + captures[3].downcase != "w" ? lon = captures[4].to_f : lon = -(captures[4].to_f) end { :lat => lat, :lon => lon } end @@ -368,11 +368,11 @@ class GeocoderController < ApplicationController def ddm_to_decdeg(captures) begin Float(captures[0]) - captures[3].downcase != 's' ? lat = captures[0].to_f + captures[1].to_f / 60 : lat = -(captures[0].to_f + captures[1].to_f / 60) - captures[7].downcase != 'w' ? lon = captures[4].to_f + captures[5].to_f / 60 : lon = -(captures[4].to_f + captures[5].to_f / 60) + captures[3].downcase != "s" ? lat = captures[0].to_f + captures[1].to_f / 60 : lat = -(captures[0].to_f + captures[1].to_f / 60) + captures[7].downcase != "w" ? lon = captures[4].to_f + captures[5].to_f / 60 : lon = -(captures[4].to_f + captures[5].to_f / 60) rescue - captures[0].downcase != 's' ? lat = captures[1].to_f + captures[2].to_f / 60 : lat = -(captures[1].to_f + captures[2].to_f / 60) - captures[4].downcase != 'w' ? lon = captures[5].to_f + captures[6].to_f / 60 : lon = -(captures[5].to_f + captures[6].to_f / 60) + captures[0].downcase != "s" ? lat = captures[1].to_f + captures[2].to_f / 60 : lat = -(captures[1].to_f + captures[2].to_f / 60) + captures[4].downcase != "w" ? lon = captures[5].to_f + captures[6].to_f / 60 : lon = -(captures[5].to_f + captures[6].to_f / 60) end { :lat => lat, :lon => lon } end @@ -380,11 +380,11 @@ class GeocoderController < ApplicationController def dms_to_decdeg(captures) begin Float(captures[0]) - captures[4].downcase != 's' ? lat = captures[0].to_f + (captures[1].to_f + captures[2].to_f / 60) / 60 : lat = -(captures[0].to_f + (captures[1].to_f + captures[2].to_f / 60) / 60) - captures[9].downcase != 'w' ? lon = captures[5].to_f + (captures[6].to_f + captures[7].to_f / 60) / 60 : lon = -(captures[5].to_f + (captures[6].to_f + captures[7].to_f / 60) / 60) + captures[4].downcase != "s" ? lat = captures[0].to_f + (captures[1].to_f + captures[2].to_f / 60) / 60 : lat = -(captures[0].to_f + (captures[1].to_f + captures[2].to_f / 60) / 60) + captures[9].downcase != "w" ? lon = captures[5].to_f + (captures[6].to_f + captures[7].to_f / 60) / 60 : lon = -(captures[5].to_f + (captures[6].to_f + captures[7].to_f / 60) / 60) rescue - captures[0].downcase != 's' ? lat = captures[1].to_f + (captures[2].to_f + captures[3].to_f / 60) / 60 : lat = -(captures[1].to_f + (captures[2].to_f + captures[3].to_f / 60) / 60) - captures[5].downcase != 'w' ? lon = captures[6].to_f + (captures[7].to_f + captures[8].to_f / 60) / 60 : lon = -(captures[6].to_f + (captures[7].to_f + captures[8].to_f / 60) / 60) + captures[0].downcase != "s" ? lat = captures[1].to_f + (captures[2].to_f + captures[3].to_f / 60) / 60 : lat = -(captures[1].to_f + (captures[2].to_f + captures[3].to_f / 60) / 60) + captures[5].downcase != "w" ? lon = captures[6].to_f + (captures[7].to_f + captures[8].to_f / 60) / 60 : lon = -(captures[6].to_f + (captures[7].to_f + captures[8].to_f / 60) / 60) end { :lat => lat, :lon => lon } end diff --git a/app/controllers/message_controller.rb b/app/controllers/message_controller.rb index 3cc80c190..32f2f8780 100644 --- a/app/controllers/message_controller.rb +++ b/app/controllers/message_controller.rb @@ -1,5 +1,5 @@ class MessageController < ApplicationController - layout 'site' + layout "site" before_filter :authorize_web before_filter :set_locale @@ -15,7 +15,7 @@ class MessageController < ApplicationController def new if params[:message] if @user.sent_messages.where("sent_on >= ?", Time.now.getutc - 1.hour).count >= MAX_MESSAGES_PER_HOUR - flash[:error] = t 'message.new.limit_exceeded' + flash[:error] = t "message.new.limit_exceeded" else @message = Message.new(message_params) @message.to_user_id = @this_user.id @@ -23,15 +23,15 @@ class MessageController < ApplicationController @message.sent_on = Time.now.getutc if @message.save - flash[:notice] = t 'message.new.message_sent' + flash[:notice] = t "message.new.message_sent" Notifier.message_notification(@message).deliver_now - redirect_to :controller => 'message', :action => 'inbox', :display_name => @user.display_name + redirect_to :controller => "message", :action => "inbox", :display_name => @user.display_name end end end @message ||= Message.new(:recipient => @this_user) - @title = t 'message.new.title' + @title = t "message.new.title" end # Allow the user to reply to another message. @@ -49,69 +49,69 @@ class MessageController < ApplicationController @title = @message.title - render :action => 'new' + render :action => "new" else - flash[:notice] = t 'message.reply.wrong_user', :user => @user.display_name + flash[:notice] = t "message.reply.wrong_user", :user => @user.display_name redirect_to :controller => "user", :action => "login", :referer => request.fullpath end rescue ActiveRecord::RecordNotFound - @title = t 'message.no_such_message.title' - render :action => 'no_such_message', :status => :not_found + @title = t "message.no_such_message.title" + render :action => "no_such_message", :status => :not_found end # Show a message def read - @title = t 'message.read.title' + @title = t "message.read.title" @message = Message.find(params[:message_id]) if @message.to_user_id == @user.id || @message.from_user_id == @user.id @message.message_read = true if @message.to_user_id == @user.id @message.save else - flash[:notice] = t 'message.read.wrong_user', :user => @user.display_name + flash[:notice] = t "message.read.wrong_user", :user => @user.display_name redirect_to :controller => "user", :action => "login", :referer => request.fullpath end rescue ActiveRecord::RecordNotFound - @title = t 'message.no_such_message.title' - render :action => 'no_such_message', :status => :not_found + @title = t "message.no_such_message.title" + render :action => "no_such_message", :status => :not_found end # Display the list of messages that have been sent to the user. def inbox - @title = t 'message.inbox.title' + @title = t "message.inbox.title" if @user && params[:display_name] == @user.display_name else - redirect_to :controller => 'message', :action => 'inbox', :display_name => @user.display_name + redirect_to :controller => "message", :action => "inbox", :display_name => @user.display_name end end # Display the list of messages that the user has sent to other users. def outbox - @title = t 'message.outbox.title' + @title = t "message.outbox.title" if @user && params[:display_name] == @user.display_name else - redirect_to :controller => 'message', :action => 'outbox', :display_name => @user.display_name + redirect_to :controller => "message", :action => "outbox", :display_name => @user.display_name end end # Set the message as being read or unread. def mark @message = Message.where("to_user_id = ? OR from_user_id = ?", @user.id, @user.id).find(params[:message_id]) - if params[:mark] == 'unread' + if params[:mark] == "unread" message_read = false - notice = t 'message.mark.as_unread' + notice = t "message.mark.as_unread" else message_read = true - notice = t 'message.mark.as_read' + notice = t "message.mark.as_read" end @message.message_read = message_read if @message.save && !request.xhr? flash[:notice] = notice - redirect_to :controller => 'message', :action => 'inbox', :display_name => @user.display_name + redirect_to :controller => "message", :action => "inbox", :display_name => @user.display_name end rescue ActiveRecord::RecordNotFound - @title = t 'message.no_such_message.title' - render :action => 'no_such_message', :status => :not_found + @title = t "message.no_such_message.title" + render :action => "no_such_message", :status => :not_found end # Delete the message. @@ -120,17 +120,17 @@ class MessageController < ApplicationController @message.from_user_visible = false if @message.sender == @user @message.to_user_visible = false if @message.recipient == @user if @message.save && !request.xhr? - flash[:notice] = t 'message.delete.deleted' + flash[:notice] = t "message.delete.deleted" if params[:referer] redirect_to params[:referer] else - redirect_to :controller => 'message', :action => 'inbox', :display_name => @user.display_name + redirect_to :controller => "message", :action => "inbox", :display_name => @user.display_name end end rescue ActiveRecord::RecordNotFound - @title = t 'message.no_such_message.title' - render :action => 'no_such_message', :status => :not_found + @title = t "message.no_such_message.title" + render :action => "no_such_message", :status => :not_found end private diff --git a/app/controllers/node_controller.rb b/app/controllers/node_controller.rb index cd5b893e3..8c57ad8f9 100644 --- a/app/controllers/node_controller.rb +++ b/app/controllers/node_controller.rb @@ -1,7 +1,7 @@ # The NodeController is the RESTful interface to Node objects class NodeController < ApplicationController - require 'xml/libxml' + require "xml/libxml" skip_before_filter :verify_authenticity_token before_filter :authorize, :only => [:create, :update, :delete] @@ -64,11 +64,11 @@ class NodeController < ApplicationController # Dump the details on many nodes whose ids are given in the "nodes" parameter. def nodes - unless params['nodes'] + unless params["nodes"] fail OSM::APIBadUserInput.new("The parameter nodes is required, and must be of the form nodes=id[,id[,id...]]") end - ids = params['nodes'].split(',').collect(&:to_i) + ids = params["nodes"].split(",").collect(&:to_i) if ids.length == 0 fail OSM::APIBadUserInput.new("No nodes were given to search for") diff --git a/app/controllers/notes_controller.rb b/app/controllers/notes_controller.rb index 5fdda44f4..5bdf28862 100644 --- a/app/controllers/notes_controller.rb +++ b/app/controllers/notes_controller.rb @@ -1,5 +1,5 @@ class NotesController < ApplicationController - layout 'site', :only => [:mine] + layout "site", :only => [:mine] before_filter :check_api_readable before_filter :authorize_web, :only => [:mine] @@ -279,17 +279,17 @@ class NotesController < ApplicationController def mine if params[:display_name] if @this_user = User.active.find_by_display_name(params[:display_name]) - @title = t 'note.mine.title', :user => @this_user.display_name - @heading = t 'note.mine.heading', :user => @this_user.display_name - @description = t 'note.mine.subheading', :user => render_to_string(:partial => "user", :object => @this_user) + @title = t "note.mine.title", :user => @this_user.display_name + @heading = t "note.mine.heading", :user => @this_user.display_name + @description = t "note.mine.subheading", :user => render_to_string(:partial => "user", :object => @this_user) @page = (params[:page] || 1).to_i @page_size = 10 @notes = @this_user.notes.order("updated_at DESC, id").uniq.offset((@page - 1) * @page_size).limit(@page_size).preload(:comments => :author).to_a else - @title = t 'user.no_such_user.title' + @title = t "user.no_such_user.title" @not_found_user = params[:display_name] - render :template => 'user/no_such_user', :status => :not_found + render :template => "user/no_such_user", :status => :not_found end end end diff --git a/app/controllers/oauth_clients_controller.rb b/app/controllers/oauth_clients_controller.rb index 48074ddd4..bf55679e8 100644 --- a/app/controllers/oauth_clients_controller.rb +++ b/app/controllers/oauth_clients_controller.rb @@ -1,5 +1,5 @@ class OauthClientsController < ApplicationController - layout 'site' + layout "site" before_filter :authorize_web before_filter :set_locale @@ -17,7 +17,7 @@ class OauthClientsController < ApplicationController def create @client_application = @user.client_applications.build(application_params) if @client_application.save - flash[:notice] = t 'oauth_clients.create.flash' + flash[:notice] = t "oauth_clients.create.flash" redirect_to :action => "show", :id => @client_application.id else render :action => "new" @@ -41,7 +41,7 @@ class OauthClientsController < ApplicationController def update @client_application = @user.client_applications.find(params[:id]) if @client_application.update_attributes(application_params) - flash[:notice] = t 'oauth_clients.update.flash' + flash[:notice] = t "oauth_clients.update.flash" redirect_to :action => "show", :id => @client_application.id else render :action => "edit" @@ -54,7 +54,7 @@ class OauthClientsController < ApplicationController def destroy @client_application = @user.client_applications.find(params[:id]) @client_application.destroy - flash[:notice] = t 'oauth_clients.destroy.flash' + flash[:notice] = t "oauth_clients.destroy.flash" redirect_to :action => "index" rescue ActiveRecord::RecordNotFound @type = "client application" diff --git a/app/controllers/oauth_controller.rb b/app/controllers/oauth_controller.rb index 819f74dc1..ed7853d6c 100644 --- a/app/controllers/oauth_controller.rb +++ b/app/controllers/oauth_controller.rb @@ -1,9 +1,9 @@ -require 'oauth/controllers/provider_controller' +require "oauth/controllers/provider_controller" class OauthController < ApplicationController include OAuth::Controllers::ProviderController - layout 'site' + layout "site" def login_required authorize_web @@ -30,7 +30,7 @@ class OauthController < ApplicationController @token = current_user.oauth_tokens.find_by_token params[:token] if @token @token.invalidate! - flash[:notice] = t('oauth.revoke.flash', :application => @token.client_application.name) + flash[:notice] = t("oauth.revoke.flash", :application => @token.client_application.name) end redirect_to oauth_clients_url(:display_name => @token.user.display_name) end diff --git a/app/controllers/old_controller.rb b/app/controllers/old_controller.rb index 9d7cf2113..ff86407f5 100644 --- a/app/controllers/old_controller.rb +++ b/app/controllers/old_controller.rb @@ -2,7 +2,7 @@ # into one place. as it turns out, the API methods for historical # nodes, ways and relations are basically identical. class OldController < ApplicationController - require 'xml/libxml' + require "xml/libxml" skip_before_filter :verify_authenticity_token before_filter :setup_user_auth, :only => [:history, :version] @@ -52,7 +52,7 @@ class OldController < ApplicationController end def redact - redaction_id = params['redaction'] + redaction_id = params["redaction"] if redaction_id.nil? # if no redaction ID was provided, then this is an unredact # operation. diff --git a/app/controllers/redactions_controller.rb b/app/controllers/redactions_controller.rb index 8ba5c7d9d..beff596a0 100644 --- a/app/controllers/redactions_controller.rb +++ b/app/controllers/redactions_controller.rb @@ -1,5 +1,5 @@ class RedactionsController < ApplicationController - layout 'site' + layout "site" before_filter :authorize_web before_filter :set_locale @@ -25,10 +25,10 @@ class RedactionsController < ApplicationController # note that the description format will default to 'markdown' if @redaction.save - flash[:notice] = t('redaction.create.flash') + flash[:notice] = t("redaction.create.flash") redirect_to @redaction else - render :action => 'new' + render :action => "new" end end @@ -44,10 +44,10 @@ class RedactionsController < ApplicationController @redaction.description = params[:redaction][:description] if @redaction.save - flash[:notice] = t('redaction.update.flash') + flash[:notice] = t("redaction.update.flash") redirect_to @redaction else - render :action => 'edit' + render :action => "edit" end end @@ -56,14 +56,14 @@ class RedactionsController < ApplicationController @redaction.old_ways.empty? && @redaction.old_relations.empty? if @redaction.destroy - flash[:notice] = t('redaction.destroy.flash') + flash[:notice] = t("redaction.destroy.flash") redirect_to :redactions else - flash[:error] = t('redaction.destroy.error') + flash[:error] = t("redaction.destroy.error") redirect_to @redaction end else - flash[:error] = t('redaction.destroy.not_empty') + flash[:error] = t("redaction.destroy.not_empty") redirect_to @redaction end end diff --git a/app/controllers/relation_controller.rb b/app/controllers/relation_controller.rb index 132b78e9b..22a8d2831 100644 --- a/app/controllers/relation_controller.rb +++ b/app/controllers/relation_controller.rb @@ -1,5 +1,5 @@ class RelationController < ApplicationController - require 'xml/libxml' + require "xml/libxml" skip_before_filter :verify_authenticity_token before_filter :authorize, :only => [:create, :update, :delete] @@ -76,9 +76,9 @@ class RelationController < ApplicationController # first find the ids of nodes, ways and relations referenced by this # relation - note that we exclude this relation just in case. - node_ids = relation.members.select { |m| m[0] == 'Node' }.map { |m| m[1] } - way_ids = relation.members.select { |m| m[0] == 'Way' }.map { |m| m[1] } - relation_ids = relation.members.select { |m| m[0] == 'Relation' && m[1] != relation.id }.map { |m| m[1] } + node_ids = relation.members.select { |m| m[0] == "Node" }.map { |m| m[1] } + way_ids = relation.members.select { |m| m[0] == "Way" }.map { |m| m[1] } + relation_ids = relation.members.select { |m| m[0] == "Relation" && m[1] != relation.id }.map { |m| m[1] } # next load the relations and the ways. @@ -133,11 +133,11 @@ class RelationController < ApplicationController end def relations - unless params['relations'] + unless params["relations"] fail OSM::APIBadUserInput.new("The parameter relations is required, and must be of the form relations=id[,id[,id...]]") end - ids = params['relations'].split(',').collect(&:to_i) + ids = params["relations"].split(",").collect(&:to_i) if ids.length == 0 fail OSM::APIBadUserInput.new("No relations were given to search for") diff --git a/app/controllers/search_controller.rb b/app/controllers/search_controller.rb index 7cd6f4ca7..0217bb29e 100644 --- a/app/controllers/search_controller.rb +++ b/app/controllers/search_controller.rb @@ -22,24 +22,24 @@ class SearchController < ApplicationController end def do_search(do_ways, do_nodes, do_relations) - type = params['type'] - value = params['value'] + type = params["type"] + value = params["value"] unless type || value - name = params['name'] + name = params["name"] if name - type = 'name' + type = "name" value = name end end if do_nodes - response.headers['Error'] = "Searching of nodes is currently unavailable" + response.headers["Error"] = "Searching of nodes is currently unavailable" render :text => "", :status => :service_unavailable return false end unless value - response.headers['Error'] = "Searching for a key without value is currently unavailable" + response.headers["Error"] = "Searching for a key without value is currently unavailable" render :text => "", :status => :service_unavailable return false end diff --git a/app/controllers/site_controller.rb b/app/controllers/site_controller.rb index 01cdcf23f..4034950b7 100644 --- a/app/controllers/site_controller.rb +++ b/app/controllers/site_controller.rb @@ -1,5 +1,5 @@ class SiteController < ApplicationController - layout 'site' + layout "site" layout :map_layout, :only => [:index, :export] before_filter :authorize_web @@ -11,7 +11,7 @@ class SiteController < ApplicationController def index unless STATUS == :database_readonly || STATUS == :database_offline - session[:location] ||= OSM.ip_location(request.env['REMOTE_ADDR']) + session[:location] ||= OSM.ip_location(request.env["REMOTE_ADDR"]) end end @@ -26,24 +26,24 @@ class SiteController < ApplicationController end if params.key? :node - new_params[:controller] = 'browse' - new_params[:action] = 'node' + new_params[:controller] = "browse" + new_params[:action] = "node" new_params[:id] = params[:node] elsif params.key? :way - new_params[:controller] = 'browse' - new_params[:action] = 'way' + new_params[:controller] = "browse" + new_params[:action] = "way" new_params[:id] = params[:way] elsif params.key? :relation - new_params[:controller] = 'browse' - new_params[:action] = 'relation' + new_params[:controller] = "browse" + new_params[:action] = "relation" new_params[:id] = params[:relation] elsif params.key? :changeset - new_params[:controller] = 'browse' - new_params[:action] = 'changeset' + new_params[:controller] = "browse" + new_params[:action] = "changeset" new_params[:id] = params[:changeset] else - new_params[:controller] = 'site' - new_params[:action] = 'index' + new_params[:controller] = "site" + new_params[:action] = "index" end new_params[:anchor] = "map=#{zoom}/#{lat}/#{lon}" @@ -143,12 +143,12 @@ class SiteController < ApplicationController if params[:layers] anchor << "layers=#{params.delete(:layers)}" - elsif params.delete(:notes) == 'yes' + elsif params.delete(:notes) == "yes" anchor << "layers=N" end if anchor.present? - redirect_to Hash[params].merge(:anchor => anchor.join('&')) + redirect_to Hash[params].merge(:anchor => anchor.join("&")) end end end diff --git a/app/controllers/swf_controller.rb b/app/controllers/swf_controller.rb index af5afb7c9..51fe4010b 100644 --- a/app/controllers/swf_controller.rb +++ b/app/controllers/swf_controller.rb @@ -15,13 +15,13 @@ class SwfController < ApplicationController def trackpoints # - Initialise - baselong = params['baselong'].to_f - basey = params['basey'].to_f - masterscale = params['masterscale'].to_f + baselong = params["baselong"].to_f + basey = params["basey"].to_f + masterscale = params["masterscale"].to_f - bbox = BoundingBox.new(params['xmin'], params['ymin'], - params['xmax'], params['ymax']) - start = params['start'].to_i + bbox = BoundingBox.new(params["xmin"], params["ymin"], + params["xmax"], params["ymax"]) + start = params["start"].to_i # - Begin movie @@ -30,7 +30,7 @@ class SwfController < ApplicationController bounds_bottom = 0 bounds_top = 240 * 20 - m = '' + m = "" m += swf_record(9, 255.chr + 155.chr + 155.chr) # Background absx = 0 absy = 0 @@ -39,11 +39,11 @@ class SwfController < ApplicationController # - Send SQL for GPS tracks - b = '' + b = "" lasttime = 0 - lasttrack = lastfile = '-1' + lasttrack = lastfile = "-1" - if params['token'] + if params["token"] user = User.authenticate(:token => params[:token]) sql = "SELECT gps_points.latitude*0.0000001 AS lat,gps_points.longitude*0.0000001 AS lon,gpx_files.id AS fileid," + " EXTRACT(EPOCH FROM gps_points.timestamp) AS ts, gps_points.trackid AS trackid " + " FROM gpx_files,gps_points " + "WHERE gpx_files.id=gpx_id " + " AND gpx_files.user_id=#{user.id} " + " AND " + OSM.sql_for_area(bbox, "gps_points.") + " AND (gps_points.timestamp IS NOT NULL) " + "ORDER BY fileid DESC,ts " + "LIMIT 10000 OFFSET #{start}" else @@ -55,23 +55,23 @@ class SwfController < ApplicationController r = start_shape gpslist.each do |row| - xs = (long2coord(row['lon'].to_f, baselong, masterscale) * 20).floor - ys = (lat2coord(row['lat'].to_f, basey, masterscale) * 20).floor + xs = (long2coord(row["lon"].to_f, baselong, masterscale) * 20).floor + ys = (lat2coord(row["lat"].to_f, basey, masterscale) * 20).floor xl = [xs, xl].min xr = [xs, xr].max yb = [ys, yb].min yt = [ys, yt].max - if row['ts'].to_i - lasttime > 180 || row['fileid'] != lastfile || row['trackid'] != lasttrack # or row['ts'].to_i==lasttime - b += start_and_move(xs, ys, '01') + if row["ts"].to_i - lasttime > 180 || row["fileid"] != lastfile || row["trackid"] != lasttrack # or row['ts'].to_i==lasttime + b += start_and_move(xs, ys, "01") absx = xs.floor absy = ys.floor end b += draw_to(absx, absy, xs, ys) absx = xs.floor absy = ys.floor - lasttime = row['ts'].to_i - lastfile = row['fileid'] - lasttrack = row['trackid'] + lasttime = row["ts"].to_i + lastfile = row["fileid"] + lasttrack = row["trackid"] r += [b.slice!(0...80)].pack("B*") while b.length > 80 end @@ -86,11 +86,11 @@ class SwfController < ApplicationController # - Create Flash header and write to browser - m += swf_record(1, '') # Show frame - m += swf_record(0, '') # End + m += swf_record(1, "") # Show frame + m += swf_record(0, "") # End m = pack_rect(bounds_left, bounds_right, bounds_bottom, bounds_top) + 0.chr + 12.chr + pack_u16(1) + m - m = 'FWS' + 6.chr + pack_u32(m.length + 8) + m + m = "FWS" + 6.chr + pack_u32(m.length + 8) + m render :text => m, :content_type => "application/x-shockwave-flash" end @@ -113,11 +113,11 @@ class SwfController < ApplicationController end def end_shape - '000000' + "000000" end def start_and_move(x, y, col) - d = '001001' # Line style change, moveTo + d = "001001" # Line style change, moveTo l = [length_sb(x), length_sb(y)].max d += sprintf("%05b%0#{l}b%0#{l}b", l, x, y) d += col # Select line style @@ -133,7 +133,7 @@ class SwfController < ApplicationController mstep = [dx.abs / 16383, dy.abs / 16383, 1].max.ceil xstep = dx / mstep ystep = dy / mstep - d = '' + d = "" 1.upto(mstep).each do d += draw_section(x, y, x + xstep, y + ystep) x += xstep @@ -143,12 +143,12 @@ class SwfController < ApplicationController end def draw_section(x1, y1, x2, y2) - d = '11' # TypeFlag, EdgeFlag + d = "11" # TypeFlag, EdgeFlag dx = x2 - x1 dy = y2 - y1 l = [length_sb(dx), length_sb(dy)].max d += sprintf("%04b", l - 2) - d += '1' # GeneralLine + d += "1" # GeneralLine d += sprintf("%0#{l}b%0#{l}b", dx, dy) d end diff --git a/app/controllers/trace_controller.rb b/app/controllers/trace_controller.rb index 538cf10d2..9d6dad600 100644 --- a/app/controllers/trace_controller.rb +++ b/app/controllers/trace_controller.rb @@ -1,5 +1,5 @@ class TraceController < ApplicationController - layout 'site' + layout "site" skip_before_filter :verify_authenticity_token, :only => [:api_create, :api_read, :api_update, :api_delete, :api_data] before_filter :authorize_web @@ -31,14 +31,14 @@ class TraceController < ApplicationController # set title if target_user.nil? - @title = t 'trace.list.public_traces' + @title = t "trace.list.public_traces" elsif @user && @user == target_user - @title = t 'trace.list.your_traces' + @title = t "trace.list.your_traces" else - @title = t 'trace.list.public_traces_from', :user => target_user.display_name + @title = t "trace.list.public_traces_from", :user => target_user.display_name end - @title += t 'trace.list.tagged_with', :tags => params[:tag] if params[:tag] + @title += t "trace.list.tagged_with", :tags => params[:tag] if params[:tag] # four main cases: # 1 - all traces, logged in = all public traces + all user's (i.e + all mine) @@ -94,14 +94,14 @@ class TraceController < ApplicationController if @trace && @trace.visible? && (@trace.public? || @trace.user == @user) - @title = t 'trace.view.title', :name => @trace.name + @title = t "trace.view.title", :name => @trace.name else - flash[:error] = t 'trace.view.trace_not_found' - redirect_to :controller => 'trace', :action => 'list' + flash[:error] = t "trace.view.trace_not_found" + redirect_to :controller => "trace", :action => "list" end rescue ActiveRecord::RecordNotFound - flash[:error] = t 'trace.view.trace_not_found' - redirect_to :controller => 'trace', :action => 'list' + flash[:error] = t "trace.view.trace_not_found" + redirect_to :controller => "trace", :action => "list" end def create @@ -118,10 +118,10 @@ class TraceController < ApplicationController if @trace.id logger.info("id is #{@trace.id}") - flash[:notice] = t 'trace.create.trace_uploaded' + flash[:notice] = t "trace.create.trace_uploaded" if @user.traces.where(:inserted => false).count > 4 - flash[:warning] = t 'trace.trace_header.traces_waiting', :count => @user.traces.where(:inserted => false).count + flash[:warning] = t "trace.trace_header.traces_waiting", :count => @user.traces.where(:inserted => false).count end redirect_to :action => :list, :display_name => @user.display_name @@ -140,7 +140,7 @@ class TraceController < ApplicationController @trace = Trace.new(:visibility => default_visibility) end - @title = t 'trace.create.upload_trace' + @title = t "trace.create.upload_trace" end def data @@ -150,11 +150,11 @@ class TraceController < ApplicationController if Acl.no_trace_download(request.remote_ip) render :text => "", :status => :forbidden elsif request.format == Mime::XML - send_file(trace.xml_file, :filename => "#{trace.id}.xml", :type => request.format.to_s, :disposition => 'attachment') + send_file(trace.xml_file, :filename => "#{trace.id}.xml", :type => request.format.to_s, :disposition => "attachment") elsif request.format == Mime::GPX - send_file(trace.xml_file, :filename => "#{trace.id}.gpx", :type => request.format.to_s, :disposition => 'attachment') + send_file(trace.xml_file, :filename => "#{trace.id}.gpx", :type => request.format.to_s, :disposition => "attachment") else - send_file(trace.trace_name, :filename => "#{trace.id}#{trace.extension_name}", :type => trace.mime_type, :disposition => 'attachment') + send_file(trace.trace_name, :filename => "#{trace.id}#{trace.extension_name}", :type => trace.mime_type, :disposition => "attachment") end else render :text => "", :status => :not_found @@ -171,14 +171,14 @@ class TraceController < ApplicationController elsif @user.nil? || @trace.user != @user render :text => "", :status => :forbidden else - @title = t 'trace.edit.title', :name => @trace.name + @title = t "trace.edit.title", :name => @trace.name if params[:trace] @trace.description = params[:trace][:description] @trace.tagstring = params[:trace][:tagstring] @trace.visibility = params[:trace][:visibility] if @trace.save - redirect_to :action => 'view', :display_name => @user.display_name + redirect_to :action => "view", :display_name => @user.display_name end end end @@ -196,7 +196,7 @@ class TraceController < ApplicationController else trace.visible = false trace.save - flash[:notice] = t 'trace.delete.scheduled_for_deletion' + flash[:notice] = t "trace.delete.scheduled_for_deletion" redirect_to :action => :list, :display_name => @user.display_name end rescue ActiveRecord::RecordNotFound @@ -222,7 +222,7 @@ class TraceController < ApplicationController if trace.inserted? if trace.public? || (@user && @user == trace.user) expires_in 7.days, :private => !trace.public?, :public => trace.public? - send_file(trace.large_picture_name, :filename => "#{trace.id}.gif", :type => 'image/gif', :disposition => 'inline') + send_file(trace.large_picture_name, :filename => "#{trace.id}.gif", :type => "image/gif", :disposition => "inline") else render :text => "", :status => :forbidden end @@ -239,7 +239,7 @@ class TraceController < ApplicationController if trace.inserted? if trace.public? || (@user && @user == trace.user) expires_in 7.days, :private => !trace.public?, :public => trace.public? - send_file(trace.icon_picture_name, :filename => "#{trace.id}_icon.gif", :type => 'image/gif', :disposition => 'inline') + send_file(trace.icon_picture_name, :filename => "#{trace.id}_icon.gif", :type => "image/gif", :disposition => "inline") else render :text => "", :status => :forbidden end @@ -299,9 +299,9 @@ class TraceController < ApplicationController if trace.public? || trace.user == @user if request.format == Mime::XML || request.format == Mime::GPX - send_file(trace.xml_file, :filename => "#{trace.id}.xml", :type => request.format.to_s, :disposition => 'attachment') + send_file(trace.xml_file, :filename => "#{trace.id}.xml", :type => request.format.to_s, :disposition => "attachment") else - send_file(trace.trace_name, :filename => "#{trace.id}#{trace.extension_name}", :type => trace.mime_type, :disposition => 'attachment') + send_file(trace.trace_name, :filename => "#{trace.id}#{trace.extension_name}", :type => trace.mime_type, :disposition => "attachment") end else render :text => "", :status => :forbidden @@ -340,7 +340,7 @@ class TraceController < ApplicationController def do_create(file, tags, description, visibility) # Sanitise the user's filename - name = file.original_filename.gsub(/[^a-zA-Z0-9.]/, '_') + name = file.original_filename.gsub(/[^a-zA-Z0-9.]/, "_") # Get a temporary filename... filename = "/tmp/#{rand}" @@ -398,7 +398,7 @@ class TraceController < ApplicationController end def offline_warning - flash.now[:warning] = t 'trace.offline_warning.message' if STATUS == :gpx_offline + flash.now[:warning] = t "trace.offline_warning.message" if STATUS == :gpx_offline end def offline_redirect diff --git a/app/controllers/user_blocks_controller.rb b/app/controllers/user_blocks_controller.rb index 1b2ff8965..b0ac27dd4 100644 --- a/app/controllers/user_blocks_controller.rb +++ b/app/controllers/user_blocks_controller.rb @@ -1,5 +1,5 @@ class UserBlocksController < ApplicationController - layout 'site' + layout "site" before_filter :authorize_web before_filter :set_locale @@ -44,7 +44,7 @@ class UserBlocksController < ApplicationController ) if @user_block.save - flash[:notice] = t('user_block.create.flash', :name => @this_user.display_name) + flash[:notice] = t("user_block.create.flash", :name => @this_user.display_name) redirect_to @user_block else render :action => "new" @@ -57,14 +57,14 @@ class UserBlocksController < ApplicationController def update if @valid_params if @user_block.creator_id != @user.id - flash[:error] = t('user_block.update.only_creator_can_edit') + flash[:error] = t("user_block.update.only_creator_can_edit") redirect_to :action => "edit" elsif @user_block.update_attributes( :ends_at => Time.now.getutc + @block_period.hours, :reason => params[:user_block][:reason], :needs_view => params[:user_block][:needs_view] ) - flash[:notice] = t('user_block.update.success') + flash[:notice] = t("user_block.update.success") redirect_to(@user_block) else render :action => "edit" @@ -79,7 +79,7 @@ class UserBlocksController < ApplicationController def revoke if params[:confirm] if @user_block.revoke! @user - flash[:notice] = t 'user_block.revoke.flash' + flash[:notice] = t "user_block.revoke.flash" redirect_to(@user_block) end end @@ -125,10 +125,10 @@ class UserBlocksController < ApplicationController @valid_params = false if !UserBlock::PERIODS.include?(@block_period) - flash[:error] = t('user_block.filter.block_period') + flash[:error] = t("user_block.filter.block_period") elsif @user_block && !@user_block.active? - flash[:error] = t('user_block.filter.block_expired') + flash[:error] = t("user_block.filter.block_expired") else @valid_params = true diff --git a/app/controllers/user_controller.rb b/app/controllers/user_controller.rb index 70fa4f7fc..1a7f3810a 100644 --- a/app/controllers/user_controller.rb +++ b/app/controllers/user_controller.rb @@ -1,5 +1,5 @@ class UserController < ApplicationController - layout 'site', :except => [:api_details] + layout "site", :except => [:api_details] skip_before_filter :verify_authenticity_token, :only => [:api_read, :api_details, :api_gpx_files] before_filter :disable_terms_redirect, :only => [:terms, :save, :logout, :api_details] @@ -26,7 +26,7 @@ class UserController < ApplicationController if request.xhr? render :partial => "terms" else - @title = t 'user.terms.title' + @title = t "user.terms.title" if @user && @user.terms_agreed? # Already agreed to terms, so just show settings @@ -38,14 +38,14 @@ class UserController < ApplicationController end def save - @title = t 'user.new.title' + @title = t "user.new.title" if params[:decline] if @user @user.terms_seen = true if @user.save - flash[:notice] = t 'user.new.terms declined', :url => t('user.new.terms declined url') + flash[:notice] = t "user.new.terms declined", :url => t("user.new.terms declined url") end if params[:referer] @@ -54,7 +54,7 @@ class UserController < ApplicationController redirect_to :action => :account, :display_name => @user.display_name end else - redirect_to t('user.terms.declined') + redirect_to t("user.terms.declined") end elsif @user unless @user.terms_agreed? @@ -62,7 +62,7 @@ class UserController < ApplicationController @user.terms_agreed = Time.now.getutc @user.terms_seen = true - flash[:notice] = t 'user.new.terms accepted' if @user.save + flash[:notice] = t "user.new.terms accepted" if @user.save end if params[:referer] @@ -90,10 +90,10 @@ class UserController < ApplicationController begin uri = URI(session[:referer]) /map=(.*)\/(.*)\/(.*)/.match(uri.fragment) do |m| - editor = Rack::Utils.parse_query(uri.query).slice('editor') - referer = welcome_path({ 'zoom' => m[1], - 'lat' => m[2], - 'lon' => m[3] }.merge(editor)) + editor = Rack::Utils.parse_query(uri.query).slice("editor") + referer = welcome_path({ "zoom" => m[1], + "lat" => m[2], + "lon" => m[3] }.merge(editor)) end rescue # Use default @@ -105,17 +105,17 @@ class UserController < ApplicationController else session[:token] = @user.tokens.create.token Notifier.signup_confirm(@user, @user.tokens.create(:referer => referer)).deliver_now - redirect_to :action => 'confirm', :display_name => @user.display_name + redirect_to :action => "confirm", :display_name => @user.display_name end else - render :action => 'new', :referer => params[:referer] + render :action => "new", :referer => params[:referer] end end end end def account - @title = t 'user.account.title' + @title = t "user.account.title" @tokens = @user.oauth_tokens.authorized if params[:user] && params[:user][:display_name] && params[:user][:description] @@ -144,12 +144,12 @@ class UserController < ApplicationController def go_public @user.data_public = true @user.save - flash[:notice] = t 'user.go_public.flash success' - redirect_to :controller => 'user', :action => 'account', :display_name => @user.display_name + flash[:notice] = t "user.go_public.flash success" + redirect_to :controller => "user", :action => "account", :display_name => @user.display_name end def lost_password - @title = t 'user.lost_password.title' + @title = t "user.lost_password.title" if params[:user] && params[:user][:email] user = User.visible.find_by_email(params[:user][:email]) @@ -163,16 +163,16 @@ class UserController < ApplicationController if user token = user.tokens.create Notifier.lost_password(user, token).deliver_now - flash[:notice] = t 'user.lost_password.notice email on way' - redirect_to :action => 'login' + flash[:notice] = t "user.lost_password.notice email on way" + redirect_to :action => "login" else - flash.now[:error] = t 'user.lost_password.notice email cannot find' + flash.now[:error] = t "user.lost_password.notice email cannot find" end end end def reset_password - @title = t 'user.reset_password.title' + @title = t "user.reset_password.title" if params[:token] token = UserToken.find_by_token(params[:token]) @@ -188,13 +188,13 @@ class UserController < ApplicationController if @user.save token.destroy - flash[:notice] = t 'user.reset_password.flash changed' - redirect_to :action => 'login' + flash[:notice] = t "user.reset_password.flash changed" + redirect_to :action => "login" end end else - flash[:error] = t 'user.reset_password.flash token bad' - redirect_to :action => 'lost_password' + flash[:error] = t "user.reset_password.flash token bad" + redirect_to :action => "lost_password" end else render :text => "", :status => :bad_request @@ -202,7 +202,7 @@ class UserController < ApplicationController end def new - @title = t 'user.new.title' + @title = t "user.new.title" @referer = params[:referer] || session[:referer] if using_open_id? @@ -216,10 +216,10 @@ class UserController < ApplicationController end if @user.openid_url.nil? || @user.invalid? - render :action => 'new' + render :action => "new" else session[:new_user] = @user - redirect_to :action => 'terms' + redirect_to :action => "terms" end elsif @user # The user is logged in already, so don't show them the signup @@ -227,7 +227,7 @@ class UserController < ApplicationController if @referer redirect_to @referer else - redirect_to :controller => 'site', :action => 'index' + redirect_to :controller => "site", :action => "index" end elsif params.key?(:openid) @user = User.new(:email => params[:email], @@ -235,7 +235,7 @@ class UserController < ApplicationController :display_name => params[:nickname], :openid_url => params[:openid]) - flash.now[:notice] = t 'user.new.openid association' + flash.now[:notice] = t "user.new.openid association" else check_signup_allowed end @@ -286,7 +286,7 @@ class UserController < ApplicationController end def logout - @title = t 'user.logout.title' + @title = t "user.logout.title" if params[:session] == request.session_options[:id] if session[:token] @@ -299,7 +299,7 @@ class UserController < ApplicationController if params[:referer] redirect_to params[:referer] else - redirect_to :controller => 'site', :action => 'index' + redirect_to :controller => "site", :action => "index" end end end @@ -308,11 +308,11 @@ class UserController < ApplicationController if request.post? token = UserToken.find_by_token(params[:confirm_string]) if token && token.user.active? - flash[:error] = t('user.confirm.already active') - redirect_to :action => 'login' + flash[:error] = t("user.confirm.already active") + redirect_to :action => "login" elsif !token || token.expired? - flash[:error] = t('user.confirm.unknown token') - redirect_to :action => 'confirm' + flash[:error] = t("user.confirm.unknown token") + redirect_to :action => "confirm" else user = token.user user.status = "active" @@ -329,7 +329,7 @@ class UserController < ApplicationController end if token.nil? || token.user != user - flash[:notice] = t('user.confirm.success') + flash[:notice] = t("user.confirm.success") redirect_to :action => :login, :referer => referer else token.destroy @@ -349,12 +349,12 @@ class UserController < ApplicationController def confirm_resend if user = User.find_by_display_name(params[:display_name]) Notifier.signup_confirm(user, user.tokens.create).deliver_now - flash[:notice] = t 'user.confirm_resend.success', :email => user.email + flash[:notice] = t "user.confirm_resend.success", :email => user.email else - flash[:notice] = t 'user.confirm_resend.failure', :name => params[:display_name] + flash[:notice] = t "user.confirm_resend.failure", :name => params[:display_name] end - redirect_to :action => 'login' + redirect_to :action => "login" end def confirm_email @@ -366,16 +366,16 @@ class UserController < ApplicationController @user.new_email = nil @user.email_valid = true if @user.save - flash[:notice] = t 'user.confirm_email.success' + flash[:notice] = t "user.confirm_email.success" else flash[:errors] = @user.errors end token.destroy session[:user] = @user.id - redirect_to :action => 'account', :display_name => @user.display_name + redirect_to :action => "account", :display_name => @user.display_name else - flash[:error] = t 'user.confirm_email.failure' - redirect_to :action => 'account', :display_name => @user.display_name + flash[:error] = t "user.confirm_email.failure" + redirect_to :action => "account", :display_name => @user.display_name end end end @@ -417,20 +417,20 @@ class UserController < ApplicationController friend.user_id = @user.id friend.friend_user_id = @new_friend.id if @user.is_friends_with?(@new_friend) - flash[:warning] = t 'user.make_friend.already_a_friend', :name => @new_friend.display_name + flash[:warning] = t "user.make_friend.already_a_friend", :name => @new_friend.display_name else if friend.save - flash[:notice] = t 'user.make_friend.success', :name => @new_friend.display_name + flash[:notice] = t "user.make_friend.success", :name => @new_friend.display_name Notifier.friend_notification(friend).deliver_now else - friend.add_error(t('user.make_friend.failed', :name => @new_friend.display_name)) + friend.add_error(t("user.make_friend.failed", :name => @new_friend.display_name)) end end if params[:referer] redirect_to params[:referer] else - redirect_to :controller => 'user', :action => 'view' + redirect_to :controller => "user", :action => "view" end end else @@ -445,15 +445,15 @@ class UserController < ApplicationController if request.post? if @user.is_friends_with?(@friend) Friend.delete_all "user_id = #{@user.id} AND friend_user_id = #{@friend.id}" - flash[:notice] = t 'user.remove_friend.success', :name => @friend.display_name + flash[:notice] = t "user.remove_friend.success", :name => @friend.display_name else - flash[:error] = t 'user.remove_friend.not_a_friend', :name => @friend.display_name + flash[:error] = t "user.remove_friend.not_a_friend", :name => @friend.display_name end if params[:referer] redirect_to params[:referer] else - redirect_to :controller => 'user', :action => 'view' + redirect_to :controller => "user", :action => "view" end end else @@ -466,14 +466,14 @@ class UserController < ApplicationController def set_status @this_user.status = params[:status] @this_user.save - redirect_to :controller => 'user', :action => 'view', :display_name => params[:display_name] + redirect_to :controller => "user", :action => "view", :display_name => params[:display_name] end ## # delete a user, marking them as deleted and removing personal data def delete @this_user.delete - redirect_to :controller => 'user', :action => 'view', :display_name => params[:display_name] + redirect_to :controller => "user", :action => "view", :display_name => params[:display_name] end ## @@ -508,9 +508,9 @@ class UserController < ApplicationController elsif user = User.authenticate(:username => username, :password => password, :pending => true) unconfirmed_login(user) elsif User.authenticate(:username => username, :password => password, :suspended => true) - failed_login t('user.login.account is suspended', :webmaster => "mailto:webmaster@openstreetmap.org") + failed_login t("user.login.account is suspended", :webmaster => "mailto:webmaster@openstreetmap.org") else - failed_login t('user.login.auth failure') + failed_login t("user.login.auth failure") end end @@ -541,9 +541,9 @@ class UserController < ApplicationController when "active", "confirmed" then successful_login(user) when "suspended" then - failed_login t('user.login.account is suspended', :webmaster => "mailto:webmaster@openstreetmap.org") + failed_login t("user.login.account is suspended", :webmaster => "mailto:webmaster@openstreetmap.org") else - failed_login t('user.login.auth failure') + failed_login t("user.login.auth failure") end else # Guard against not getting any extension data @@ -557,14 +557,14 @@ class UserController < ApplicationController nickname = sreg["nickname"] || ax["http://axschema.org/namePerson/friendly"].first email = sreg["email"] || ax["http://axschema.org/contact/email"].first - redirect_to :controller => 'user', :action => 'new', :nickname => nickname, :email => email, :openid => identity_url + redirect_to :controller => "user", :action => "new", :nickname => nickname, :email => email, :openid => identity_url end elsif result.missing? - failed_login t('user.login.openid missing provider') + failed_login t("user.login.openid missing provider") elsif result.invalid? - failed_login t('user.login.openid invalid') + failed_login t("user.login.openid invalid") else - failed_login t('user.login.auth failure') + failed_login t("user.login.auth failure") end end end @@ -595,11 +595,11 @@ class UserController < ApplicationController user.openid_url = identity_url yield user, verified_email elsif result.missing? - flash.now[:error] = t 'user.login.openid missing provider' + flash.now[:error] = t "user.login.openid missing provider" elsif result.invalid? - flash.now[:error] = t 'user.login.openid invalid' + flash.now[:error] = t "user.login.openid invalid" else - flash.now[:error] = t 'user.login.auth failure' + flash.now[:error] = t "user.login.auth failure" end end end @@ -615,7 +615,7 @@ class UserController < ApplicationController # provider and, unlike yahoo.com, where it works automatically, Google # have hidden their OpenID endpoint somewhere obscure this making it # somewhat less user friendly. - return 'https://www.google.com/accounts/o8/id' + return "https://www.google.com/accounts/o8/id" else return openid_url end @@ -660,7 +660,7 @@ class UserController < ApplicationController def failed_login(message) flash[:error] = message - redirect_to :action => 'login', :referer => session[:referer] + redirect_to :action => "login", :referer => session[:referer] session.delete(:remember_me) session.delete(:referer) @@ -669,7 +669,7 @@ class UserController < ApplicationController ## # def unconfirmed_login(user) - redirect_to :action => 'confirm', :display_name => user.display_name + redirect_to :action => "confirm", :display_name => user.display_name session.delete(:remember_me) session.delete(:referer) @@ -720,12 +720,12 @@ class UserController < ApplicationController set_locale if user.new_email.blank? || user.new_email == user.email - flash.now[:notice] = t 'user.account.flash update success' + flash.now[:notice] = t "user.account.flash update success" else user.email = user.new_email if user.valid? - flash.now[:notice] = t 'user.account.flash update success confirm needed' + flash.now[:notice] = t "user.account.flash update success confirm needed" begin Notifier.email_confirm(user, user.tokens.create).deliver_now @@ -747,15 +747,15 @@ class UserController < ApplicationController # and return them to the user page. def require_administrator if @user && !@user.administrator? - flash[:error] = t('user.filter.not_an_administrator') + flash[:error] = t("user.filter.not_an_administrator") if params[:display_name] - redirect_to :controller => 'user', :action => 'view', :display_name => params[:display_name] + redirect_to :controller => "user", :action => "view", :display_name => params[:display_name] else - redirect_to :controller => 'user', :action => 'login', :referer => request.fullpath + redirect_to :controller => "user", :action => "login", :referer => request.fullpath end elsif !@user - redirect_to :controller => 'user', :action => 'login', :referer => request.fullpath + redirect_to :controller => "user", :action => "login", :referer => request.fullpath end end @@ -778,7 +778,7 @@ class UserController < ApplicationController def lookup_user_by_name @this_user = User.find_by_display_name(params[:display_name]) rescue ActiveRecord::RecordNotFound - redirect_to :controller => 'user', :action => 'view', :display_name => params[:display_name] unless @this_user + redirect_to :controller => "user", :action => "view", :display_name => params[:display_name] unless @this_user end ## @@ -808,7 +808,7 @@ class UserController < ApplicationController if blocked = Acl.no_account_creation(request.remote_ip, domain) logger.info "Blocked signup from #{request.remote_ip} for #{email}" - render :action => 'blocked' + render :action => "blocked" end !blocked diff --git a/app/controllers/user_preference_controller.rb b/app/controllers/user_preference_controller.rb index 60463967c..78f310ce5 100644 --- a/app/controllers/user_preference_controller.rb +++ b/app/controllers/user_preference_controller.rb @@ -13,7 +13,7 @@ class UserPreferenceController < ApplicationController prefs = @user.preferences - el1 = XML::Node.new 'preferences' + el1 = XML::Node.new "preferences" prefs.each do |pref| el1 << pref.to_xml_node @@ -41,7 +41,7 @@ class UserPreferenceController < ApplicationController doc = XML::Parser.string(request.raw_post).parse - doc.find('//preferences/preference').each do |pt| + doc.find("//preferences/preference").each do |pt| if preference = old_preferences.delete(pt["k"]) preference.v = pt["v"] elsif new_preferences.include?(pt["k"]) diff --git a/app/controllers/user_roles_controller.rb b/app/controllers/user_roles_controller.rb index 4316c5e94..8b1c2e8c0 100644 --- a/app/controllers/user_roles_controller.rb +++ b/app/controllers/user_roles_controller.rb @@ -1,5 +1,5 @@ class UserRolesController < ApplicationController - layout 'site' + layout "site" before_filter :authorize_web before_filter :require_user @@ -11,12 +11,12 @@ class UserRolesController < ApplicationController def grant @this_user.roles.create(:role => @role, :granter_id => @user.id) - redirect_to :controller => 'user', :action => 'view', :display_name => @this_user.display_name + redirect_to :controller => "user", :action => "view", :display_name => @this_user.display_name end def revoke UserRole.delete_all(:user_id => @this_user.id, :role => @role) - redirect_to :controller => 'user', :action => 'view', :display_name => @this_user.display_name + redirect_to :controller => "user", :action => "view", :display_name => @this_user.display_name end private @@ -26,8 +26,8 @@ class UserRolesController < ApplicationController # and return them to theuser page. def require_administrator unless @user.administrator? - flash[:error] = t 'user_role.filter.not_an_administrator' - redirect_to :controller => 'user', :action => 'view', :display_name => @this_user.display_name + flash[:error] = t "user_role.filter.not_an_administrator" + redirect_to :controller => "user", :action => "view", :display_name => @this_user.display_name end end @@ -37,8 +37,8 @@ class UserRolesController < ApplicationController def require_valid_role @role = params[:role] unless UserRole::ALL_ROLES.include?(@role) - flash[:error] = t('user_role.filter.not_a_role', :role => @role) - redirect_to :controller => 'user', :action => 'view', :display_name => @this_user.display_name + flash[:error] = t("user_role.filter.not_a_role", :role => @role) + redirect_to :controller => "user", :action => "view", :display_name => @this_user.display_name end end @@ -46,8 +46,8 @@ class UserRolesController < ApplicationController # checks that the user doesn't already have this role def not_in_role if @this_user.has_role? @role - flash[:error] = t('user_role.filter.already_has_role', :role => @role) - redirect_to :controller => 'user', :action => 'view', :display_name => @this_user.display_name + flash[:error] = t("user_role.filter.already_has_role", :role => @role) + redirect_to :controller => "user", :action => "view", :display_name => @this_user.display_name end end @@ -55,8 +55,8 @@ class UserRolesController < ApplicationController # checks that the user already has this role def in_role unless @this_user.has_role? @role - flash[:error] = t('user_role.filter.doesnt_have_role', :role => @role) - redirect_to :controller => 'user', :action => 'view', :display_name => @this_user.display_name + flash[:error] = t("user_role.filter.doesnt_have_role", :role => @role) + redirect_to :controller => "user", :action => "view", :display_name => @this_user.display_name end end end diff --git a/app/controllers/way_controller.rb b/app/controllers/way_controller.rb index 0c83b5b92..b13c91b08 100644 --- a/app/controllers/way_controller.rb +++ b/app/controllers/way_controller.rb @@ -1,5 +1,5 @@ class WayController < ApplicationController - require 'xml/libxml' + require "xml/libxml" skip_before_filter :verify_authenticity_token before_filter :authorize, :only => [:create, :update, :delete] @@ -84,11 +84,11 @@ class WayController < ApplicationController end def ways - unless params['ways'] + unless params["ways"] fail OSM::APIBadUserInput.new("The parameter ways is required, and must be of the form ways=id[,id[,id...]]") end - ids = params['ways'].split(',').collect(&:to_i) + ids = params["ways"].split(",").collect(&:to_i) if ids.length == 0 fail OSM::APIBadUserInput.new("No ways were given to search for") diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index b4a0ad192..329aa25e8 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1,5 +1,5 @@ module ApplicationHelper - require 'rexml/document' + require "rexml/document" def linkify(text) if text.html_safe? diff --git a/app/helpers/browse_helper.rb b/app/helpers/browse_helper.rb index e9aa6e4e8..4027ddb2f 100644 --- a/app/helpers/browse_helper.rb +++ b/app/helpers/browse_helper.rb @@ -5,9 +5,9 @@ module BrowseHelper else id = object.id end - name = t 'printable_name.with_id', :id => id.to_s + name = t "printable_name.with_id", :id => id.to_s if version - name = t 'printable_name.with_version', :id => name, :version => object.version.to_s + name = t "printable_name.with_version", :id => name, :version => object.version.to_s end # don't look at object tags if redacted, so as to avoid giving @@ -20,9 +20,9 @@ module BrowseHelper end if object.tags.include? "name:#{locale}" - name = t 'printable_name.with_name_html', :name => content_tag(:bdi, object.tags["name:#{locale}"].to_s), :id => content_tag(:bdi, name) - elsif object.tags.include? 'name' - name = t 'printable_name.with_name_html', :name => content_tag(:bdi, object.tags['name'].to_s), :id => content_tag(:bdi, name) + name = t "printable_name.with_name_html", :name => content_tag(:bdi, object.tags["name:#{locale}"].to_s), :id => content_tag(:bdi, name) + elsif object.tags.include? "name" + name = t "printable_name.with_name_html", :name => content_tag(:bdi, object.tags["name"].to_s), :id => content_tag(:bdi, name) end end @@ -46,13 +46,13 @@ module BrowseHelper if object.redacted? "" else - h(icon_tags(object).map { |k, v| k + '=' + v }.to_sentence) + h(icon_tags(object).map { |k, v| k + "=" + v }.to_sentence) end end def format_key(key) if url = wiki_link("key", key) - link_to h(key), url, :title => t('browse.tag_details.wiki_link.key', :key => key) + link_to h(key), url, :title => t("browse.tag_details.wiki_link.key", :key => key) else h(key) end @@ -60,13 +60,13 @@ module BrowseHelper def format_value(key, value) if wp = wikipedia_link(key, value) - link_to h(wp[:title]), wp[:url], :title => t('browse.tag_details.wikipedia_link', :page => wp[:title]) + link_to h(wp[:title]), wp[:url], :title => t("browse.tag_details.wikipedia_link", :page => wp[:title]) elsif wdt = wikidata_link(key, value) - link_to h(wdt[:title]), wdt[:url], :title => t('browse.tag_details.wikidata_link', :page => wdt[:title]) + link_to h(wdt[:title]), wdt[:url], :title => t("browse.tag_details.wikidata_link", :page => wdt[:title]) elsif url = wiki_link("tag", "#{key}=#{value}") - link_to h(value), url, :title => t('browse.tag_details.wiki_link.tag', :key => key, :value => value) + link_to h(value), url, :title => t("browse.tag_details.wiki_link.tag", :key => key, :value => value) elsif url = telephone_link(key, value) - link_to h(value), url, :title => t('browse.tag_details.telephone_link', :phone_number => value) + link_to h(value), url, :title => t("browse.tag_details.telephone_link", :phone_number => value) else linkify h(value) end @@ -123,7 +123,7 @@ module BrowseHelper lang = $1 else # Value is so default to English Wikipedia - lang = 'en' + lang = "en" end elsif key =~ /^wikipedia:(\S+)$/ # Language is in the key, so assume value is the title @@ -164,7 +164,7 @@ module BrowseHelper # remove all whitespace instead of encoding it http://tools.ietf.org/html/rfc3966#section-5.1.1 # "+1 (234) 567-8901 " -> "+1(234)567-8901" - value_no_whitespace = value.gsub(/\s+/, '') + value_no_whitespace = value.gsub(/\s+/, "") "tel:#{value_no_whitespace}" end diff --git a/app/helpers/changeset_helper.rb b/app/helpers/changeset_helper.rb index cae1335c4..c3141297c 100644 --- a/app/helpers/changeset_helper.rb +++ b/app/helpers/changeset_helper.rb @@ -3,7 +3,7 @@ module ChangesetHelper if changeset.user.data_public? link_to(changeset.user.display_name, user_path(changeset.user.display_name)) else - t('browse.anonymous') + t("browse.anonymous") end end diff --git a/app/helpers/geocoder_helper.rb b/app/helpers/geocoder_helper.rb index f0663108e..d8dc8c558 100644 --- a/app/helpers/geocoder_helper.rb +++ b/app/helpers/geocoder_helper.rb @@ -11,7 +11,7 @@ module GeocoderHelper end result.each do |key, value| - html_options[:data][key.to_s.tr('_', '-')] = value + html_options[:data][key.to_s.tr("_", "-")] = value end html = "" diff --git a/app/helpers/title_helper.rb b/app/helpers/title_helper.rb index a1a2125a1..b44628248 100644 --- a/app/helpers/title_helper.rb +++ b/app/helpers/title_helper.rb @@ -1,4 +1,4 @@ -require 'htmlentities' +require "htmlentities" module TitleHelper @@coder = HTMLEntities.new @@ -6,10 +6,10 @@ module TitleHelper def set_title(title = false) if title @title = @@coder.decode(title.gsub("<bdi>", "\u202a").gsub("</bdi>", "\u202c")) - response.headers["X-Page-Title"] = t('layouts.project_name.title') + ' | ' + @title + response.headers["X-Page-Title"] = t("layouts.project_name.title") + " | " + @title else @title = title - response.headers["X-Page-Title"] = t('layouts.project_name.title') + response.headers["X-Page-Title"] = t("layouts.project_name.title") end end end diff --git a/app/helpers/user_blocks_helper.rb b/app/helpers/user_blocks_helper.rb index f645d360b..b6d4a9a9f 100644 --- a/app/helpers/user_blocks_helper.rb +++ b/app/helpers/user_blocks_helper.rb @@ -5,16 +5,16 @@ module UserBlocksHelper def block_status(block) if block.active? if block.needs_view? - I18n.t('user_block.helper.until_login') + I18n.t("user_block.helper.until_login") else - I18n.t('user_block.helper.time_future', :time => distance_of_time_in_words_to_now(block.ends_at)) + I18n.t("user_block.helper.time_future", :time => distance_of_time_in_words_to_now(block.ends_at)) end else # the max of the last update time or the ends_at time is when this block finished # either because the user viewed the block (updated_at) or it expired or was # revoked (ends_at) last_time = [block.ends_at, block.updated_at].max - I18n.t('user_block.helper.time_past', :time => distance_of_time_in_words_to_now(last_time)) + I18n.t("user_block.helper.time_past", :time => distance_of_time_in_words_to_now(last_time)) end end end diff --git a/app/helpers/user_helper.rb b/app/helpers/user_helper.rb index 51978307a..a3d598086 100644 --- a/app/helpers/user_helper.rb +++ b/app/helpers/user_helper.rb @@ -45,7 +45,7 @@ module UserHelper # OpenID support def openid_logo - image_tag "openid_small.png", :alt => t('user.login.openid_logo_alt'), :class => "openid_logo" + image_tag "openid_small.png", :alt => t("user.login.openid_logo_alt"), :class => "openid_logo" end def openid_button(name, url) diff --git a/app/models/changeset.rb b/app/models/changeset.rb index 89aaa262d..11a098137 100644 --- a/app/models/changeset.rb +++ b/app/models/changeset.rb @@ -1,5 +1,5 @@ class Changeset < ActiveRecord::Base - require 'xml/libxml' + require "xml/libxml" belongs_to :user, :counter_cache => true @@ -13,7 +13,7 @@ class Changeset < ActiveRecord::Base has_many :old_relations has_many :comments, -> { where(:visible => true).order(:created_at) }, :class_name => "ChangesetComment" - has_and_belongs_to_many :subscribers, :class_name => 'User', :join_table => 'changesets_subscribers', :association_foreign_key => 'subscriber_id' + has_and_belongs_to_many :subscribers, :class_name => "User", :join_table => "changesets_subscribers", :association_foreign_key => "subscriber_id" validates_presence_of :id, :on => :update validates_presence_of :user_id, :created_at, :closed_at, :num_changes @@ -57,7 +57,7 @@ class Changeset < ActiveRecord::Base p = XML::Parser.string(xml, :options => XML::Parser::Options::NOERROR) doc = p.parse - doc.find('//osm/changeset').each do |pt| + doc.find("//osm/changeset").each do |pt| return Changeset.from_xml_node(pt, create) end fail OSM::APIBadXMLError.new("changeset", xml, "XML doesn't contain an osm/changeset element.") @@ -76,10 +76,10 @@ class Changeset < ActiveRecord::Base cs.num_changes = 0 end - pt.find('tag').each do |tag| - fail OSM::APIBadXMLError.new("changeset", pt, "tag is missing key") if tag['k'].nil? - fail OSM::APIBadXMLError.new("changeset", pt, "tag is missing value") if tag['v'].nil? - cs.add_tag_keyval(tag['k'], tag['v']) + pt.find("tag").each do |tag| + fail OSM::APIBadXMLError.new("changeset", pt, "tag is missing key") if tag["k"].nil? + fail OSM::APIBadXMLError.new("changeset", pt, "tag is missing value") if tag["v"].nil? + cs.add_tag_keyval(tag["k"], tag["v"]) end cs @@ -183,8 +183,8 @@ class Changeset < ActiveRecord::Base end def to_xml_node(user_display_name_cache = nil, include_discussion = false) - el1 = XML::Node.new 'changeset' - el1['id'] = id.to_s + el1 = XML::Node.new "changeset" + el1["id"] = id.to_s user_display_name_cache = {} if user_display_name_cache.nil? @@ -196,32 +196,32 @@ class Changeset < ActiveRecord::Base user_display_name_cache[user_id] = nil end - el1['user'] = user_display_name_cache[user_id] unless user_display_name_cache[user_id].nil? - el1['uid'] = user_id.to_s if user.data_public? + el1["user"] = user_display_name_cache[user_id] unless user_display_name_cache[user_id].nil? + el1["uid"] = user_id.to_s if user.data_public? tags.each do |k, v| - el2 = XML::Node.new('tag') - el2['k'] = k.to_s - el2['v'] = v.to_s + el2 = XML::Node.new("tag") + el2["k"] = k.to_s + el2["v"] = v.to_s el1 << el2 end - el1['created_at'] = created_at.xmlschema - el1['closed_at'] = closed_at.xmlschema unless is_open? - el1['open'] = is_open?.to_s + el1["created_at"] = created_at.xmlschema + el1["closed_at"] = closed_at.xmlschema unless is_open? + el1["open"] = is_open?.to_s - bbox.to_unscaled.add_bounds_to(el1, '_') if bbox.complete? + bbox.to_unscaled.add_bounds_to(el1, "_") if bbox.complete? - el1['comments_count'] = comments.count.to_s + el1["comments_count"] = comments.count.to_s if include_discussion - el2 = XML::Node.new('discussion') + el2 = XML::Node.new("discussion") comments.includes(:author).each do |comment| - el3 = XML::Node.new('comment') - el3['date'] = comment.created_at.xmlschema - el3['uid'] = comment.author.id.to_s if comment.author.data_public? - el3['user'] = comment.author.display_name.to_s if comment.author.data_public? - el4 = XML::Node.new('text') + el3 = XML::Node.new("comment") + el3["date"] = comment.created_at.xmlschema + el3["uid"] = comment.author.id.to_s if comment.author.data_public? + el3["user"] = comment.author.display_name.to_s if comment.author.data_public? + el4 = XML::Node.new("text") el4.content = comment.body.to_s el3 << el4 el2 << el3 diff --git a/app/models/client_application.rb b/app/models/client_application.rb index 34856f82b..84f5b978c 100644 --- a/app/models/client_application.rb +++ b/app/models/client_application.rb @@ -1,4 +1,4 @@ -require 'oauth' +require "oauth" class ClientApplication < ActiveRecord::Base belongs_to :user diff --git a/app/models/diary_entry.rb b/app/models/diary_entry.rb index a66eb599d..fa3c4c848 100644 --- a/app/models/diary_entry.rb +++ b/app/models/diary_entry.rb @@ -1,6 +1,6 @@ class DiaryEntry < ActiveRecord::Base belongs_to :user, :counter_cache => true - belongs_to :language, :foreign_key => 'language_code' + belongs_to :language, :foreign_key => "language_code" has_many :comments, -> { order(:id).preload(:user) }, :class_name => "DiaryComment" has_many :visible_comments, -> { joins(:user).where(:visible => true, :users => { :status => %w(active confirmed) }).order(:id) }, :class_name => "DiaryComment" diff --git a/app/models/language.rb b/app/models/language.rb index 8ccb00a5d..bb31c82ee 100644 --- a/app/models/language.rb +++ b/app/models/language.rb @@ -1,7 +1,7 @@ class Language < ActiveRecord::Base self.primary_key = "code" - has_many :diary_entries, :foreign_key => 'language' + has_many :diary_entries, :foreign_key => "language" def self.load(file) Language.transaction do diff --git a/app/models/message.rb b/app/models/message.rb index 65c2d29ed..10b6bda8a 100644 --- a/app/models/message.rb +++ b/app/models/message.rb @@ -1,4 +1,4 @@ -require 'validators' +require "validators" class Message < ActiveRecord::Base belongs_to :sender, :class_name => "User", :foreign_key => :from_user_id diff --git a/app/models/node.rb b/app/models/node.rb index 19210b8ac..1b81cc823 100644 --- a/app/models/node.rb +++ b/app/models/node.rb @@ -1,5 +1,5 @@ class Node < ActiveRecord::Base - require 'xml/libxml' + require "xml/libxml" include GeoRecord include ConsistencyValidations @@ -45,7 +45,7 @@ class Node < ActiveRecord::Base p = XML::Parser.string(xml) doc = p.parse - doc.find('//osm/node').each do |pt| + doc.find("//osm/node").each do |pt| return Node.from_xml_node(pt, create) end fail OSM::APIBadXMLError.new("node", xml, "XML doesn't contain an osm/node element.") @@ -56,22 +56,22 @@ class Node < ActiveRecord::Base def self.from_xml_node(pt, create = false) node = Node.new - fail OSM::APIBadXMLError.new("node", pt, "lat missing") if pt['lat'].nil? - fail OSM::APIBadXMLError.new("node", pt, "lon missing") if pt['lon'].nil? - node.lat = OSM.parse_float(pt['lat'], OSM::APIBadXMLError, "node", pt, "lat not a number") - node.lon = OSM.parse_float(pt['lon'], OSM::APIBadXMLError, "node", pt, "lon not a number") - fail OSM::APIBadXMLError.new("node", pt, "Changeset id is missing") if pt['changeset'].nil? - node.changeset_id = pt['changeset'].to_i + fail OSM::APIBadXMLError.new("node", pt, "lat missing") if pt["lat"].nil? + fail OSM::APIBadXMLError.new("node", pt, "lon missing") if pt["lon"].nil? + node.lat = OSM.parse_float(pt["lat"], OSM::APIBadXMLError, "node", pt, "lat not a number") + node.lon = OSM.parse_float(pt["lon"], OSM::APIBadXMLError, "node", pt, "lon not a number") + fail OSM::APIBadXMLError.new("node", pt, "Changeset id is missing") if pt["changeset"].nil? + node.changeset_id = pt["changeset"].to_i fail OSM::APIBadUserInput.new("The node is outside this world") unless node.in_world? # version must be present unless creating - fail OSM::APIBadXMLError.new("node", pt, "Version is required when updating") unless create || !pt['version'].nil? - node.version = create ? 0 : pt['version'].to_i + fail OSM::APIBadXMLError.new("node", pt, "Version is required when updating") unless create || !pt["version"].nil? + node.version = create ? 0 : pt["version"].to_i unless create - fail OSM::APIBadXMLError.new("node", pt, "ID is required when updating.") if pt['id'].nil? - node.id = pt['id'].to_i + fail OSM::APIBadXMLError.new("node", pt, "ID is required when updating.") if pt["id"].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 fail OSM::APIBadUserInput.new("ID of node cannot be zero when updating.") if node.id == 0 @@ -86,10 +86,10 @@ class Node < ActiveRecord::Base node.tags = {} # Add in any tags from the XML - pt.find('tag').each do |tag| - fail OSM::APIBadXMLError.new("node", pt, "tag is missing key") if tag['k'].nil? - fail OSM::APIBadXMLError.new("node", pt, "tag is missing value") if tag['v'].nil? - node.add_tag_key_val(tag['k'], tag['v']) + pt.find("tag").each do |tag| + fail OSM::APIBadXMLError.new("node", pt, "tag is missing key") if tag["k"].nil? + fail OSM::APIBadXMLError.new("node", pt, "tag is missing value") if tag["v"].nil? + node.add_tag_key_val(tag["k"], tag["v"]) end node @@ -172,14 +172,14 @@ class Node < ActiveRecord::Base end def to_xml_node(changeset_cache = {}, user_display_name_cache = {}) - el = XML::Node.new 'node' - el['id'] = id.to_s + el = XML::Node.new "node" + el["id"] = id.to_s add_metadata_to_xml_node(el, self, changeset_cache, user_display_name_cache) if self.visible? - el['lat'] = lat.to_s - el['lon'] = lon.to_s + el["lat"] = lat.to_s + el["lon"] = lon.to_s end add_tags_to_xml_node(el, node_tags) diff --git a/app/models/notifier.rb b/app/models/notifier.rb index be7b8d145..bc018cbe8 100644 --- a/app/models/notifier.rb +++ b/app/models/notifier.rb @@ -12,7 +12,7 @@ class Notifier < ActionMailer::Base :confirm_string => token.token) mail :to => user.email, - :subject => I18n.t('notifier.signup_confirm.subject') + :subject => I18n.t("notifier.signup_confirm.subject") end end @@ -24,7 +24,7 @@ class Notifier < ActionMailer::Base :confirm_string => token.token) mail :to => user.new_email, - :subject => I18n.t('notifier.email_confirm.subject') + :subject => I18n.t("notifier.email_confirm.subject") end end @@ -35,7 +35,7 @@ class Notifier < ActionMailer::Base :token => token.token) mail :to => user.email, - :subject => I18n.t('notifier.lost_password.subject') + :subject => I18n.t("notifier.lost_password.subject") end end @@ -48,7 +48,7 @@ class Notifier < ActionMailer::Base @possible_points = possible_points mail :to => trace.user.email, - :subject => I18n.t('notifier.gpx_notification.success.subject') + :subject => I18n.t("notifier.gpx_notification.success.subject") end end @@ -60,7 +60,7 @@ class Notifier < ActionMailer::Base @error = error mail :to => trace.user.email, - :subject => I18n.t('notifier.gpx_notification.failure.subject') + :subject => I18n.t("notifier.gpx_notification.failure.subject") end end @@ -79,7 +79,7 @@ class Notifier < ActionMailer::Base mail :from => from_address(message.sender.display_name, "m", message.id, message.digest), :to => message.recipient.email, - :subject => I18n.t('notifier.message_notification.subject_header', :subject => message.title) + :subject => I18n.t("notifier.message_notification.subject_header", :subject => message.title) end end @@ -109,7 +109,7 @@ class Notifier < ActionMailer::Base mail :from => from_address(comment.user.display_name, "c", comment.id, comment.digest), :to => comment.diary_entry.user.email, - :subject => I18n.t('notifier.diary_comment_notification.subject', :user => comment.user.display_name) + :subject => I18n.t("notifier.diary_comment_notification.subject", :user => comment.user.display_name) end end @@ -118,7 +118,7 @@ class Notifier < ActionMailer::Base @friend = friend mail :to => friend.befriendee.email, - :subject => I18n.t('notifier.friend_notification.subject', :user => friend.befriender.display_name) + :subject => I18n.t("notifier.friend_notification.subject", :user => friend.befriender.display_name) end end @@ -152,7 +152,7 @@ class Notifier < ActionMailer::Base @comment = comment.body @owner = recipient == comment.changeset.user @commenter = comment.author.display_name - @changeset_comment = comment.changeset.tags['comment'].presence + @changeset_comment = comment.changeset.tags["comment"].presence @time = comment.created_at @changeset_author = comment.changeset.user.display_name diff --git a/app/models/oauth2_token.rb b/app/models/oauth2_token.rb index 6dd421ab1..1e67194fe 100644 --- a/app/models/oauth2_token.rb +++ b/app/models/oauth2_token.rb @@ -2,7 +2,7 @@ class Oauth2Token < AccessToken attr_accessor :state def as_json(_options = {}) - d = { :access_token => token, :token_type => 'bearer' } + d = { :access_token => token, :token_type => "bearer" } d[:expires_in] = expires_in if expires_at d end diff --git a/app/models/old_node.rb b/app/models/old_node.rb index 00f46dba6..5b5739ff2 100644 --- a/app/models/old_node.rb +++ b/app/models/old_node.rb @@ -20,7 +20,7 @@ class OldNode < ActiveRecord::Base belongs_to :redaction belongs_to :current_node, :class_name => "Node", :foreign_key => "node_id" - has_many :old_tags, :class_name => 'OldNodeTag', :foreign_key => [:node_id, :version] + has_many :old_tags, :class_name => "OldNodeTag", :foreign_key => [:node_id, :version] def validate_position errors.add(:base, "Node is not in the world") unless in_world? @@ -46,14 +46,14 @@ class OldNode < ActiveRecord::Base end def to_xml_node(changeset_cache = {}, user_display_name_cache = {}) - el = XML::Node.new 'node' - el['id'] = node_id.to_s + el = XML::Node.new "node" + el["id"] = node_id.to_s add_metadata_to_xml_node(el, self, changeset_cache, user_display_name_cache) if self.visible? - el['lat'] = lat.to_s - el['lon'] = lon.to_s + el["lat"] = lat.to_s + el["lon"] = lon.to_s end add_tags_to_xml_node(el, old_tags) diff --git a/app/models/old_relation.rb b/app/models/old_relation.rb index 8e0727743..deba6ecb6 100644 --- a/app/models/old_relation.rb +++ b/app/models/old_relation.rb @@ -13,8 +13,8 @@ class OldRelation < ActiveRecord::Base belongs_to :redaction belongs_to :current_relation, :class_name => "Relation", :foreign_key => "relation_id" - has_many :old_members, -> { order(:sequence_id) }, :class_name => 'OldRelationMember', :foreign_key => [:relation_id, :version] - has_many :old_tags, :class_name => 'OldRelationTag', :foreign_key => [:relation_id, :version] + has_many :old_members, -> { order(:sequence_id) }, :class_name => "OldRelationMember", :foreign_key => [:relation_id, :version] + has_many :old_tags, :class_name => "OldRelationTag", :foreign_key => [:relation_id, :version] validates_associated :changeset @@ -73,16 +73,16 @@ class OldRelation < ActiveRecord::Base end def to_xml_node(changeset_cache = {}, user_display_name_cache = {}) - el = XML::Node.new 'relation' - el['id'] = relation_id.to_s + el = XML::Node.new "relation" + el["id"] = relation_id.to_s add_metadata_to_xml_node(el, self, changeset_cache, user_display_name_cache) old_members.each do |member| - member_el = XML::Node.new 'member' - member_el['type'] = member.member_type.to_s.downcase - member_el['ref'] = member.member_id.to_s # "id" is considered uncool here as it should be unique in XML - member_el['role'] = member.member_role.to_s + member_el = XML::Node.new "member" + member_el["type"] = member.member_type.to_s.downcase + member_el["ref"] = member.member_id.to_s # "id" is considered uncool here as it should be unique in XML + member_el["role"] = member.member_role.to_s el << member_el end diff --git a/app/models/old_way.rb b/app/models/old_way.rb index 3447cf6bb..92fe19ffb 100644 --- a/app/models/old_way.rb +++ b/app/models/old_way.rb @@ -13,8 +13,8 @@ class OldWay < ActiveRecord::Base belongs_to :redaction belongs_to :current_way, :class_name => "Way", :foreign_key => "way_id" - has_many :old_nodes, :class_name => 'OldWayNode', :foreign_key => [:way_id, :version] - has_many :old_tags, :class_name => 'OldWayTag', :foreign_key => [:way_id, :version] + has_many :old_nodes, :class_name => "OldWayNode", :foreign_key => [:way_id, :version] + has_many :old_tags, :class_name => "OldWayTag", :foreign_key => [:way_id, :version] validates_associated :changeset @@ -65,14 +65,14 @@ class OldWay < ActiveRecord::Base attr_writer :tags def to_xml_node(changeset_cache = {}, user_display_name_cache = {}) - el = XML::Node.new 'way' - el['id'] = way_id.to_s + el = XML::Node.new "way" + el["id"] = way_id.to_s add_metadata_to_xml_node(el, self, changeset_cache, user_display_name_cache) old_nodes.each do |nd| # FIXME need to make sure they come back in the right order - node_el = XML::Node.new 'nd' - node_el['ref'] = nd.node_id.to_s + node_el = XML::Node.new "nd" + node_el["ref"] = nd.node_id.to_s el << node_el end @@ -98,7 +98,7 @@ class OldWay < ActiveRecord::Base def get_nodes_revert(timestamp) points = [] nds.each do |n| - oldnode = OldNode.where('node_id = ? AND timestamp <= ?', n, timestamp).unredacted.order("timestamp DESC").first + oldnode = OldNode.where("node_id = ? AND timestamp <= ?", n, timestamp).unredacted.order("timestamp DESC").first curnode = Node.find(n) id = n reuse = curnode.visible diff --git a/app/models/relation.rb b/app/models/relation.rb index 39c1ad834..120fe4723 100644 --- a/app/models/relation.rb +++ b/app/models/relation.rb @@ -1,5 +1,5 @@ class Relation < ActiveRecord::Base - require 'xml/libxml' + require "xml/libxml" include ConsistencyValidations include NotRedactable @@ -37,7 +37,7 @@ class Relation < ActiveRecord::Base p = XML::Parser.string(xml) doc = p.parse - doc.find('//osm/relation').each do |pt| + doc.find("//osm/relation").each do |pt| return Relation.from_xml_node(pt, create) end fail OSM::APIBadXMLError.new("node", xml, "XML doesn't contain an osm/relation element.") @@ -48,14 +48,14 @@ class Relation < ActiveRecord::Base def self.from_xml_node(pt, create = false) relation = Relation.new - fail OSM::APIBadXMLError.new("relation", pt, "Version is required when updating") unless create || !pt['version'].nil? - relation.version = pt['version'] - fail OSM::APIBadXMLError.new("relation", pt, "Changeset id is missing") if pt['changeset'].nil? - relation.changeset_id = pt['changeset'] + fail OSM::APIBadXMLError.new("relation", pt, "Version is required when updating") unless create || !pt["version"].nil? + relation.version = pt["version"] + fail OSM::APIBadXMLError.new("relation", pt, "Changeset id is missing") if pt["changeset"].nil? + relation.changeset_id = pt["changeset"] unless create - fail OSM::APIBadXMLError.new("relation", pt, "ID is required when updating") if pt['id'].nil? - relation.id = pt['id'].to_i + fail OSM::APIBadXMLError.new("relation", pt, "ID is required when updating") if pt["id"].nil? + 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 fail OSM::APIBadUserInput.new("ID of relation cannot be zero when updating.") if relation.id == 0 @@ -70,10 +70,10 @@ class Relation < ActiveRecord::Base relation.tags = {} # Add in any tags from the XML - pt.find('tag').each do |tag| - fail OSM::APIBadXMLError.new("relation", pt, "tag is missing key") if tag['k'].nil? - fail OSM::APIBadXMLError.new("relation", pt, "tag is missing value") if tag['v'].nil? - relation.add_tag_keyval(tag['k'], tag['v']) + pt.find("tag").each do |tag| + fail OSM::APIBadXMLError.new("relation", pt, "tag is missing key") if tag["k"].nil? + fail OSM::APIBadXMLError.new("relation", pt, "tag is missing value") if tag["v"].nil? + relation.add_tag_keyval(tag["k"], tag["v"]) end # need to initialise the relation members array explicitly, as if this @@ -82,16 +82,16 @@ class Relation < ActiveRecord::Base # empty, as intended. relation.members = [] - pt.find('member').each do |member| + pt.find("member").each do |member| # member_type = logger.debug "each member" - fail OSM::APIBadXMLError.new("relation", pt, "The #{member['type']} is not allowed only, #{TYPES.inspect} allowed") unless TYPES.include? member['type'] + fail OSM::APIBadXMLError.new("relation", pt, "The #{member['type']} is not allowed only, #{TYPES.inspect} allowed") unless TYPES.include? member["type"] logger.debug "after raise" # member_ref = member['ref'] # member_role - member['role'] ||= "" # Allow the upload to not include this, in which case we default to an empty string. - logger.debug member['role'] - relation.add_member(member['type'].classify, member['ref'], member['role']) + member["role"] ||= "" # Allow the upload to not include this, in which case we default to an empty string. + logger.debug member["role"] + relation.add_member(member["type"].classify, member["ref"], member["role"]) end fail OSM::APIBadUserInput.new("Some bad xml in relation") if relation.nil? @@ -105,8 +105,8 @@ class Relation < ActiveRecord::Base end def to_xml_node(visible_members = nil, changeset_cache = {}, user_display_name_cache = {}) - el = XML::Node.new 'relation' - el['id'] = id.to_s + el = XML::Node.new "relation" + el["id"] = id.to_s add_metadata_to_xml_node(el, self, changeset_cache, user_display_name_cache) @@ -123,10 +123,10 @@ class Relation < ActiveRecord::Base next unless p - member_el = XML::Node.new 'member' - member_el['type'] = member.member_type.downcase - member_el['ref'] = member.member_id.to_s - member_el['role'] = member.member_role + member_el = XML::Node.new "member" + member_el["type"] = member.member_type.downcase + member_el["ref"] = member.member_id.to_s + member_el["role"] = member.member_role el << member_el end diff --git a/app/models/request_token.rb b/app/models/request_token.rb index 0d55375ff..02f168346 100644 --- a/app/models/request_token.rb +++ b/app/models/request_token.rb @@ -35,7 +35,7 @@ class RequestToken < OauthToken end def oob? - callback_url.nil? || callback_url.downcase == 'oob' + callback_url.nil? || callback_url.downcase == "oob" end def oauth10? diff --git a/app/models/trace.rb b/app/models/trace.rb index d8cc6048a..1a935293a 100644 --- a/app/models/trace.rb +++ b/app/models/trace.rb @@ -2,8 +2,8 @@ class Trace < ActiveRecord::Base self.table_name = "gpx_files" belongs_to :user, :counter_cache => true - has_many :tags, :class_name => 'Tracetag', :foreign_key => 'gpx_id', :dependent => :delete_all - has_many :points, :class_name => 'Tracepoint', :foreign_key => 'gpx_id', :dependent => :delete_all + has_many :tags, :class_name => "Tracetag", :foreign_key => "gpx_id", :dependent => :delete_all + has_many :points, :class_name => "Tracepoint", :foreign_key => "gpx_id", :dependent => :delete_all scope :visible, -> { where(:visible => true) } scope :visible_to, ->(u) { visible.where("visibility IN ('public', 'identifiable') OR user_id = ?", u) } @@ -30,7 +30,7 @@ class Trace < ActiveRecord::Base end def tagstring=(s) - if s.include? ',' + if s.include? "," self.tags = s.split(/\s*,\s*/).select { |tag| tag !~ /^\s*$/ }.collect {|tag| tt = Tracetag.new tt.tag = tag @@ -151,22 +151,22 @@ class Trace < ActiveRecord::Base end def to_xml_node - el1 = XML::Node.new 'gpx_file' - el1['id'] = id.to_s - el1['name'] = name.to_s - el1['lat'] = latitude.to_s if inserted - el1['lon'] = longitude.to_s if inserted - el1['user'] = user.display_name - el1['visibility'] = visibility - el1['pending'] = (!inserted).to_s - el1['timestamp'] = timestamp.xmlschema - - el2 = XML::Node.new 'description' + el1 = XML::Node.new "gpx_file" + el1["id"] = id.to_s + el1["name"] = name.to_s + el1["lat"] = latitude.to_s if inserted + el1["lon"] = longitude.to_s if inserted + el1["user"] = user.display_name + el1["visibility"] = visibility + el1["pending"] = (!inserted).to_s + el1["timestamp"] = timestamp.xmlschema + + el2 = XML::Node.new "description" el2 << description el1 << el2 tags.each do |tag| - el2 = XML::Node.new('tag') + el2 = XML::Node.new("tag") el2 << tag.tag el1 << el2 end @@ -179,7 +179,7 @@ class Trace < ActiveRecord::Base p = XML::Parser.string(xml) doc = p.parse - doc.find('//osm/gpx_file').each do |pt| + doc.find("//osm/gpx_file").each do |pt| return Trace.from_xml_node(pt, create) end @@ -191,12 +191,12 @@ class Trace < ActiveRecord::Base def self.from_xml_node(pt, create = false) trace = Trace.new - fail OSM::APIBadXMLError.new("trace", pt, "visibility missing") if pt['visibility'].nil? - trace.visibility = pt['visibility'] + fail OSM::APIBadXMLError.new("trace", pt, "visibility missing") if pt["visibility"].nil? + trace.visibility = pt["visibility"] unless create - fail OSM::APIBadXMLError.new("trace", pt, "ID is required when updating.") if pt['id'].nil? - trace.id = pt['id'].to_i + fail OSM::APIBadXMLError.new("trace", pt, "ID is required when updating.") if pt["id"].nil? + trace.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 fail OSM::APIBadUserInput.new("ID of trace cannot be zero when updating.") if trace.id == 0 @@ -207,11 +207,11 @@ class Trace < ActiveRecord::Base # and set manually before the actual delete trace.visible = true - description = pt.find('description').first + description = pt.find("description").first fail OSM::APIBadXMLError.new("trace", pt, "description missing") if description.nil? trace.description = description.content - pt.find('tag').each do |tag| + pt.find("tag").each do |tag| trace.tags.build(:tag => tag.content) end diff --git a/app/models/tracepoint.rb b/app/models/tracepoint.rb index 879702822..398a849d0 100644 --- a/app/models/tracepoint.rb +++ b/app/models/tracepoint.rb @@ -9,12 +9,12 @@ class Tracepoint < ActiveRecord::Base validates_associated :trace validates_presence_of :timestamp - belongs_to :trace, :foreign_key => 'gpx_id' + belongs_to :trace, :foreign_key => "gpx_id" def to_xml_node(print_timestamp = false) - el1 = XML::Node.new 'trkpt' - el1['lat'] = lat.to_s - el1['lon'] = lon.to_s + el1 = XML::Node.new "trkpt" + el1["lat"] = lat.to_s + el1["lon"] = lon.to_s el1 << (XML::Node.new("time") << timestamp.xmlschema) if print_timestamp el1 end diff --git a/app/models/tracetag.rb b/app/models/tracetag.rb index 00f195e69..2614e5971 100644 --- a/app/models/tracetag.rb +++ b/app/models/tracetag.rb @@ -4,5 +4,5 @@ class Tracetag < ActiveRecord::Base validates_format_of :tag, :with => /\A[^\/;.,?]*\z/ validates_length_of :tag, :within => 1..255 - belongs_to :trace, :foreign_key => 'gpx_id' + belongs_to :trace, :foreign_key => "gpx_id" end diff --git a/app/models/user.rb b/app/models/user.rb index 132f0de21..e6a11b6bd 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1,5 +1,5 @@ class User < ActiveRecord::Base - require 'xml/libxml' + require "xml/libxml" has_many :traces, -> { where(:visible => true) } has_many :diary_entries, -> { order(:created_at => :desc) } @@ -13,7 +13,7 @@ class User < ActiveRecord::Base has_many :preferences, :class_name => "UserPreference" has_many :changesets, -> { order(:created_at => :desc) } has_many :changeset_comments, :foreign_key => :author_id - has_and_belongs_to_many :changeset_subscriptions, :class_name => 'Changeset', :join_table => 'changesets_subscribers', :foreign_key => 'subscriber_id' + has_and_belongs_to_many :changeset_subscriptions, :class_name => "Changeset", :join_table => "changesets_subscribers", :foreign_key => "subscriber_id" has_many :note_comments, :foreign_key => :author_id has_many :notes, :through => :note_comments @@ -100,14 +100,14 @@ class User < ActiveRecord::Base end def to_xml_node - el1 = XML::Node.new 'user' - el1['display_name'] = display_name.to_s - el1['account_created'] = creation_time.xmlschema + el1 = XML::Node.new "user" + el1["display_name"] = display_name.to_s + el1["account_created"] = creation_time.xmlschema if home_lat && home_lon - home = XML::Node.new 'home' - home['lat'] = home_lat.to_s - home['lon'] = home_lon.to_s - home['zoom'] = home_zoom.to_s + home = XML::Node.new "home" + home["lat"] = home_lat.to_s + home["lon"] = home_lon.to_s + home["zoom"] = home_zoom.to_s el1 << home end el1 @@ -167,13 +167,13 @@ class User < ActiveRecord::Base ## # returns true if the user has the moderator role, false otherwise def moderator? - has_role? 'moderator' + has_role? "moderator" end ## # returns true if the user has the administrator role, false otherwise def administrator? - has_role? 'administrator' + has_role? "administrator" end ## diff --git a/app/models/user_block.rb b/app/models/user_block.rb index 6ebdeee0b..3759afd69 100644 --- a/app/models/user_block.rb +++ b/app/models/user_block.rb @@ -44,7 +44,7 @@ class UserBlock < ActiveRecord::Base # block. this should be caught and dealt with in the controller, # but i've also included it here just in case. def moderator_permissions - errors.add(:base, I18n.t('user_block.model.non_moderator_update')) if creator_id_changed? && !creator.moderator? - errors.add(:base, I18n.t('user_block.model.non_moderator_revoke')) unless revoker_id.nil? || revoker.moderator? + errors.add(:base, I18n.t("user_block.model.non_moderator_update")) if creator_id_changed? && !creator.moderator? + errors.add(:base, I18n.t("user_block.model.non_moderator_revoke")) unless revoker_id.nil? || revoker.moderator? end end diff --git a/app/models/user_preference.rb b/app/models/user_preference.rb index 969a368e3..0533ccad2 100644 --- a/app/models/user_preference.rb +++ b/app/models/user_preference.rb @@ -8,9 +8,9 @@ class UserPreference < ActiveRecord::Base # Turn this Node in to an XML Node without the <osm> wrapper. def to_xml_node - el1 = XML::Node.new 'preference' - el1['k'] = k - el1['v'] = v + el1 = XML::Node.new "preference" + el1["k"] = k + el1["v"] = v el1 end diff --git a/app/models/way.rb b/app/models/way.rb index 2d427051c..9b1765d12 100644 --- a/app/models/way.rb +++ b/app/models/way.rb @@ -1,5 +1,5 @@ class Way < ActiveRecord::Base - require 'xml/libxml' + require "xml/libxml" include ConsistencyValidations include NotRedactable @@ -35,7 +35,7 @@ class Way < ActiveRecord::Base p = XML::Parser.string(xml) doc = p.parse - doc.find('//osm/way').each do |pt| + doc.find("//osm/way").each do |pt| return Way.from_xml_node(pt, create) end fail OSM::APIBadXMLError.new("node", xml, "XML doesn't contain an osm/way element.") @@ -46,14 +46,14 @@ class Way < ActiveRecord::Base def self.from_xml_node(pt, create = false) way = Way.new - fail OSM::APIBadXMLError.new("way", pt, "Version is required when updating") unless create || !pt['version'].nil? - way.version = pt['version'] - fail OSM::APIBadXMLError.new("way", pt, "Changeset id is missing") if pt['changeset'].nil? - way.changeset_id = pt['changeset'] + fail OSM::APIBadXMLError.new("way", pt, "Version is required when updating") unless create || !pt["version"].nil? + way.version = pt["version"] + fail OSM::APIBadXMLError.new("way", pt, "Changeset id is missing") if pt["changeset"].nil? + way.changeset_id = pt["changeset"] unless create - fail OSM::APIBadXMLError.new("way", pt, "ID is required when updating") if pt['id'].nil? - way.id = pt['id'].to_i + fail OSM::APIBadXMLError.new("way", pt, "ID is required when updating") if pt["id"].nil? + 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 fail OSM::APIBadUserInput.new("ID of way cannot be zero when updating.") if way.id == 0 @@ -68,14 +68,14 @@ class Way < ActiveRecord::Base way.tags = {} # Add in any tags from the XML - pt.find('tag').each do |tag| - fail OSM::APIBadXMLError.new("way", pt, "tag is missing key") if tag['k'].nil? - fail OSM::APIBadXMLError.new("way", pt, "tag is missing value") if tag['v'].nil? - way.add_tag_keyval(tag['k'], tag['v']) + pt.find("tag").each do |tag| + fail OSM::APIBadXMLError.new("way", pt, "tag is missing key") if tag["k"].nil? + fail OSM::APIBadXMLError.new("way", pt, "tag is missing value") if tag["v"].nil? + way.add_tag_keyval(tag["k"], tag["v"]) end - pt.find('nd').each do |nd| - way.add_nd_num(nd['ref']) + pt.find("nd").each do |nd| + way.add_nd_num(nd["ref"]) end way @@ -99,8 +99,8 @@ class Way < ActiveRecord::Base end def to_xml_node(visible_nodes = nil, changeset_cache = {}, user_display_name_cache = {}) - el = XML::Node.new 'way' - el['id'] = id.to_s + el = XML::Node.new "way" + el["id"] = id.to_s add_metadata_to_xml_node(el, self, changeset_cache, user_display_name_cache) @@ -121,10 +121,10 @@ class Way < ActiveRecord::Base end ordered_nodes.each do |nd_id| - next unless nd_id && nd_id != '0' + next unless nd_id && nd_id != "0" - node_el = XML::Node.new 'nd' - node_el['ref'] = nd_id + node_el = XML::Node.new "nd" + node_el["ref"] = nd_id el << node_el end diff --git a/config/application.rb b/config/application.rb index 12d777c24..8ba628c8e 100644 --- a/config/application.rb +++ b/config/application.rb @@ -1,6 +1,6 @@ -require File.expand_path('../boot', __FILE__) +require File.expand_path("../boot", __FILE__) -require File.expand_path('../preinitializer', __FILE__) +require File.expand_path("../preinitializer", __FILE__) if STATUS == :database_offline require "action_controller/railtie" @@ -9,7 +9,7 @@ if STATUS == :database_offline require "sprockets/railtie" require "rails/test_unit/railtie" else - require 'rails/all' + require "rails/all" end # Require the gems listed in Gemfile, including any gems diff --git a/config/boot.rb b/config/boot.rb index 6b750f00b..fb24cf2ed 100644 --- a/config/boot.rb +++ b/config/boot.rb @@ -1,3 +1,3 @@ -ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) +ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", __FILE__) -require 'bundler/setup' # Set up gems listed in the Gemfile. +require "bundler/setup" # Set up gems listed in the Gemfile. diff --git a/config/environment.rb b/config/environment.rb index ee8d90dc6..171198560 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -1,5 +1,5 @@ # Load the Rails application. -require File.expand_path('../application', __FILE__) +require File.expand_path("../application", __FILE__) # Initialize the Rails application. Rails.application.initialize! diff --git a/config/environments/production.rb b/config/environments/production.rb index 3c6c21cef..707202c52 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -22,7 +22,7 @@ OpenStreetMap::Application.configure do # Disable serving static files from the `/public` folder by default since # Apache or NGINX already handles this. - config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present? + config.serve_static_files = ENV["RAILS_SERVE_STATIC_FILES"].present? # Compress JavaScripts and CSS. config.assets.js_compressor = :uglifier diff --git a/config/environments/test.rb b/config/environments/test.rb index 3c8b55457..06bda1839 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -14,7 +14,7 @@ OpenStreetMap::Application.configure do # Configure static file server for tests with Cache-Control for performance. config.serve_static_files = true - config.static_cache_control = 'public, max-age=3600' + config.static_cache_control = "public, max-age=3600" # Show full error reports and disable caching. config.consider_all_requests_local = true diff --git a/config/initializers/action_mailer.rb b/config/initializers/action_mailer.rb index 6a42c6dfe..6b27bb686 100644 --- a/config/initializers/action_mailer.rb +++ b/config/initializers/action_mailer.rb @@ -1,7 +1,7 @@ # Configure ActionMailer SMTP settings ActionMailer::Base.smtp_settings = { - :address => 'localhost', + :address => "localhost", :port => 25, - :domain => 'localhost', + :domain => "localhost", :enable_starttls_auto => false } diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb index 21d9312a4..ffc283931 100644 --- a/config/initializers/assets.rb +++ b/config/initializers/assets.rb @@ -1,7 +1,7 @@ # Be sure to restart your server when you modify this file. # Version of your assets, change this if you want to expire all your assets. -Rails.application.config.assets.version = '1.0' +Rails.application.config.assets.version = "1.0" # Add additional assets to the asset load path # Rails.application.config.assets.paths << Emoji.images_path diff --git a/config/initializers/classic_pagination.rb b/config/initializers/classic_pagination.rb index 96e7f64f6..d87993a2b 100644 --- a/config/initializers/classic_pagination.rb +++ b/config/initializers/classic_pagination.rb @@ -21,8 +21,8 @@ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #++ -require 'classic_pagination/pagination' -require 'classic_pagination/pagination_helper' +require "classic_pagination/pagination" +require "classic_pagination/pagination_helper" ActionController::Base.class_eval do include ActionController::Pagination diff --git a/config/initializers/cors.rb b/config/initializers/cors.rb index 1a8ce106d..320c1db2c 100644 --- a/config/initializers/cors.rb +++ b/config/initializers/cors.rb @@ -7,8 +7,8 @@ module OpenStreetMap class Cors < Rack::Cors def call(env) status, headers, body = super env - if headers['Access-Control-Allow-Origin'] - headers['Cache-Control'] = 'no-cache' + if headers["Access-Control-Allow-Origin"] + headers["Cache-Control"] = "no-cache" end [status, headers, body] end diff --git a/config/initializers/field_error.rb b/config/initializers/field_error.rb index 6ddacda96..3ccd1d391 100644 --- a/config/initializers/field_error.rb +++ b/config/initializers/field_error.rb @@ -2,7 +2,7 @@ ActionView::Base.field_error_proc = proc do |html_tag, _instance| class_attr_index = html_tag.index 'class="' if class_attr_index - html_tag.insert class_attr_index + 7, 'field_with_errors ' + html_tag.insert class_attr_index + 7, "field_with_errors " else html_tag.insert html_tag.index(/\/?>/), ' class="field_with_errors"' end diff --git a/config/initializers/konacha.rb b/config/initializers/konacha.rb index 2924efab6..f97b19aaf 100644 --- a/config/initializers/konacha.rb +++ b/config/initializers/konacha.rb @@ -1,5 +1,5 @@ Konacha.configure do |config| - require 'capybara/poltergeist' + require "capybara/poltergeist" config.spec_dir = "test/javascripts" config.driver = :poltergeist end if defined?(Konacha) diff --git a/config/initializers/oauth.rb b/config/initializers/oauth.rb index fa9685d70..437a00c97 100644 --- a/config/initializers/oauth.rb +++ b/config/initializers/oauth.rb @@ -1,4 +1,4 @@ -require 'oauth/rack/oauth_filter' +require "oauth/rack/oauth_filter" Rails.configuration.middleware.use OAuth::Rack::OAuthFilter diff --git a/config/initializers/output_compression.rb b/config/initializers/output_compression.rb index 5a42e2a16..ab246314d 100644 --- a/config/initializers/output_compression.rb +++ b/config/initializers/output_compression.rb @@ -1 +1 @@ -require 'output_compression/output_compression' +require "output_compression/output_compression" diff --git a/config/initializers/r2.rb b/config/initializers/r2.rb index 114041202..bad88e1ba 100644 --- a/config/initializers/r2.rb +++ b/config/initializers/r2.rb @@ -1,5 +1,5 @@ class R2Template < Tilt::Template - self.default_mime_type = 'text/css' + self.default_mime_type = "text/css" def self.engine_initialized? defined? ::R2 diff --git a/config/initializers/sanitize.rb b/config/initializers/sanitize.rb index 7ae94feef..c7be1380f 100644 --- a/config/initializers/sanitize.rb +++ b/config/initializers/sanitize.rb @@ -1,5 +1,5 @@ Sanitize::Config::OSM = Sanitize::Config::RELAXED.dup Sanitize::Config::OSM[:elements] -= %w(div style) -Sanitize::Config::OSM[:add_attributes] = { 'a' => { 'rel' => 'nofollow' } } +Sanitize::Config::OSM[:add_attributes] = { "a" => { "rel" => "nofollow" } } Sanitize::Config::OSM[:remove_contents] = %w(script style) diff --git a/config/initializers/session_store.rb b/config/initializers/session_store.rb index 97886ab3e..0f9e89970 100644 --- a/config/initializers/session_store.rb +++ b/config/initializers/session_store.rb @@ -3,5 +3,5 @@ if defined?(MEMCACHE_SERVERS) Rails.application.config.session_store :mem_cache_store, :memcache_server => MEMCACHE_SERVERS, :namespace => "rails:session", :key => "_osm_session" else - Rails.application.config.session_store :cache_store, :key => '_osm_session' + Rails.application.config.session_store :cache_store, :key => "_osm_session" end diff --git a/config/preinitializer.rb b/config/preinitializer.rb index 34a9a3858..de8367e9f 100644 --- a/config/preinitializer.rb +++ b/config/preinitializer.rb @@ -1,9 +1,9 @@ -require 'yaml' +require "yaml" if defined?(Rake.application) && Rake.application.top_level_tasks.grep(/^(default$|test(:|$))/).any? env = "test" else - env = ENV['RAILS_ENV'] || 'development' + env = ENV["RAILS_ENV"] || "development" end config = YAML.load_file(File.expand_path(env == "test" ? "../example.application.yml" : "../application.yml", __FILE__)) diff --git a/config/routes.rb b/config/routes.rb index dc24e3000..c9563f8d4 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,287 +1,287 @@ OpenStreetMap::Application.routes.draw do # API - match 'api/capabilities' => 'api#capabilities', :via => :get - match 'api/0.6/capabilities' => 'api#capabilities', :via => :get - match 'api/0.6/permissions' => 'api#permissions', :via => :get - - match 'api/0.6/changeset/create' => 'changeset#create', :via => :put - match 'api/0.6/changeset/:id/upload' => 'changeset#upload', :via => :post, :id => /\d+/ - match 'api/0.6/changeset/:id/download' => 'changeset#download', :via => :get, :as => :changeset_download, :id => /\d+/ - match 'api/0.6/changeset/:id/expand_bbox' => 'changeset#expand_bbox', :via => :post, :id => /\d+/ - match 'api/0.6/changeset/:id' => 'changeset#read', :via => :get, :as => :changeset_read, :id => /\d+/ - match 'api/0.6/changeset/:id/subscribe' => 'changeset#subscribe', :via => :post, :as => :changeset_subscribe, :id => /\d+/ - match 'api/0.6/changeset/:id/unsubscribe' => 'changeset#unsubscribe', :via => :post, :as => :changeset_unsubscribe, :id => /\d+/ - match 'api/0.6/changeset/:id' => 'changeset#update', :via => :put, :id => /\d+/ - match 'api/0.6/changeset/:id/close' => 'changeset#close', :via => :put, :id => /\d+/ - match 'api/0.6/changesets' => 'changeset#query', :via => :get - post 'api/0.6/changeset/:id/comment' => 'changeset#comment', :as => :changeset_comment, :id => /\d+/ - post 'api/0.6/changeset/comment/:id/hide' => 'changeset#hide_comment', :as => :changeset_comment_hide, :id => /\d+/ - post 'api/0.6/changeset/comment/:id/unhide' => 'changeset#unhide_comment', :as => :changeset_comment_unhide, :id => /\d+/ - - match 'api/0.6/node/create' => 'node#create', :via => :put - match 'api/0.6/node/:id/ways' => 'way#ways_for_node', :via => :get, :id => /\d+/ - match 'api/0.6/node/:id/relations' => 'relation#relations_for_node', :via => :get, :id => /\d+/ - match 'api/0.6/node/:id/history' => 'old_node#history', :via => :get, :id => /\d+/ - match 'api/0.6/node/:id/:version/redact' => 'old_node#redact', :via => :post, :version => /\d+/, :id => /\d+/ - match 'api/0.6/node/:id/:version' => 'old_node#version', :via => :get, :id => /\d+/, :version => /\d+/ - match 'api/0.6/node/:id' => 'node#read', :via => :get, :id => /\d+/ - match 'api/0.6/node/:id' => 'node#update', :via => :put, :id => /\d+/ - match 'api/0.6/node/:id' => 'node#delete', :via => :delete, :id => /\d+/ - match 'api/0.6/nodes' => 'node#nodes', :via => :get - - match 'api/0.6/way/create' => 'way#create', :via => :put - match 'api/0.6/way/:id/history' => 'old_way#history', :via => :get, :id => /\d+/ - match 'api/0.6/way/:id/full' => 'way#full', :via => :get, :id => /\d+/ - match 'api/0.6/way/:id/relations' => 'relation#relations_for_way', :via => :get, :id => /\d+/ - match 'api/0.6/way/:id/:version/redact' => 'old_way#redact', :via => :post, :version => /\d+/, :id => /\d+/ - match 'api/0.6/way/:id/:version' => 'old_way#version', :via => :get, :id => /\d+/, :version => /\d+/ - match 'api/0.6/way/:id' => 'way#read', :via => :get, :id => /\d+/ - match 'api/0.6/way/:id' => 'way#update', :via => :put, :id => /\d+/ - match 'api/0.6/way/:id' => 'way#delete', :via => :delete, :id => /\d+/ - match 'api/0.6/ways' => 'way#ways', :via => :get - - match 'api/0.6/relation/create' => 'relation#create', :via => :put - match 'api/0.6/relation/:id/relations' => 'relation#relations_for_relation', :via => :get, :id => /\d+/ - match 'api/0.6/relation/:id/history' => 'old_relation#history', :via => :get, :id => /\d+/ - match 'api/0.6/relation/:id/full' => 'relation#full', :via => :get, :id => /\d+/ - match 'api/0.6/relation/:id/:version/redact' => 'old_relation#redact', :via => :post, :version => /\d+/, :id => /\d+/ - match 'api/0.6/relation/:id/:version' => 'old_relation#version', :via => :get, :id => /\d+/, :version => /\d+/ - match 'api/0.6/relation/:id' => 'relation#read', :via => :get, :id => /\d+/ - match 'api/0.6/relation/:id' => 'relation#update', :via => :put, :id => /\d+/ - match 'api/0.6/relation/:id' => 'relation#delete', :via => :delete, :id => /\d+/ - match 'api/0.6/relations' => 'relation#relations', :via => :get - - match 'api/0.6/map' => 'api#map', :via => :get - - match 'api/0.6/trackpoints' => 'api#trackpoints', :via => :get - - match 'api/0.6/changes' => 'api#changes', :via => :get - - match 'api/0.6/search' => 'search#search_all', :via => :get - match 'api/0.6/ways/search' => 'search#search_ways', :via => :get - match 'api/0.6/relations/search' => 'search#search_relations', :via => :get - match 'api/0.6/nodes/search' => 'search#search_nodes', :via => :get - - match 'api/0.6/user/:id' => 'user#api_read', :via => :get, :id => /\d+/ - match 'api/0.6/user/details' => 'user#api_details', :via => :get - match 'api/0.6/user/gpx_files' => 'user#api_gpx_files', :via => :get - - match 'api/0.6/user/preferences' => 'user_preference#read', :via => :get - match 'api/0.6/user/preferences/:preference_key' => 'user_preference#read_one', :via => :get - match 'api/0.6/user/preferences' => 'user_preference#update', :via => :put - match 'api/0.6/user/preferences/:preference_key' => 'user_preference#update_one', :via => :put - match 'api/0.6/user/preferences/:preference_key' => 'user_preference#delete_one', :via => :delete - - match 'api/0.6/gpx/create' => 'trace#api_create', :via => :post - match 'api/0.6/gpx/:id' => 'trace#api_read', :via => :get, :id => /\d+/ - match 'api/0.6/gpx/:id' => 'trace#api_update', :via => :put, :id => /\d+/ - match 'api/0.6/gpx/:id' => 'trace#api_delete', :via => :delete, :id => /\d+/ - match 'api/0.6/gpx/:id/details' => 'trace#api_read', :via => :get, :id => /\d+/ - match 'api/0.6/gpx/:id/data' => 'trace#api_data', :via => :get + match "api/capabilities" => "api#capabilities", :via => :get + match "api/0.6/capabilities" => "api#capabilities", :via => :get + match "api/0.6/permissions" => "api#permissions", :via => :get + + match "api/0.6/changeset/create" => "changeset#create", :via => :put + match "api/0.6/changeset/:id/upload" => "changeset#upload", :via => :post, :id => /\d+/ + match "api/0.6/changeset/:id/download" => "changeset#download", :via => :get, :as => :changeset_download, :id => /\d+/ + match "api/0.6/changeset/:id/expand_bbox" => "changeset#expand_bbox", :via => :post, :id => /\d+/ + match "api/0.6/changeset/:id" => "changeset#read", :via => :get, :as => :changeset_read, :id => /\d+/ + match "api/0.6/changeset/:id/subscribe" => "changeset#subscribe", :via => :post, :as => :changeset_subscribe, :id => /\d+/ + match "api/0.6/changeset/:id/unsubscribe" => "changeset#unsubscribe", :via => :post, :as => :changeset_unsubscribe, :id => /\d+/ + match "api/0.6/changeset/:id" => "changeset#update", :via => :put, :id => /\d+/ + match "api/0.6/changeset/:id/close" => "changeset#close", :via => :put, :id => /\d+/ + match "api/0.6/changesets" => "changeset#query", :via => :get + post "api/0.6/changeset/:id/comment" => "changeset#comment", :as => :changeset_comment, :id => /\d+/ + post "api/0.6/changeset/comment/:id/hide" => "changeset#hide_comment", :as => :changeset_comment_hide, :id => /\d+/ + post "api/0.6/changeset/comment/:id/unhide" => "changeset#unhide_comment", :as => :changeset_comment_unhide, :id => /\d+/ + + match "api/0.6/node/create" => "node#create", :via => :put + match "api/0.6/node/:id/ways" => "way#ways_for_node", :via => :get, :id => /\d+/ + match "api/0.6/node/:id/relations" => "relation#relations_for_node", :via => :get, :id => /\d+/ + match "api/0.6/node/:id/history" => "old_node#history", :via => :get, :id => /\d+/ + match "api/0.6/node/:id/:version/redact" => "old_node#redact", :via => :post, :version => /\d+/, :id => /\d+/ + match "api/0.6/node/:id/:version" => "old_node#version", :via => :get, :id => /\d+/, :version => /\d+/ + match "api/0.6/node/:id" => "node#read", :via => :get, :id => /\d+/ + match "api/0.6/node/:id" => "node#update", :via => :put, :id => /\d+/ + match "api/0.6/node/:id" => "node#delete", :via => :delete, :id => /\d+/ + match "api/0.6/nodes" => "node#nodes", :via => :get + + match "api/0.6/way/create" => "way#create", :via => :put + match "api/0.6/way/:id/history" => "old_way#history", :via => :get, :id => /\d+/ + match "api/0.6/way/:id/full" => "way#full", :via => :get, :id => /\d+/ + match "api/0.6/way/:id/relations" => "relation#relations_for_way", :via => :get, :id => /\d+/ + match "api/0.6/way/:id/:version/redact" => "old_way#redact", :via => :post, :version => /\d+/, :id => /\d+/ + match "api/0.6/way/:id/:version" => "old_way#version", :via => :get, :id => /\d+/, :version => /\d+/ + match "api/0.6/way/:id" => "way#read", :via => :get, :id => /\d+/ + match "api/0.6/way/:id" => "way#update", :via => :put, :id => /\d+/ + match "api/0.6/way/:id" => "way#delete", :via => :delete, :id => /\d+/ + match "api/0.6/ways" => "way#ways", :via => :get + + match "api/0.6/relation/create" => "relation#create", :via => :put + match "api/0.6/relation/:id/relations" => "relation#relations_for_relation", :via => :get, :id => /\d+/ + match "api/0.6/relation/:id/history" => "old_relation#history", :via => :get, :id => /\d+/ + match "api/0.6/relation/:id/full" => "relation#full", :via => :get, :id => /\d+/ + match "api/0.6/relation/:id/:version/redact" => "old_relation#redact", :via => :post, :version => /\d+/, :id => /\d+/ + match "api/0.6/relation/:id/:version" => "old_relation#version", :via => :get, :id => /\d+/, :version => /\d+/ + match "api/0.6/relation/:id" => "relation#read", :via => :get, :id => /\d+/ + match "api/0.6/relation/:id" => "relation#update", :via => :put, :id => /\d+/ + match "api/0.6/relation/:id" => "relation#delete", :via => :delete, :id => /\d+/ + match "api/0.6/relations" => "relation#relations", :via => :get + + match "api/0.6/map" => "api#map", :via => :get + + match "api/0.6/trackpoints" => "api#trackpoints", :via => :get + + match "api/0.6/changes" => "api#changes", :via => :get + + match "api/0.6/search" => "search#search_all", :via => :get + match "api/0.6/ways/search" => "search#search_ways", :via => :get + match "api/0.6/relations/search" => "search#search_relations", :via => :get + match "api/0.6/nodes/search" => "search#search_nodes", :via => :get + + match "api/0.6/user/:id" => "user#api_read", :via => :get, :id => /\d+/ + match "api/0.6/user/details" => "user#api_details", :via => :get + match "api/0.6/user/gpx_files" => "user#api_gpx_files", :via => :get + + match "api/0.6/user/preferences" => "user_preference#read", :via => :get + match "api/0.6/user/preferences/:preference_key" => "user_preference#read_one", :via => :get + match "api/0.6/user/preferences" => "user_preference#update", :via => :put + match "api/0.6/user/preferences/:preference_key" => "user_preference#update_one", :via => :put + match "api/0.6/user/preferences/:preference_key" => "user_preference#delete_one", :via => :delete + + match "api/0.6/gpx/create" => "trace#api_create", :via => :post + match "api/0.6/gpx/:id" => "trace#api_read", :via => :get, :id => /\d+/ + match "api/0.6/gpx/:id" => "trace#api_update", :via => :put, :id => /\d+/ + match "api/0.6/gpx/:id" => "trace#api_delete", :via => :delete, :id => /\d+/ + match "api/0.6/gpx/:id/details" => "trace#api_read", :via => :get, :id => /\d+/ + match "api/0.6/gpx/:id/data" => "trace#api_data", :via => :get # AMF (ActionScript) API - match 'api/0.6/amf/read' => 'amf#amf_read', :via => :post - match 'api/0.6/amf/write' => 'amf#amf_write', :via => :post - match 'api/0.6/swf/trackpoints' => 'swf#trackpoints', :via => :get + match "api/0.6/amf/read" => "amf#amf_read", :via => :post + match "api/0.6/amf/write" => "amf#amf_write", :via => :post + match "api/0.6/swf/trackpoints" => "swf#trackpoints", :via => :get # Map notes API scope "api/0.6" do resources :notes, :except => [:new, :edit, :update], :constraints => { :id => /\d+/ }, :defaults => { :format => "xml" } do collection do - get 'search' - get 'feed', :defaults => { :format => "rss" } + get "search" + get "feed", :defaults => { :format => "rss" } end member do - post 'comment' - post 'close' - post 'reopen' + post "comment" + post "close" + post "reopen" end end - match 'notes/addPOIexec' => 'notes#create', :via => :post - match 'notes/closePOIexec' => 'notes#close', :via => :post - match 'notes/editPOIexec' => 'notes#comment', :via => :post - match 'notes/getGPX' => 'notes#index', :via => :get, :format => "gpx" - match 'notes/getRSSfeed' => 'notes#feed', :via => :get, :format => "rss" + match "notes/addPOIexec" => "notes#create", :via => :post + match "notes/closePOIexec" => "notes#close", :via => :post + match "notes/editPOIexec" => "notes#comment", :via => :post + match "notes/getGPX" => "notes#index", :via => :get, :format => "gpx" + match "notes/getRSSfeed" => "notes#feed", :via => :get, :format => "rss" end # Data browsing - match '/way/:id' => 'browse#way', :via => :get, :id => /\d+/, :as => :way - match '/way/:id/history' => 'browse#way_history', :via => :get, :id => /\d+/ - match '/node/:id' => 'browse#node', :via => :get, :id => /\d+/, :as => :node - match '/node/:id/history' => 'browse#node_history', :via => :get, :id => /\d+/ - match '/relation/:id' => 'browse#relation', :via => :get, :id => /\d+/, :as => :relation - match '/relation/:id/history' => 'browse#relation_history', :via => :get, :id => /\d+/ - match '/changeset/:id' => 'browse#changeset', :via => :get, :as => :changeset, :id => /\d+/ - match '/changeset/:id/comments/feed' => 'changeset#comments_feed', :via => :get, :as => :changeset_comments_feed, :id => /\d*/, :defaults => { :format => 'rss' } - match '/note/:id' => 'browse#note', :via => :get, :id => /\d+/, :as => "browse_note" - match '/note/new' => 'browse#new_note', :via => :get - match '/user/:display_name/history' => 'changeset#list', :via => :get - match '/user/:display_name/history/feed' => 'changeset#feed', :via => :get, :defaults => { :format => :atom } - match '/user/:display_name/notes' => 'notes#mine', :via => :get - match '/history/friends' => 'changeset#list', :via => :get, :friends => true, :as => "friend_changesets" - match '/history/nearby' => 'changeset#list', :via => :get, :nearby => true, :as => "nearby_changesets" - - get '/browse/way/:id', :to => redirect(:path => '/way/%{id}') - get '/browse/way/:id/history', :to => redirect(:path => '/way/%{id}/history') - get '/browse/node/:id', :to => redirect(:path => '/node/%{id}') - get '/browse/node/:id/history', :to => redirect(:path => '/node/%{id}/history') - get '/browse/relation/:id', :to => redirect(:path => '/relation/%{id}') - get '/browse/relation/:id/history', :to => redirect(:path => '/relation/%{id}/history') - get '/browse/changeset/:id', :to => redirect(:path => '/changeset/%{id}') - get '/browse/note/:id', :to => redirect(:path => '/note/%{id}') - get '/user/:display_name/edits', :to => redirect(:path => '/user/%{display_name}/history') - get '/user/:display_name/edits/feed', :to => redirect(:path => '/user/%{display_name}/history/feed') - get '/browse/friends', :to => redirect(:path => '/history/friends') - get '/browse/nearby', :to => redirect(:path => '/history/nearby') - get '/browse/changesets/feed', :to => redirect(:path => '/history/feed') - get '/browse/changesets', :to => redirect(:path => '/history') - get '/browse', :to => redirect(:path => '/history') + match "/way/:id" => "browse#way", :via => :get, :id => /\d+/, :as => :way + match "/way/:id/history" => "browse#way_history", :via => :get, :id => /\d+/ + match "/node/:id" => "browse#node", :via => :get, :id => /\d+/, :as => :node + match "/node/:id/history" => "browse#node_history", :via => :get, :id => /\d+/ + match "/relation/:id" => "browse#relation", :via => :get, :id => /\d+/, :as => :relation + match "/relation/:id/history" => "browse#relation_history", :via => :get, :id => /\d+/ + match "/changeset/:id" => "browse#changeset", :via => :get, :as => :changeset, :id => /\d+/ + match "/changeset/:id/comments/feed" => "changeset#comments_feed", :via => :get, :as => :changeset_comments_feed, :id => /\d*/, :defaults => { :format => "rss" } + match "/note/:id" => "browse#note", :via => :get, :id => /\d+/, :as => "browse_note" + match "/note/new" => "browse#new_note", :via => :get + match "/user/:display_name/history" => "changeset#list", :via => :get + match "/user/:display_name/history/feed" => "changeset#feed", :via => :get, :defaults => { :format => :atom } + match "/user/:display_name/notes" => "notes#mine", :via => :get + match "/history/friends" => "changeset#list", :via => :get, :friends => true, :as => "friend_changesets" + match "/history/nearby" => "changeset#list", :via => :get, :nearby => true, :as => "nearby_changesets" + + get "/browse/way/:id", :to => redirect(:path => "/way/%{id}") + get "/browse/way/:id/history", :to => redirect(:path => "/way/%{id}/history") + get "/browse/node/:id", :to => redirect(:path => "/node/%{id}") + get "/browse/node/:id/history", :to => redirect(:path => "/node/%{id}/history") + get "/browse/relation/:id", :to => redirect(:path => "/relation/%{id}") + get "/browse/relation/:id/history", :to => redirect(:path => "/relation/%{id}/history") + get "/browse/changeset/:id", :to => redirect(:path => "/changeset/%{id}") + get "/browse/note/:id", :to => redirect(:path => "/note/%{id}") + get "/user/:display_name/edits", :to => redirect(:path => "/user/%{display_name}/history") + get "/user/:display_name/edits/feed", :to => redirect(:path => "/user/%{display_name}/history/feed") + get "/browse/friends", :to => redirect(:path => "/history/friends") + get "/browse/nearby", :to => redirect(:path => "/history/nearby") + get "/browse/changesets/feed", :to => redirect(:path => "/history/feed") + get "/browse/changesets", :to => redirect(:path => "/history") + get "/browse", :to => redirect(:path => "/history") # web site - root :to => 'site#index', :via => [:get, :post] - match '/edit' => 'site#edit', :via => :get, :as => :edit - match '/copyright/:copyright_locale' => 'site#copyright', :via => :get - match '/copyright' => 'site#copyright', :via => :get - match '/welcome' => 'site#welcome', :via => :get, :as => :welcome - match '/fixthemap' => 'site#fixthemap', :via => :get, :as => :fixthemap - match '/help' => 'site#help', :via => :get, :as => :help - match '/about' => 'site#about', :via => :get, :as => :about - match '/history' => 'changeset#list', :via => :get - match '/history/feed' => 'changeset#feed', :via => :get, :defaults => { :format => :atom } - match '/history/comments/feed' => 'changeset#comments_feed', :via => :get, :as => :changesets_comments_feed, :defaults => { :format => 'rss' } - match '/export' => 'site#export', :via => :get - match '/login' => 'user#login', :via => [:get, :post] - match '/logout' => 'user#logout', :via => [:get, :post] - match '/offline' => 'site#offline', :via => :get - match '/key' => 'site#key', :via => :get - match '/id' => 'site#id', :via => :get - match '/query' => 'browse#query', :via => :get - match '/user/new' => 'user#new', :via => :get - match '/user/new' => 'user#create', :via => :post - match '/user/terms' => 'user#terms', :via => :get - match '/user/save' => 'user#save', :via => :post - match '/user/:display_name/confirm/resend' => 'user#confirm_resend', :via => :get - match '/user/:display_name/confirm' => 'user#confirm', :via => [:get, :post] - match '/user/confirm' => 'user#confirm', :via => [:get, :post] - match '/user/confirm-email' => 'user#confirm_email', :via => [:get, :post] - match '/user/go_public' => 'user#go_public', :via => :post - match '/user/reset-password' => 'user#reset_password', :via => [:get, :post] - match '/user/forgot-password' => 'user#lost_password', :via => [:get, :post] - match '/user/suspended' => 'user#suspended', :via => :get - - get '/index.html', :to => redirect(:path => "/") - get '/create-account.html', :to => redirect(:path => "/user/new") - get '/forgot-password.html', :to => redirect(:path => "/user/forgot-password") + root :to => "site#index", :via => [:get, :post] + match "/edit" => "site#edit", :via => :get, :as => :edit + match "/copyright/:copyright_locale" => "site#copyright", :via => :get + match "/copyright" => "site#copyright", :via => :get + match "/welcome" => "site#welcome", :via => :get, :as => :welcome + match "/fixthemap" => "site#fixthemap", :via => :get, :as => :fixthemap + match "/help" => "site#help", :via => :get, :as => :help + match "/about" => "site#about", :via => :get, :as => :about + match "/history" => "changeset#list", :via => :get + match "/history/feed" => "changeset#feed", :via => :get, :defaults => { :format => :atom } + match "/history/comments/feed" => "changeset#comments_feed", :via => :get, :as => :changesets_comments_feed, :defaults => { :format => "rss" } + match "/export" => "site#export", :via => :get + match "/login" => "user#login", :via => [:get, :post] + match "/logout" => "user#logout", :via => [:get, :post] + match "/offline" => "site#offline", :via => :get + match "/key" => "site#key", :via => :get + match "/id" => "site#id", :via => :get + match "/query" => "browse#query", :via => :get + match "/user/new" => "user#new", :via => :get + match "/user/new" => "user#create", :via => :post + match "/user/terms" => "user#terms", :via => :get + match "/user/save" => "user#save", :via => :post + match "/user/:display_name/confirm/resend" => "user#confirm_resend", :via => :get + match "/user/:display_name/confirm" => "user#confirm", :via => [:get, :post] + match "/user/confirm" => "user#confirm", :via => [:get, :post] + match "/user/confirm-email" => "user#confirm_email", :via => [:get, :post] + match "/user/go_public" => "user#go_public", :via => :post + match "/user/reset-password" => "user#reset_password", :via => [:get, :post] + match "/user/forgot-password" => "user#lost_password", :via => [:get, :post] + match "/user/suspended" => "user#suspended", :via => :get + + get "/index.html", :to => redirect(:path => "/") + get "/create-account.html", :to => redirect(:path => "/user/new") + get "/forgot-password.html", :to => redirect(:path => "/user/forgot-password") # permalink - match '/go/:code' => 'site#permalink', :via => :get, :code => /[a-zA-Z0-9_@~]+[=-]*/ + match "/go/:code" => "site#permalink", :via => :get, :code => /[a-zA-Z0-9_@~]+[=-]*/ # rich text preview - match '/preview/:format' => 'site#preview', :via => :post, :as => :preview + match "/preview/:format" => "site#preview", :via => :post, :as => :preview # traces - match '/user/:display_name/traces/tag/:tag/page/:page' => 'trace#list', :via => :get - match '/user/:display_name/traces/tag/:tag' => 'trace#list', :via => :get - match '/user/:display_name/traces/page/:page' => 'trace#list', :via => :get - match '/user/:display_name/traces' => 'trace#list', :via => :get - match '/user/:display_name/traces/tag/:tag/rss' => 'trace#georss', :via => :get, :defaults => { :format => :rss } - match '/user/:display_name/traces/rss' => 'trace#georss', :via => :get, :defaults => { :format => :rss } - match '/user/:display_name/traces/:id' => 'trace#view', :via => :get - match '/user/:display_name/traces/:id/picture' => 'trace#picture', :via => :get - match '/user/:display_name/traces/:id/icon' => 'trace#icon', :via => :get - match '/traces/tag/:tag/page/:page' => 'trace#list', :via => :get - match '/traces/tag/:tag' => 'trace#list', :via => :get - match '/traces/page/:page' => 'trace#list', :via => :get - match '/traces' => 'trace#list', :via => :get - match '/traces/tag/:tag/rss' => 'trace#georss', :via => :get, :defaults => { :format => :rss } - match '/traces/rss' => 'trace#georss', :via => :get, :defaults => { :format => :rss } - match '/traces/mine/tag/:tag/page/:page' => 'trace#mine', :via => :get - match '/traces/mine/tag/:tag' => 'trace#mine', :via => :get - match '/traces/mine/page/:page' => 'trace#mine', :via => :get - match '/traces/mine' => 'trace#mine', :via => :get - match '/trace/create' => 'trace#create', :via => [:get, :post] - match '/trace/:id/data' => 'trace#data', :via => :get, :id => /\d+/, :as => "trace_data" - match '/trace/:id/edit' => 'trace#edit', :via => [:get, :post, :patch], :id => /\d+/, :as => "trace_edit" - match '/trace/:id/delete' => 'trace#delete', :via => :post, :id => /\d+/ + match "/user/:display_name/traces/tag/:tag/page/:page" => "trace#list", :via => :get + match "/user/:display_name/traces/tag/:tag" => "trace#list", :via => :get + match "/user/:display_name/traces/page/:page" => "trace#list", :via => :get + match "/user/:display_name/traces" => "trace#list", :via => :get + match "/user/:display_name/traces/tag/:tag/rss" => "trace#georss", :via => :get, :defaults => { :format => :rss } + match "/user/:display_name/traces/rss" => "trace#georss", :via => :get, :defaults => { :format => :rss } + match "/user/:display_name/traces/:id" => "trace#view", :via => :get + match "/user/:display_name/traces/:id/picture" => "trace#picture", :via => :get + match "/user/:display_name/traces/:id/icon" => "trace#icon", :via => :get + match "/traces/tag/:tag/page/:page" => "trace#list", :via => :get + match "/traces/tag/:tag" => "trace#list", :via => :get + match "/traces/page/:page" => "trace#list", :via => :get + match "/traces" => "trace#list", :via => :get + match "/traces/tag/:tag/rss" => "trace#georss", :via => :get, :defaults => { :format => :rss } + match "/traces/rss" => "trace#georss", :via => :get, :defaults => { :format => :rss } + match "/traces/mine/tag/:tag/page/:page" => "trace#mine", :via => :get + match "/traces/mine/tag/:tag" => "trace#mine", :via => :get + match "/traces/mine/page/:page" => "trace#mine", :via => :get + match "/traces/mine" => "trace#mine", :via => :get + match "/trace/create" => "trace#create", :via => [:get, :post] + match "/trace/:id/data" => "trace#data", :via => :get, :id => /\d+/, :as => "trace_data" + match "/trace/:id/edit" => "trace#edit", :via => [:get, :post, :patch], :id => /\d+/, :as => "trace_edit" + match "/trace/:id/delete" => "trace#delete", :via => :post, :id => /\d+/ # diary pages - match '/diary/new' => 'diary_entry#new', :via => [:get, :post] - match '/diary/friends' => 'diary_entry#list', :friends => true, :via => :get, :as => "friend_diaries" - match '/diary/nearby' => 'diary_entry#list', :nearby => true, :via => :get, :as => "nearby_diaries" - match '/user/:display_name/diary/rss' => 'diary_entry#rss', :via => :get, :defaults => { :format => :rss } - match '/diary/:language/rss' => 'diary_entry#rss', :via => :get, :defaults => { :format => :rss } - match '/diary/rss' => 'diary_entry#rss', :via => :get, :defaults => { :format => :rss } - match '/user/:display_name/diary/comments/:page' => 'diary_entry#comments', :via => :get, :page => /\d+/ - match '/user/:display_name/diary/comments/' => 'diary_entry#comments', :via => :get - match '/user/:display_name/diary' => 'diary_entry#list', :via => :get - match '/diary/:language' => 'diary_entry#list', :via => :get - match '/diary' => 'diary_entry#list', :via => :get - match '/user/:display_name/diary/:id' => 'diary_entry#view', :via => :get, :id => /\d+/ - match '/user/:display_name/diary/:id/newcomment' => 'diary_entry#comment', :via => :post, :id => /\d+/ - match '/user/:display_name/diary/:id/edit' => 'diary_entry#edit', :via => [:get, :post], :id => /\d+/ - match '/user/:display_name/diary/:id/hide' => 'diary_entry#hide', :via => :post, :id => /\d+/, :as => :hide_diary_entry - match '/user/:display_name/diary/:id/hidecomment/:comment' => 'diary_entry#hidecomment', :via => :post, :id => /\d+/, :comment => /\d+/, :as => :hide_diary_comment + match "/diary/new" => "diary_entry#new", :via => [:get, :post] + match "/diary/friends" => "diary_entry#list", :friends => true, :via => :get, :as => "friend_diaries" + match "/diary/nearby" => "diary_entry#list", :nearby => true, :via => :get, :as => "nearby_diaries" + match "/user/:display_name/diary/rss" => "diary_entry#rss", :via => :get, :defaults => { :format => :rss } + match "/diary/:language/rss" => "diary_entry#rss", :via => :get, :defaults => { :format => :rss } + match "/diary/rss" => "diary_entry#rss", :via => :get, :defaults => { :format => :rss } + match "/user/:display_name/diary/comments/:page" => "diary_entry#comments", :via => :get, :page => /\d+/ + match "/user/:display_name/diary/comments/" => "diary_entry#comments", :via => :get + match "/user/:display_name/diary" => "diary_entry#list", :via => :get + match "/diary/:language" => "diary_entry#list", :via => :get + match "/diary" => "diary_entry#list", :via => :get + match "/user/:display_name/diary/:id" => "diary_entry#view", :via => :get, :id => /\d+/ + match "/user/:display_name/diary/:id/newcomment" => "diary_entry#comment", :via => :post, :id => /\d+/ + match "/user/:display_name/diary/:id/edit" => "diary_entry#edit", :via => [:get, :post], :id => /\d+/ + match "/user/:display_name/diary/:id/hide" => "diary_entry#hide", :via => :post, :id => /\d+/, :as => :hide_diary_entry + match "/user/:display_name/diary/:id/hidecomment/:comment" => "diary_entry#hidecomment", :via => :post, :id => /\d+/, :comment => /\d+/, :as => :hide_diary_comment # user pages - match '/user/:display_name' => 'user#view', :via => :get, :as => "user" - match '/user/:display_name/make_friend' => 'user#make_friend', :via => [:get, :post], :as => "make_friend" - match '/user/:display_name/remove_friend' => 'user#remove_friend', :via => [:get, :post], :as => "remove_friend" - match '/user/:display_name/account' => 'user#account', :via => [:get, :post] - match '/user/:display_name/set_status' => 'user#set_status', :via => :get, :as => :set_status_user - match '/user/:display_name/delete' => 'user#delete', :via => :get, :as => :delete_user + match "/user/:display_name" => "user#view", :via => :get, :as => "user" + match "/user/:display_name/make_friend" => "user#make_friend", :via => [:get, :post], :as => "make_friend" + match "/user/:display_name/remove_friend" => "user#remove_friend", :via => [:get, :post], :as => "remove_friend" + match "/user/:display_name/account" => "user#account", :via => [:get, :post] + match "/user/:display_name/set_status" => "user#set_status", :via => :get, :as => :set_status_user + match "/user/:display_name/delete" => "user#delete", :via => :get, :as => :delete_user # user lists - match '/users' => 'user#list', :via => [:get, :post] - match '/users/:status' => 'user#list', :via => [:get, :post] + match "/users" => "user#list", :via => [:get, :post] + match "/users/:status" => "user#list", :via => [:get, :post] # geocoder - match '/search' => 'geocoder#search', :via => :get, :as => :search - match '/geocoder/search_latlon' => 'geocoder#search_latlon', :via => :get - match '/geocoder/search_us_postcode' => 'geocoder#search_us_postcode', :via => :get - match '/geocoder/search_uk_postcode' => 'geocoder#search_uk_postcode', :via => :get - match '/geocoder/search_ca_postcode' => 'geocoder#search_ca_postcode', :via => :get - match '/geocoder/search_osm_nominatim' => 'geocoder#search_osm_nominatim', :via => :get - match '/geocoder/search_geonames' => 'geocoder#search_geonames', :via => :get - match '/geocoder/search_osm_nominatim_reverse' => 'geocoder#search_osm_nominatim_reverse', :via => :get - match '/geocoder/search_geonames_reverse' => 'geocoder#search_geonames_reverse', :via => :get + match "/search" => "geocoder#search", :via => :get, :as => :search + match "/geocoder/search_latlon" => "geocoder#search_latlon", :via => :get + match "/geocoder/search_us_postcode" => "geocoder#search_us_postcode", :via => :get + match "/geocoder/search_uk_postcode" => "geocoder#search_uk_postcode", :via => :get + match "/geocoder/search_ca_postcode" => "geocoder#search_ca_postcode", :via => :get + match "/geocoder/search_osm_nominatim" => "geocoder#search_osm_nominatim", :via => :get + match "/geocoder/search_geonames" => "geocoder#search_geonames", :via => :get + match "/geocoder/search_osm_nominatim_reverse" => "geocoder#search_osm_nominatim_reverse", :via => :get + match "/geocoder/search_geonames_reverse" => "geocoder#search_geonames_reverse", :via => :get # directions - match '/directions' => 'directions#search', :via => :get, :as => :directions + match "/directions" => "directions#search", :via => :get, :as => :directions # export - match '/export/finish' => 'export#finish', :via => :post - match '/export/embed' => 'export#embed', :via => :get + match "/export/finish" => "export#finish", :via => :post + match "/export/embed" => "export#embed", :via => :get # messages - match '/user/:display_name/inbox' => 'message#inbox', :via => :get, :as => "inbox" - match '/user/:display_name/outbox' => 'message#outbox', :via => :get, :as => "outbox" - match '/message/new/:display_name' => 'message#new', :via => [:get, :post], :as => "new_message" - match '/message/read/:message_id' => 'message#read', :via => :get, :as => "read_message" - match '/message/mark/:message_id' => 'message#mark', :via => :post, :as => "mark_message" - match '/message/reply/:message_id' => 'message#reply', :via => [:get, :post], :as => "reply_message" - match '/message/delete/:message_id' => 'message#delete', :via => :post, :as => "delete_message" + match "/user/:display_name/inbox" => "message#inbox", :via => :get, :as => "inbox" + match "/user/:display_name/outbox" => "message#outbox", :via => :get, :as => "outbox" + match "/message/new/:display_name" => "message#new", :via => [:get, :post], :as => "new_message" + match "/message/read/:message_id" => "message#read", :via => :get, :as => "read_message" + match "/message/mark/:message_id" => "message#mark", :via => :post, :as => "mark_message" + match "/message/reply/:message_id" => "message#reply", :via => [:get, :post], :as => "reply_message" + match "/message/delete/:message_id" => "message#delete", :via => :post, :as => "delete_message" # oauth admin pages (i.e: for setting up new clients, etc...) scope "/user/:display_name" do resources :oauth_clients end - match '/oauth/revoke' => 'oauth#revoke', :via => [:get, :post] - match '/oauth/authorize' => 'oauth#authorize', :via => [:get, :post], :as => :authorize - match '/oauth/token' => 'oauth#token', :via => :get, :as => :token - match '/oauth/request_token' => 'oauth#request_token', :via => [:get, :post], :as => :request_token - match '/oauth/access_token' => 'oauth#access_token', :via => [:get, :post], :as => :access_token - match '/oauth/test_request' => 'oauth#test_request', :via => :get, :as => :test_request + match "/oauth/revoke" => "oauth#revoke", :via => [:get, :post] + match "/oauth/authorize" => "oauth#authorize", :via => [:get, :post], :as => :authorize + match "/oauth/token" => "oauth#token", :via => :get, :as => :token + match "/oauth/request_token" => "oauth#request_token", :via => [:get, :post], :as => :request_token + match "/oauth/access_token" => "oauth#access_token", :via => [:get, :post], :as => :access_token + match "/oauth/test_request" => "oauth#test_request", :via => :get, :as => :test_request # roles and banning pages - match '/user/:display_name/role/:role/grant' => 'user_roles#grant', :via => :post, :as => "grant_role" - match '/user/:display_name/role/:role/revoke' => 'user_roles#revoke', :via => :post, :as => "revoke_role" - match '/user/:display_name/blocks' => 'user_blocks#blocks_on', :via => :get - match '/user/:display_name/blocks_by' => 'user_blocks#blocks_by', :via => :get - match '/blocks/new/:display_name' => 'user_blocks#new', :via => :get, :as => "new_user_block" + match "/user/:display_name/role/:role/grant" => "user_roles#grant", :via => :post, :as => "grant_role" + match "/user/:display_name/role/:role/revoke" => "user_roles#revoke", :via => :post, :as => "revoke_role" + match "/user/:display_name/blocks" => "user_blocks#blocks_on", :via => :get + match "/user/:display_name/blocks_by" => "user_blocks#blocks_by", :via => :get + match "/blocks/new/:display_name" => "user_blocks#new", :via => :get, :as => "new_user_block" resources :user_blocks - match '/blocks/:id/revoke' => 'user_blocks#revoke', :via => [:get, :post], :as => "revoke_user_block" + match "/blocks/:id/revoke" => "user_blocks#revoke", :via => [:get, :post], :as => "revoke_user_block" # redactions resources :redactions diff --git a/db/migrate/001_create_osm_db.rb b/db/migrate/001_create_osm_db.rb index 34cf27b50..985997ac2 100644 --- a/db/migrate/001_create_osm_db.rb +++ b/db/migrate/001_create_osm_db.rb @@ -1,4 +1,4 @@ -require 'migrate' +require "migrate" class CreateOsmDb < ActiveRecord::Migration def self.up diff --git a/db/migrate/002_cleanup_osm_db.rb b/db/migrate/002_cleanup_osm_db.rb index 2f6af1c17..866b1ae51 100644 --- a/db/migrate/002_cleanup_osm_db.rb +++ b/db/migrate/002_cleanup_osm_db.rb @@ -1,4 +1,4 @@ -require 'migrate' +require "migrate" class CleanupOsmDb < ActiveRecord::Migration def self.up diff --git a/db/migrate/003_sql_session_store_setup.rb b/db/migrate/003_sql_session_store_setup.rb index 69ad969b7..9531ccc5e 100644 --- a/db/migrate/003_sql_session_store_setup.rb +++ b/db/migrate/003_sql_session_store_setup.rb @@ -1,4 +1,4 @@ -require 'migrate' +require "migrate" class SqlSessionStoreSetup < ActiveRecord::Migration def self.up diff --git a/db/migrate/004_user_enhancements.rb b/db/migrate/004_user_enhancements.rb index 92f996200..4d53d0382 100644 --- a/db/migrate/004_user_enhancements.rb +++ b/db/migrate/004_user_enhancements.rb @@ -1,4 +1,4 @@ -require 'migrate' +require "migrate" class UserEnhancements < ActiveRecord::Migration def self.up diff --git a/db/migrate/005_tile_tracepoints.rb b/db/migrate/005_tile_tracepoints.rb index f260f234a..f77d34959 100644 --- a/db/migrate/005_tile_tracepoints.rb +++ b/db/migrate/005_tile_tracepoints.rb @@ -1,4 +1,4 @@ -require 'migrate' +require "migrate" class TileTracepoints < ActiveRecord::Migration def self.up diff --git a/db/migrate/006_tile_nodes.rb b/db/migrate/006_tile_nodes.rb index 016ba040b..fd9dbfb67 100644 --- a/db/migrate/006_tile_nodes.rb +++ b/db/migrate/006_tile_nodes.rb @@ -1,4 +1,4 @@ -require 'migrate' +require "migrate" class TileNodes < ActiveRecord::Migration def self.upgrade_table(from_table, to_table, model) diff --git a/db/migrate/007_add_relations.rb b/db/migrate/007_add_relations.rb index 064fd05c9..78270f103 100644 --- a/db/migrate/007_add_relations.rb +++ b/db/migrate/007_add_relations.rb @@ -1,4 +1,4 @@ -require 'migrate' +require "migrate" class AddRelations < ActiveRecord::Migration def self.up diff --git a/db/migrate/008_remove_segments.rb b/db/migrate/008_remove_segments.rb index 2820f82f8..241a144b0 100644 --- a/db/migrate/008_remove_segments.rb +++ b/db/migrate/008_remove_segments.rb @@ -1,4 +1,4 @@ -require 'migrate' +require "migrate" class RemoveSegments < ActiveRecord::Migration def self.up @@ -10,7 +10,7 @@ class RemoveSegments < ActiveRecord::Migration 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}") || fail end diff --git a/db/migrate/010_diary_comments.rb b/db/migrate/010_diary_comments.rb index 2473bcb3b..4e95b1976 100644 --- a/db/migrate/010_diary_comments.rb +++ b/db/migrate/010_diary_comments.rb @@ -1,4 +1,4 @@ -require 'migrate' +require "migrate" class DiaryComments < ActiveRecord::Migration def self.up diff --git a/db/migrate/018_create_acls.rb b/db/migrate/018_create_acls.rb index 0db06f30c..e5a524dc1 100644 --- a/db/migrate/018_create_acls.rb +++ b/db/migrate/018_create_acls.rb @@ -1,4 +1,4 @@ -require 'migrate' +require "migrate" class CreateAcls < ActiveRecord::Migration def self.up diff --git a/db/migrate/020_populate_node_tags_and_remove.rb b/db/migrate/020_populate_node_tags_and_remove.rb index 6aa0bc44b..d12ede317 100644 --- a/db/migrate/020_populate_node_tags_and_remove.rb +++ b/db/migrate/020_populate_node_tags_and_remove.rb @@ -1,4 +1,4 @@ -require 'migrate' +require "migrate" class PopulateNodeTagsAndRemove < ActiveRecord::Migration def self.up @@ -10,7 +10,7 @@ class PopulateNodeTagsAndRemove < ActiveRecord::Migration 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}") || fail end diff --git a/db/migrate/021_move_to_innodb.rb b/db/migrate/021_move_to_innodb.rb index 72a4607d9..57a69b570 100644 --- a/db/migrate/021_move_to_innodb.rb +++ b/db/migrate/021_move_to_innodb.rb @@ -1,4 +1,4 @@ -require 'migrate' +require "migrate" class MoveToInnodb < ActiveRecord::Migration @@conv_tables = %w(nodes ways way_tags way_nodes current_way_tags relation_members relations relation_tags current_relation_tags) diff --git a/db/migrate/022_key_constraints.rb b/db/migrate/022_key_constraints.rb index 79706bc4a..aa4c496c9 100644 --- a/db/migrate/022_key_constraints.rb +++ b/db/migrate/022_key_constraints.rb @@ -1,4 +1,4 @@ -require 'migrate' +require "migrate" class KeyConstraints < ActiveRecord::Migration def self.up diff --git a/db/migrate/023_add_changesets.rb b/db/migrate/023_add_changesets.rb index b54494759..8bd9a930d 100644 --- a/db/migrate/023_add_changesets.rb +++ b/db/migrate/023_add_changesets.rb @@ -1,4 +1,4 @@ -require 'migrate' +require "migrate" class AddChangesets < ActiveRecord::Migration @@conv_user_tables = %w(current_nodes current_relations current_ways nodes relations ways) diff --git a/db/migrate/024_order_relation_members.rb b/db/migrate/024_order_relation_members.rb index 4914a8a60..fbb276dd5 100644 --- a/db/migrate/024_order_relation_members.rb +++ b/db/migrate/024_order_relation_members.rb @@ -1,4 +1,4 @@ -require 'migrate' +require "migrate" class OrderRelationMembers < ActiveRecord::Migration def self.up diff --git a/db/migrate/025_add_end_time_to_changesets.rb b/db/migrate/025_add_end_time_to_changesets.rb index 129315a3f..4255c6f67 100644 --- a/db/migrate/025_add_end_time_to_changesets.rb +++ b/db/migrate/025_add_end_time_to_changesets.rb @@ -1,4 +1,4 @@ -require 'migrate' +require "migrate" class AddEndTimeToChangesets < ActiveRecord::Migration def self.up diff --git a/db/migrate/028_add_more_changeset_indexes.rb b/db/migrate/028_add_more_changeset_indexes.rb index b7b1be955..b64c9caf0 100644 --- a/db/migrate/028_add_more_changeset_indexes.rb +++ b/db/migrate/028_add_more_changeset_indexes.rb @@ -1,4 +1,4 @@ -require 'migrate' +require "migrate" class AddMoreChangesetIndexes < ActiveRecord::Migration def self.up diff --git a/db/migrate/029_add_user_foreign_keys.rb b/db/migrate/029_add_user_foreign_keys.rb index 5d3532c72..224d589a8 100644 --- a/db/migrate/029_add_user_foreign_keys.rb +++ b/db/migrate/029_add_user_foreign_keys.rb @@ -1,4 +1,4 @@ -require 'migrate' +require "migrate" class AddUserForeignKeys < ActiveRecord::Migration def change diff --git a/db/migrate/030_add_foreign_keys.rb b/db/migrate/030_add_foreign_keys.rb index 2a68d422f..54820aab1 100644 --- a/db/migrate/030_add_foreign_keys.rb +++ b/db/migrate/030_add_foreign_keys.rb @@ -1,4 +1,4 @@ -require 'migrate' +require "migrate" class AddForeignKeys < ActiveRecord::Migration def self.up diff --git a/db/migrate/031_create_countries.rb b/db/migrate/031_create_countries.rb index c0b4fb634..b146cbadb 100644 --- a/db/migrate/031_create_countries.rb +++ b/db/migrate/031_create_countries.rb @@ -1,5 +1,5 @@ -require 'migrate' -require 'rexml/document' +require "migrate" +require "rexml/document" class CreateCountries < ActiveRecord::Migration def self.up diff --git a/db/migrate/034_create_languages.rb b/db/migrate/034_create_languages.rb index 8f5244f22..05a70e7a9 100644 --- a/db/migrate/034_create_languages.rb +++ b/db/migrate/034_create_languages.rb @@ -1,4 +1,4 @@ -require 'migrate' +require "migrate" class CreateLanguages < ActiveRecord::Migration def change diff --git a/db/migrate/035_change_user_locale.rb b/db/migrate/035_change_user_locale.rb index 117e1cd0c..cfdb657f2 100644 --- a/db/migrate/035_change_user_locale.rb +++ b/db/migrate/035_change_user_locale.rb @@ -1,4 +1,4 @@ -require 'migrate' +require "migrate" class ChangeUserLocale < ActiveRecord::Migration def self.up diff --git a/db/migrate/039_add_more_controls_to_gpx_files.rb b/db/migrate/039_add_more_controls_to_gpx_files.rb index 5382324b3..c1e20ffd7 100644 --- a/db/migrate/039_add_more_controls_to_gpx_files.rb +++ b/db/migrate/039_add_more_controls_to_gpx_files.rb @@ -1,4 +1,4 @@ -require 'migrate' +require "migrate" class AddMoreControlsToGpxFiles < ActiveRecord::Migration def self.up diff --git a/db/migrate/042_add_foreign_keys_to_oauth_tables.rb b/db/migrate/042_add_foreign_keys_to_oauth_tables.rb index abc4e9c51..f8e36711f 100644 --- a/db/migrate/042_add_foreign_keys_to_oauth_tables.rb +++ b/db/migrate/042_add_foreign_keys_to_oauth_tables.rb @@ -1,4 +1,4 @@ -require 'migrate' +require "migrate" class AddForeignKeysToOauthTables < ActiveRecord::Migration def change diff --git a/db/migrate/044_create_user_roles.rb b/db/migrate/044_create_user_roles.rb index bd7ac41af..b5e439406 100644 --- a/db/migrate/044_create_user_roles.rb +++ b/db/migrate/044_create_user_roles.rb @@ -1,4 +1,4 @@ -require 'migrate' +require "migrate" class CreateUserRoles < ActiveRecord::Migration def self.up diff --git a/db/migrate/045_create_user_blocks.rb b/db/migrate/045_create_user_blocks.rb index e97822a0d..cdb36cd15 100644 --- a/db/migrate/045_create_user_blocks.rb +++ b/db/migrate/045_create_user_blocks.rb @@ -1,4 +1,4 @@ -require 'migrate' +require "migrate" class CreateUserBlocks < ActiveRecord::Migration def change diff --git a/db/migrate/046_alter_user_roles_and_blocks.rb b/db/migrate/046_alter_user_roles_and_blocks.rb index 864f0db5d..5957b13ba 100644 --- a/db/migrate/046_alter_user_roles_and_blocks.rb +++ b/db/migrate/046_alter_user_roles_and_blocks.rb @@ -1,4 +1,4 @@ -require 'migrate' +require "migrate" class AlterUserRolesAndBlocks < ActiveRecord::Migration def self.up diff --git a/db/migrate/051_add_status_to_user.rb b/db/migrate/051_add_status_to_user.rb index dc8d58138..f98cfd1eb 100644 --- a/db/migrate/051_add_status_to_user.rb +++ b/db/migrate/051_add_status_to_user.rb @@ -1,4 +1,4 @@ -require 'migrate' +require "migrate" class AddStatusToUser < ActiveRecord::Migration def self.up diff --git a/db/migrate/053_add_map_bug_tables.rb b/db/migrate/053_add_map_bug_tables.rb index 54c23fd1d..52d190424 100644 --- a/db/migrate/053_add_map_bug_tables.rb +++ b/db/migrate/053_add_map_bug_tables.rb @@ -1,4 +1,4 @@ -require 'migrate' +require "migrate" class AddMapBugTables < ActiveRecord::Migration def self.up diff --git a/db/migrate/054_refactor_map_bug_tables.rb b/db/migrate/054_refactor_map_bug_tables.rb index 588f654d0..70ed81e45 100644 --- a/db/migrate/054_refactor_map_bug_tables.rb +++ b/db/migrate/054_refactor_map_bug_tables.rb @@ -1,4 +1,4 @@ -require 'migrate' +require "migrate" class RefactorMapBugTables < ActiveRecord::Migration def self.up diff --git a/db/migrate/055_change_map_bug_comment_type.rb b/db/migrate/055_change_map_bug_comment_type.rb index 35186100d..4f979da98 100644 --- a/db/migrate/055_change_map_bug_comment_type.rb +++ b/db/migrate/055_change_map_bug_comment_type.rb @@ -1,4 +1,4 @@ -require 'migrate' +require "migrate" class ChangeMapBugCommentType < ActiveRecord::Migration def self.up diff --git a/db/migrate/056_add_date_closed.rb b/db/migrate/056_add_date_closed.rb index 39a63852f..50aeb6c4f 100644 --- a/db/migrate/056_add_date_closed.rb +++ b/db/migrate/056_add_date_closed.rb @@ -1,4 +1,4 @@ -require 'migrate' +require "migrate" class AddDateClosed < ActiveRecord::Migration def self.up diff --git a/db/migrate/057_add_map_bug_comment_event.rb b/db/migrate/057_add_map_bug_comment_event.rb index 98e64599e..d5e77f499 100644 --- a/db/migrate/057_add_map_bug_comment_event.rb +++ b/db/migrate/057_add_map_bug_comment_event.rb @@ -1,4 +1,4 @@ -require 'migrate' +require "migrate" class AddMapBugCommentEvent < ActiveRecord::Migration def self.up diff --git a/db/migrate/20110521142405_rename_bugs_to_notes.rb b/db/migrate/20110521142405_rename_bugs_to_notes.rb index 5b9933e04..44ca1f484 100644 --- a/db/migrate/20110521142405_rename_bugs_to_notes.rb +++ b/db/migrate/20110521142405_rename_bugs_to_notes.rb @@ -1,4 +1,4 @@ -require 'migrate' +require "migrate" class RenameBugsToNotes < ActiveRecord::Migration def self.up diff --git a/db/migrate/20111212183945_add_lowercase_user_indexes.rb b/db/migrate/20111212183945_add_lowercase_user_indexes.rb index 69e7ed299..f25175590 100644 --- a/db/migrate/20111212183945_add_lowercase_user_indexes.rb +++ b/db/migrate/20111212183945_add_lowercase_user_indexes.rb @@ -1,4 +1,4 @@ -require 'migrate' +require "migrate" class AddLowercaseUserIndexes < ActiveRecord::Migration def up diff --git a/db/migrate/20120214210114_add_text_format.rb b/db/migrate/20120214210114_add_text_format.rb index 0b0ca5004..3f82c3292 100644 --- a/db/migrate/20120214210114_add_text_format.rb +++ b/db/migrate/20120214210114_add_text_format.rb @@ -1,4 +1,4 @@ -require 'migrate' +require "migrate" class AddTextFormat < ActiveRecord::Migration def up diff --git a/db/migrate/20120318201948_create_redactions.rb b/db/migrate/20120318201948_create_redactions.rb index 15cc1e13b..bb9786db4 100644 --- a/db/migrate/20120318201948_create_redactions.rb +++ b/db/migrate/20120318201948_create_redactions.rb @@ -1,4 +1,4 @@ -require 'migrate' +require "migrate" class CreateRedactions < ActiveRecord::Migration def change diff --git a/db/migrate/20120328090602_drop_session_table.rb b/db/migrate/20120328090602_drop_session_table.rb index 627db6d7c..0ffcb899b 100644 --- a/db/migrate/20120328090602_drop_session_table.rb +++ b/db/migrate/20120328090602_drop_session_table.rb @@ -1,4 +1,4 @@ -require 'migrate' +require "migrate" class DropSessionTable < ActiveRecord::Migration def up diff --git a/db/migrate/20120404205604_add_user_and_description_to_redaction.rb b/db/migrate/20120404205604_add_user_and_description_to_redaction.rb index 0ca0be4a0..5de170ca7 100644 --- a/db/migrate/20120404205604_add_user_and_description_to_redaction.rb +++ b/db/migrate/20120404205604_add_user_and_description_to_redaction.rb @@ -1,4 +1,4 @@ -require 'migrate' +require "migrate" class AddUserAndDescriptionToRedaction < ActiveRecord::Migration def change diff --git a/db/migrate/20140115192822_add_text_index_to_note_comments.rb b/db/migrate/20140115192822_add_text_index_to_note_comments.rb index e0d223060..fe9134048 100644 --- a/db/migrate/20140115192822_add_text_index_to_note_comments.rb +++ b/db/migrate/20140115192822_add_text_index_to_note_comments.rb @@ -1,4 +1,4 @@ -require 'migrate' +require "migrate" class AddTextIndexToNoteComments < ActiveRecord::Migration def up diff --git a/db/migrate/20140507110937_create_changeset_comments.rb b/db/migrate/20140507110937_create_changeset_comments.rb index cfc499535..26c257cbc 100644 --- a/db/migrate/20140507110937_create_changeset_comments.rb +++ b/db/migrate/20140507110937_create_changeset_comments.rb @@ -1,4 +1,4 @@ -require 'migrate' +require "migrate" class CreateChangesetComments < ActiveRecord::Migration def change diff --git a/db/migrate/20140519141742_add_join_table_between_users_and_changesets.rb b/db/migrate/20140519141742_add_join_table_between_users_and_changesets.rb index c23ed1f9f..b6962e7d5 100644 --- a/db/migrate/20140519141742_add_join_table_between_users_and_changesets.rb +++ b/db/migrate/20140519141742_add_join_table_between_users_and_changesets.rb @@ -1,4 +1,4 @@ -require 'migrate' +require "migrate" class AddJoinTableBetweenUsersAndChangesets < ActiveRecord::Migration def change diff --git a/lib/bounding_box.rb b/lib/bounding_box.rb index a8ae1d99c..6fa133e06 100644 --- a/lib/bounding_box.rb +++ b/lib/bounding_box.rb @@ -16,12 +16,12 @@ class BoundingBox end def self.from_s(s) - BoundingBox.new(*s.split(/,/)) if s.count(',') == 3 + BoundingBox.new(*s.split(/,/)) if s.count(",") == 3 end def self.from_bbox_params(params) - if params[:bbox] && params[:bbox].count(',') == 3 - bbox_array = params[:bbox].split(',') + if params[:bbox] && params[:bbox].count(",") == 3 + bbox_array = params[:bbox].split(",") end from_bbox_array(bbox_array) end diff --git a/lib/classic_pagination/pagination.rb b/lib/classic_pagination/pagination.rb index 3fa1109f0..990a53d8b 100644 --- a/lib/classic_pagination/pagination.rb +++ b/lib/classic_pagination/pagination.rb @@ -77,7 +77,7 @@ module ActionController :include => nil, :select => nil, :group => nil, - :parameter => 'page' + :parameter => "page" } end @@ -226,7 +226,7 @@ module ActionController # than or equal to zero). The page CGI parameter for links defaults to # "page" and can be overridden with +page_parameter+. def initialize(controller, item_count, items_per_page, current_page = 1) - fail ArgumentError, 'must have at least one item per page' if + fail ArgumentError, "must have at least one item per page" if items_per_page <= 0 @controller = controller @@ -243,7 +243,7 @@ module ActionController # not belong to this Paginator, an ArgumentError is raised. def current_page=(page) if page.is_a? Page - fail ArgumentError, 'Page/Paginator mismatch' unless + fail ArgumentError, "Page/Paginator mismatch" unless page.paginator == self end page = page.to_i diff --git a/lib/classic_pagination/pagination_helper.rb b/lib/classic_pagination/pagination_helper.rb index cb7ef9dfe..da1bcbec6 100644 --- a/lib/classic_pagination/pagination_helper.rb +++ b/lib/classic_pagination/pagination_helper.rb @@ -60,8 +60,8 @@ module ActionView name = options[:name] || DEFAULT_OPTIONS[:name] params = (options[:params] || DEFAULT_OPTIONS[:params]).clone - prefix = options[:prefix] || '' - suffix = options[:suffix] || '' + prefix = options[:prefix] || "" + suffix = options[:suffix] || "" pagination_links_each(paginator, options, prefix, suffix) do |n| params[name] = n @@ -101,14 +101,14 @@ module ActionView first, last = paginator.first, paginator.last - html = '' + html = "" html << prefix if prefix if always_show_anchors && !(wp_first = window_pages[0]).first? html << yield(first.number) - html << ' ... ' if wp_first.number - first.number > 1 - html << ' ' + html << " ... " if wp_first.number - first.number > 1 + html << " " end window_pages.each do |page| @@ -117,11 +117,11 @@ module ActionView else html << yield(page.number) end - html << ' ' + html << " " end if always_show_anchors && !(wp_last = window_pages[-1]).last? - html << ' ... ' if last.number - wp_last.number > 1 + html << " ... " if last.number - wp_last.number > 1 html << yield(last.number) end diff --git a/lib/daemons/gpx_import.rb b/lib/daemons/gpx_import.rb index 3679aa448..4445d1ec0 100755 --- a/lib/daemons/gpx_import.rb +++ b/lib/daemons/gpx_import.rb @@ -23,7 +23,7 @@ loop do if gpx.actual_points > 0 Notifier.gpx_success(trace, gpx.actual_points).deliver else - 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 end rescue StandardError => ex diff --git a/lib/daemons/gpx_import_ctl b/lib/daemons/gpx_import_ctl index fc81e7549..43fb48c15 100755 --- a/lib/daemons/gpx_import_ctl +++ b/lib/daemons/gpx_import_ctl @@ -1,8 +1,8 @@ #!/usr/bin/env ruby -require 'rubygems' +require "rubygems" require "daemons" -require 'yaml' -require 'erb' +require "yaml" +require "erb" class Hash def with_symbols! @@ -18,4 +18,4 @@ options = YAML.load( )).result).with_symbols! options[:dir_mode] = options[:dir_mode].to_sym -Daemons.run File.dirname(__FILE__) + '/gpx_import.rb', options +Daemons.run File.dirname(__FILE__) + "/gpx_import.rb", options diff --git a/lib/diff_reader.rb b/lib/diff_reader.rb index be6fee7bb..3ec4f146a 100644 --- a/lib/diff_reader.rb +++ b/lib/diff_reader.rb @@ -129,14 +129,14 @@ class DiffReader # take the first element and check that it is an osmChange element @reader.read - fail OSM::APIBadUserInput.new("Document element should be 'osmChange'.") if @reader.name != 'osmChange' + fail OSM::APIBadUserInput.new("Document element should be 'osmChange'.") if @reader.name != "osmChange" result = OSM::API.new.get_xml_doc result.root.name = "diffResult" # loop at the top level, within the <osmChange> element with_element do |action_name, action_attributes| - if action_name == 'create' + if action_name == "create" # create a new element. this code is agnostic of the element type # because all the elements support the methods that we're using. with_model do |model, xml| @@ -145,7 +145,7 @@ class DiffReader # when this element is saved it will get a new ID, so we save it # to produce the mapping which is sent to other elements. - placeholder_id = xml['id'].to_i + placeholder_id = xml["id"].to_i fail OSM::APIBadXMLError.new(model, xml) if placeholder_id.nil? # check if the placeholder ID has been given before and throw @@ -171,7 +171,7 @@ class DiffReader result.root << xml_result end - elsif action_name == 'modify' + elsif action_name == "modify" # modify an existing element. again, this code doesn't directly deal # with types, but uses duck typing to handle them transparently. with_model do |model, xml| @@ -203,13 +203,13 @@ class DiffReader result.root << xml_result end - elsif action_name == 'delete' + elsif action_name == "delete" # delete action. this takes a payload in API 0.6, so we need to do # most of the same checks that are done for the modify. with_model do |model, xml| # delete doesn't have to contain a full payload, according to # the wiki docs, so we just extract the things we need. - new_id = xml['id'].to_i + new_id = xml["id"].to_i fail OSM::APIBadXMLError.new(model, xml, "ID attribute is required") if new_id.nil? # if the ID is a placeholder then map it to the real ID @@ -219,8 +219,8 @@ class DiffReader # build the "new" element by modifying the existing one new = model.find(id) - new.changeset_id = xml['changeset'].to_i - new.version = xml['version'].to_i + new.changeset_id = xml["changeset"].to_i + new.version = xml["version"].to_i check(model, xml, new) # fetch the matching old element from the DB diff --git a/lib/gpx.rb b/lib/gpx.rb index 5a61b344a..9b93f07f2 100644 --- a/lib/gpx.rb +++ b/lib/gpx.rb @@ -52,21 +52,21 @@ module GPX proj = OSM::Mercator.new(min_lat, min_lon, max_lat, max_lon, width, height) linegc = Magick::Draw.new - linegc.stroke_linejoin('miter') + linegc.stroke_linejoin("miter") linegc.stroke_width(1) - linegc.stroke('#BBBBBB') - linegc.fill('#BBBBBB') + linegc.stroke("#BBBBBB") + linegc.fill("#BBBBBB") highlightgc = Magick::Draw.new - highlightgc.stroke_linejoin('miter') + highlightgc.stroke_linejoin("miter") highlightgc.stroke_width(3) - highlightgc.stroke('#000000') - highlightgc.fill('#000000') + highlightgc.stroke("#000000") + highlightgc.fill("#000000") images = frames.times.collect do Magick::Image.new(width, height) do |image| - image.background_color = 'white' - image.format = 'GIF' + image.background_color = "white" + image.format = "GIF" end end @@ -107,7 +107,7 @@ module GPX end il.delay = 50 - il.format = 'GIF' + il.format = "GIF" il.to_blob end @@ -118,14 +118,14 @@ module GPX proj = OSM::Mercator.new(min_lat, min_lon, max_lat, max_lon, width, height) gc = Magick::Draw.new - gc.stroke_linejoin('miter') + gc.stroke_linejoin("miter") gc.stroke_width(1) - gc.stroke('#000000') - gc.fill('#000000') + gc.stroke("#000000") + gc.fill("#000000") image = Magick::Image.new(width, height) do |i| - i.background_color = 'white' - i.format = 'GIF' + i.background_color = "white" + i.format = "GIF" end oldpx = 0.0 diff --git a/lib/id.rb b/lib/id.rb index 732194422..15f918e79 100644 --- a/lib/id.rb +++ b/lib/id.rb @@ -1,3 +1,3 @@ module ID - LOCALES = Rails.root.join('vendor/assets/iD/iD/locales').entries.map { |p| p.basename.to_s[/(.*).json/] && $1 }.compact + LOCALES = Rails.root.join("vendor/assets/iD/iD/locales").entries.map { |p| p.basename.to_s[/(.*).json/] && $1 }.compact end diff --git a/lib/nominatim.rb b/lib/nominatim.rb index c5d60cebd..97d158cfd 100644 --- a/lib/nominatim.rb +++ b/lib/nominatim.rb @@ -3,7 +3,7 @@ module Nominatim def self.describe_location(lat, lon, zoom = nil, language = nil) zoom ||= 14 - language ||= http_accept_language.user_preferred_languages.join(',') + language ||= http_accept_language.user_preferred_languages.join(",") Rails.cache.fetch "/nominatim/location/#{lat}/#{lon}/#{zoom}/#{language}" do url = "http://nominatim.openstreetmap.org/reverse?lat=#{lat}&lon=#{lon}&zoom=#{zoom}&accept-language=#{language}" diff --git a/lib/not_redactable.rb b/lib/not_redactable.rb index 75ff33176..fb945612a 100644 --- a/lib/not_redactable.rb +++ b/lib/not_redactable.rb @@ -1,4 +1,4 @@ -require 'osm' +require "osm" module NotRedactable def redacted? diff --git a/lib/object_metadata.rb b/lib/object_metadata.rb index 4243c6437..c765df526 100644 --- a/lib/object_metadata.rb +++ b/lib/object_metadata.rb @@ -1,10 +1,10 @@ module ObjectMetadata def add_metadata_to_xml_node(el, osm, changeset_cache, user_display_name_cache) - el['changeset'] = osm.changeset_id.to_s - el['redacted'] = osm.redaction.id.to_s if osm.redacted? - el['timestamp'] = osm.timestamp.xmlschema - el['version'] = osm.version.to_s - el['visible'] = osm.visible.to_s + el["changeset"] = osm.changeset_id.to_s + el["redacted"] = osm.redaction.id.to_s if osm.redacted? + el["timestamp"] = osm.timestamp.xmlschema + el["version"] = osm.version.to_s + el["visible"] = osm.visible.to_s if changeset_cache.key?(osm.changeset_id) # use the cache if available @@ -23,17 +23,17 @@ module ObjectMetadata end unless user_display_name_cache[user_id].nil? - el['user'] = user_display_name_cache[user_id] - el['uid'] = user_id.to_s + el["user"] = user_display_name_cache[user_id] + el["uid"] = user_id.to_s end end def add_tags_to_xml_node(el, tags) tags.each do |tag| - tag_el = XML::Node.new('tag') + tag_el = XML::Node.new("tag") - tag_el['k'] = tag.k - tag_el['v'] = tag.v + tag_el["k"] = tag.k + tag_el["v"] = tag.v el << tag_el end diff --git a/lib/osm.rb b/lib/osm.rb index 89333763f..3a0beccdf 100644 --- a/lib/osm.rb +++ b/lib/osm.rb @@ -1,14 +1,14 @@ # The OSM module provides support functions for OSM. module OSM - require 'time' - require 'rexml/parsers/sax2parser' - require 'rexml/text' - require 'xml/libxml' + require "time" + require "rexml/parsers/sax2parser" + require "rexml/text" + require "xml/libxml" if defined?(SystemTimer) Timer = SystemTimer else - require 'timeout' + require "timeout" Timer = Timeout end @@ -482,12 +482,12 @@ module OSM def get_xml_doc doc = XML::Document.new doc.encoding = XML::Encoding::UTF_8 - root = XML::Node.new 'osm' - root['version'] = API_VERSION.to_s - root['generator'] = GENERATOR - root['copyright'] = COPYRIGHT_OWNER - root['attribution'] = ATTRIBUTION_URL - root['license'] = LICENSE_URL + root = XML::Node.new "osm" + root["version"] = API_VERSION.to_s + root["generator"] = GENERATOR + root["copyright"] = COPYRIGHT_OWNER + root["attribution"] = ATTRIBUTION_URL + root["license"] = LICENSE_URL doc.root = root doc end @@ -500,7 +500,7 @@ module OSM if ipinfo.status == Quova::SUCCESS country = ipinfo.country_code else - Net::HTTP.start('api.hostip.info') do |http| + Net::HTTP.start("api.hostip.info") do |http| country = http.get("/country.php?ip=#{ip_address}").body country = "GB" if country == "UK" end @@ -533,8 +533,8 @@ module OSM # Construct a random token of a given length def self.make_token(length = 30) - chars = 'abcdefghijklmnopqrtuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789' - token = '' + chars = "abcdefghijklmnopqrtuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" + token = "" length.times do token += chars[(rand * chars.length).to_i].chr diff --git a/lib/output_compression/output_compression.rb b/lib/output_compression/output_compression.rb index df8e55cb6..fc80d68ad 100644 --- a/lib/output_compression/output_compression.rb +++ b/lib/output_compression/output_compression.rb @@ -13,8 +13,8 @@ # end begin - require 'zlib' - require 'stringio' + require "zlib" + require "stringio" GZIP_SUPPORTED = true rescue GZIP_SUPPORTED = false @@ -34,13 +34,13 @@ module CompressionSystem if output.length < response.body.length @old_response_body = response.body response.body = output.string - response.headers['Content-encoding'] = @compression_encoding + response.headers["Content-encoding"] = @compression_encoding end end def accepts_gzip? return false unless GZIP_SUPPORTED - accepts = request.env['HTTP_ACCEPT_ENCODING'] + accepts = request.env["HTTP_ACCEPT_ENCODING"] return false unless accepts && accepts =~ /(x-gzip|gzip)/ @compression_encoding = $1 true @@ -49,15 +49,15 @@ module CompressionSystem def strip_whitespace response.body.gsub!(/()|(.*?<\/script>)|()|()|\s+/m) do |m| if m =~ /^()(.*?)<\/script>$/m - $1 + $2.strip.gsub(/\s+/, ' ').gsub('', "\n-->") + '' + $1 + $2.strip.gsub(/\s+/, " ").gsub("", "\n-->") + "" elsif m =~ /^$/m - '' + "" elsif m =~ /^<(textarea|pre)/ m - else ' ' + else " " end end - response.body.gsub! /\s+\s+/, '>' + response.body.gsub! /\s+\s+/, ">" end end diff --git a/lib/potlatch.rb b/lib/potlatch.rb index 879972e03..2030f55c3 100644 --- a/lib/potlatch.rb +++ b/lib/potlatch.rb @@ -1,4 +1,4 @@ -require 'stringio' +require "stringio" # The Potlatch module provides helper functions for potlatch and its communication with the server module Potlatch @@ -24,7 +24,7 @@ module Potlatch # Return eight-byte double-precision float def self.getdouble(s) - a = s.read(8).unpack('G') # G big-endian, E little-endian + a = s.read(8).unpack("G") # G big-endian, E little-endian a[0] end @@ -39,7 +39,7 @@ module Potlatch def self.getobject(s) arr = {} while (key = getstring(s)) - break if key == '' + break if key == "" arr[key] = getvalue(s) end s.getbyte # skip the 9 'end of object' value @@ -74,27 +74,27 @@ module Potlatch # Pack variables as AMF def self.encodevalue(n) case n.class.to_s - when 'Array' + when "Array" a = 10.chr + encodelong(n.length) n.each do |b| a += encodevalue(b) end a - when 'Hash' + when "Hash" a = 3.chr n.each do |k, v| a += encodestring(k.to_s) + encodevalue(v) end a + 0.chr + 0.chr + 9.chr - when 'String' + when "String" 2.chr + encodestring(n) - when 'Bignum', 'Fixnum', 'Float' + when "Bignum", "Fixnum", "Float" 0.chr + encodedouble(n) - when 'NilClass' + when "NilClass" 5.chr - when 'TrueClass' + when "TrueClass" 0.chr + encodedouble(1) - when 'FalseClass' + when "FalseClass" 0.chr + encodedouble(0) else Rails.logger.error("Unexpected Ruby type for AMF conversion: " + n.class.to_s) @@ -110,12 +110,12 @@ module Potlatch # Encode number as eight-byte double precision float def self.encodedouble(n) - [n].pack('G') + [n].pack("G") end # Encode number as four-byte long def self.encodelong(n) - [n].pack('N') + [n].pack("N") end end @@ -175,10 +175,10 @@ module Potlatch # Read preset menus presets = {} - presetmenus = { 'point' => [], 'way' => [], 'POI' => [] } - presetnames = { 'point' => {}, 'way' => {}, 'POI' => {} } - presettype = '' - presetcategory = '' + presetmenus = { "point" => [], "way" => [], "POI" => [] } + presetnames = { "point" => {}, "way" => {}, "POI" => {} } + presettype = "" + presetcategory = "" # StringIO.open(txt) do |file| File.open("#{Rails.root}/config/potlatch/presets.txt") do |file| file.each_line do|line| @@ -193,7 +193,7 @@ module Potlatch kv = $2 presetnames[presettype][presetcategory].push(pre) presets[pre] = {} - kv.split(',').each do|a| + kv.split(",").each do|a| presets[pre][$1] = $2 if a =~ /^(.+)=(.*)$/ end end @@ -209,9 +209,9 @@ module Potlatch next unless line.chomp =~ /(\w+)\s+([^\s]+)\s+([^\s]+)\s+([^\s]+)/ tag = $1 - colours[tag] = $2.hex if $2 != '-' - casing[tag] = $3.hex if $3 != '-' - areas[tag] = $4.hex if $4 != '-' + colours[tag] = $2.hex if $2 != "-" + casing[tag] = $3.hex if $3 != "-" + areas[tag] = $4.hex if $4 != "-" end end @@ -224,9 +224,9 @@ module Potlatch next unless line.chomp =~ /(\w+)\s+([^\s]+)\s+([^\s]+)\s+([^\s]+)/ tag = $1 - relcolours[tag] = $2.hex if $2 != '-' - relalphas[tag] = $3.to_i if $3 != '-' - relwidths[tag] = $4.to_i if $4 != '-' + relcolours[tag] = $2.hex if $2 != "-" + relalphas[tag] = $3.to_i if $3 != "-" + relwidths[tag] = $4.to_i if $4 != "-" end end @@ -243,7 +243,7 @@ module Potlatch icon_list.reverse! # Read auto-complete - autotags = { 'point' => {}, 'way' => {}, 'POI' => {} } + autotags = { "point" => {}, "way" => {}, "POI" => {} } File.open("#{Rails.root}/config/potlatch/autocomplete.txt") do |file| file.each_line do|line| next unless line.chomp =~ /^([\w:]+)\/(\w+)\s+(.+)$/ @@ -251,10 +251,10 @@ module Potlatch tag = $1 type = $2 values = $3 - if values == '-' + if values == "-" autotags[type][tag] = [] else - autotags[type][tag] = values.split(',').sort.reverse + autotags[type][tag] = values.split(",").sort.reverse end end end diff --git a/lib/quova.rb b/lib/quova.rb index a59f432b5..6cfc2ff92 100644 --- a/lib/quova.rb +++ b/lib/quova.rb @@ -1,6 +1,6 @@ ## # Load required libraries -require 'soap/wsdlDriver' +require "soap/wsdlDriver" ## # Monkey patch WSDL parser to stop it moaning diff --git a/lib/redactable.rb b/lib/redactable.rb index c46b32737..a42164ec7 100644 --- a/lib/redactable.rb +++ b/lib/redactable.rb @@ -1,4 +1,4 @@ -require 'osm' +require "osm" module Redactable def self.included(base) diff --git a/lib/short_link.rb b/lib/short_link.rb index 44b9d719d..69634cea5 100644 --- a/lib/short_link.rb +++ b/lib/short_link.rb @@ -8,7 +8,7 @@ module ShortLink # array of 64 chars to encode 6 bits. this is almost like base64 encoding, but # the symbolic chars are different, as base64's + and / aren't very # URL-friendly. - ARRAY = ('A'..'Z').to_a + ('a'..'z').to_a + ('0'..'9').to_a + ['_', '~'] + ARRAY = ("A".."Z").to_a + ("a".."z").to_a + ("0".."9").to_a + ["_", "~"] ## # Given a string encoding a location, returns the [lon, lat, z] tuple of that diff --git a/lib/tasks/add_version_to_nodes.rake b/lib/tasks/add_version_to_nodes.rake index f86961904..cdcf13a3e 100644 --- a/lib/tasks/add_version_to_nodes.rake +++ b/lib/tasks/add_version_to_nodes.rake @@ -1,17 +1,17 @@ -namespace 'db' do - desc 'Adds a version number to the nodes table' +namespace "db" do + desc "Adds a version number to the nodes table" task :node_version do - require File.dirname(__FILE__) + '/../../config/environment' + require File.dirname(__FILE__) + "/../../config/environment" increment = 1000 offset = 0 - id_max = OldNode.find(:first, :order => 'id desc').id + id_max = OldNode.find(:first, :order => "id desc").id while offset < (id_max + increment) hash = {} # should be offsetting not selecting - OldNode.find(:all, :limit => increment, :offset => offset, :order => 'timestamp').each do |node| + OldNode.find(:all, :limit => increment, :offset => offset, :order => "timestamp").each do |node| hash[node.id] ||= [] hash[node.id] << node end diff --git a/lib/tasks/testing.rake b/lib/tasks/testing.rake index ec0bd9459..ffee7f050 100644 --- a/lib/tasks/testing.rake +++ b/lib/tasks/testing.rake @@ -1,5 +1,5 @@ namespace :test do Rails::TestTask.new(lib: "test:prepare") do |t| - t.pattern = 'test/lib/**/*_test.rb' + t.pattern = "test/lib/**/*_test.rb" end end diff --git a/lib/utf8.rb b/lib/utf8.rb index e669d8aae..9e9279deb 100644 --- a/lib/utf8.rb +++ b/lib/utf8.rb @@ -2,13 +2,13 @@ module UTF8 ## # Checks that a string is valid UTF-8 by trying to convert it to UTF-8 # using the iconv library, which is in the standard library. - if ''.respond_to?("valid_encoding?") + if "".respond_to?("valid_encoding?") def self.valid?(str) return true if str.nil? str.valid_encoding? end else - require 'iconv' + require "iconv" def self.valid?(str) return true if str.nil? diff --git a/script/cleanup b/script/cleanup index 797193cce..d7f29239c 100755 --- a/script/cleanup +++ b/script/cleanup @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -require File.dirname(__FILE__) + '/../config/environment' +require File.dirname(__FILE__) + "/../config/environment" UserToken.delete_all("expiry < NOW()") diff --git a/script/deliver-message b/script/deliver-message index e6a5ebbd7..04dcb881b 100755 --- a/script/deliver-message +++ b/script/deliver-message @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -require File.dirname(__FILE__) + '/../config/environment' +require File.dirname(__FILE__) + "/../config/environment" exit 0 unless recipient = ARGV[0].match(/^([cm])-(\d+)-(.*)$/) diff --git a/script/locale/po2yaml b/script/locale/po2yaml index a4b8ac8b7..69278ea69 100755 --- a/script/locale/po2yaml +++ b/script/locale/po2yaml @@ -21,11 +21,11 @@ end def po2hash(f) trs = {} path = [] - msgstr = '' + msgstr = "" f.each_line do |line| line.strip! if line[0..8] == 'msgctxt "' - path = line[9..-2].split(':') + path = line[9..-2].split(":") elsif line[0..7] == 'msgstr "' msgstr = line[8..-2] end @@ -34,7 +34,7 @@ def po2hash(f) add_translation(trs, path, msgstr) path = [] - msgstr = '' + msgstr = "" end trs end @@ -42,7 +42,7 @@ end filename = ARGV[0] pofile = File.open(filename, "r") -langcode = File.basename(filename, '.po') +langcode = File.basename(filename, ".po") tr = { langcode => po2hash(pofile) } diff --git a/script/locale/reload-languages b/script/locale/reload-languages index b4f829c7b..56a96b6c8 100755 --- a/script/locale/reload-languages +++ b/script/locale/reload-languages @@ -1,5 +1,5 @@ #!/usr/bin/env ruby -require File.dirname(__FILE__) + '/../../config/environment' +require File.dirname(__FILE__) + "/../../config/environment" Language.load(RAILS_ROOT + "/config/languages.yml") diff --git a/script/locale/yaml2po b/script/locale/yaml2po index 2753d69b7..dbfa1eb74 100755 --- a/script/locale/yaml2po +++ b/script/locale/yaml2po @@ -12,15 +12,15 @@ require "yaml" require "optparse" -LOCALE_DIR = File.dirname(__FILE__) + '/../../config/locales/' -EN = YAML.load_file(LOCALE_DIR + 'en.yml') +LOCALE_DIR = File.dirname(__FILE__) + "/../../config/locales/" +EN = YAML.load_file(LOCALE_DIR + "en.yml") -def iterate(hash, fhash = {}, path = '', outfile = $stdout) +def iterate(hash, fhash = {}, path = "", outfile = $stdout) hash.each do |key, val| fhash[key] = {} unless fhash.key? key if val.is_a? Hash fhash[key] = {} unless fhash[key].is_a? Hash - iterate(val, fhash[key], path + key + ':', outfile) + iterate(val, fhash[key], path + key + ":", outfile) else outfile.puts "msgctxt \"#{path}#{key}\"" outfile.puts "msgid \"#{val}\"" @@ -31,34 +31,34 @@ end def lang2po(lang, outfile = $stdout) puts lang - infile = LOCALE_DIR + lang + '.yml' + infile = LOCALE_DIR + lang + ".yml" if File.exist? infile oth = YAML.load_file(infile) oth = oth[lang] - iterate(EN['en'], oth, '', outfile) + iterate(EN["en"], oth, "", outfile) else - iterate(EN['en'], {}, '', outfile) + iterate(EN["en"], {}, "", outfile) end end opt = ARGV[0] -if opt == '--all' +if opt == "--all" # Produce .po files for all langs, and a .pot template - PO_DIR = LOCALE_DIR + 'po/' + PO_DIR = LOCALE_DIR + "po/" Dir.mkdir(PO_DIR) unless File.directory?(PO_DIR) Dir.glob(LOCALE_DIR + "*.yml") do |filename| - lang = File.basename(filename, '.yml') - unless lang == 'en' - outfile = File.new(PO_DIR + "#{lang}.po", 'w') + lang = File.basename(filename, ".yml") + unless lang == "en" + outfile = File.new(PO_DIR + "#{lang}.po", "w") lang2po(lang, outfile) outfile.close end end - outfile = File.new(PO_DIR + "rails_port.pot", 'w') - iterate(EN['en'], {}, '', outfile) + outfile = File.new(PO_DIR + "rails_port.pot", "w") + iterate(EN["en"], {}, "", outfile) outfile.close elsif opt lang2po(opt) else - iterate(EN['en']) + iterate(EN["en"]) end diff --git a/script/rails b/script/rails index f8da2cffd..e667e55e3 100755 --- a/script/rails +++ b/script/rails @@ -1,6 +1,6 @@ #!/usr/bin/env ruby # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application. -APP_PATH = File.expand_path('../../config/application', __FILE__) -require File.expand_path('../../config/boot', __FILE__) -require 'rails/commands' +APP_PATH = File.expand_path("../../config/application", __FILE__) +require File.expand_path("../../config/boot", __FILE__) +require "rails/commands" diff --git a/script/statistics b/script/statistics index 4165bb0d3..912302c2e 100755 --- a/script/statistics +++ b/script/statistics @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -require File.dirname(__FILE__) + '/../config/environment' +require File.dirname(__FILE__) + "/../config/environment" start_time = Time.now @@ -34,7 +34,7 @@ begin puts "<tr><th>User</th><th>Number of Points</th></tr>" Trace.where(:inserted => true).group(:user_id).order("sum_size DESC").limit(50).sum(:size).each do |user, count| - display_name = User.find(user).display_name.gsub('@', ' at ').gsub('.', ' dot ') + display_name = User.find(user).display_name.gsub("@", " at ").gsub(".", " dot ") puts "<tr><td><a href=\"/user/#{display_name}\">#{display_name}</a></td><td>#{count}</td></tr>" end @@ -72,7 +72,7 @@ begin if column.nil? puts "<td></td>" else - display_name = User.find(column[0]).display_name.gsub('@', ' at ').gsub('.', ' dot ') + display_name = User.find(column[0]).display_name.gsub("@", " at ").gsub(".", " dot ") count = column[1] puts "<td>#{count} <a href=\"/user/#{display_name}\">#{display_name}</a></td>" end diff --git a/script/update-spam-blocks b/script/update-spam-blocks index 772417774..4367fd8da 100755 --- a/script/update-spam-blocks +++ b/script/update-spam-blocks @@ -1,7 +1,7 @@ #!/usr/bin/env ruby -require File.dirname(__FILE__) + '/../config/environment' -require 'generator' +require File.dirname(__FILE__) + "/../config/environment" +require "generator" addresses = User.count( :conditions => { diff --git a/test/controllers/amf_controller_test.rb b/test/controllers/amf_controller_test.rb index def849f2a..fb506ee14 100644 --- a/test/controllers/amf_controller_test.rb +++ b/test/controllers/amf_controller_test.rb @@ -1,5 +1,5 @@ -require 'test_helper' -require 'stringio' +require "test_helper" +require "stringio" include Potlatch class AmfControllerTest < ActionController::TestCase @@ -129,35 +129,35 @@ class AmfControllerTest < ActionController::TestCase # check contents of message map = amf_result "/1" - assert_equal 0, map[0], 'map error code should be 0' - assert_equal "", map[1], 'map error text should be empty' + assert_equal 0, map[0], "map error code should be 0" + assert_equal "", map[1], "map error text should be empty" # check the formatting of the message - assert_equal 5, map.length, 'map should have length 5' + assert_equal 5, map.length, "map should have length 5" assert_equal Array, map[2].class, 'map "ways" element should be an array' assert_equal Array, map[3].class, 'map "nodes" element should be an array' assert_equal Array, map[4].class, 'map "relations" element should be an array' map[2].each do |w| - assert_equal 2, w.length, 'way should be (id, version) pair' - assert w[0] == w[0].floor, 'way ID should be an integer' - assert w[1] == w[1].floor, 'way version should be an integer' + assert_equal 2, w.length, "way should be (id, version) pair" + assert w[0] == w[0].floor, "way ID should be an integer" + assert w[1] == w[1].floor, "way version should be an integer" end map[3].each do |n| - assert_equal 5, w.length, 'node should be (id, lat, lon, [tags], version) tuple' - assert n[0] == n[0].floor, 'node ID should be an integer' - assert n[1] >= minlat - 0.01, 'node lat should be greater than min' - assert n[1] <= maxlat - 0.01, 'node lat should be less than max' - assert n[2] >= minlon - 0.01, 'node lon should be greater than min' - assert n[2] <= maxlon - 0.01, 'node lon should be less than max' - assert_equal Array, a[3].class, 'node tags should be array' - assert n[4] == n[4].floor, 'node version should be an integer' + assert_equal 5, w.length, "node should be (id, lat, lon, [tags], version) tuple" + assert n[0] == n[0].floor, "node ID should be an integer" + assert n[1] >= minlat - 0.01, "node lat should be greater than min" + assert n[1] <= maxlat - 0.01, "node lat should be less than max" + assert n[2] >= minlon - 0.01, "node lon should be greater than min" + assert n[2] <= maxlon - 0.01, "node lon should be less than max" + assert_equal Array, a[3].class, "node tags should be array" + assert n[4] == n[4].floor, "node version should be an integer" end map[4].each do |r| - assert_equal 2, r.length, 'relation should be (id, version) pair' - assert r[0] == r[0].floor, 'relation ID should be an integer' - assert r[1] == r[1].floor, 'relation version should be an integer' + assert_equal 2, r.length, "relation should be (id, version) pair" + assert r[0] == r[0].floor, "relation ID should be an integer" + assert r[1] == r[1].floor, "relation version should be an integer" end # TODO: looks like amf_controller changed since this test was written @@ -166,7 +166,7 @@ class AmfControllerTest < ActionController::TestCase assert ways.include?(current_ways(:used_way).id), "map should include used way" assert !ways.include?(current_ways(:invisible_way).id), - 'map should not include deleted way' + "map should not include deleted way" end ## @@ -214,15 +214,15 @@ class AmfControllerTest < ActionController::TestCase # check contents of message map = amf_result "/1" - assert_equal 0, map[0], 'first map element should be 0' - assert_equal "", map[1], 'second map element should be an empty string' - assert_equal Array, map[2].class, 'third map element should be an array' + assert_equal 0, map[0], "first map element should be 0" + assert_equal "", map[1], "second map element should be an empty string" + assert_equal Array, map[2].class, "third map element should be an array" # TODO: looks like amf_controller changed since this test was written # so someone who knows what they're doing should check this! assert !map[2].include?(current_ways(:used_way).id), "map should not include used way" assert map[2].include?(current_ways(:invisible_way).id), - 'map should include deleted way' + "map should include deleted way" end def test_whichways_deleted_toobig @@ -280,7 +280,7 @@ class AmfControllerTest < ActionController::TestCase # instead of a version number... # try to get version 1 v1 = ways(:way_with_versions_v1) - { latest.id => '', + { latest.id => "", v1.way_id => v1.timestamp.strftime("%d %b %Y, %H:%M:%S") }.each do |id, t| amf_content "getway_old", "/1", [id, t] @@ -323,8 +323,8 @@ class AmfControllerTest < ActionController::TestCase v1 = ways(:way_with_versions_v1) # try to get last visible version of non-existent way # try to get specific version of non-existent way - [[0, ''], - [0, '1 Jan 1970, 00:00:00'], + [[0, ""], + [0, "1 Jan 1970, 00:00:00"], [v1.way_id, (v1.timestamp - 10).strftime("%d %b %Y, %H:%M:%S")] ].each do |id, t| amf_content "getway_old", "/1", [id, t] @@ -350,7 +350,7 @@ class AmfControllerTest < ActionController::TestCase history = amf_result("/1") # ['way',wayid,history] - assert_equal 'way', history[0] + assert_equal "way", history[0] assert_equal latest.id, history[1] # We use dates rather than version numbers here, because you might # have moved a node within a way (i.e. way version not incremented). @@ -368,7 +368,7 @@ class AmfControllerTest < ActionController::TestCase history = amf_result("/1") # ['way',wayid,history] - assert_equal history[0], 'way' + assert_equal history[0], "way" assert_equal history[1], 0 assert history[2].empty? end @@ -384,16 +384,16 @@ class AmfControllerTest < ActionController::TestCase # ['node',nodeid,history] # note that (as per getway_history) we actually round up # to the next second - assert_equal history[0], 'node', + assert_equal history[0], "node", 'first element should be "node"' assert_equal history[1], latest.id, - 'second element should be the input node ID' + "second element should be the input node ID" assert_equal history[2].first[0], (latest.timestamp + 1).strftime("%d %b %Y, %H:%M:%S"), - 'first element in third element (array) should be the latest version' + "first element in third element (array) should be the latest version" assert_equal history[2].last[0], (nodes(:node_with_versions_v1).timestamp + 1).strftime("%d %b %Y, %H:%M:%S"), - 'last element in third element (array) should be the initial version' + "last element in third element (array) should be the initial version" end def test_getnode_history_nonexistent @@ -404,7 +404,7 @@ class AmfControllerTest < ActionController::TestCase history = amf_result("/1") # ['node',nodeid,history] - assert_equal history[0], 'node' + assert_equal history[0], "node" assert_equal history[1], 0 assert history[2].empty? end diff --git a/test/controllers/api_controller_test.rb b/test/controllers/api_controller_test.rb index 75e77f776..5437e2422 100644 --- a/test/controllers/api_controller_test.rb +++ b/test/controllers/api_controller_test.rb @@ -1,5 +1,5 @@ -require 'test_helper' -require 'api_controller' +require "test_helper" +require "api_controller" class ApiControllerTest < ActionController::TestCase api_fixtures @@ -231,7 +231,7 @@ class ApiControllerTest < ActionController::TestCase # http://wiki.openstreetmap.org/wiki/Rails#Installing_the_quadtile_functions # or by looking at the readme in db/README def test_changes_simple - Timecop.freeze(Time.parse('2010-04-03 10:55:00')) + Timecop.freeze(Time.parse("2010-04-03 10:55:00")) get :changes assert_response :success # print @response.body diff --git a/test/controllers/browse_controller_test.rb b/test/controllers/browse_controller_test.rb index 50bd253fc..a84138184 100644 --- a/test/controllers/browse_controller_test.rb +++ b/test/controllers/browse_controller_test.rb @@ -1,5 +1,5 @@ -require 'test_helper' -require 'browse_controller' +require "test_helper" +require "browse_controller" class BrowseControllerTest < ActionController::TestCase api_fixtures @@ -46,35 +46,35 @@ class BrowseControllerTest < ActionController::TestCase end def test_read_relation - browse_check 'relation', relations(:visible_relation).relation_id, 'browse/feature' + browse_check "relation", relations(:visible_relation).relation_id, "browse/feature" end def test_read_relation_history - browse_check 'relation_history', relations(:visible_relation).relation_id, 'browse/history' + browse_check "relation_history", relations(:visible_relation).relation_id, "browse/history" end def test_read_way - browse_check 'way', ways(:visible_way).way_id, 'browse/feature' + browse_check "way", ways(:visible_way).way_id, "browse/feature" end def test_read_way_history - browse_check 'way_history', ways(:visible_way).way_id, 'browse/history' + browse_check "way_history", ways(:visible_way).way_id, "browse/history" end def test_read_node - browse_check 'node', nodes(:visible_node).node_id, 'browse/feature' + browse_check "node", nodes(:visible_node).node_id, "browse/feature" end def test_read_node_history - browse_check 'node_history', nodes(:visible_node).node_id, 'browse/history' + browse_check "node_history", nodes(:visible_node).node_id, "browse/history" end def test_read_changeset - browse_check 'changeset', changesets(:normal_user_first_change).id, 'browse/changeset' + browse_check "changeset", changesets(:normal_user_first_change).id, "browse/changeset" end def test_read_note - browse_check 'note', notes(:open_note).id, 'browse/note' + browse_check "note", notes(:open_note).id, "browse/note" end ## @@ -114,7 +114,7 @@ class BrowseControllerTest < ActionController::TestCase def test_redacted_way_history get :way_history, :id => ways(:way_with_redacted_versions_v1).way_id assert_response :success - assert_template 'browse/history' + assert_template "browse/history" # there are 4 revisions of the redacted way, but only 2 # should be showing details here. @@ -126,7 +126,7 @@ class BrowseControllerTest < ActionController::TestCase def test_redacted_relation_history get :relation_history, :id => relations(:relation_with_redacted_versions_v1).relation_id assert_response :success - assert_template 'browse/history' + assert_template "browse/history" # there are 4 revisions of the redacted relation, but only 2 # should be showing details here. diff --git a/test/controllers/changeset_controller_test.rb b/test/controllers/changeset_controller_test.rb index b65926d93..aad27a06d 100644 --- a/test/controllers/changeset_controller_test.rb +++ b/test/controllers/changeset_controller_test.rb @@ -1,5 +1,5 @@ -require 'test_helper' -require 'changeset_controller' +require "test_helper" +require "changeset_controller" class ChangesetControllerTest < ActionController::TestCase api_fixtures @@ -464,7 +464,7 @@ EOF changeset_id = changesets(:public_user_first_change).id %w(node way relation).each do |type| delete.find("//osmChange/delete/#{type}").each do |n| - n['changeset'] = changeset_id.to_s + n["changeset"] = changeset_id.to_s end end @@ -517,7 +517,7 @@ EOF content "<osm><changeset>" + "<tag k='created_by' v='osm test suite checking changesets'/>" + "</changeset></osm>" - assert_difference('Changeset.count', 1) do + assert_difference("Changeset.count", 1) do put :create end assert_response :success @@ -726,7 +726,7 @@ EOF assert_equal 2, Node.find(new_node_id).tags.size, "new node should have two tags" assert_equal [new_node_id, 3], Way.find(1).nds, "way nodes should match" Relation.find(1).members.each do |type, id, _role| - if type == 'node' + if type == "node" assert_equal new_node_id, id, "relation should contain new node" end end @@ -1544,39 +1544,39 @@ EOF assert_response :success, "can't get changesets by user and open" assert_changesets [1] - get :query, :time => '2007-12-31' + get :query, :time => "2007-12-31" assert_response :success, "can't get changesets by time-since" assert_changesets [1, 2, 4, 5, 6] - get :query, :time => '2008-01-01T12:34Z' + get :query, :time => "2008-01-01T12:34Z" assert_response :success, "can't get changesets by time-since with hour" assert_changesets [1, 2, 4, 5, 6] - get :query, :time => '2007-12-31T23:59Z,2008-01-01T00:01Z' + get :query, :time => "2007-12-31T23:59Z,2008-01-01T00:01Z" assert_response :success, "can't get changesets by time-range" assert_changesets [1, 5, 6] - get :query, :open => 'true' + get :query, :open => "true" assert_response :success, "can't get changesets by open-ness" assert_changesets [1, 2, 4] - get :query, :closed => 'true' + get :query, :closed => "true" assert_response :success, "can't get changesets by closed-ness" assert_changesets [3, 5, 6, 7, 8] - get :query, :closed => 'true', :user => users(:normal_user).id + get :query, :closed => "true", :user => users(:normal_user).id assert_response :success, "can't get changesets by closed-ness and user" assert_changesets [3, 6, 8] - get :query, :closed => 'true', :user => users(:public_user).id + get :query, :closed => "true", :user => users(:public_user).id assert_response :success, "can't get changesets by closed-ness and user" assert_changesets [7] - get :query, :changesets => '1,2,3' + get :query, :changesets => "1,2,3" assert_response :success, "can't get changesets by id (as comma-separated string)" assert_changesets [1, 2, 3] - get :query, :changesets => '' + get :query, :changesets => "" assert_response :bad_request, "should be a bad request since changesets is empty" end @@ -1619,8 +1619,8 @@ EOF changeset = changesets(:normal_user_first_change) new_changeset = changeset.to_xml new_tag = XML::Node.new "tag" - new_tag['k'] = "tagtesting" - new_tag['v'] = "valuetesting" + new_tag["k"] = "tagtesting" + new_tag["v"] = "valuetesting" new_changeset.find("//osm/changeset").first << new_tag content new_changeset @@ -1642,8 +1642,8 @@ EOF changeset = changesets(:public_user_first_change) new_changeset = changeset.to_xml new_tag = XML::Node.new "tag" - new_tag['k'] = "tagtesting" - new_tag['v'] = "valuetesting" + new_tag["k"] = "tagtesting" + new_tag["v"] = "valuetesting" new_changeset.find("//osm/changeset").first << new_tag content new_changeset @@ -1676,8 +1676,8 @@ EOF changeset = changesets(:normal_user_first_change) new_changeset = changeset.to_xml new_tag = XML::Node.new "tag" - new_tag['k'] = "testing" - new_tag['v'] = "testing" + new_tag["k"] = "testing" + new_tag["v"] = "testing" new_changeset.find("//osm/changeset").first << new_tag content new_changeset @@ -1719,9 +1719,9 @@ EOF # loop until we fill the changeset with nodes offset.times do |i| - node_xml['lat'] = rand.to_s - node_xml['lon'] = rand.to_s - node_xml['version'] = (i + 1).to_s + node_xml["lat"] = rand.to_s + node_xml["lon"] = rand.to_s + node_xml["version"] = (i + 1).to_s content node_doc put :update, :id => node_id @@ -1729,9 +1729,9 @@ EOF end # trying again should fail - node_xml['lat'] = rand.to_s - node_xml['lon'] = rand.to_s - node_xml['version'] = offset.to_s + node_xml["lat"] = rand.to_s + node_xml["lon"] = rand.to_s + node_xml["version"] = offset.to_s content node_doc put :update, :id => node_id @@ -1756,7 +1756,7 @@ EOF assert_template :layout => "map" assert_select "h2", :text => "Changesets", :count => 1 - get :list, :format => "html", :list => '1', :bbox => '-180,-90,90,180' + get :list, :format => "html", :list => "1", :bbox => "-180,-90,90,180" assert_response :success assert_template "list" @@ -1782,7 +1782,7 @@ EOF assert_template :layout => "xhr" assert_select "h2", :text => "Changesets", :count => 1 - get :list, :format => "html", :list => '1', :bbox => '-180,-90,90,180' + get :list, :format => "html", :list => "1", :bbox => "-180,-90,90,180" assert_response :success assert_template "list" @@ -1814,7 +1814,7 @@ EOF def test_list_user_not_found get :list, :format => "html", :display_name => "Some random user" assert_response :not_found - assert_template 'user/no_such_user' + assert_template "user/no_such_user" end ## @@ -1870,10 +1870,10 @@ EOF ## # create comment success def test_create_comment_success - basic_authorization(users(:public_user).email, 'test') + basic_authorization(users(:public_user).email, "test") - assert_difference('ChangesetComment.count') do - post :comment, :id => changesets(:normal_user_closed_change).id, :text => 'This is a comment' + assert_difference("ChangesetComment.count") do + post :comment, :id => changesets(:normal_user_closed_change).id, :text => "This is a comment" end assert_response :success end @@ -1882,32 +1882,32 @@ EOF # create comment fail def test_create_comment_fail # unauthorized - post :comment, :id => changesets(:normal_user_closed_change).id, :text => 'This is a comment' + post :comment, :id => changesets(:normal_user_closed_change).id, :text => "This is a comment" assert_response :unauthorized - basic_authorization(users(:public_user).email, 'test') + basic_authorization(users(:public_user).email, "test") # bad changeset id - assert_no_difference('ChangesetComment.count') do - post :comment, :id => 999111, :text => 'This is a comment' + assert_no_difference("ChangesetComment.count") do + post :comment, :id => 999111, :text => "This is a comment" end assert_response :not_found # not closed changeset - assert_no_difference('ChangesetComment.count') do - post :comment, :id => changesets(:normal_user_first_change).id, :text => 'This is a comment' + assert_no_difference("ChangesetComment.count") do + post :comment, :id => changesets(:normal_user_first_change).id, :text => "This is a comment" end assert_response :conflict # no text - assert_no_difference('ChangesetComment.count') do + assert_no_difference("ChangesetComment.count") do post :comment, :id => changesets(:normal_user_closed_change).id end assert_response :bad_request # empty text - assert_no_difference('ChangesetComment.count') do - post :comment, :id => changesets(:normal_user_closed_change).id, :text => '' + assert_no_difference("ChangesetComment.count") do + post :comment, :id => changesets(:normal_user_closed_change).id, :text => "" end assert_response :bad_request end @@ -1915,10 +1915,10 @@ EOF ## # test subscribe success def test_subscribe_success - basic_authorization(users(:public_user).email, 'test') + basic_authorization(users(:public_user).email, "test") changeset = changesets(:normal_user_closed_change) - assert_difference('changeset.subscribers.count') do + assert_difference("changeset.subscribers.count") do post :subscribe, :id => changeset.id end assert_response :success @@ -1929,29 +1929,29 @@ EOF def test_subscribe_fail # unauthorized changeset = changesets(:normal_user_closed_change) - assert_no_difference('changeset.subscribers.count') do + assert_no_difference("changeset.subscribers.count") do post :subscribe, :id => changeset.id end assert_response :unauthorized - basic_authorization(users(:public_user).email, 'test') + basic_authorization(users(:public_user).email, "test") # bad changeset id - assert_no_difference('changeset.subscribers.count') do + assert_no_difference("changeset.subscribers.count") do post :subscribe, :id => 999111 end assert_response :not_found # not closed changeset changeset = changesets(:normal_user_first_change) - assert_no_difference('changeset.subscribers.count') do + assert_no_difference("changeset.subscribers.count") do post :subscribe, :id => changeset.id end assert_response :conflict # trying to subscribe when already subscribed changeset = changesets(:normal_user_subscribed_change) - assert_no_difference('changeset.subscribers.count') do + assert_no_difference("changeset.subscribers.count") do post :subscribe, :id => changeset.id end assert_response :conflict @@ -1960,10 +1960,10 @@ EOF ## # test unsubscribe success def test_unsubscribe_success - basic_authorization(users(:public_user).email, 'test') + basic_authorization(users(:public_user).email, "test") changeset = changesets(:normal_user_subscribed_change) - assert_difference('changeset.subscribers.count', -1) do + assert_difference("changeset.subscribers.count", -1) do post :unsubscribe, :id => changeset.id end assert_response :success @@ -1974,29 +1974,29 @@ EOF def test_unsubscribe_fail # unauthorized changeset = changesets(:normal_user_closed_change) - assert_no_difference('changeset.subscribers.count') do + assert_no_difference("changeset.subscribers.count") do post :unsubscribe, :id => changeset.id end assert_response :unauthorized - basic_authorization(users(:public_user).email, 'test') + basic_authorization(users(:public_user).email, "test") # bad changeset id - assert_no_difference('changeset.subscribers.count', -1) do + assert_no_difference("changeset.subscribers.count", -1) do post :unsubscribe, :id => 999111 end assert_response :not_found # not closed changeset changeset = changesets(:normal_user_first_change) - assert_no_difference('changeset.subscribers.count', -1) do + assert_no_difference("changeset.subscribers.count", -1) do post :unsubscribe, :id => changeset.id end assert_response :conflict # trying to unsubscribe when not subscribed changeset = changesets(:normal_user_closed_change) - assert_no_difference('changeset.subscribers.count') do + assert_no_difference("changeset.subscribers.count") do post :unsubscribe, :id => changeset.id end assert_response :not_found @@ -2007,20 +2007,20 @@ EOF def test_hide_comment_fail # unauthorized comment = changeset_comments(:normal_comment_1) - assert('comment.visible') do + assert("comment.visible") do post :hide_comment, :id => comment.id assert_response :unauthorized end - basic_authorization(users(:public_user).email, 'test') + basic_authorization(users(:public_user).email, "test") # not a moderator - assert('comment.visible') do + assert("comment.visible") do post :hide_comment, :id => comment.id assert_response :forbidden end - basic_authorization(users(:moderator_user).email, 'test') + basic_authorization(users(:moderator_user).email, "test") # bad comment id post :hide_comment, :id => 999111 @@ -2032,9 +2032,9 @@ EOF def test_hide_comment_success comment = changeset_comments(:normal_comment_1) - basic_authorization(users(:moderator_user).email, 'test') + basic_authorization(users(:moderator_user).email, "test") - assert('!comment.visible') do + assert("!comment.visible") do post :hide_comment, :id => comment.id end assert_response :success @@ -2045,20 +2045,20 @@ EOF def test_unhide_comment_fail # unauthorized comment = changeset_comments(:normal_comment_1) - assert('comment.visible') do + assert("comment.visible") do post :unhide_comment, :id => comment.id assert_response :unauthorized end - basic_authorization(users(:public_user).email, 'test') + basic_authorization(users(:public_user).email, "test") # not a moderator - assert('comment.visible') do + assert("comment.visible") do post :unhide_comment, :id => comment.id assert_response :forbidden end - basic_authorization(users(:moderator_user).email, 'test') + basic_authorization(users(:moderator_user).email, "test") # bad comment id post :unhide_comment, :id => 999111 @@ -2070,9 +2070,9 @@ EOF def test_unhide_comment_success comment = changeset_comments(:normal_comment_1) - basic_authorization(users(:moderator_user).email, 'test') + basic_authorization(users(:moderator_user).email, "test") - assert('!comment.visible') do + assert("!comment.visible") do post :unhide_comment, :id => comment.id end assert_response :success @@ -2128,16 +2128,16 @@ EOF # check the bbox doc = XML::Parser.string(@response.body).parse changeset = doc.find("//osm/changeset").first - assert_equal bbox[0], changeset['min_lon'].to_f, "min lon" - assert_equal bbox[1], changeset['min_lat'].to_f, "min lat" - assert_equal bbox[2], changeset['max_lon'].to_f, "max lon" - assert_equal bbox[3], changeset['max_lat'].to_f, "max lat" + assert_equal bbox[0], changeset["min_lon"].to_f, "min lon" + assert_equal bbox[1], changeset["min_lat"].to_f, "min lat" + assert_equal bbox[2], changeset["max_lon"].to_f, "max lon" + assert_equal bbox[3], changeset["max_lat"].to_f, "max lat" end ## # update the changeset_id of a way element def update_changeset(xml, changeset_id) - xml_attr_rewrite(xml, 'changeset', changeset_id) + xml_attr_rewrite(xml, "changeset", changeset_id) end ## diff --git a/test/controllers/diary_entry_controller_test.rb b/test/controllers/diary_entry_controller_test.rb index 1260fa468..333be0c64 100644 --- a/test/controllers/diary_entry_controller_test.rb +++ b/test/controllers/diary_entry_controller_test.rb @@ -1,4 +1,4 @@ -require 'test_helper' +require "test_helper" class DiaryEntryControllerTest < ActionController::TestCase fixtures :users, :diary_entries, :diary_comments, :languages @@ -91,7 +91,7 @@ class DiaryEntryControllerTest < ActionController::TestCase assert_redirected_to :controller => :user, :action => "login", :referer => "/diary/new" # Now pretend to login by using the session hash, with the # id of the person we want to login as through session(:user)=user.id - get(:new, nil, 'user' => users(:normal_user).id) + get(:new, nil, "user" => users(:normal_user).id) assert_response :success # print @response.body @@ -123,7 +123,7 @@ class DiaryEntryControllerTest < ActionController::TestCase assert_redirected_to :controller => :user, :action => "login", :referer => "/user/#{entry.user.display_name}/diary/#{entry.id}/edit" # Verify that you get a not found error, when you pass a bogus id - get(:edit, { :display_name => entry.user.display_name, :id => 9999 }, { 'user' => entry.user.id }) + get(:edit, { :display_name => entry.user.display_name, :id => 9999 }, { "user" => entry.user.id }) assert_response :not_found assert_select "div.content-heading", :count => 1 do assert_select "h2", :text => "No entry with the id: 9999", :count => 1 @@ -131,7 +131,7 @@ class DiaryEntryControllerTest < ActionController::TestCase # Now pass the id, and check that you can edit it, when using the same # user as the person who created the entry - get(:edit, { :display_name => entry.user.display_name, :id => entry.id }, { 'user' => entry.user.id }) + get(:edit, { :display_name => entry.user.display_name, :id => entry.id }, { "user" => entry.user.id }) assert_response :success assert_select "title", :text => /Edit diary entry/, :count => 1 assert_select "div.content-heading", :count => 1 do @@ -157,17 +157,17 @@ class DiaryEntryControllerTest < ActionController::TestCase new_latitude = "1.1" new_longitude = "2.2" new_language_code = "en" - post(:edit, { :display_name => entry.user.display_name, :id => entry.id, 'commit' => 'save', - 'diary_entry' => { 'title' => new_title, 'body' => new_body, 'latitude' => new_latitude, - 'longitude' => new_longitude, 'language_code' => new_language_code } }, - { 'user' => entry.user.id }) + post(:edit, { :display_name => entry.user.display_name, :id => entry.id, "commit" => "save", + "diary_entry" => { "title" => new_title, "body" => new_body, "latitude" => new_latitude, + "longitude" => new_longitude, "language_code" => new_language_code } }, + { "user" => entry.user.id }) assert_response :redirect assert_redirected_to :action => :view, :display_name => entry.user.display_name, :id => entry.id # Now check that the new data is rendered, when logged in - get :view, { :display_name => entry.user.display_name, :id => entry.id }, { 'user' => entry.user.id } + get :view, { :display_name => entry.user.display_name, :id => entry.id }, { "user" => entry.user.id } assert_response :success - assert_template 'diary_entry/view' + assert_template "diary_entry/view" assert_select "title", :text => /Users' diaries | /, :count => 1 assert_select "div.content-heading", :count => 1 do assert_select "h2", :text => /#{entry.user.display_name}'s diary/, :count => 1 @@ -184,9 +184,9 @@ class DiaryEntryControllerTest < ActionController::TestCase end # and when not logged in as the user who wrote the entry - get :view, { :display_name => entry.user.display_name, :id => entry.id }, { 'user' => entry.user.id } + get :view, { :display_name => entry.user.display_name, :id => entry.id }, { "user" => entry.user.id } assert_response :success - assert_template 'diary_entry/view' + assert_template "diary_entry/view" assert_select "title", :text => /Users' diaries | /, :count => 1 assert_select "div.content-heading", :count => 1 do assert_select "h2", :text => /#{users(:normal_user).display_name}'s diary/, :count => 1 @@ -205,7 +205,7 @@ class DiaryEntryControllerTest < ActionController::TestCase end def test_edit_diary_entry_i18n - get :edit, { :display_name => users(:normal_user).display_name, :id => diary_entries(:normal_user_entry_1).id }, { 'user' => users(:normal_user).id } + get :edit, { :display_name => users(:normal_user).display_name, :id => diary_entries(:normal_user_entry_1).id }, { "user" => users(:normal_user).id } assert_response :success assert_select "span[class=translation_missing]", false, "Missing translation in edit diary entry" end @@ -245,9 +245,9 @@ class DiaryEntryControllerTest < ActionController::TestCase new_longitude = "2.2" new_language_code = "en" assert_difference "DiaryEntry.count", 1 do - post(:new, { 'commit' => 'save', - 'diary_entry' => { 'title' => new_title, 'body' => new_body, 'latitude' => new_latitude, - 'longitude' => new_longitude, 'language_code' => new_language_code } }, + post(:new, { "commit" => "save", + "diary_entry" => { "title" => new_title, "body" => new_body, "latitude" => new_latitude, + "longitude" => new_longitude, "language_code" => new_language_code } }, { :user => users(:normal_user).id }) end assert_response :redirect @@ -310,13 +310,13 @@ class DiaryEntryControllerTest < ActionController::TestCase def test_listing_diary_entries get :list assert_response :success, "Should be able to list the diary entries in locale" - assert_template 'list', "Should use the list template in locale" + assert_template "list", "Should use the list template in locale" assert_select "span[class=translation_missing]", false, "Missing translation in list of diary entries" # Now try to find a specific user's diary entry get :list, :display_name => users(:normal_user).display_name assert_response :success, "Should be able to list the diary entries for a user in locale" - assert_template 'list', "Should use the list template for a user in locale" + assert_template "list", "Should use the list template for a user in locale" assert_no_missing_translations end @@ -344,7 +344,7 @@ class DiaryEntryControllerTest < ActionController::TestCase # end def test_rss_language_with_no_entries - get :rss, :language => 'sl', :format => :rss + get :rss, :language => "sl", :format => :rss assert_response :success, "Should be able to get a specific language diary RSS" assert_select "rss>channel>item", :count => 0 # , "Diary entries should be filtered by language" end @@ -357,7 +357,7 @@ class DiaryEntryControllerTest < ActionController::TestCase def test_rss_nonexisting_user # Try a user that has never existed - get :rss, :display_name => 'fakeUsername76543', :format => :rss + get :rss, :display_name => "fakeUsername76543", :format => :rss assert_response :not_found, "Should not be able to get a nonexisting users diary RSS" # Try a suspended user diff --git a/test/controllers/directions_controller_test.rb b/test/controllers/directions_controller_test.rb index e80d796bd..1335ea469 100644 --- a/test/controllers/directions_controller_test.rb +++ b/test/controllers/directions_controller_test.rb @@ -1,4 +1,4 @@ -require 'test_helper' +require "test_helper" class DirectionsControllerTest < ActionController::TestCase ## diff --git a/test/controllers/export_controller_test.rb b/test/controllers/export_controller_test.rb index ab93f74bc..adf2fc4ba 100644 --- a/test/controllers/export_controller_test.rb +++ b/test/controllers/export_controller_test.rb @@ -1,4 +1,4 @@ -require 'test_helper' +require "test_helper" class ExportControllerTest < ActionController::TestCase ## @@ -17,7 +17,7 @@ class ExportControllerTest < ActionController::TestCase ### # test the finish action for raw OSM data def test_finish_osm - get :finish, :minlon => 0, :minlat => 50, :maxlon => 1, :maxlat => 51, :format => 'osm' + get :finish, :minlon => 0, :minlat => 50, :maxlon => 1, :maxlat => 51, :format => "osm" assert_response :redirect assert_redirected_to "http://api.openstreetmap.org/api/#{API_VERSION}/map?bbox=0.0,50.0,1.0,51.0" end @@ -25,7 +25,7 @@ class ExportControllerTest < ActionController::TestCase ### # test the finish action for mapnik images def test_finish_mapnik - get :finish, :minlon => 0, :minlat => 50, :maxlon => 1, :maxlat => 51, :format => 'mapnik', :mapnik_format => 'test', :mapnik_scale => '12' + get :finish, :minlon => 0, :minlat => 50, :maxlon => 1, :maxlat => 51, :format => "mapnik", :mapnik_format => "test", :mapnik_scale => "12" assert_response :redirect assert_redirected_to "http://render.openstreetmap.org/cgi-bin/export?bbox=0.0,50.0,1.0,51.0&scale=12&format=test" end diff --git a/test/controllers/geocoder_controller_test.rb b/test/controllers/geocoder_controller_test.rb index 3ac4c090e..1d2eb87f5 100644 --- a/test/controllers/geocoder_controller_test.rb +++ b/test/controllers/geocoder_controller_test.rb @@ -1,7 +1,7 @@ # coding: utf-8 -require 'test_helper' -require 'geocoder_controller' +require "test_helper" +require "geocoder_controller" class GeocoderControllerTest < ActionController::TestCase ## @@ -49,10 +49,10 @@ class GeocoderControllerTest < ActionController::TestCase # Test identification of basic lat/lon pairs def test_identify_latlon_basic [ - '50.06773 14.37742', - '50.06773, 14.37742', - '+50.06773 +14.37742', - '+50.06773, +14.37742' + "50.06773 14.37742", + "50.06773, 14.37742", + "+50.06773 +14.37742", + "+50.06773, +14.37742" ].each do |code| latlon_check code, 50.06773, 14.37742 end @@ -62,10 +62,10 @@ class GeocoderControllerTest < ActionController::TestCase # Test identification of lat/lon pairs using N/E with degrees def test_identify_latlon_ne_d [ - 'N50.06773 E14.37742', - 'N50.06773, E14.37742', - '50.06773N 14.37742E', - '50.06773N, 14.37742E' + "N50.06773 E14.37742", + "N50.06773, E14.37742", + "50.06773N 14.37742E", + "50.06773N, 14.37742E" ].each do |code| latlon_check code, 50.06773, 14.37742 end @@ -75,10 +75,10 @@ class GeocoderControllerTest < ActionController::TestCase # Test identification of lat/lon pairs using N/W with degrees def test_identify_latlon_nw_d [ - 'N50.06773 W14.37742', - 'N50.06773, W14.37742', - '50.06773N 14.37742W', - '50.06773N, 14.37742W' + "N50.06773 W14.37742", + "N50.06773, W14.37742", + "50.06773N 14.37742W", + "50.06773N, 14.37742W" ].each do |code| latlon_check code, 50.06773, -14.37742 end @@ -88,10 +88,10 @@ class GeocoderControllerTest < ActionController::TestCase # Test identification of lat/lon pairs using S/E with degrees def test_identify_latlon_se_d [ - 'S50.06773 E14.37742', - 'S50.06773, E14.37742', - '50.06773S 14.37742E', - '50.06773S, 14.37742E' + "S50.06773 E14.37742", + "S50.06773, E14.37742", + "50.06773S 14.37742E", + "50.06773S, 14.37742E" ].each do |code| latlon_check code, -50.06773, 14.37742 end @@ -101,10 +101,10 @@ class GeocoderControllerTest < ActionController::TestCase # Test identification of lat/lon pairs using S/W with degrees def test_identify_latlon_sw_d [ - 'S50.06773 W14.37742', - 'S50.06773, W14.37742', - '50.06773S 14.37742W', - '50.06773S, 14.37742W' + "S50.06773 W14.37742", + "S50.06773, W14.37742", + "50.06773S 14.37742W", + "50.06773S, 14.37742W" ].each do |code| latlon_check code, -50.06773, -14.37742 end @@ -114,12 +114,12 @@ class GeocoderControllerTest < ActionController::TestCase # Test identification of lat/lon pairs using N/E with degrees/mins def test_identify_latlon_ne_dm [ - 'N 50° 04.064 E 014° 22.645', + "N 50° 04.064 E 014° 22.645", "N 50° 04.064' E 014° 22.645", "N 50° 04.064', E 014° 22.645'", - 'N50° 04.064 E14° 22.645', - 'N 50 04.064 E 014 22.645', - 'N50 4.064 E14 22.645', + "N50° 04.064 E14° 22.645", + "N 50 04.064 E 014 22.645", + "N50 4.064 E14 22.645", "50° 04.064' N, 014° 22.645' E" ].each do |code| latlon_check code, 50.06773, 14.37742 @@ -130,12 +130,12 @@ class GeocoderControllerTest < ActionController::TestCase # Test identification of lat/lon pairs using N/W with degrees/mins def test_identify_latlon_nw_dm [ - 'N 50° 04.064 W 014° 22.645', + "N 50° 04.064 W 014° 22.645", "N 50° 04.064' W 014° 22.645", "N 50° 04.064', W 014° 22.645'", - 'N50° 04.064 W14° 22.645', - 'N 50 04.064 W 014 22.645', - 'N50 4.064 W14 22.645', + "N50° 04.064 W14° 22.645", + "N 50 04.064 W 014 22.645", + "N50 4.064 W14 22.645", "50° 04.064' N, 014° 22.645' W" ].each do |code| latlon_check code, 50.06773, -14.37742 @@ -146,12 +146,12 @@ class GeocoderControllerTest < ActionController::TestCase # Test identification of lat/lon pairs using S/E with degrees/mins def test_identify_latlon_se_dm [ - 'S 50° 04.064 E 014° 22.645', + "S 50° 04.064 E 014° 22.645", "S 50° 04.064' E 014° 22.645", "S 50° 04.064', E 014° 22.645'", - 'S50° 04.064 E14° 22.645', - 'S 50 04.064 E 014 22.645', - 'S50 4.064 E14 22.645', + "S50° 04.064 E14° 22.645", + "S 50 04.064 E 014 22.645", + "S50 4.064 E14 22.645", "50° 04.064' S, 014° 22.645' E" ].each do |code| latlon_check code, -50.06773, 14.37742 @@ -162,12 +162,12 @@ class GeocoderControllerTest < ActionController::TestCase # Test identification of lat/lon pairs using S/W with degrees/mins def test_identify_latlon_sw_dm [ - 'S 50° 04.064 W 014° 22.645', + "S 50° 04.064 W 014° 22.645", "S 50° 04.064' W 014° 22.645", "S 50° 04.064', W 014° 22.645'", - 'S50° 04.064 W14° 22.645', - 'S 50 04.064 W 014 22.645', - 'S50 4.064 W14 22.645', + "S50° 04.064 W14° 22.645", + "S 50 04.064 W 014 22.645", + "S50 4.064 W14 22.645", "50° 04.064' S, 014° 22.645' W" ].each do |code| latlon_check code, -50.06773, -14.37742 @@ -181,8 +181,8 @@ class GeocoderControllerTest < ActionController::TestCase "N 50° 4' 03.828\" E 14° 22' 38.712\"", "N 50° 4' 03.828\", E 14° 22' 38.712\"", "N 50° 4′ 03.828″, E 14° 22′ 38.712″", - 'N50 4 03.828 E14 22 38.712', - 'N50 4 03.828, E14 22 38.712', + "N50 4 03.828 E14 22 38.712", + "N50 4 03.828, E14 22 38.712", "50°4'3.828\"N 14°22'38.712\"E" ].each do |code| latlon_check code, 50.06773, 14.37742 @@ -196,8 +196,8 @@ class GeocoderControllerTest < ActionController::TestCase "N 50° 4' 03.828\" W 14° 22' 38.712\"", "N 50° 4' 03.828\", W 14° 22' 38.712\"", "N 50° 4′ 03.828″, W 14° 22′ 38.712″", - 'N50 4 03.828 W14 22 38.712', - 'N50 4 03.828, W14 22 38.712', + "N50 4 03.828 W14 22 38.712", + "N50 4 03.828, W14 22 38.712", "50°4'3.828\"N 14°22'38.712\"W" ].each do |code| latlon_check code, 50.06773, -14.37742 @@ -211,8 +211,8 @@ class GeocoderControllerTest < ActionController::TestCase "S 50° 4' 03.828\" E 14° 22' 38.712\"", "S 50° 4' 03.828\", E 14° 22' 38.712\"", "S 50° 4′ 03.828″, E 14° 22′ 38.712″", - 'S50 4 03.828 E14 22 38.712', - 'S50 4 03.828, E14 22 38.712', + "S50 4 03.828 E14 22 38.712", + "S50 4 03.828, E14 22 38.712", "50°4'3.828\"S 14°22'38.712\"E" ].each do |code| latlon_check code, -50.06773, 14.37742 @@ -226,8 +226,8 @@ class GeocoderControllerTest < ActionController::TestCase "S 50° 4' 03.828\" W 14° 22' 38.712\"", "S 50° 4' 03.828\", W 14° 22' 38.712\"", "S 50° 4′ 03.828″, W 14° 22′ 38.712″", - 'S50 4 03.828 W14 22 38.712', - 'S50 4 03.828, W14 22 38.712', + "S50 4 03.828 W14 22 38.712", + "S50 4 03.828, W14 22 38.712", "50°4'3.828\"S 14°22'38.712\"W" ].each do |code| latlon_check code, -50.06773, -14.37742 @@ -238,8 +238,8 @@ class GeocoderControllerTest < ActionController::TestCase # Test identification of US zipcodes def test_identify_us_postcode [ - '12345', - '12345-6789' + "12345", + "12345-6789" ].each do |code| post :search, query: code assert_response :success @@ -252,12 +252,12 @@ class GeocoderControllerTest < ActionController::TestCase # http://en.wikipedia.org/wiki/Postcodes_in_the_United_Kingdom def test_identify_uk_postcode [ - 'EC1A 1BB', - 'W1A 1HQ', - 'M1 1AA', - 'B33 8TH', - 'CR2 6XH', - 'DN55 1PT' + "EC1A 1BB", + "W1A 1HQ", + "M1 1AA", + "B33 8TH", + "CR2 6XH", + "DN55 1PT" ].each do |code| search_check code, %w(uk_postcode osm_nominatim) end @@ -266,13 +266,13 @@ class GeocoderControllerTest < ActionController::TestCase ## # Test identification of Canadian postcodes def test_identify_ca_postcode - search_check 'A1B 2C3', %w(ca_postcode osm_nominatim) + search_check "A1B 2C3", %w(ca_postcode osm_nominatim) end ## # Test identification fall through to the default case def test_identify_default - search_check 'foo bar baz', ['osm_nominatim'] + search_check "foo bar baz", ["osm_nominatim"] end private diff --git a/test/controllers/message_controller_test.rb b/test/controllers/message_controller_test.rb index 2de1875ac..eb4222bd5 100644 --- a/test/controllers/message_controller_test.rb +++ b/test/controllers/message_controller_test.rb @@ -1,4 +1,4 @@ -require 'test_helper' +require "test_helper" class MessageControllerTest < ActionController::TestCase fixtures :users, :messages diff --git a/test/controllers/node_controller_test.rb b/test/controllers/node_controller_test.rb index 9e030ed39..5ea1dd5a4 100644 --- a/test/controllers/node_controller_test.rb +++ b/test/controllers/node_controller_test.rb @@ -1,4 +1,4 @@ -require 'test_helper' +require "test_helper" class NodeControllerTest < ActionController::TestCase api_fixtures @@ -39,7 +39,7 @@ class NodeControllerTest < ActionController::TestCase changeset = changesets(:normal_user_first_change) # create a minimal xml file content("<osm><node lat='#{lat}' lon='#{lon}' changeset='#{changeset.id}'/></osm>") - assert_difference('OldNode.count', 0) do + assert_difference("OldNode.count", 0) do put :create end # hope for unauthorized @@ -55,7 +55,7 @@ class NodeControllerTest < ActionController::TestCase changeset = changesets(:normal_user_first_change) # create a minimal xml file content("<osm><node lat='#{lat}' lon='#{lon}' changeset='#{changeset.id}'/></osm>") - assert_difference('Node.count', 0) do + assert_difference("Node.count", 0) do put :create end # hope for success @@ -298,19 +298,19 @@ class NodeControllerTest < ActionController::TestCase assert_require_public_data("update with changeset=0 should be forbidden, when data isn't public") ## try and submit invalid updates - content xml_attr_rewrite(current_nodes(:visible_node).to_xml, 'lat', 91.0) + content xml_attr_rewrite(current_nodes(:visible_node).to_xml, "lat", 91.0) put :update, :id => current_nodes(:visible_node).id assert_require_public_data "node at lat=91 should be forbidden, when data isn't public" - content xml_attr_rewrite(current_nodes(:visible_node).to_xml, 'lat', -91.0) + content xml_attr_rewrite(current_nodes(:visible_node).to_xml, "lat", -91.0) put :update, :id => current_nodes(:visible_node).id assert_require_public_data "node at lat=-91 should be forbidden, when data isn't public" - content xml_attr_rewrite(current_nodes(:visible_node).to_xml, 'lon', 181.0) + content xml_attr_rewrite(current_nodes(:visible_node).to_xml, "lon", 181.0) put :update, :id => current_nodes(:visible_node).id assert_require_public_data "node at lon=181 should be forbidden, when data isn't public" - content xml_attr_rewrite(current_nodes(:visible_node).to_xml, 'lon', -181.0) + content xml_attr_rewrite(current_nodes(:visible_node).to_xml, "lon", -181.0) put :update, :id => current_nodes(:visible_node).id assert_require_public_data "node at lon=-181 should be forbidden, when data isn't public" @@ -350,19 +350,19 @@ class NodeControllerTest < ActionController::TestCase assert_response :conflict, "update with changeset=0 should be rejected" ## try and submit invalid updates - content xml_attr_rewrite(current_nodes(:visible_node).to_xml, 'lat', 91.0) + content xml_attr_rewrite(current_nodes(:visible_node).to_xml, "lat", 91.0) put :update, :id => current_nodes(:visible_node).id assert_response :bad_request, "node at lat=91 should be rejected" - content xml_attr_rewrite(current_nodes(:visible_node).to_xml, 'lat', -91.0) + content xml_attr_rewrite(current_nodes(:visible_node).to_xml, "lat", -91.0) put :update, :id => current_nodes(:visible_node).id assert_response :bad_request, "node at lat=-91 should be rejected" - content xml_attr_rewrite(current_nodes(:visible_node).to_xml, 'lon', 181.0) + content xml_attr_rewrite(current_nodes(:visible_node).to_xml, "lon", 181.0) put :update, :id => current_nodes(:visible_node).id assert_response :bad_request, "node at lon=181 should be rejected" - content xml_attr_rewrite(current_nodes(:visible_node).to_xml, 'lon', -181.0) + content xml_attr_rewrite(current_nodes(:visible_node).to_xml, "lon", -181.0) put :update, :id => current_nodes(:visible_node).id assert_response :bad_request, "node at lon=-181 should be rejected" @@ -371,19 +371,19 @@ class NodeControllerTest < ActionController::TestCase # try and submit a version behind content xml_attr_rewrite(current_nodes(:visible_node).to_xml, - 'version', current_node_version - 1) + "version", current_node_version - 1) put :update, :id => current_nodes(:visible_node).id assert_response :conflict, "should have failed on old version number" # try and submit a version ahead content xml_attr_rewrite(current_nodes(:visible_node).to_xml, - 'version', current_node_version + 1) + "version", current_node_version + 1) put :update, :id => current_nodes(:visible_node).id assert_response :conflict, "should have failed on skipped version number" # try and submit total crap in the version field content xml_attr_rewrite(current_nodes(:visible_node).to_xml, - 'version', 'p1r4t3s!') + "version", "p1r4t3s!") put :update, :id => current_nodes(:visible_node).id assert_response :conflict, "should not be able to put 'p1r4at3s!' in the version field" @@ -442,8 +442,8 @@ class NodeControllerTest < ActionController::TestCase # add an identical tag to the node tag_xml = XML::Node.new("tag") - tag_xml['k'] = current_node_tags(:public_v_t1).k - tag_xml['v'] = current_node_tags(:public_v_t1).v + tag_xml["k"] = current_node_tags(:public_v_t1).k + tag_xml["v"] = current_node_tags(:public_v_t1).v # add the tag into the existing xml node_xml = current_nodes(:public_visible_node).to_xml @@ -467,7 +467,7 @@ class NodeControllerTest < ActionController::TestCase # use unquoted and therefore allow code injection... content "<osm><node lat='0' lon='0' changeset='#{changeset_id}'>" + '<tag k="#{@user.inspect}" v="0"/>' + - '</node></osm>' + "</node></osm>" put :create assert_require_public_data "Shouldn't be able to create with non-public user" @@ -479,7 +479,7 @@ class NodeControllerTest < ActionController::TestCase # use unquoted and therefore allow code injection... content "<osm><node lat='0' lon='0' changeset='#{changeset_id}'>" + '<tag k="#{@user.inspect}" v="0"/>' + - '</node></osm>' + "</node></osm>" put :create assert_response :success nodeid = @response.body @@ -496,7 +496,7 @@ class NodeControllerTest < ActionController::TestCase # check the tags are not corrupted assert_equal checknode.tags, apinode.tags - assert apinode.tags.include?('#{@user.inspect}') + assert apinode.tags.include?("\#{@user.inspect}") end def basic_authorization(user, pass) @@ -510,7 +510,7 @@ class NodeControllerTest < ActionController::TestCase ## # update the changeset_id of a node element def update_changeset(xml, changeset_id) - xml_attr_rewrite(xml, 'changeset', changeset_id) + xml_attr_rewrite(xml, "changeset", changeset_id) end ## diff --git a/test/controllers/notes_controller_test.rb b/test/controllers/notes_controller_test.rb index 25c6d096b..81193899f 100644 --- a/test/controllers/notes_controller_test.rb +++ b/test/controllers/notes_controller_test.rb @@ -1,4 +1,4 @@ -require 'test_helper' +require "test_helper" class NotesControllerTest < ActionController::TestCase fixtures :users, :notes, :note_comments @@ -122,8 +122,8 @@ class NotesControllerTest < ActionController::TestCase end def test_create_success - assert_difference('Note.count') do - assert_difference('NoteComment.count') do + assert_difference("Note.count") do + assert_difference("NoteComment.count") do post :create, :lat => -1.0, :lon => -1.0, :text => "This is a comment", :format => "json" end end @@ -156,65 +156,65 @@ class NotesControllerTest < ActionController::TestCase end def test_create_fail - assert_no_difference('Note.count') do - assert_no_difference('NoteComment.count') do + assert_no_difference("Note.count") do + assert_no_difference("NoteComment.count") do post :create, :lon => -1.0, :text => "This is a comment" end end assert_response :bad_request - assert_no_difference('Note.count') do - assert_no_difference('NoteComment.count') do + assert_no_difference("Note.count") do + assert_no_difference("NoteComment.count") do post :create, :lat => -1.0, :text => "This is a comment" end end assert_response :bad_request - assert_no_difference('Note.count') do - assert_no_difference('NoteComment.count') do + assert_no_difference("Note.count") do + assert_no_difference("NoteComment.count") do post :create, :lat => -1.0, :lon => -1.0 end end assert_response :bad_request - assert_no_difference('Note.count') do - assert_no_difference('NoteComment.count') do + assert_no_difference("Note.count") do + assert_no_difference("NoteComment.count") do post :create, :lat => -1.0, :lon => -1.0, :text => "" end end assert_response :bad_request - assert_no_difference('Note.count') do - assert_no_difference('NoteComment.count') do + assert_no_difference("Note.count") do + assert_no_difference("NoteComment.count") do post :create, :lat => -100.0, :lon => -1.0, :text => "This is a comment" end end assert_response :bad_request - assert_no_difference('Note.count') do - assert_no_difference('NoteComment.count') do + assert_no_difference("Note.count") do + assert_no_difference("NoteComment.count") do post :create, :lat => -1.0, :lon => -200.0, :text => "This is a comment" end end assert_response :bad_request - assert_no_difference('Note.count') do - assert_no_difference('NoteComment.count') do - post :create, :lat => 'abc', :lon => -1.0, :text => "This is a comment" + assert_no_difference("Note.count") do + assert_no_difference("NoteComment.count") do + post :create, :lat => "abc", :lon => -1.0, :text => "This is a comment" end end assert_response :bad_request - assert_no_difference('Note.count') do - assert_no_difference('NoteComment.count') do - post :create, :lat => -1.0, :lon => 'abc', :text => "This is a comment" + assert_no_difference("Note.count") do + assert_no_difference("NoteComment.count") do + post :create, :lat => -1.0, :lon => "abc", :text => "This is a comment" end end assert_response :bad_request end def test_comment_success - assert_difference('NoteComment.count') do + assert_difference("NoteComment.count") do post :comment, :id => notes(:open_note_with_comment).id, :text => "This is an additional comment", :format => "json" end assert_response :success @@ -242,32 +242,32 @@ class NotesControllerTest < ActionController::TestCase end def test_comment_fail - assert_no_difference('NoteComment.count') do + assert_no_difference("NoteComment.count") do post :comment, :text => "This is an additional comment" end assert_response :bad_request - assert_no_difference('NoteComment.count') do + assert_no_difference("NoteComment.count") do post :comment, :id => notes(:open_note_with_comment).id end assert_response :bad_request - assert_no_difference('NoteComment.count') do + assert_no_difference("NoteComment.count") do post :comment, :id => notes(:open_note_with_comment).id, :text => "" end assert_response :bad_request - assert_no_difference('NoteComment.count') do + assert_no_difference("NoteComment.count") do post :comment, :id => 12345, :text => "This is an additional comment" end assert_response :not_found - assert_no_difference('NoteComment.count') do + assert_no_difference("NoteComment.count") do post :comment, :id => notes(:hidden_note_with_comment).id, :text => "This is an additional comment" end assert_response :gone - assert_no_difference('NoteComment.count') do + assert_no_difference("NoteComment.count") do post :comment, :id => notes(:closed_note_with_comment).id, :text => "This is an additional comment" end assert_response :conflict @@ -478,7 +478,7 @@ class NotesControllerTest < ActionController::TestCase assert_equal "This is a hide comment", js["properties"]["comments"].last["text"] assert_equal "moderator", js["properties"]["comments"].last["user"] - get :show, :id => notes(:open_note_with_comment).id, :format => 'json' + get :show, :id => notes(:open_note_with_comment).id, :format => "json" assert_response :gone end @@ -501,7 +501,7 @@ class NotesControllerTest < ActionController::TestCase end def test_index_success - get :index, :bbox => '1,1,1.2,1.2', :format => 'rss' + get :index, :bbox => "1,1,1.2,1.2", :format => "rss" assert_response :success assert_equal "application/rss+xml", @response.content_type assert_select "rss", :count => 1 do @@ -510,7 +510,7 @@ class NotesControllerTest < ActionController::TestCase end end - get :index, :bbox => '1,1,1.2,1.2', :format => 'json' + get :index, :bbox => "1,1,1.2,1.2", :format => "json" assert_response :success assert_equal "application/json", @response.content_type js = ActiveSupport::JSON.decode(@response.body) @@ -518,14 +518,14 @@ class NotesControllerTest < ActionController::TestCase assert_equal "FeatureCollection", js["type"] assert_equal 2, js["features"].count - get :index, :bbox => '1,1,1.2,1.2', :format => 'xml' + get :index, :bbox => "1,1,1.2,1.2", :format => "xml" assert_response :success assert_equal "application/xml", @response.content_type assert_select "osm", :count => 1 do assert_select "note", :count => 2 end - get :index, :bbox => '1,1,1.2,1.2', :format => 'gpx' + get :index, :bbox => "1,1,1.2,1.2", :format => "gpx" assert_response :success assert_equal "application/gpx+xml", @response.content_type assert_select "gpx", :count => 1 do @@ -534,7 +534,7 @@ class NotesControllerTest < ActionController::TestCase end def test_index_empty_area - get :index, :bbox => '5,5,5.1,5.1', :format => 'rss' + get :index, :bbox => "5,5,5.1,5.1", :format => "rss" assert_response :success assert_equal "application/rss+xml", @response.content_type assert_select "rss", :count => 1 do @@ -543,7 +543,7 @@ class NotesControllerTest < ActionController::TestCase end end - get :index, :bbox => '5,5,5.1,5.1', :format => 'json' + get :index, :bbox => "5,5,5.1,5.1", :format => "json" assert_response :success assert_equal "application/json", @response.content_type js = ActiveSupport::JSON.decode(@response.body) @@ -551,14 +551,14 @@ class NotesControllerTest < ActionController::TestCase assert_equal "FeatureCollection", js["type"] assert_equal 0, js["features"].count - get :index, :bbox => '5,5,5.1,5.1', :format => 'xml' + get :index, :bbox => "5,5,5.1,5.1", :format => "xml" assert_response :success assert_equal "application/xml", @response.content_type assert_select "osm", :count => 1 do assert_select "note", :count => 0 end - get :index, :bbox => '5,5,5.1,5.1', :format => 'gpx' + get :index, :bbox => "5,5,5.1,5.1", :format => "gpx" assert_response :success assert_equal "application/gpx+xml", @response.content_type assert_select "gpx", :count => 1 do @@ -567,25 +567,25 @@ class NotesControllerTest < ActionController::TestCase end def test_index_large_area - get :index, :bbox => '-2.5,-2.5,2.5,2.5', :format => :json + get :index, :bbox => "-2.5,-2.5,2.5,2.5", :format => :json assert_response :success assert_equal "application/json", @response.content_type - get :index, :l => '-2.5', :b => '-2.5', :r => '2.5', :t => '2.5', :format => :json + get :index, :l => "-2.5", :b => "-2.5", :r => "2.5", :t => "2.5", :format => :json assert_response :success assert_equal "application/json", @response.content_type - get :index, :bbox => '-10,-10,12,12', :format => :json + get :index, :bbox => "-10,-10,12,12", :format => :json assert_response :bad_request assert_equal "text/plain", @response.content_type - get :index, :l => '-10', :b => '-10', :r => '12', :t => '12', :format => :json + get :index, :l => "-10", :b => "-10", :r => "12", :t => "12", :format => :json assert_response :bad_request assert_equal "text/plain", @response.content_type end def test_index_closed - get :index, :bbox => '1,1,1.7,1.7', :closed => '7', :format => 'json' + get :index, :bbox => "1,1,1.7,1.7", :closed => "7", :format => "json" assert_response :success assert_equal "application/json", @response.content_type js = ActiveSupport::JSON.decode(@response.body) @@ -593,7 +593,7 @@ class NotesControllerTest < ActionController::TestCase assert_equal "FeatureCollection", js["type"] assert_equal 4, js["features"].count - get :index, :bbox => '1,1,1.7,1.7', :closed => '0', :format => 'json' + get :index, :bbox => "1,1,1.7,1.7", :closed => "0", :format => "json" assert_response :success assert_equal "application/json", @response.content_type js = ActiveSupport::JSON.decode(@response.body) @@ -601,7 +601,7 @@ class NotesControllerTest < ActionController::TestCase assert_equal "FeatureCollection", js["type"] assert_equal 4, js["features"].count - get :index, :bbox => '1,1,1.7,1.7', :closed => '-1', :format => 'json' + get :index, :bbox => "1,1,1.7,1.7", :closed => "-1", :format => "json" assert_response :success assert_equal "application/json", @response.content_type js = ActiveSupport::JSON.decode(@response.body) @@ -611,40 +611,40 @@ class NotesControllerTest < ActionController::TestCase end def test_index_bad_params - get :index, :bbox => '-2.5,-2.5,2.5' + get :index, :bbox => "-2.5,-2.5,2.5" assert_response :bad_request - get :index, :bbox => '-2.5,-2.5,2.5,2.5,2.5' + get :index, :bbox => "-2.5,-2.5,2.5,2.5,2.5" assert_response :bad_request - get :index, :b => '-2.5', :r => '2.5', :t => '2.5' + get :index, :b => "-2.5", :r => "2.5", :t => "2.5" assert_response :bad_request - get :index, :l => '-2.5', :r => '2.5', :t => '2.5' + get :index, :l => "-2.5", :r => "2.5", :t => "2.5" assert_response :bad_request - get :index, :l => '-2.5', :b => '-2.5', :t => '2.5' + get :index, :l => "-2.5", :b => "-2.5", :t => "2.5" assert_response :bad_request - get :index, :l => '-2.5', :b => '-2.5', :r => '2.5' + get :index, :l => "-2.5", :b => "-2.5", :r => "2.5" assert_response :bad_request - get :index, :bbox => '1,1,1.7,1.7', :limit => '0', :format => 'json' + get :index, :bbox => "1,1,1.7,1.7", :limit => "0", :format => "json" assert_response :bad_request - get :index, :bbox => '1,1,1.7,1.7', :limit => '10001', :format => 'json' + get :index, :bbox => "1,1,1.7,1.7", :limit => "10001", :format => "json" assert_response :bad_request end def test_search_success - get :search, :q => 'note 1', :format => 'xml' + get :search, :q => "note 1", :format => "xml" assert_response :success assert_equal "application/xml", @response.content_type assert_select "osm", :count => 1 do assert_select "note", :count => 1 end - get :search, :q => 'note 1', :format => 'json' + get :search, :q => "note 1", :format => "json" assert_response :success assert_equal "application/json", @response.content_type js = ActiveSupport::JSON.decode(@response.body) @@ -652,7 +652,7 @@ class NotesControllerTest < ActionController::TestCase assert_equal "FeatureCollection", js["type"] assert_equal 1, js["features"].count - get :search, :q => 'note 1', :format => 'rss' + get :search, :q => "note 1", :format => "rss" assert_response :success assert_equal "application/rss+xml", @response.content_type assert_select "rss", :count => 1 do @@ -661,7 +661,7 @@ class NotesControllerTest < ActionController::TestCase end end - get :search, :q => 'note 1', :format => 'gpx' + get :search, :q => "note 1", :format => "gpx" assert_response :success assert_equal "application/gpx+xml", @response.content_type assert_select "gpx", :count => 1 do @@ -670,14 +670,14 @@ class NotesControllerTest < ActionController::TestCase end def test_search_no_match - get :search, :q => 'no match', :format => 'xml' + get :search, :q => "no match", :format => "xml" assert_response :success assert_equal "application/xml", @response.content_type assert_select "osm", :count => 1 do assert_select "note", :count => 0 end - get :search, :q => 'no match', :format => 'json' + get :search, :q => "no match", :format => "json" assert_response :success assert_equal "application/json", @response.content_type js = ActiveSupport::JSON.decode(@response.body) @@ -685,7 +685,7 @@ class NotesControllerTest < ActionController::TestCase assert_equal "FeatureCollection", js["type"] assert_equal 0, js["features"].count - get :search, :q => 'no match', :format => 'rss' + get :search, :q => "no match", :format => "rss" assert_response :success assert_equal "application/rss+xml", @response.content_type assert_select "rss", :count => 1 do @@ -694,7 +694,7 @@ class NotesControllerTest < ActionController::TestCase end end - get :search, :q => 'no match', :format => 'gpx' + get :search, :q => "no match", :format => "gpx" assert_response :success assert_equal "application/gpx+xml", @response.content_type assert_select "gpx", :count => 1 do @@ -706,10 +706,10 @@ class NotesControllerTest < ActionController::TestCase get :search assert_response :bad_request - get :search, :q => 'no match', :limit => '0', :format => 'json' + get :search, :q => "no match", :limit => "0", :format => "json" assert_response :bad_request - get :search, :q => 'no match', :limit => '10001', :format => 'json' + get :search, :q => "no match", :limit => "10001", :format => "json" assert_response :bad_request end @@ -740,10 +740,10 @@ class NotesControllerTest < ActionController::TestCase get :feed, :bbox => "1,1,1.2,1.2,1.2", :format => "rss" assert_response :bad_request - get :feed, :bbox => "1,1,1.2,1.2", :limit => '0', :format => "rss" + get :feed, :bbox => "1,1,1.2,1.2", :limit => "0", :format => "rss" assert_response :bad_request - get :feed, :bbox => "1,1,1.2,1.2", :limit => '10001', :format => "rss" + get :feed, :bbox => "1,1,1.2,1.2", :limit => "10001", :format => "rss" assert_response :bad_request end diff --git a/test/controllers/oauth_clients_controller_test.rb b/test/controllers/oauth_clients_controller_test.rb index f32c6cf97..1c3c14f86 100644 --- a/test/controllers/oauth_clients_controller_test.rb +++ b/test/controllers/oauth_clients_controller_test.rb @@ -1,4 +1,4 @@ -require 'test_helper' +require "test_helper" class OauthClientsControllerTest < ActionController::TestCase fixtures :users, :client_applications diff --git a/test/controllers/oauth_controller_test.rb b/test/controllers/oauth_controller_test.rb index 879e259c3..8608ba2b0 100644 --- a/test/controllers/oauth_controller_test.rb +++ b/test/controllers/oauth_controller_test.rb @@ -1,4 +1,4 @@ -require 'test_helper' +require "test_helper" class OauthControllerTest < ActionController::TestCase ## diff --git a/test/controllers/old_node_controller_test.rb b/test/controllers/old_node_controller_test.rb index 1b131b340..bdeec8014 100644 --- a/test/controllers/old_node_controller_test.rb +++ b/test/controllers/old_node_controller_test.rb @@ -1,5 +1,5 @@ -require 'test_helper' -require 'old_node_controller' +require "test_helper" +require "old_node_controller" class OldNodeControllerTest < ActionController::TestCase api_fixtures @@ -46,38 +46,38 @@ class OldNodeControllerTest < ActionController::TestCase versions = {} # save a version for later checking - versions[xml_node['version']] = xml_doc.to_s + versions[xml_node["version"]] = xml_doc.to_s # randomly move the node about 20.times do # move the node somewhere else - xml_node['lat'] = precision(rand * 180 - 90).to_s - xml_node['lon'] = precision(rand * 360 - 180).to_s + xml_node["lat"] = precision(rand * 180 - 90).to_s + xml_node["lon"] = precision(rand * 360 - 180).to_s with_controller(NodeController.new) do content xml_doc put :update, :id => nodeid assert_response :forbidden, "Should have rejected node update" - xml_node['version'] = @response.body.to_s + xml_node["version"] = @response.body.to_s end # save a version for later checking - versions[xml_node['version']] = xml_doc.to_s + versions[xml_node["version"]] = xml_doc.to_s end # add a bunch of random tags 30.times do xml_tag = XML::Node.new("tag") - xml_tag['k'] = random_string - xml_tag['v'] = random_string + xml_tag["k"] = random_string + xml_tag["v"] = random_string xml_node << xml_tag with_controller(NodeController.new) do content xml_doc put :update, :id => nodeid assert_response :forbidden, "should have rejected node #{nodeid} (#{@response.body}) with forbidden" - xml_node['version'] = @response.body.to_s + xml_node["version"] = @response.body.to_s end # save a version for later checking - versions[xml_node['version']] = xml_doc.to_s + versions[xml_node["version"]] = xml_doc.to_s end # probably should check that they didn't get written to the database @@ -95,38 +95,38 @@ class OldNodeControllerTest < ActionController::TestCase versions = {} # save a version for later checking - versions[xml_node['version']] = xml_doc.to_s + versions[xml_node["version"]] = xml_doc.to_s # randomly move the node about 20.times do # move the node somewhere else - xml_node['lat'] = precision(rand * 180 - 90).to_s - xml_node['lon'] = precision(rand * 360 - 180).to_s + xml_node["lat"] = precision(rand * 180 - 90).to_s + xml_node["lon"] = precision(rand * 360 - 180).to_s with_controller(NodeController.new) do content xml_doc put :update, :id => nodeid assert_response :success - xml_node['version'] = @response.body.to_s + xml_node["version"] = @response.body.to_s end # save a version for later checking - versions[xml_node['version']] = xml_doc.to_s + versions[xml_node["version"]] = xml_doc.to_s end # add a bunch of random tags 30.times do xml_tag = XML::Node.new("tag") - xml_tag['k'] = random_string - xml_tag['v'] = random_string + xml_tag["k"] = random_string + xml_tag["v"] = random_string xml_node << xml_tag with_controller(NodeController.new) do content xml_doc put :update, :id => nodeid assert_response :success, "couldn't update node #{nodeid} (#{@response.body})" - xml_node['version'] = @response.body.to_s + xml_node["version"] = @response.body.to_s end # save a version for later checking - versions[xml_node['version']] = xml_doc.to_s + versions[xml_node["version"]] = xml_doc.to_s end # check all the versions @@ -244,14 +244,14 @@ class OldNodeControllerTest < ActionController::TestCase # the appropriate flag get :version, :id => node.node_id, :version => node.version assert_response :forbidden, "After redaction, node should be gone for moderator, when flag not passed." - get :version, :id => node.node_id, :version => node.version, :show_redactions => 'true' + get :version, :id => node.node_id, :version => node.version, :show_redactions => "true" assert_response :success, "After redaction, node should not be gone for moderator, when flag passed." # and when accessed via history get :history, :id => node.node_id assert_response :success, "Redaction shouldn't have stopped history working." assert_select "osm node[id='#{node.node_id}'][version='#{node.version}']", 0, "node #{node.node_id} version #{node.version} should not be present in the history for moderators when not passing flag." - get :history, :id => node.node_id, :show_redactions => 'true' + get :history, :id => node.node_id, :show_redactions => "true" assert_response :success, "Redaction shouldn't have stopped history working." assert_select "osm node[id='#{node.node_id}'][version='#{node.version}']", 1, "node #{node.node_id} version #{node.version} should still be present in the history for moderators when passing flag." end @@ -308,10 +308,10 @@ class OldNodeControllerTest < ActionController::TestCase # returns a 16 character long string with some nasty characters in it. # this ought to stress-test the tag handling as well as the versioning. def random_string - letters = [['!', '"', '$', '&', ';', '@'], - ('a'..'z').to_a, - ('A'..'Z').to_a, - ('0'..'9').to_a].flatten + letters = [["!", '"', "$", "&", ";", "@"], + ("a".."z").to_a, + ("A".."Z").to_a, + ("0".."9").to_a].flatten (1..16).map { |_i| letters[rand(letters.length)] }.join end diff --git a/test/controllers/old_relation_controller_test.rb b/test/controllers/old_relation_controller_test.rb index 669e4431e..1ce87a252 100644 --- a/test/controllers/old_relation_controller_test.rb +++ b/test/controllers/old_relation_controller_test.rb @@ -1,5 +1,5 @@ -require 'test_helper' -require 'old_relation_controller' +require "test_helper" +require "old_relation_controller" class OldRelationControllerTest < ActionController::TestCase api_fixtures @@ -111,14 +111,14 @@ class OldRelationControllerTest < ActionController::TestCase # the appropriate flag get :version, :id => relation.relation_id, :version => relation.version assert_response :forbidden, "After redaction, node should be gone for moderator, when flag not passed." - get :version, :id => relation.relation_id, :version => relation.version, :show_redactions => 'true' + get :version, :id => relation.relation_id, :version => relation.version, :show_redactions => "true" assert_response :success, "After redaction, node should not be gone for moderator, when flag passed." # and when accessed via history get :history, :id => relation.relation_id assert_response :success, "Redaction shouldn't have stopped history working." assert_select "osm relation[id='#{relation.relation_id}'][version='#{relation.version}']", 0, "relation #{relation.relation_id} version #{relation.version} should not be present in the history for moderators when not passing flag." - get :history, :id => relation.relation_id, :show_redactions => 'true' + get :history, :id => relation.relation_id, :show_redactions => "true" assert_response :success, "Redaction shouldn't have stopped history working." assert_select "osm relation[id='#{relation.relation_id}'][version='#{relation.version}']", 1, "relation #{relation.relation_id} version #{relation.version} should still be present in the history for moderators when passing flag." end diff --git a/test/controllers/old_way_controller_test.rb b/test/controllers/old_way_controller_test.rb index efaa029bd..f48b0cb89 100644 --- a/test/controllers/old_way_controller_test.rb +++ b/test/controllers/old_way_controller_test.rb @@ -1,5 +1,5 @@ -require 'test_helper' -require 'old_way_controller' +require "test_helper" +require "old_way_controller" class OldWayControllerTest < ActionController::TestCase api_fixtures @@ -137,14 +137,14 @@ class OldWayControllerTest < ActionController::TestCase # the appropriate flag get :version, :id => way.way_id, :version => way.version assert_response :forbidden, "After redaction, node should be gone for moderator, when flag not passed." - get :version, :id => way.way_id, :version => way.version, :show_redactions => 'true' + get :version, :id => way.way_id, :version => way.version, :show_redactions => "true" assert_response :success, "After redaction, node should not be gone for moderator, when flag passed." # and when accessed via history get :history, :id => way.way_id assert_response :success, "Redaction shouldn't have stopped history working." assert_select "osm way[id='#{way.way_id}'][version='#{way.version}']", 0, "way #{way.way_id} version #{way.version} should not be present in the history for moderators when not passing flag." - get :history, :id => way.way_id, :show_redactions => 'true' + get :history, :id => way.way_id, :show_redactions => "true" assert_response :success, "Redaction shouldn't have stopped history working." assert_select "osm way[id='#{way.way_id}'][version='#{way.version}']", 1, "way #{way.way_id} version #{way.version} should still be present in the history for moderators when passing flag." end diff --git a/test/controllers/redactions_controller_test.rb b/test/controllers/redactions_controller_test.rb index 214b54972..7e9170a2c 100644 --- a/test/controllers/redactions_controller_test.rb +++ b/test/controllers/redactions_controller_test.rb @@ -1,5 +1,5 @@ -require 'test_helper' -require 'redactions_controller' +require "test_helper" +require "redactions_controller" class RedactionsControllerTest < ActionController::TestCase api_fixtures diff --git a/test/controllers/relation_controller_test.rb b/test/controllers/relation_controller_test.rb index fb50ebc5b..347c0d121 100644 --- a/test/controllers/relation_controller_test.rb +++ b/test/controllers/relation_controller_test.rb @@ -1,5 +1,5 @@ -require 'test_helper' -require 'relation_controller' +require "test_helper" +require "relation_controller" class RelationControllerTest < ActionController::TestCase api_fixtures @@ -337,7 +337,7 @@ class RelationControllerTest < ActionController::TestCase with_relation(rel_id) do |rel| # alter one of the tags tag = rel.find("//osm/relation/tag").first - tag['v'] = 'some changed value' + tag["v"] = "some changed value" update_changeset(rel, cs_id) # check that the downloaded tags are the same as the uploaded tags... @@ -366,7 +366,7 @@ class RelationControllerTest < ActionController::TestCase with_relation(rel_id) do |rel| # alter one of the tags tag = rel.find("//osm/relation/tag").first - tag['v'] = 'some changed value' + tag["v"] = "some changed value" update_changeset(rel, cs_id) # check that the downloaded tags are the same as the uploaded tags... @@ -566,8 +566,8 @@ class RelationControllerTest < ActionController::TestCase relation_xml = current_relations(:visible_relation).to_xml relation_element = relation_xml.find("//osm/relation").first new_tag = XML::Node.new("tag") - new_tag['k'] = "some_new_tag" - new_tag['v'] = "some_new_value" + new_tag["k"] = "some_new_tag" + new_tag["v"] = "some_new_value" relation_element << new_tag # update changeset ID to point to new changeset @@ -596,9 +596,9 @@ class RelationControllerTest < ActionController::TestCase relation_xml = Relation.find(relation_id).to_xml relation_element = relation_xml.find("//osm/relation").first new_member = XML::Node.new("member") - new_member['ref'] = element.id.to_s - new_member['type'] = element.class.to_s.downcase - new_member['role'] = "some_role" + new_member["ref"] = element.id.to_s + new_member["type"] = element.class.to_s.downcase + new_member["role"] = "some_role" relation_element << new_member # update changeset ID to point to new changeset @@ -667,13 +667,13 @@ OSM # insert a member at the front new_member = XML::Node.new "member" - new_member['ref'] = 5.to_s - new_member['type'] = 'node' - new_member['role'] = 'new first' + new_member["ref"] = 5.to_s + new_member["type"] = "node" + new_member["role"] = "new first" doc.find("//osm/relation").first.child.prev = new_member # update the version, should be 1? - doc.find("//osm/relation").first['id'] = relation_id.to_s - doc.find("//osm/relation").first['version'] = 1.to_s + doc.find("//osm/relation").first["id"] = relation_id.to_s + doc.find("//osm/relation").first["version"] = 1.to_s # upload the next version of the relation content doc @@ -800,11 +800,11 @@ OSM new_doc = XML::Parser.string(xml).parse doc_members = doc.find("//osm/relation/member").collect do |m| - [m['ref'].to_i, m['type'].to_sym, m['role']] + [m["ref"].to_i, m["type"].to_sym, m["role"]] end new_members = new_doc.find("//osm/relation/member").collect do |m| - [m['ref'].to_i, m['type'].to_sym, m['role']] + [m["ref"].to_i, m["type"].to_sym, m["role"]] end doc_members.zip(new_members).each do |d, n| @@ -898,14 +898,14 @@ OSM # the parsed XML doc is retured. def with_update_diff(rel) rel_id = rel.find("//osm/relation").first["id"].to_i - cs_id = rel.find("//osm/relation").first['changeset'].to_i + cs_id = rel.find("//osm/relation").first["changeset"].to_i version = nil with_controller(ChangesetController.new) do doc = OSM::API.new.get_xml_doc - change = XML::Node.new 'osmChange' + change = XML::Node.new "osmChange" doc.root = change - modify = XML::Node.new 'modify' + modify = XML::Node.new "modify" change << modify modify << doc.import(rel.find("//osm/relation").first) @@ -928,8 +928,8 @@ OSM ## # returns a k->v hash of tags from an xml doc def get_tags_as_hash(a) - a.find("//osm/relation/tag").sort_by { |v| v['k'] }.each_with_object({}) do |v, h| - h[v['k']] = v['v'] + a.find("//osm/relation/tag").sort_by { |v| v["k"] }.each_with_object({}) do |v, h| + h[v["k"]] = v["v"] end end @@ -952,7 +952,7 @@ OSM ## # update the changeset_id of a node element def update_changeset(xml, changeset_id) - xml_attr_rewrite(xml, 'changeset', changeset_id) + xml_attr_rewrite(xml, "changeset", changeset_id) end ## diff --git a/test/controllers/search_controller_test.rb b/test/controllers/search_controller_test.rb index c75304774..590840be7 100644 --- a/test/controllers/search_controller_test.rb +++ b/test/controllers/search_controller_test.rb @@ -1,4 +1,4 @@ -require 'test_helper' +require "test_helper" class SearchControllerTest < ActionController::TestCase ## diff --git a/test/controllers/site_controller_test.rb b/test/controllers/site_controller_test.rb index 3fd41c662..01c1f3a22 100644 --- a/test/controllers/site_controller_test.rb +++ b/test/controllers/site_controller_test.rb @@ -1,4 +1,4 @@ -require 'test_helper' +require "test_helper" class SiteControllerTest < ActionController::TestCase api_fixtures @@ -86,56 +86,56 @@ class SiteControllerTest < ActionController::TestCase def test_index get :index assert_response :success - assert_template 'index' + assert_template "index" end # Test the index page redirects def test_index_redirect get :index, :lat => 4, :lon => 5 - assert_redirected_to :controller => :site, :action => :index, :anchor => 'map=5/4/5' + assert_redirected_to :controller => :site, :action => :index, :anchor => "map=5/4/5" get :index, :lat => 4, :lon => 5, :zoom => 3 - assert_redirected_to :controller => :site, :action => :index, :anchor => 'map=3/4/5' + assert_redirected_to :controller => :site, :action => :index, :anchor => "map=3/4/5" - get :index, :layers => 'T' - assert_redirected_to :controller => :site, :action => :index, :anchor => 'layers=T' + get :index, :layers => "T" + assert_redirected_to :controller => :site, :action => :index, :anchor => "layers=T" - get :index, :notes => 'yes' - assert_redirected_to :controller => :site, :action => :index, :anchor => 'layers=N' + get :index, :notes => "yes" + assert_redirected_to :controller => :site, :action => :index, :anchor => "layers=N" - get :index, :lat => 4, :lon => 5, :zoom => 3, :layers => 'T' - assert_redirected_to :controller => :site, :action => :index, :anchor => 'map=3/4/5&layers=T' + get :index, :lat => 4, :lon => 5, :zoom => 3, :layers => "T" + assert_redirected_to :controller => :site, :action => :index, :anchor => "map=3/4/5&layers=T" end # Test the permalink redirect def test_permalink - get :permalink, :code => 'wBz3--' + get :permalink, :code => "wBz3--" assert_response :redirect - assert_redirected_to :controller => :site, :action => :index, :anchor => 'map=3/4.8779296875/3.955078125' + assert_redirected_to :controller => :site, :action => :index, :anchor => "map=3/4.8779296875/3.955078125" - get :permalink, :code => 'wBz3--', :m => '' + get :permalink, :code => "wBz3--", :m => "" assert_response :redirect - assert_redirected_to :controller => :site, :action => :index, :mlat => '4.8779296875', :mlon => '3.955078125', :anchor => 'map=3/4.8779296875/3.955078125' + assert_redirected_to :controller => :site, :action => :index, :mlat => "4.8779296875", :mlon => "3.955078125", :anchor => "map=3/4.8779296875/3.955078125" - get :permalink, :code => 'wBz3--', :layers => 'T' + get :permalink, :code => "wBz3--", :layers => "T" assert_response :redirect - assert_redirected_to :controller => :site, :action => :index, :anchor => 'map=3/4.8779296875/3.955078125&layers=T' + assert_redirected_to :controller => :site, :action => :index, :anchor => "map=3/4.8779296875/3.955078125&layers=T" - get :permalink, :code => 'wBz3--', :node => 1 + get :permalink, :code => "wBz3--", :node => 1 assert_response :redirect - assert_redirected_to :controller => :browse, :action => :node, :id => 1, :anchor => 'map=3/4.8779296875/3.955078125' + assert_redirected_to :controller => :browse, :action => :node, :id => 1, :anchor => "map=3/4.8779296875/3.955078125" - get :permalink, :code => 'wBz3--', :way => 2 + get :permalink, :code => "wBz3--", :way => 2 assert_response :redirect - assert_redirected_to :controller => :browse, :action => :way, :id => 2, :anchor => 'map=3/4.8779296875/3.955078125' + assert_redirected_to :controller => :browse, :action => :way, :id => 2, :anchor => "map=3/4.8779296875/3.955078125" - get :permalink, :code => 'wBz3--', :relation => 3 + get :permalink, :code => "wBz3--", :relation => 3 assert_response :redirect - assert_redirected_to :controller => :browse, :action => :relation, :id => 3, :anchor => 'map=3/4.8779296875/3.955078125' + assert_redirected_to :controller => :browse, :action => :relation, :id => 3, :anchor => "map=3/4.8779296875/3.955078125" - get :permalink, :code => 'wBz3--', :changeset => 4 + get :permalink, :code => "wBz3--", :changeset => 4 assert_response :redirect - assert_redirected_to :controller => :browse, :action => :changeset, :id => 4, :anchor => 'map=3/4.8779296875/3.955078125' + assert_redirected_to :controller => :browse, :action => :changeset, :id => 4, :anchor => "map=3/4.8779296875/3.955078125" end # Test the key page @@ -254,13 +254,13 @@ class SiteControllerTest < ActionController::TestCase # Test the edit page redirects def test_edit_redirect get :edit, :lat => 4, :lon => 5 - assert_redirected_to :controller => :site, :action => :edit, :anchor => 'map=5/4/5' + assert_redirected_to :controller => :site, :action => :edit, :anchor => "map=5/4/5" get :edit, :lat => 4, :lon => 5, :zoom => 3 - assert_redirected_to :controller => :site, :action => :edit, :anchor => 'map=3/4/5' + assert_redirected_to :controller => :site, :action => :edit, :anchor => "map=3/4/5" - get :edit, :lat => 4, :lon => 5, :zoom => 3, :editor => 'id' - assert_redirected_to :controller => :site, :action => :edit, :editor => 'id', :anchor => 'map=3/4/5' + get :edit, :lat => 4, :lon => 5, :zoom => 3, :editor => "id" + assert_redirected_to :controller => :site, :action => :edit, :editor => "id", :anchor => "map=3/4/5" end # Test the copyright page diff --git a/test/controllers/swf_controller_test.rb b/test/controllers/swf_controller_test.rb index d7213133b..aab339c4e 100644 --- a/test/controllers/swf_controller_test.rb +++ b/test/controllers/swf_controller_test.rb @@ -1,4 +1,4 @@ -require 'test_helper' +require "test_helper" class SwfControllerTest < ActionController::TestCase ## diff --git a/test/controllers/trace_controller_test.rb b/test/controllers/trace_controller_test.rb index 4f5c4b3be..a61a47024 100644 --- a/test/controllers/trace_controller_test.rb +++ b/test/controllers/trace_controller_test.rb @@ -1,4 +1,4 @@ -require 'test_helper' +require "test_helper" class TraceControllerTest < ActionController::TestCase fixtures :users, :gpx_files @@ -173,11 +173,11 @@ class TraceControllerTest < ActionController::TestCase def test_list_mine # First try to get it when not logged in get :mine - assert_redirected_to :controller => 'user', :action => 'login', :referer => '/traces/mine' + assert_redirected_to :controller => "user", :action => "login", :referer => "/traces/mine" # Now try when logged in get :mine, {}, { :user => users(:public_user).id } - assert_redirected_to :controller => 'trace', :action => 'list', :display_name => users(:public_user).display_name + assert_redirected_to :controller => "trace", :action => "list", :display_name => users(:public_user).display_name # Fetch the actual list get :list, { :display_name => users(:public_user).display_name }, { :user => users(:public_user).id } diff --git a/test/controllers/user_blocks_controller_test.rb b/test/controllers/user_blocks_controller_test.rb index db8e2564d..ebf57488c 100644 --- a/test/controllers/user_blocks_controller_test.rb +++ b/test/controllers/user_blocks_controller_test.rb @@ -1,4 +1,4 @@ -require 'test_helper' +require "test_helper" class UserBlocksControllerTest < ActionController::TestCase fixtures :users, :user_roles, :user_blocks diff --git a/test/controllers/user_controller_test.rb b/test/controllers/user_controller_test.rb index a0f0fcd3a..8cbf498a9 100644 --- a/test/controllers/user_controller_test.rb +++ b/test/controllers/user_controller_test.rb @@ -1,4 +1,4 @@ -require 'test_helper' +require "test_helper" class UserControllerTest < ActionController::TestCase fixtures :users @@ -222,8 +222,8 @@ class UserControllerTest < ActionController::TestCase def test_user_create_success user = new_user - assert_difference('User.count', 1) do - assert_difference('ActionMailer::Base.deliveries.size', 1) do + assert_difference("User.count", 1) do + assert_difference("ActionMailer::Base.deliveries.size", 1) do post :save, {}, { :new_user => user } end end @@ -235,7 +235,7 @@ class UserControllerTest < ActionController::TestCase assert_match /#{@url}/, register_email.body.to_s # Check the page - assert_redirected_to :action => 'confirm', :display_name => user.display_name + assert_redirected_to :action => "confirm", :display_name => user.display_name ActionMailer::Base.deliveries.clear end @@ -244,14 +244,14 @@ class UserControllerTest < ActionController::TestCase user = new_user user.email = users(:public_user).email - assert_no_difference('User.count') do - assert_no_difference('ActionMailer::Base.deliveries.size') do + assert_no_difference("User.count") do + assert_no_difference("ActionMailer::Base.deliveries.size") do post :save, {}, { :new_user => user } end end assert_response :success - assert_template 'new' + assert_template "new" assert_select "form > fieldset > div.form-row > input.field_with_errors#user_email" end @@ -259,14 +259,14 @@ class UserControllerTest < ActionController::TestCase user = new_user user.email = users(:public_user).email.upcase - assert_no_difference('User.count') do - assert_no_difference('ActionMailer::Base.deliveries.size') do + assert_no_difference("User.count") do + assert_no_difference("ActionMailer::Base.deliveries.size") do post :save, {}, { :new_user => user } end end assert_response :success - assert_template 'new' + assert_template "new" assert_select "form > fieldset > div.form-row > input.field_with_errors#user_email" end @@ -274,14 +274,14 @@ class UserControllerTest < ActionController::TestCase user = new_user user.display_name = users(:public_user).display_name - assert_no_difference('User.count') do - assert_no_difference('ActionMailer::Base.deliveries.size') do + assert_no_difference("User.count") do + assert_no_difference("ActionMailer::Base.deliveries.size") do post :save, {}, { :new_user => user } end end assert_response :success - assert_template 'new' + assert_template "new" assert_select "form > fieldset > div.form-row > input.field_with_errors#user_display_name" end @@ -289,28 +289,28 @@ class UserControllerTest < ActionController::TestCase user = new_user user.display_name = users(:public_user).display_name.upcase - assert_no_difference('User.count') do - assert_no_difference('ActionMailer::Base.deliveries.size') do + assert_no_difference("User.count") do + assert_no_difference("ActionMailer::Base.deliveries.size") do post :save, {}, { :new_user => user } end end assert_response :success - assert_template 'new' + assert_template "new" assert_select "form > fieldset > div.form-row > input.field_with_errors#user_display_name" end def test_user_save_referer_params user = new_user - assert_difference('User.count', 1) do - assert_difference('ActionMailer::Base.deliveries.size', 1) do + assert_difference("User.count", 1) do + assert_difference("ActionMailer::Base.deliveries.size", 1) do post :save, {}, { :new_user => user, - :referer => '/edit?editor=id#map=1/2/3' } + :referer => "/edit?editor=id#map=1/2/3" } end end - assert_equal welcome_path(:editor => 'id', :zoom => 1, :lat => 2, :lon => 3), + assert_equal welcome_path(:editor => "id", :zoom => 1, :lat => 2, :lon => 3), user.tokens.order("id DESC").first.referer ActionMailer::Base.deliveries.clear @@ -325,7 +325,7 @@ class UserControllerTest < ActionController::TestCase @request.cookies["_osm_session"] = user.display_name post :confirm, :confirm_string => token.token - assert_redirected_to :action => 'confirm' + assert_redirected_to :action => "confirm" assert_match /expired/, flash[:error] end @@ -336,7 +336,7 @@ class UserControllerTest < ActionController::TestCase @request.cookies["_osm_session"] = user.display_name post :confirm, :confirm_string => token.token - assert_redirected_to :action => 'login' + assert_redirected_to :action => "login" assert_match /confirmed/, flash[:error] end @@ -370,7 +370,7 @@ class UserControllerTest < ActionController::TestCase # Test resetting using the address as recorded for a user that has an # address which is duplicated in a different case by another user - assert_difference('ActionMailer::Base.deliveries.size', 1) do + assert_difference("ActionMailer::Base.deliveries.size", 1) do post :lost_password, :user => { :email => users(:normal_user).email } end assert_response :redirect @@ -383,7 +383,7 @@ class UserControllerTest < ActionController::TestCase # Test resetting using an address that matches a different user # that has the same address in a different case - assert_difference('ActionMailer::Base.deliveries.size', 1) do + assert_difference("ActionMailer::Base.deliveries.size", 1) do post :lost_password, :user => { :email => users(:normal_user).email.upcase } end assert_response :redirect @@ -396,7 +396,7 @@ class UserControllerTest < ActionController::TestCase # Test resetting using an address that is a case insensitive match # for more than one user but not an exact match for either - assert_difference('ActionMailer::Base.deliveries.size', 0) do + assert_difference("ActionMailer::Base.deliveries.size", 0) do post :lost_password, :user => { :email => users(:normal_user).email.titlecase } end assert_response :success @@ -405,7 +405,7 @@ class UserControllerTest < ActionController::TestCase # Test resetting using the address as recorded for a user that has an # address which is case insensitively unique - assert_difference('ActionMailer::Base.deliveries.size', 1) do + assert_difference("ActionMailer::Base.deliveries.size", 1) do post :lost_password, :user => { :email => users(:public_user).email } end assert_response :redirect @@ -418,7 +418,7 @@ class UserControllerTest < ActionController::TestCase # Test resetting using an address that matches a user that has the # same (case insensitively unique) address in a different case - assert_difference('ActionMailer::Base.deliveries.size', 1) do + assert_difference("ActionMailer::Base.deliveries.size", 1) do post :lost_password, :user => { :email => users(:public_user).email.upcase } end assert_response :redirect @@ -521,7 +521,7 @@ class UserControllerTest < ActionController::TestCase # Changing email to one that exists should fail user.new_email = users(:public_user).email - assert_no_difference('ActionMailer::Base.deliveries.size') do + assert_no_difference("ActionMailer::Base.deliveries.size") do post :account, { :display_name => user.display_name, :user => user.attributes }, { "user" => user.id } end assert_response :success @@ -532,7 +532,7 @@ class UserControllerTest < ActionController::TestCase # Changing email to one that exists should fail, regardless of case user.new_email = users(:public_user).email.upcase - assert_no_difference('ActionMailer::Base.deliveries.size') do + assert_no_difference("ActionMailer::Base.deliveries.size") do post :account, { :display_name => user.display_name, :user => user.attributes }, { "user" => user.id } end assert_response :success @@ -543,7 +543,7 @@ class UserControllerTest < ActionController::TestCase # Changing email to one that doesn't exist should work user.new_email = "new_tester@example.com" - assert_difference('ActionMailer::Base.deliveries.size', 1) do + assert_difference("ActionMailer::Base.deliveries.size", 1) do post :account, { :display_name => user.display_name, :user => user.attributes }, { "user" => user.id } end assert_response :success @@ -772,7 +772,7 @@ class UserControllerTest < ActionController::TestCase assert_nil Friend.where(:user_id => user.id, :friend_user_id => friend.id).first # When logged in a POST should add the friendship - assert_difference('ActionMailer::Base.deliveries.size', 1) do + assert_difference("ActionMailer::Base.deliveries.size", 1) do post :make_friend, { :display_name => friend.display_name }, { "user" => user } end assert_redirected_to user_path(:display_name => friend.display_name) @@ -784,7 +784,7 @@ class UserControllerTest < ActionController::TestCase ActionMailer::Base.deliveries.clear # A second POST should report that the friendship already exists - assert_no_difference('ActionMailer::Base.deliveries.size') do + assert_no_difference("ActionMailer::Base.deliveries.size") do post :make_friend, { :display_name => friend.display_name }, { "user" => user } end assert_redirected_to user_path(:display_name => friend.display_name) diff --git a/test/controllers/user_preference_controller_test.rb b/test/controllers/user_preference_controller_test.rb index 46c631f92..3c36b29d1 100644 --- a/test/controllers/user_preference_controller_test.rb +++ b/test/controllers/user_preference_controller_test.rb @@ -1,4 +1,4 @@ -require 'test_helper' +require "test_helper" class UserPreferenceControllerTest < ActionController::TestCase fixtures :users, :user_preferences diff --git a/test/controllers/user_roles_controller_test.rb b/test/controllers/user_roles_controller_test.rb index 81a8ac1a4..61cf78b88 100644 --- a/test/controllers/user_roles_controller_test.rb +++ b/test/controllers/user_roles_controller_test.rb @@ -1,4 +1,4 @@ -require 'test_helper' +require "test_helper" class UserRolesControllerTest < ActionController::TestCase fixtures :users, :user_roles diff --git a/test/controllers/way_controller_test.rb b/test/controllers/way_controller_test.rb index 33d9b4579..ee6833889 100644 --- a/test/controllers/way_controller_test.rb +++ b/test/controllers/way_controller_test.rb @@ -1,5 +1,5 @@ -require 'test_helper' -require 'way_controller' +require "test_helper" +require "way_controller" class WayControllerTest < ActionController::TestCase api_fixtures @@ -369,8 +369,8 @@ class WayControllerTest < ActionController::TestCase # add an identical tag to the way tag_xml = XML::Node.new("tag") - tag_xml['k'] = current_way_tags(:t1).k - tag_xml['v'] = current_way_tags(:t1).v + tag_xml["k"] = current_way_tags(:t1).k + tag_xml["v"] = current_way_tags(:t1).v # add the tag into the existing xml way_xml = current_ways(:visible_way).to_xml @@ -388,8 +388,8 @@ class WayControllerTest < ActionController::TestCase # add an identical tag to the way tag_xml = XML::Node.new("tag") - tag_xml['k'] = current_way_tags(:t1).k - tag_xml['v'] = current_way_tags(:t1).v + tag_xml["k"] = current_way_tags(:t1).k + tag_xml["v"] = current_way_tags(:t1).v # add the tag into the existing xml way_xml = current_ways(:visible_way).to_xml @@ -412,8 +412,8 @@ class WayControllerTest < ActionController::TestCase # create duplicate tag tag_xml = XML::Node.new("tag") - tag_xml['k'] = "i_am_a_duplicate" - tag_xml['v'] = "foobar" + tag_xml["k"] = "i_am_a_duplicate" + tag_xml["v"] = "foobar" # add the tag into the existing xml way_xml = current_ways(:visible_way).to_xml @@ -433,8 +433,8 @@ class WayControllerTest < ActionController::TestCase # create duplicate tag tag_xml = XML::Node.new("tag") - tag_xml['k'] = "i_am_a_duplicate" - tag_xml['v'] = "foobar" + tag_xml["k"] = "i_am_a_duplicate" + tag_xml["v"] = "foobar" # add the tag into the existing xml way_xml = current_ways(:visible_way).to_xml @@ -519,7 +519,7 @@ class WayControllerTest < ActionController::TestCase ## # update the changeset_id of a node element def update_changeset(xml, changeset_id) - xml_attr_rewrite(xml, 'changeset', changeset_id) + xml_attr_rewrite(xml, "changeset", changeset_id) end ## diff --git a/test/helpers/application_helper_test.rb b/test/helpers/application_helper_test.rb index 04517c2b5..e48b84e4c 100644 --- a/test/helpers/application_helper_test.rb +++ b/test/helpers/application_helper_test.rb @@ -1,4 +1,4 @@ -require 'test_helper' +require "test_helper" class ApplicationHelperTest < ActionView::TestCase fixtures :users, :user_roles diff --git a/test/helpers/asset_helper_test.rb b/test/helpers/asset_helper_test.rb index 70debcd73..8a4653b25 100644 --- a/test/helpers/asset_helper_test.rb +++ b/test/helpers/asset_helper_test.rb @@ -1,4 +1,4 @@ -require 'test_helper' +require "test_helper" class AssetHelperTest < ActionView::TestCase def test_assets diff --git a/test/helpers/browse_helper_test.rb b/test/helpers/browse_helper_test.rb index 2e949988f..f89561781 100644 --- a/test/helpers/browse_helper_test.rb +++ b/test/helpers/browse_helper_test.rb @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -require 'test_helper' +require "test_helper" class BrowseHelperTest < ActionView::TestCase include ERB::Util diff --git a/test/helpers/changeset_helper_test.rb b/test/helpers/changeset_helper_test.rb index 3fa5d266d..f8ffa1824 100644 --- a/test/helpers/changeset_helper_test.rb +++ b/test/helpers/changeset_helper_test.rb @@ -1,4 +1,4 @@ -require 'test_helper' +require "test_helper" class ChangesetHelperTest < ActionView::TestCase fixtures :changesets, :users diff --git a/test/helpers/note_helper_test.rb b/test/helpers/note_helper_test.rb index 3c87c4f6b..ccfcadc93 100644 --- a/test/helpers/note_helper_test.rb +++ b/test/helpers/note_helper_test.rb @@ -1,4 +1,4 @@ -require 'test_helper' +require "test_helper" class NoteHelperTest < ActionView::TestCase include ERB::Util diff --git a/test/helpers/title_helper_test.rb b/test/helpers/title_helper_test.rb index 11578cc11..2a3cbc46e 100644 --- a/test/helpers/title_helper_test.rb +++ b/test/helpers/title_helper_test.rb @@ -1,4 +1,4 @@ -require 'test_helper' +require "test_helper" class TitleHelperTest < ActionView::TestCase def test_set_title diff --git a/test/integration/client_application_test.rb b/test/integration/client_application_test.rb index 9aa1bc56a..f74e3dc22 100644 --- a/test/integration/client_application_test.rb +++ b/test/integration/client_application_test.rb @@ -1,4 +1,4 @@ -require 'test_helper' +require "test_helper" class ClientApplicationTest < ActionDispatch::IntegrationTest fixtures :users, :client_applications @@ -7,19 +7,19 @@ class ClientApplicationTest < ActionDispatch::IntegrationTest # run through the procedure of creating a client application and checking # that it shows up on the user's account page. def test_create_application - get '/login' + get "/login" assert_response :redirect assert_redirected_to "controller" => "user", "action" => "login", "cookie_test" => "true" follow_redirect! assert_response :success - post '/login', 'username' => "test@example.com", 'password' => "test", :referer => '/user/test2' + post "/login", "username" => "test@example.com", "password" => "test", :referer => "/user/test2" assert_response :redirect follow_redirect! assert_response :success - assert_template 'user/view' - get '/user/test2/account' + assert_template "user/view" + get "/user/test2/account" assert_response :success - assert_template 'user/account' + assert_template "user/account" # check that the form to allow new client application creations exists assert_in_heading do @@ -27,14 +27,14 @@ class ClientApplicationTest < ActionDispatch::IntegrationTest end # now we follow the link to the oauth client list - get '/user/test2/oauth_clients' + get "/user/test2/oauth_clients" assert_response :success assert_in_body do assert_select "a[href='/user/test2/oauth_clients/new']" end # now we follow the link to the new oauth client page - get '/user/test2/oauth_clients/new' + get "/user/test2/oauth_clients/new" assert_response :success assert_in_heading do assert_select "h1", "Register a new application" @@ -50,20 +50,20 @@ class ClientApplicationTest < ActionDispatch::IntegrationTest end end - post '/user/test2/oauth_clients', 'client_application[name]' => 'My New App', - 'client_application[url]' => 'http://my.new.app.org/', - 'client_application[callback_url]' => 'http://my.new.app.org/callback', - 'client_application[support_url]' => 'http://my.new.app.org/support' + post "/user/test2/oauth_clients", "client_application[name]" => "My New App", + "client_application[url]" => "http://my.new.app.org/", + "client_application[callback_url]" => "http://my.new.app.org/callback", + "client_application[support_url]" => "http://my.new.app.org/support" assert_response :redirect follow_redirect! assert_response :success - assert_template 'oauth_clients/show' - assert_equal 'Registered the information successfully', flash[:notice] + assert_template "oauth_clients/show" + assert_equal "Registered the information successfully", flash[:notice] # now go back to the account page and check its listed under this user - get '/user/test2/oauth_clients' + get "/user/test2/oauth_clients" assert_response :success - assert_template 'oauth_clients/index' + assert_template "oauth_clients/index" assert_in_body { assert_select "div>a", "My New App" } end diff --git a/test/integration/cors_test.rb b/test/integration/cors_test.rb index f3581f6a2..fdecfc256 100644 --- a/test/integration/cors_test.rb +++ b/test/integration/cors_test.rb @@ -1,4 +1,4 @@ -require 'test_helper' +require "test_helper" class CORSTest < ActionDispatch::IntegrationTest # Rails 4 adds a built-in `options` method. When we upgrade, we can remove @@ -15,18 +15,18 @@ class CORSTest < ActionDispatch::IntegrationTest def test_api_routes_allow_cross_origin_requests options "/api/capabilities", nil, - 'HTTP_ORIGIN' => "http://www.example.com", - 'HTTP_ACCESS_CONTROL_REQUEST_METHOD' => 'GET' + "HTTP_ORIGIN" => "http://www.example.com", + "HTTP_ACCESS_CONTROL_REQUEST_METHOD" => "GET" assert_response :success - assert_equal "http://www.example.com", response.headers['Access-Control-Allow-Origin'] + assert_equal "http://www.example.com", response.headers["Access-Control-Allow-Origin"] end def test_non_api_routes_dont_allow_cross_origin_requests assert_raises ActionController::RoutingError do options "/", nil, - 'HTTP_ORIGIN' => "http://www.example.com", - 'HTTP_ACCESS_CONTROL_REQUEST_METHOD' => 'GET' + "HTTP_ORIGIN" => "http://www.example.com", + "HTTP_ACCESS_CONTROL_REQUEST_METHOD" => "GET" end end end diff --git a/test/integration/oauth_test.rb b/test/integration/oauth_test.rb index 610c7f4e1..9bbe2c2a9 100644 --- a/test/integration/oauth_test.rb +++ b/test/integration/oauth_test.rb @@ -1,4 +1,4 @@ -require 'test_helper' +require "test_helper" class OAuthTest < ActionDispatch::IntegrationTest fixtures :users, :client_applications, :gpx_files diff --git a/test/integration/redirect_test.rb b/test/integration/redirect_test.rb index a4ff2eb7e..8f5d9fef5 100644 --- a/test/integration/redirect_test.rb +++ b/test/integration/redirect_test.rb @@ -1,4 +1,4 @@ -require 'test_helper' +require "test_helper" class RedirectTest < ActionDispatch::IntegrationTest def test_legacy_redirects diff --git a/test/integration/short_links_test.rb b/test/integration/short_links_test.rb index 31c6cc111..0d42ae738 100644 --- a/test/integration/short_links_test.rb +++ b/test/integration/short_links_test.rb @@ -1,11 +1,11 @@ -require 'test_helper' +require "test_helper" class ShortLinksTest < ActionDispatch::IntegrationTest ## # test the short link with various parameters and ensure they're # kept in the redirect. def test_short_link_params - assert_short_link_redirect('1N8H@P_5W') + assert_short_link_redirect("1N8H@P_5W") assert_short_link_redirect(ShortLink.encode(-0.107846, 51.50771, 18)) end @@ -16,21 +16,21 @@ class ShortLinksTest < ActionDispatch::IntegrationTest anchor = "map=#{zoom}/#{lat}/#{lon}" # test without marker - get '/go/' + short_link - assert_redirected_to :controller => 'site', :action => 'index', :anchor => anchor + get "/go/" + short_link + assert_redirected_to :controller => "site", :action => "index", :anchor => anchor # test with marker - get '/go/' + short_link + "?m" - assert_redirected_to :controller => 'site', :action => 'index', :mlat => lat.to_s, :mlon => lon.to_s, :anchor => anchor + get "/go/" + short_link + "?m" + assert_redirected_to :controller => "site", :action => "index", :mlat => lat.to_s, :mlon => lon.to_s, :anchor => anchor # test with layers and a marker - get '/go/' + short_link + "?m&layers=B000FTF" - assert_redirected_to :controller => 'site', :action => 'index', :mlat => lat.to_s, :mlon => lon.to_s, :anchor => "#{anchor}&layers=B000FTF" - get '/go/' + short_link + "?layers=B000FTF&m" - assert_redirected_to :controller => 'site', :action => 'index', :mlat => lat.to_s, :mlon => lon.to_s, :anchor => "#{anchor}&layers=B000FTF" + get "/go/" + short_link + "?m&layers=B000FTF" + assert_redirected_to :controller => "site", :action => "index", :mlat => lat.to_s, :mlon => lon.to_s, :anchor => "#{anchor}&layers=B000FTF" + get "/go/" + short_link + "?layers=B000FTF&m" + assert_redirected_to :controller => "site", :action => "index", :mlat => lat.to_s, :mlon => lon.to_s, :anchor => "#{anchor}&layers=B000FTF" # test with some random query parameters we haven't even implemented yet - get '/go/' + short_link + "?foobar=yes" - assert_redirected_to :controller => 'site', :action => 'index', :foobar => "yes", :anchor => anchor + get "/go/" + short_link + "?foobar=yes" + assert_redirected_to :controller => "site", :action => "index", :foobar => "yes", :anchor => anchor end end diff --git a/test/integration/user_blocks_test.rb b/test/integration/user_blocks_test.rb index 1b2515cc7..38c64df7d 100644 --- a/test/integration/user_blocks_test.rb +++ b/test/integration/user_blocks_test.rb @@ -1,4 +1,4 @@ -require 'test_helper' +require "test_helper" class UserBlocksTest < ActionDispatch::IntegrationTest fixtures :users, :user_blocks, :user_roles @@ -41,18 +41,18 @@ class UserBlocksTest < ActionDispatch::IntegrationTest assert_response :forbidden # revoke the ban - get '/login' + get "/login" assert_response :success - post '/login', 'username' => moderator.email, 'password' => "test", :referer => "/blocks/#{block.id}/revoke" + post "/login", "username" => moderator.email, "password" => "test", :referer => "/blocks/#{block.id}/revoke" assert_response :redirect follow_redirect! assert_response :success - assert_template 'user_blocks/revoke' - post "/blocks/#{block.id}/revoke", 'confirm' => "yes" + assert_template "user_blocks/revoke" + post "/blocks/#{block.id}/revoke", "confirm" => "yes" assert_response :redirect follow_redirect! assert_response :success - assert_template 'user_blocks/show' + assert_template "user_blocks/show" reset! # access the API again. this time it should work diff --git a/test/integration/user_changeset_comments_test.rb b/test/integration/user_changeset_comments_test.rb index eb79d7183..d183e4d56 100644 --- a/test/integration/user_changeset_comments_test.rb +++ b/test/integration/user_changeset_comments_test.rb @@ -1,4 +1,4 @@ -require 'test_helper' +require "test_helper" class UserChangesetCommentsTest < ActionDispatch::IntegrationTest fixtures :users, :changesets, :changeset_comments @@ -21,18 +21,18 @@ class UserChangesetCommentsTest < ActionDispatch::IntegrationTest # Test if the form is shown def test_displaying_form - get_via_redirect '/login' + get_via_redirect "/login" # We should now be at the login page assert_response :success - assert_template 'user/login' + assert_template "user/login" # We can now login - post '/login', 'username' => "test@openstreetmap.org", 'password' => "test" + post "/login", "username" => "test@openstreetmap.org", "password" => "test" assert_response :redirect get "/changeset/#{changesets(:normal_user_closed_change).id}" assert_response :success - assert_template 'browse/changeset' + assert_template "browse/changeset" assert_select "div#content" do assert_select "div#sidebar" do diff --git a/test/integration/user_creation_test.rb b/test/integration/user_creation_test.rb index 3b79c433d..3625a2e0e 100644 --- a/test/integration/user_creation_test.rb +++ b/test/integration/user_creation_test.rb @@ -1,4 +1,4 @@ -require 'test_helper' +require "test_helper" class UserCreationTest < ActionDispatch::IntegrationTest fixtures :users @@ -9,9 +9,9 @@ class UserCreationTest < ActionDispatch::IntegrationTest def test_create_user_form I18n.available_locales.each do |locale| - get_via_redirect '/user/new', {}, { "HTTP_ACCEPT_LANGUAGE" => locale.to_s } + get_via_redirect "/user/new", {}, { "HTTP_ACCEPT_LANGUAGE" => locale.to_s } assert_response :success - assert_template 'user/new' + assert_template "user/new" end end @@ -19,16 +19,16 @@ class UserCreationTest < ActionDispatch::IntegrationTest I18n.available_locales.each do |locale| dup_email = users(:public_user).email display_name = "#{locale}_new_tester" - assert_difference('User.count', 0) do - assert_difference('ActionMailer::Base.deliveries.size', 0) do - post '/user/new', + assert_difference("User.count", 0) do + assert_difference("ActionMailer::Base.deliveries.size", 0) do + post "/user/new", { :user => { :email => dup_email, :email_confirmation => dup_email, :display_name => display_name, :pass_crypt => "testtest", :pass_crypt_confirmation => "testtest" } }, { "HTTP_ACCEPT_LANGUAGE" => locale.to_s } end end assert_response :success - assert_template 'user/new' - assert_equal response.headers['Content-Language'][0..1], locale.to_s[0..1] unless locale == :root + assert_template "user/new" + assert_equal response.headers["Content-Language"][0..1], locale.to_s[0..1] unless locale == :root assert_select "form > fieldset > div.form-row > input.field_with_errors#user_email" assert_no_missing_translations end @@ -38,15 +38,15 @@ class UserCreationTest < ActionDispatch::IntegrationTest I18n.available_locales.each do |locale| dup_display_name = users(:public_user).display_name email = "#{locale}_new_tester" - assert_difference('User.count', 0) do - assert_difference('ActionMailer::Base.deliveries.size', 0) do - post '/user/new', + assert_difference("User.count", 0) do + assert_difference("ActionMailer::Base.deliveries.size", 0) do + post "/user/new", { :user => { :email => email, :email_confirmation => email, :display_name => dup_display_name, :pass_crypt => "testtest", :pass_crypt_confirmation => "testtest" } }, { "HTTP_ACCEPT_LANGUAGE" => locale.to_s } end end assert_response :success - assert_template 'user/new' + assert_template "user/new" assert_select "form > fieldset > div.form-row > input.field_with_errors#user_display_name" assert_no_missing_translations end @@ -57,8 +57,8 @@ class UserCreationTest < ActionDispatch::IntegrationTest new_email = "#{locale}newtester@osm.org" display_name = "#{locale}_new_tester" - assert_difference('User.count', 0) do - assert_difference('ActionMailer::Base.deliveries.size', 0) do + assert_difference("User.count", 0) do + assert_difference("ActionMailer::Base.deliveries.size", 0) do post "/user/new", :user => { :email => new_email, :email_confirmation => new_email, :display_name => display_name, :pass_crypt => "testtest", :pass_crypt_confirmation => "testtest" } end @@ -66,8 +66,8 @@ class UserCreationTest < ActionDispatch::IntegrationTest assert_redirected_to "/user/terms" - assert_difference('User.count') do - assert_difference('ActionMailer::Base.deliveries.size', 1) do + assert_difference("User.count") do + assert_difference("ActionMailer::Base.deliveries.size", 1) do post_via_redirect "/user/save", {}, { "HTTP_ACCEPT_LANGUAGE" => "#{locale}" } end @@ -82,7 +82,7 @@ class UserCreationTest < ActionDispatch::IntegrationTest # Check the page assert_response :success - assert_template 'user/confirm' + assert_template "user/confirm" ActionMailer::Base.deliveries.clear end @@ -103,8 +103,8 @@ class UserCreationTest < ActionDispatch::IntegrationTest password = "testtest" # nothing special about this page, just need a protected page to redirect back to. referer = "/traces/mine" - assert_difference('User.count') do - assert_difference('ActionMailer::Base.deliveries.size', 1) do + assert_difference("User.count") do + assert_difference("ActionMailer::Base.deliveries.size", 1) do post "/user/new", :user => { :email => new_email, :email_confirmation => new_email, :display_name => display_name, :pass_crypt => password, :pass_crypt_confirmation => password }, :referer => referer assert_redirected_to "/user/terms" @@ -126,35 +126,35 @@ class UserCreationTest < ActionDispatch::IntegrationTest # Check the page assert_response :success - assert_template 'user/confirm' + assert_template "user/confirm" ActionMailer::Base.deliveries.clear # Go to the confirmation page get "/user/#{display_name}/confirm", :confirm_string => confirm_string assert_response :success - assert_template 'user/confirm' + assert_template "user/confirm" post "/user/#{display_name}/confirm", :confirm_string => confirm_string assert_response :redirect follow_redirect! assert_response :success - assert_template 'site/welcome' + assert_template "site/welcome" end def test_user_create_openid_success new_email = "newtester-openid@osm.org" display_name = "new_tester-openid" password = "testtest" - assert_difference('User.count') do - assert_difference('ActionMailer::Base.deliveries.size', 1) do + assert_difference("User.count") do + assert_difference("ActionMailer::Base.deliveries.size", 1) do post "/user/new", :user => { :email => new_email, :email_confirmation => new_email, :display_name => display_name, :openid_url => "http://localhost:1123/john.doe?openid.success=newuser", :pass_crypt => "", :pass_crypt_confirmation => "" } assert_response :redirect res = openid_request(@response.redirect_url) get "/user/new", res assert_redirected_to "/user/terms" - post '/user/save', + post "/user/save", :user => { :email => new_email, :email_confirmation => new_email, :display_name => display_name, :openid_url => "http://localhost:1123/john.doe?openid.success=newuser", :pass_crypt => password, :pass_crypt_confirmation => password } assert_response :redirect follow_redirect! @@ -163,7 +163,7 @@ class UserCreationTest < ActionDispatch::IntegrationTest # Check the page assert_response :success - assert_template 'user/confirm' + assert_template "user/confirm" ActionMailer::Base.deliveries.clear end @@ -171,15 +171,15 @@ class UserCreationTest < ActionDispatch::IntegrationTest def test_user_create_openid_failure new_email = "newtester-openid2@osm.org" display_name = "new_tester-openid2" - assert_difference('User.count', 0) do - assert_difference('ActionMailer::Base.deliveries.size', 0) do + assert_difference("User.count", 0) do + assert_difference("ActionMailer::Base.deliveries.size", 0) do post "/user/new", :user => { :email => new_email, :email_confirmation => new_email, :display_name => display_name, :openid_url => "http://localhost:1123/john.doe?openid.failure=newuser", :pass_crypt => "", :pass_crypt_confirmation => "" } assert_response :redirect res = openid_request(@response.redirect_url) - get '/user/new', res + get "/user/new", res assert_response :success - assert_template 'user/new' + assert_template "user/new" end end @@ -191,8 +191,8 @@ class UserCreationTest < ActionDispatch::IntegrationTest display_name = "redirect_tester_openid" # nothing special about this page, just need a protected page to redirect back to. referer = "/traces/mine" - assert_difference('User.count') do - assert_difference('ActionMailer::Base.deliveries.size', 1) do + assert_difference("User.count") do + assert_difference("ActionMailer::Base.deliveries.size", 1) do post "/user/new", :user => { :email => new_email, :email_confirmation => new_email, :display_name => display_name, :openid_url => "http://localhost:1123/john.doe?openid.success=newuser", :pass_crypt => "", :pass_crypt_confirmation => "" }, :referer => referer assert_response :redirect @@ -217,19 +217,19 @@ class UserCreationTest < ActionDispatch::IntegrationTest # Check the page assert_response :success - assert_template 'user/confirm' + assert_template "user/confirm" ActionMailer::Base.deliveries.clear # Go to the confirmation page get "/user/#{display_name}/confirm", :confirm_string => confirm_string assert_response :success - assert_template 'user/confirm' + assert_template "user/confirm" post "/user/#{display_name}/confirm", :confirm_string => confirm_string assert_response :redirect follow_redirect! assert_response :success - assert_template 'site/welcome' + assert_template "site/welcome" end end diff --git a/test/integration/user_diaries_test.rb b/test/integration/user_diaries_test.rb index f76df33ad..a0b084f92 100644 --- a/test/integration/user_diaries_test.rb +++ b/test/integration/user_diaries_test.rb @@ -1,4 +1,4 @@ -require 'test_helper' +require "test_helper" class UserDiariesTest < ActionDispatch::IntegrationTest fixtures :users, :diary_entries @@ -6,12 +6,12 @@ class UserDiariesTest < ActionDispatch::IntegrationTest # Test the creation of a diary entry, making sure that you are redirected to # login page when not logged in def test_showing_create_diary_entry - get_via_redirect '/diary/new' + get_via_redirect "/diary/new" # We should now be at the login page assert_response :success - assert_template 'user/login' + assert_template "user/login" # We can now login - post '/login', 'username' => "test@openstreetmap.org", 'password' => "test", :referer => '/diary/new' + post "/login", "username" => "test@openstreetmap.org", "password" => "test", :referer => "/diary/new" assert_response :redirect # print @response.body # Check that there is some payload alerting the user to the redirect @@ -27,7 +27,7 @@ class UserDiariesTest < ActionDispatch::IntegrationTest follow_redirect! assert_response :success - assert_template 'diary_entry/edit' + assert_template "diary_entry/edit" # print @response.body # print @html_document.to_yaml diff --git a/test/integration/user_login_test.rb b/test/integration/user_login_test.rb index 83322c76c..cea92466a 100644 --- a/test/integration/user_login_test.rb +++ b/test/integration/user_login_test.rb @@ -1,4 +1,4 @@ -require 'test_helper' +require "test_helper" class UserLoginTest < ActionDispatch::IntegrationTest fixtures :users @@ -10,361 +10,361 @@ class UserLoginTest < ActionDispatch::IntegrationTest def test_login_email_password_normal user = users(:normal_user) - get '/login' + get "/login" assert_response :redirect assert_redirected_to "controller" => "user", "action" => "login", "cookie_test" => "true" follow_redirect! assert_response :success - post '/login', 'username' => user.email, 'password' => "wrong", :referer => "/history" + post "/login", "username" => user.email, "password" => "wrong", :referer => "/history" assert_response :redirect follow_redirect! assert_response :success - assert_template 'login' + assert_template "login" - post '/login', 'username' => user.email, 'password' => "test", :referer => "/history" + post "/login", "username" => user.email, "password" => "test", :referer => "/history" assert_response :redirect follow_redirect! assert_response :success - assert_template 'changeset/history' + assert_template "changeset/history" assert_select "span.username", "test" end def test_login_email_password_normal_upcase user = users(:normal_user) - get '/login' + get "/login" assert_response :redirect assert_redirected_to "controller" => "user", "action" => "login", "cookie_test" => "true" follow_redirect! assert_response :success - post '/login', 'username' => user.email.upcase, 'password' => "wrong", :referer => "/history" + post "/login", "username" => user.email.upcase, "password" => "wrong", :referer => "/history" assert_response :redirect follow_redirect! assert_response :success - assert_template 'login' + assert_template "login" - post '/login', 'username' => user.email.upcase, 'password' => "test", :referer => "/history" + post "/login", "username" => user.email.upcase, "password" => "test", :referer => "/history" assert_response :redirect follow_redirect! assert_response :success - assert_template 'changeset/history' + assert_template "changeset/history" assert_select "span.username", "TEST" end def test_login_email_password_normal_titlecase user = users(:normal_user) - get '/login' + get "/login" assert_response :redirect assert_redirected_to "controller" => "user", "action" => "login", "cookie_test" => "true" follow_redirect! assert_response :success - post '/login', 'username' => user.email.titlecase, 'password' => "wrong", :referer => "/history" + post "/login", "username" => user.email.titlecase, "password" => "wrong", :referer => "/history" assert_response :redirect follow_redirect! assert_response :success - assert_template 'login' + assert_template "login" - post '/login', 'username' => user.email.titlecase, 'password' => "test", :referer => "/history" + post "/login", "username" => user.email.titlecase, "password" => "test", :referer => "/history" assert_response :redirect follow_redirect! assert_response :success - assert_template 'login' + assert_template "login" assert_select "span.username", false end def test_login_email_password_public user = users(:public_user) - get '/login' + get "/login" assert_response :redirect assert_redirected_to "controller" => "user", "action" => "login", "cookie_test" => "true" follow_redirect! assert_response :success - post '/login', 'username' => user.email, 'password' => "wrong", :referer => "/history" + post "/login", "username" => user.email, "password" => "wrong", :referer => "/history" assert_response :redirect follow_redirect! assert_response :success - assert_template 'login' + assert_template "login" - post '/login', 'username' => user.email, 'password' => "test", :referer => "/history" + post "/login", "username" => user.email, "password" => "test", :referer => "/history" assert_response :redirect follow_redirect! assert_response :success - assert_template 'changeset/history' + assert_template "changeset/history" assert_select "span.username", "test2" end def test_login_email_password_public_upcase user = users(:public_user) - get '/login' + get "/login" assert_response :redirect assert_redirected_to "controller" => "user", "action" => "login", "cookie_test" => "true" follow_redirect! assert_response :success - post '/login', 'username' => user.email.upcase, 'password' => "wrong", :referer => "/history" + post "/login", "username" => user.email.upcase, "password" => "wrong", :referer => "/history" assert_response :redirect follow_redirect! assert_response :success - assert_template 'login' + assert_template "login" - post '/login', 'username' => user.email.upcase, 'password' => "test", :referer => "/history" + post "/login", "username" => user.email.upcase, "password" => "test", :referer => "/history" assert_response :redirect follow_redirect! assert_response :success - assert_template 'changeset/history' + assert_template "changeset/history" assert_select "span.username", "test2" end def test_login_email_password_public_titlecase user = users(:public_user) - get '/login' + get "/login" assert_response :redirect assert_redirected_to "controller" => "user", "action" => "login", "cookie_test" => "true" follow_redirect! assert_response :success - post '/login', 'username' => user.email.titlecase, 'password' => "wrong", :referer => "/history" + post "/login", "username" => user.email.titlecase, "password" => "wrong", :referer => "/history" assert_response :redirect follow_redirect! assert_response :success - assert_template 'login' + assert_template "login" - post '/login', 'username' => user.email.titlecase, 'password' => "test", :referer => "/history" + post "/login", "username" => user.email.titlecase, "password" => "test", :referer => "/history" assert_response :redirect follow_redirect! assert_response :success - assert_template 'changeset/history' + assert_template "changeset/history" assert_select "span.username", "test2" end def test_login_username_password_normal user = users(:normal_user) - get '/login' + get "/login" assert_response :redirect assert_redirected_to "controller" => "user", "action" => "login", "cookie_test" => "true" follow_redirect! assert_response :success - post '/login', 'username' => user.display_name, 'password' => "wrong", :referer => "/history" + post "/login", "username" => user.display_name, "password" => "wrong", :referer => "/history" assert_response :redirect follow_redirect! assert_response :success - assert_template 'login' + assert_template "login" - post '/login', 'username' => user.display_name, 'password' => "test", :referer => "/history" + post "/login", "username" => user.display_name, "password" => "test", :referer => "/history" assert_response :redirect follow_redirect! assert_response :success - assert_template 'changeset/history' + assert_template "changeset/history" assert_select "span.username", "test" end def test_login_username_password_normal_upcase user = users(:normal_user) - get '/login' + get "/login" assert_response :redirect assert_redirected_to "controller" => "user", "action" => "login", "cookie_test" => "true" follow_redirect! assert_response :success - post '/login', 'username' => user.display_name.upcase, 'password' => "wrong", :referer => "/history" + post "/login", "username" => user.display_name.upcase, "password" => "wrong", :referer => "/history" assert_response :redirect follow_redirect! assert_response :success - assert_template 'login' + assert_template "login" - post '/login', 'username' => user.display_name.upcase, 'password' => "test", :referer => "/history" + post "/login", "username" => user.display_name.upcase, "password" => "test", :referer => "/history" assert_response :redirect follow_redirect! assert_response :success - assert_template 'changeset/history' + assert_template "changeset/history" assert_select "span.username", "TEST" end def test_login_username_password_normal_titlecase user = users(:normal_user) - get '/login' + get "/login" assert_response :redirect assert_redirected_to "controller" => "user", "action" => "login", "cookie_test" => "true" follow_redirect! assert_response :success - post '/login', 'username' => user.display_name.titlecase, 'password' => "wrong", :referer => "/history" + post "/login", "username" => user.display_name.titlecase, "password" => "wrong", :referer => "/history" assert_response :redirect follow_redirect! assert_response :success - assert_template 'login' + assert_template "login" - post '/login', 'username' => user.display_name.titlecase, 'password' => "test", :referer => "/history" + post "/login", "username" => user.display_name.titlecase, "password" => "test", :referer => "/history" assert_response :redirect follow_redirect! assert_response :success - assert_template 'login' + assert_template "login" assert_select "span.username", false end def test_login_username_password_public user = users(:public_user) - get '/login' + get "/login" assert_response :redirect assert_redirected_to "controller" => "user", "action" => "login", "cookie_test" => "true" follow_redirect! assert_response :success - post '/login', 'username' => user.display_name, 'password' => "wrong", :referer => "/history" + post "/login", "username" => user.display_name, "password" => "wrong", :referer => "/history" assert_response :redirect follow_redirect! assert_response :success - assert_template 'login' + assert_template "login" - post '/login', 'username' => user.display_name, 'password' => "test", :referer => "/history" + post "/login", "username" => user.display_name, "password" => "test", :referer => "/history" assert_response :redirect follow_redirect! assert_response :success - assert_template 'changeset/history' + assert_template "changeset/history" assert_select "span.username", "test2" end def test_login_username_password_public_upcase user = users(:public_user) - get '/login' + get "/login" assert_response :redirect assert_redirected_to "controller" => "user", "action" => "login", "cookie_test" => "true" follow_redirect! assert_response :success - post '/login', 'username' => user.display_name.upcase, 'password' => "wrong", :referer => "/history" + post "/login", "username" => user.display_name.upcase, "password" => "wrong", :referer => "/history" assert_response :redirect follow_redirect! assert_response :success - assert_template 'login' + assert_template "login" - post '/login', 'username' => user.display_name.upcase, 'password' => "test", :referer => "/history" + post "/login", "username" => user.display_name.upcase, "password" => "test", :referer => "/history" assert_response :redirect follow_redirect! assert_response :success - assert_template 'changeset/history' + assert_template "changeset/history" assert_select "span.username", "test2" end def test_login_username_password_public_titlecase user = users(:public_user) - get '/login' + get "/login" assert_response :redirect assert_redirected_to "controller" => "user", "action" => "login", "cookie_test" => "true" follow_redirect! assert_response :success - post '/login', 'username' => user.display_name.titlecase, 'password' => "wrong", :referer => "/history" + post "/login", "username" => user.display_name.titlecase, "password" => "wrong", :referer => "/history" assert_response :redirect follow_redirect! assert_response :success - assert_template 'login' + assert_template "login" - post '/login', 'username' => user.display_name.titlecase, 'password' => "test", :referer => "/history" + post "/login", "username" => user.display_name.titlecase, "password" => "test", :referer => "/history" assert_response :redirect follow_redirect! assert_response :success - assert_template 'changeset/history' + assert_template "changeset/history" assert_select "span.username", "test2" end def test_login_openid_success - get '/login' + get "/login" assert_response :redirect assert_redirected_to "controller" => "user", "action" => "login", "cookie_test" => "true" follow_redirect! assert_response :success - 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 - post '/login', openid_request(@response.redirect_url) + post "/login", openid_request(@response.redirect_url) assert_response :redirect follow_redirect! assert_response :success - assert_template 'changeset/history' + assert_template "changeset/history" assert_select "span.username", "openIDuser" end def test_login_openid_cancel - get '/login' + get "/login" assert_response :redirect assert_redirected_to "controller" => "user", "action" => "login", "cookie_test" => "true" follow_redirect! assert_response :success - 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 - post '/login', openid_request(@response.redirect_url) + post "/login", openid_request(@response.redirect_url) assert_response :redirect follow_redirect! assert_response :success - assert_template 'login' + assert_template "login" assert_select "span.username", false end def test_login_openid_invalid_provider - get '/login' + get "/login" assert_response :redirect assert_redirected_to "controller" => "user", "action" => "login", "cookie_test" => "true" follow_redirect! assert_response :success # Use a different port that doesn't have the OpenID provider running on to test an invalid openID - post '/login', 'openid_url' => "http://localhost:1124/john.doe", :referer => "/diary" + post "/login", "openid_url" => "http://localhost:1124/john.doe", :referer => "/diary" assert_response :redirect follow_redirect! assert_response :success - assert_template 'login' + assert_template "login" assert_select "span.username", false end def test_login_openid_invalid_url - get '/login' + get "/login" assert_response :redirect assert_redirected_to "controller" => "user", "action" => "login", "cookie_test" => "true" follow_redirect! assert_response :success # Use a url with an invalid protocol to make sure it handles that correctly too - post '/login', 'openid_url' => "htt://localhost:1123/john.doe", :referer => "/diary" + post "/login", "openid_url" => "htt://localhost:1123/john.doe", :referer => "/diary" assert_response :redirect follow_redirect! assert_response :success - assert_template 'login' + assert_template "login" assert_select "span.username", false end def test_login_openid_unknown - get '/login' + get "/login" assert_response :redirect assert_redirected_to "controller" => "user", "action" => "login", "cookie_test" => "true" follow_redirect! assert_response :success - post '/login', 'openid_url' => "http://localhost:1123/john.doe?openid.success=true_somethingelse", :referer => "/diary" + post "/login", "openid_url" => "http://localhost:1123/john.doe?openid.success=true_somethingelse", :referer => "/diary" assert_response :redirect res = openid_request(@response.redirect_url) - post '/login', res + post "/login", res assert_response :redirect follow_redirect! assert_response :success - assert_template 'user/new' + assert_template "user/new" assert_select "span.username", false end end diff --git a/test/integration/user_roles_test.rb b/test/integration/user_roles_test.rb index cbd0dbe80..573243025 100644 --- a/test/integration/user_roles_test.rb +++ b/test/integration/user_roles_test.rb @@ -1,4 +1,4 @@ -require 'test_helper' +require "test_helper" class UserRolesTest < ActionDispatch::IntegrationTest fixtures :users, :user_roles @@ -19,35 +19,35 @@ class UserRolesTest < ActionDispatch::IntegrationTest private def check_fail(action, user, role) - get '/login' + get "/login" assert_response :redirect assert_redirected_to "controller" => "user", "action" => "login", "cookie_test" => "true" follow_redirect! assert_response :success - post '/login', 'username' => users(user).email, 'password' => "test", :referer => "/" + post "/login", "username" => users(user).email, "password" => "test", :referer => "/" assert_response :redirect follow_redirect! assert_response :success post "/user/#{users(:second_public_user).display_name}/role/#{role}/#{action}" - assert_redirected_to :controller => 'user', :action => 'view', :display_name => users(:second_public_user).display_name + assert_redirected_to :controller => "user", :action => "view", :display_name => users(:second_public_user).display_name reset! end def check_success(action, user, role) - get '/login' + get "/login" assert_response :redirect assert_redirected_to "controller" => "user", "action" => "login", "cookie_test" => "true" follow_redirect! assert_response :success - post '/login', 'username' => users(user).email, 'password' => "test", :referer => "/" + post "/login", "username" => users(user).email, "password" => "test", :referer => "/" assert_response :redirect follow_redirect! assert_response :success post "/user/#{users(:second_public_user).display_name}/role/#{role}/#{action}" - assert_redirected_to :controller => 'user', :action => 'view', :display_name => users(:second_public_user).display_name + assert_redirected_to :controller => "user", :action => "view", :display_name => users(:second_public_user).display_name reset! end diff --git a/test/integration/user_terms_seen_test.rb b/test/integration/user_terms_seen_test.rb index d438a6c0c..a00ad39d5 100644 --- a/test/integration/user_terms_seen_test.rb +++ b/test/integration/user_terms_seen_test.rb @@ -1,4 +1,4 @@ -require 'test_helper' +require "test_helper" class UserTermsSeenTest < ActionDispatch::IntegrationTest fixtures :users @@ -26,8 +26,8 @@ class UserTermsSeenTest < ActionDispatch::IntegrationTest # try to log in get_via_redirect "/login" assert_response :success - assert_template 'user/login' - post "/login", 'username' => user.email, 'password' => 'test', :referer => "/" + assert_template "user/login" + post "/login", "username" => user.email, "password" => "test", :referer => "/" assert_response :redirect # but now we need to look at the terms assert_redirected_to "controller" => "user", "action" => "terms", :referer => "/" @@ -35,7 +35,7 @@ class UserTermsSeenTest < ActionDispatch::IntegrationTest assert_response :success # don't agree to the terms, but hit decline - post "/user/save", 'decline' => 'decline', 'referer' => '/' + post "/user/save", "decline" => "decline", "referer" => "/" assert_redirected_to "/" follow_redirect! @@ -52,8 +52,8 @@ class UserTermsSeenTest < ActionDispatch::IntegrationTest # try to log in get_via_redirect "/login" assert_response :success - assert_template 'user/login' - post "/login", 'username' => user.email, 'password' => 'test', :referer => "/" + assert_template "user/login" + post "/login", "username" => user.email, "password" => "test", :referer => "/" assert_response :redirect # but now we need to look at the terms assert_redirected_to "controller" => "user", "action" => "terms", :referer => "/" diff --git a/test/lib/bounding_box_test.rb b/test/lib/bounding_box_test.rb index bd2d6fec6..4e962aedf 100644 --- a/test/lib/bounding_box_test.rb +++ b/test/lib/bounding_box_test.rb @@ -1,4 +1,4 @@ -require 'test_helper' +require "test_helper" class BoundingBoxTest < ActiveSupport::TestCase def setup @@ -42,7 +42,7 @@ class BoundingBoxTest < ActiveSupport::TestCase def test_good_bbox_from_string @good_bbox.each do |string| bbox = BoundingBox.from_s(string) - array = string.split(',').collect(&:to_f) + array = string.split(",").collect(&:to_f) check_bbox(bbox, array) end end @@ -57,14 +57,14 @@ class BoundingBoxTest < ActiveSupport::TestCase def test_good_bbox_from_params @good_bbox.each do |string| bbox = BoundingBox.from_bbox_params(:bbox => string) - array = string.split(',').collect(&:to_f) + array = string.split(",").collect(&:to_f) check_bbox(bbox, array) end end def test_good_bbox_from_lon_lat_params @good_bbox.each do |string| - array = string.split(',') + array = string.split(",") bbox = BoundingBox.from_lon_lat_params(:minlon => array[0], :minlat => array[1], :maxlon => array[2], :maxlat => array[3]) check_bbox(bbox, array.collect(&:to_f)) end @@ -79,7 +79,7 @@ class BoundingBoxTest < ActiveSupport::TestCase def test_good_bbox_from_new @good_bbox.each do |string| - array = string.split(',') + array = string.split(",") bbox = BoundingBox.new(array[0], array[1], array[2], array[3]) check_bbox(bbox, array.collect(&:to_f)) end @@ -212,7 +212,7 @@ class BoundingBoxTest < ActiveSupport::TestCase def test_bbox_area @good_bbox.each do |string| bbox = BoundingBox.from_s(string) - array = string.split(',') + array = string.split(",") assert_equal ((array[2].to_f - array[0].to_f) * (array[3].to_f - array[1].to_f)), bbox.area end end @@ -224,28 +224,28 @@ class BoundingBoxTest < ActiveSupport::TestCase def test_centre_lon @good_bbox.each do |bbox_string| - array = bbox_string.split(',') + array = bbox_string.split(",") assert_equal ((array[0].to_f + array[2].to_f) / 2.0), BoundingBox.from_s(bbox_string).centre_lon end end def test_centre_lat @good_bbox.each do |bbox_string| - array = bbox_string.split(',') + array = bbox_string.split(",") assert_equal ((array[1].to_f + array[3].to_f) / 2.0), BoundingBox.from_s(bbox_string).centre_lat end end def test_width @good_bbox.each do |bbox_string| - array = bbox_string.split(',') + array = bbox_string.split(",") assert_equal (array[2].to_f - array[0].to_f), BoundingBox.from_s(bbox_string).width end end def test_height @good_bbox.each do |bbox_string| - array = bbox_string.split(',') + array = bbox_string.split(",") assert_equal (array[3].to_f - array[1].to_f), BoundingBox.from_s(bbox_string).height end end @@ -261,19 +261,19 @@ class BoundingBoxTest < ActiveSupport::TestCase def test_add_bounds_to_no_underscore bounds = @bbox_from_string.add_bounds_to({}) assert_equal 4, bounds.size - assert_equal @min_lon.to_s, bounds['minlon'] - assert_equal @min_lat.to_s, bounds['minlat'] - assert_equal @max_lon.to_s, bounds['maxlon'] - assert_equal @max_lat.to_s, bounds['maxlat'] + assert_equal @min_lon.to_s, bounds["minlon"] + assert_equal @min_lat.to_s, bounds["minlat"] + assert_equal @max_lon.to_s, bounds["maxlon"] + assert_equal @max_lat.to_s, bounds["maxlat"] end def test_add_bounds_to_with_underscore - bounds = @bbox_from_string.add_bounds_to({}, '_') + bounds = @bbox_from_string.add_bounds_to({}, "_") assert_equal 4, bounds.size - assert_equal @min_lon.to_s, bounds['min_lon'] - assert_equal @min_lat.to_s, bounds['min_lat'] - assert_equal @max_lon.to_s, bounds['max_lon'] - assert_equal @max_lat.to_s, bounds['max_lat'] + assert_equal @min_lon.to_s, bounds["min_lon"] + assert_equal @min_lat.to_s, bounds["min_lat"] + assert_equal @max_lon.to_s, bounds["max_lon"] + assert_equal @max_lat.to_s, bounds["max_lat"] end def test_to_scaled @@ -301,16 +301,16 @@ class BoundingBoxTest < ActiveSupport::TestCase private def check_expand(bbox, array_string, margin = 0, result = nil) - array = array_string.split(',').collect(&:to_f) + array = array_string.split(",").collect(&:to_f) result = array unless result bbox.expand!(BoundingBox.new(array[0], array[1], array[2], array[3]), margin) check_bbox(bbox, result) end def check_bbox(bbox, result) - assert_equal result[0], bbox.min_lon, 'min_lon' - assert_equal result[1], bbox.min_lat, 'min_lat' - assert_equal result[2], bbox.max_lon, 'max_lon' - assert_equal result[3], bbox.max_lat, 'max_lat' + assert_equal result[0], bbox.min_lon, "min_lon" + assert_equal result[1], bbox.min_lat, "min_lat" + assert_equal result[2], bbox.max_lon, "max_lon" + assert_equal result[3], bbox.max_lat, "max_lat" end end diff --git a/test/lib/country_test.rb b/test/lib/country_test.rb index 14827c05f..cc726e6f7 100644 --- a/test/lib/country_test.rb +++ b/test/lib/country_test.rb @@ -1,4 +1,4 @@ -require 'test_helper' +require "test_helper" class CountryTest < ActiveSupport::TestCase def test_gb diff --git a/test/lib/i18n_test.rb b/test/lib/i18n_test.rb index 0509da156..09965e950 100644 --- a/test/lib/i18n_test.rb +++ b/test/lib/i18n_test.rb @@ -1,4 +1,4 @@ -require 'test_helper' +require "test_helper" class I18nTest < ActiveSupport::TestCase I18n.available_locales.each do |locale| diff --git a/test/lib/password_hash_test.rb b/test/lib/password_hash_test.rb index bf253c0b8..c481cc767 100644 --- a/test/lib/password_hash_test.rb +++ b/test/lib/password_hash_test.rb @@ -1,4 +1,4 @@ -require 'test_helper' +require "test_helper" class PasswordHashTest < ActiveSupport::TestCase def test_md5_without_salt diff --git a/test/lib/rich_text_test.rb b/test/lib/rich_text_test.rb index 813dc3d35..9ba0f7dcb 100644 --- a/test/lib/rich_text_test.rb +++ b/test/lib/rich_text_test.rb @@ -1,4 +1,4 @@ -require 'test_helper' +require "test_helper" class RichTextTest < ActiveSupport::TestCase include Rails::Dom::Testing::Assertions::SelectorAssertions diff --git a/test/lib/short_link_test.rb b/test/lib/short_link_test.rb index 9b198ffc7..1c8d3ce2c 100644 --- a/test/lib/short_link_test.rb +++ b/test/lib/short_link_test.rb @@ -1,4 +1,4 @@ -require 'test_helper' +require "test_helper" class ShortLinkTest < ActiveSupport::TestCase ## diff --git a/test/lib/utf8_test.rb b/test/lib/utf8_test.rb index 1604b52f6..5762a83eb 100644 --- a/test/lib/utf8_test.rb +++ b/test/lib/utf8_test.rb @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -require 'test_helper' +require "test_helper" class UTF8Test < ActiveSupport::TestCase def test_valid? diff --git a/test/models/acl_test.rb b/test/models/acl_test.rb index 9d8431912..4022b8adb 100644 --- a/test/models/acl_test.rb +++ b/test/models/acl_test.rb @@ -1,4 +1,4 @@ -require 'test_helper' +require "test_helper" class AclTest < ActiveSupport::TestCase # Replace this with your real tests. diff --git a/test/models/changeset_comment_test.rb b/test/models/changeset_comment_test.rb index ed4f0e032..2e09bb884 100644 --- a/test/models/changeset_comment_test.rb +++ b/test/models/changeset_comment_test.rb @@ -1,4 +1,4 @@ -require 'test_helper' +require "test_helper" class ChangesetCommentTest < ActiveSupport::TestCase fixtures :changesets, :changeset_comments diff --git a/test/models/changeset_tag_test.rb b/test/models/changeset_tag_test.rb index 75bbba0ba..e62808b6e 100644 --- a/test/models/changeset_tag_test.rb +++ b/test/models/changeset_tag_test.rb @@ -1,4 +1,4 @@ -require 'test_helper' +require "test_helper" class ChangesetTagTest < ActiveSupport::TestCase api_fixtures diff --git a/test/models/changeset_test.rb b/test/models/changeset_test.rb index dba1a3b43..949b0ea22 100644 --- a/test/models/changeset_test.rb +++ b/test/models/changeset_test.rb @@ -1,4 +1,4 @@ -require 'test_helper' +require "test_helper" class ChangesetTest < ActiveSupport::TestCase api_fixtures diff --git a/test/models/diary_comment_test.rb b/test/models/diary_comment_test.rb index bf778c27a..a32c153f9 100644 --- a/test/models/diary_comment_test.rb +++ b/test/models/diary_comment_test.rb @@ -1,4 +1,4 @@ -require 'test_helper' +require "test_helper" class DiaryCommentTest < ActiveSupport::TestCase api_fixtures diff --git a/test/models/diary_entry_test.rb b/test/models/diary_entry_test.rb index ad863a7de..ab5f45ff2 100644 --- a/test/models/diary_entry_test.rb +++ b/test/models/diary_entry_test.rb @@ -1,4 +1,4 @@ -require 'test_helper' +require "test_helper" class DiaryEntryTest < ActiveSupport::TestCase api_fixtures @@ -10,10 +10,10 @@ class DiaryEntryTest < ActiveSupport::TestCase def test_diary_entry_validations diary_entry_valid({}) - diary_entry_valid({ :title => '' }, false) - diary_entry_valid(:title => 'a' * 255) - diary_entry_valid({ :title => 'a' * 256 }, false) - diary_entry_valid({ :body => '' }, false) + diary_entry_valid({ :title => "" }, false) + diary_entry_valid(:title => "a" * 255) + diary_entry_valid({ :title => "a" * 256 }, false) + diary_entry_valid({ :body => "" }, false) diary_entry_valid(:latitude => 90) diary_entry_valid({ :latitude => 90.00001 }, false) diary_entry_valid(:latitude => -90) diff --git a/test/models/friend_test.rb b/test/models/friend_test.rb index 240e3f148..a13f67470 100644 --- a/test/models/friend_test.rb +++ b/test/models/friend_test.rb @@ -1,4 +1,4 @@ -require 'test_helper' +require "test_helper" class FriendTest < ActiveSupport::TestCase api_fixtures diff --git a/test/models/language_test.rb b/test/models/language_test.rb index a9d6f5d6a..ac79b3a9d 100644 --- a/test/models/language_test.rb +++ b/test/models/language_test.rb @@ -1,4 +1,4 @@ -require 'test_helper' +require "test_helper" class LanguageTest < ActiveSupport::TestCase test "language count" do diff --git a/test/models/message_test.rb b/test/models/message_test.rb index 5cd171211..cf5572216 100644 --- a/test/models/message_test.rb +++ b/test/models/message_test.rb @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -require 'test_helper' +require "test_helper" class MessageTest < ActiveSupport::TestCase api_fixtures @@ -43,13 +43,13 @@ class MessageTest < ActiveSupport::TestCase def test_utf8_roundtrip (1..255).each do |i| - assert_message_ok('c', i) + assert_message_ok("c", i) assert_message_ok(EURO, i) end end def test_length_oversize - assert_raise(ActiveRecord::RecordInvalid) { make_message('c', 256).save! } + assert_raise(ActiveRecord::RecordInvalid) { make_message("c", 256).save! } assert_raise(ActiveRecord::RecordInvalid) { make_message(EURO, 256).save! } end @@ -89,7 +89,7 @@ class MessageTest < ActiveSupport::TestCase to "to@example.com" subject "Test message" date Time.now - content_type 'text/plain; charset=utf-8' + content_type "text/plain; charset=utf-8" body "This is a test & a message" end message = Message.from_mail(mail, users(:normal_user), users(:public_user)) @@ -107,7 +107,7 @@ class MessageTest < ActiveSupport::TestCase to "to@example.com" subject "Test message" date Time.now - content_type 'text/html; charset=utf-8' + content_type "text/html; charset=utf-8" body "<p>This is a <b>test</b> & a message</p>" end message = Message.from_mail(mail, users(:normal_user), users(:public_user)) @@ -127,12 +127,12 @@ class MessageTest < ActiveSupport::TestCase date Time.now text_part do - content_type 'text/plain; charset=utf-8' + content_type "text/plain; charset=utf-8" body "This is a test & a message in text format" end html_part do - content_type 'text/html; charset=utf-8' + content_type "text/html; charset=utf-8" body "<p>This is a <b>test</b> & a message in HTML format</p>" end end @@ -151,7 +151,7 @@ class MessageTest < ActiveSupport::TestCase date Time.now html_part do - content_type 'text/html; charset=utf-8' + content_type "text/html; charset=utf-8" body "<p>This is a <b>test</b> & a message in HTML format</p>" end end @@ -170,7 +170,7 @@ class MessageTest < ActiveSupport::TestCase to "to@example.com" subject "[OpenStreetMap] Test message" date Time.now - content_type 'text/plain; charset=utf-8' + content_type "text/plain; charset=utf-8" body "This is a test & a message" end message = Message.from_mail(mail, users(:normal_user), users(:public_user)) diff --git a/test/models/node_tag_test.rb b/test/models/node_tag_test.rb index 49e91844a..d9bce8552 100644 --- a/test/models/node_tag_test.rb +++ b/test/models/node_tag_test.rb @@ -1,4 +1,4 @@ -require 'test_helper' +require "test_helper" class NodeTagTest < ActiveSupport::TestCase api_fixtures diff --git a/test/models/node_test.rb b/test/models/node_test.rb index 247707214..113753d5a 100644 --- a/test/models/node_test.rb +++ b/test/models/node_test.rb @@ -1,4 +1,4 @@ -require 'test_helper' +require "test_helper" class NodeTest < ActiveSupport::TestCase api_fixtures diff --git a/test/models/note_comment_test.rb b/test/models/note_comment_test.rb index 9f10a62de..e61732904 100644 --- a/test/models/note_comment_test.rb +++ b/test/models/note_comment_test.rb @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -require 'test_helper' +require "test_helper" class NoteCommentTest < ActiveSupport::TestCase fixtures :users, :notes, :note_comments diff --git a/test/models/note_test.rb b/test/models/note_test.rb index 1f0cd74e5..4adbef4b8 100644 --- a/test/models/note_test.rb +++ b/test/models/note_test.rb @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -require 'test_helper' +require "test_helper" class NoteTest < ActiveSupport::TestCase fixtures :users, :notes, :note_comments diff --git a/test/models/oauth_nonce_test.rb b/test/models/oauth_nonce_test.rb index 703774ec8..f170bc69d 100644 --- a/test/models/oauth_nonce_test.rb +++ b/test/models/oauth_nonce_test.rb @@ -1,4 +1,4 @@ -require 'test_helper' +require "test_helper" class OauthNonceTest < ActiveSupport::TestCase api_fixtures diff --git a/test/models/oauth_token_test.rb b/test/models/oauth_token_test.rb index 80056d2ea..ac10bf7fe 100644 --- a/test/models/oauth_token_test.rb +++ b/test/models/oauth_token_test.rb @@ -1,4 +1,4 @@ -require 'test_helper' +require "test_helper" class OauthTokenTest < ActiveSupport::TestCase api_fixtures diff --git a/test/models/old_node_tag_test.rb b/test/models/old_node_tag_test.rb index 1e9ee19f7..2ac60ab42 100644 --- a/test/models/old_node_tag_test.rb +++ b/test/models/old_node_tag_test.rb @@ -1,4 +1,4 @@ -require 'test_helper' +require "test_helper" class OldNodeTagTest < ActiveSupport::TestCase api_fixtures diff --git a/test/models/old_node_test.rb b/test/models/old_node_test.rb index 83b9863fc..03aead2e9 100644 --- a/test/models/old_node_test.rb +++ b/test/models/old_node_test.rb @@ -1,4 +1,4 @@ -require 'test_helper' +require "test_helper" class OldNodeTest < ActiveSupport::TestCase api_fixtures diff --git a/test/models/old_relation_tag_test.rb b/test/models/old_relation_tag_test.rb index de5a1008a..e486afa79 100644 --- a/test/models/old_relation_tag_test.rb +++ b/test/models/old_relation_tag_test.rb @@ -1,4 +1,4 @@ -require 'test_helper' +require "test_helper" class OldRelationTagTest < ActiveSupport::TestCase api_fixtures diff --git a/test/models/old_relation_test.rb b/test/models/old_relation_test.rb index 66b93c9bb..c11cdcf72 100644 --- a/test/models/old_relation_test.rb +++ b/test/models/old_relation_test.rb @@ -1,4 +1,4 @@ -require 'test_helper' +require "test_helper" class OldRelationTest < ActiveSupport::TestCase api_fixtures diff --git a/test/models/old_way_tag_test.rb b/test/models/old_way_tag_test.rb index e85cb3497..20e75b37f 100644 --- a/test/models/old_way_tag_test.rb +++ b/test/models/old_way_tag_test.rb @@ -1,4 +1,4 @@ -require 'test_helper' +require "test_helper" class OldWayTagTest < ActiveSupport::TestCase api_fixtures diff --git a/test/models/old_way_test.rb b/test/models/old_way_test.rb index 77dcf92c2..37dfccad3 100644 --- a/test/models/old_way_test.rb +++ b/test/models/old_way_test.rb @@ -1,4 +1,4 @@ -require 'test_helper' +require "test_helper" class OldWayTest < ActiveSupport::TestCase api_fixtures diff --git a/test/models/redaction_test.rb b/test/models/redaction_test.rb index 3d1aecc72..b30c80c66 100644 --- a/test/models/redaction_test.rb +++ b/test/models/redaction_test.rb @@ -1,5 +1,5 @@ -require 'test_helper' -require 'osm' +require "test_helper" +require "osm" class RedactionTest < ActiveSupport::TestCase api_fixtures diff --git a/test/models/relation_member_test.rb b/test/models/relation_member_test.rb index 8ce0fc81f..2c03bc17e 100644 --- a/test/models/relation_member_test.rb +++ b/test/models/relation_member_test.rb @@ -1,4 +1,4 @@ -require 'test_helper' +require "test_helper" class RelationMemberTest < ActiveSupport::TestCase api_fixtures diff --git a/test/models/relation_tag_test.rb b/test/models/relation_tag_test.rb index 9db80f0bf..add453ab0 100644 --- a/test/models/relation_tag_test.rb +++ b/test/models/relation_tag_test.rb @@ -1,4 +1,4 @@ -require 'test_helper' +require "test_helper" class RelationTagTest < ActiveSupport::TestCase api_fixtures diff --git a/test/models/relation_test.rb b/test/models/relation_test.rb index f21a8d029..028cd7d48 100644 --- a/test/models/relation_test.rb +++ b/test/models/relation_test.rb @@ -1,4 +1,4 @@ -require 'test_helper' +require "test_helper" class RelationTest < ActiveSupport::TestCase api_fixtures diff --git a/test/models/trace_test.rb b/test/models/trace_test.rb index 3aaf75e87..8b210ec25 100644 --- a/test/models/trace_test.rb +++ b/test/models/trace_test.rb @@ -1,4 +1,4 @@ -require 'test_helper' +require "test_helper" class TraceTest < ActiveSupport::TestCase api_fixtures @@ -40,11 +40,11 @@ class TraceTest < ActiveSupport::TestCase def test_validations trace_valid({}) trace_valid({ :user_id => nil }, false) - trace_valid(:name => 'a' * 255) - trace_valid({ :name => 'a' * 256 }, false) + trace_valid(:name => "a" * 255) + trace_valid({ :name => "a" * 256 }, false) trace_valid({ :description => nil }, false) - trace_valid(:description => 'a' * 255) - trace_valid({ :description => 'a' * 256 }, false) + trace_valid(:description => "a" * 255) + trace_valid({ :description => "a" * 256 }, false) trace_valid(:visibility => "private") trace_valid(:visibility => "public") trace_valid(:visibility => "trackable") diff --git a/test/models/tracepoint_test.rb b/test/models/tracepoint_test.rb index 0dedb713a..e24a833cf 100644 --- a/test/models/tracepoint_test.rb +++ b/test/models/tracepoint_test.rb @@ -1,4 +1,4 @@ -require 'test_helper' +require "test_helper" class TracepointTest < ActiveSupport::TestCase api_fixtures diff --git a/test/models/tracetag_test.rb b/test/models/tracetag_test.rb index 0ad8cae2f..a13d41e4a 100644 --- a/test/models/tracetag_test.rb +++ b/test/models/tracetag_test.rb @@ -1,4 +1,4 @@ -require 'test_helper' +require "test_helper" class TracetagTest < ActiveSupport::TestCase api_fixtures @@ -10,15 +10,15 @@ class TracetagTest < ActiveSupport::TestCase def test_validations tracetag_valid({}) tracetag_valid({ :tag => nil }, false) - tracetag_valid({ :tag => '' }, false) - tracetag_valid(:tag => 'a') - tracetag_valid(:tag => 'a' * 255) - tracetag_valid({ :tag => 'a' * 256 }, false) - tracetag_valid({ :tag => 'a/b' }, false) - tracetag_valid({ :tag => 'a;b' }, false) - tracetag_valid({ :tag => 'a.b' }, false) - tracetag_valid({ :tag => 'a,b' }, false) - tracetag_valid({ :tag => 'a?b' }, false) + tracetag_valid({ :tag => "" }, false) + tracetag_valid(:tag => "a") + tracetag_valid(:tag => "a" * 255) + tracetag_valid({ :tag => "a" * 256 }, false) + tracetag_valid({ :tag => "a/b" }, false) + tracetag_valid({ :tag => "a;b" }, false) + tracetag_valid({ :tag => "a.b" }, false) + tracetag_valid({ :tag => "a,b" }, false) + tracetag_valid({ :tag => "a?b" }, false) end private diff --git a/test/models/user_preference_test.rb b/test/models/user_preference_test.rb index 8d9d0da4e..da6cd7666 100644 --- a/test/models/user_preference_test.rb +++ b/test/models/user_preference_test.rb @@ -1,4 +1,4 @@ -require 'test_helper' +require "test_helper" class UserPreferenceTest < ActiveSupport::TestCase api_fixtures diff --git a/test/models/user_test.rb b/test/models/user_test.rb index b517fd2af..04aa8ace4 100644 --- a/test/models/user_test.rb +++ b/test/models/user_test.rb @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -require 'test_helper' +require "test_helper" class UserTest < ActiveSupport::TestCase api_fixtures @@ -21,7 +21,7 @@ class UserTest < ActiveSupport::TestCase new_user = User.new( :email => users(:normal_user).email, :status => "active", - :pass_crypt => Digest::MD5.hexdigest('test'), + :pass_crypt => Digest::MD5.hexdigest("test"), :display_name => "new user", :data_public => 1, :description => "desc" @@ -34,7 +34,7 @@ class UserTest < ActiveSupport::TestCase new_user = User.new( :email => "tester@openstreetmap.org", :status => "pending", - :pass_crypt => Digest::MD5.hexdigest('test'), + :pass_crypt => Digest::MD5.hexdigest("test"), :display_name => users(:normal_user).display_name, :data_public => 1, :description => "desc" diff --git a/test/models/user_token_test.rb b/test/models/user_token_test.rb index fb2cc8f74..97a23045b 100644 --- a/test/models/user_token_test.rb +++ b/test/models/user_token_test.rb @@ -1,4 +1,4 @@ -require 'test_helper' +require "test_helper" class UserTokenTest < ActiveSupport::TestCase api_fixtures diff --git a/test/models/way_node_test.rb b/test/models/way_node_test.rb index 174fe0bdd..1e4508c3f 100644 --- a/test/models/way_node_test.rb +++ b/test/models/way_node_test.rb @@ -1,4 +1,4 @@ -require 'test_helper' +require "test_helper" class WayNodeTest < ActiveSupport::TestCase api_fixtures diff --git a/test/models/way_tag_test.rb b/test/models/way_tag_test.rb index 3ac310780..f1f40c73d 100644 --- a/test/models/way_tag_test.rb +++ b/test/models/way_tag_test.rb @@ -1,4 +1,4 @@ -require 'test_helper' +require "test_helper" class WayTagTest < ActiveSupport::TestCase api_fixtures diff --git a/test/models/way_test.rb b/test/models/way_test.rb index fb0a02f57..4fa18f9b8 100644 --- a/test/models/way_test.rb +++ b/test/models/way_test.rb @@ -1,4 +1,4 @@ -require 'test_helper' +require "test_helper" class WayTest < ActiveSupport::TestCase api_fixtures @@ -15,10 +15,10 @@ class WayTest < ActiveSupport::TestCase :invisible_way, :used_way].each do |way_symbol| way = current_ways(way_symbol) - assert_equal node.bbox.min_lon, way.bbox.min_lon, 'min_lon' - assert_equal node.bbox.min_lat, way.bbox.min_lat, 'min_lat' - assert_equal node.bbox.max_lon, way.bbox.max_lon, 'max_lon' - assert_equal node.bbox.max_lat, way.bbox.max_lat, 'max_lat' + assert_equal node.bbox.min_lon, way.bbox.min_lon, "min_lon" + assert_equal node.bbox.min_lat, way.bbox.min_lat, "min_lat" + assert_equal node.bbox.max_lon, way.bbox.max_lon, "max_lon" + assert_equal node.bbox.max_lat, way.bbox.max_lat, "max_lat" end end diff --git a/test/test_helper.rb b/test/test_helper.rb index b1219b765..8f75a7ab0 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -1,7 +1,7 @@ ENV["RAILS_ENV"] = "test" -require File.expand_path('../../config/environment', __FILE__) -require 'rails/test_help' -load 'composite_primary_keys/fixtures.rb' +require File.expand_path("../../config/environment", __FILE__) +require "rails/test_help" +load "composite_primary_keys/fixtures.rb" module ActiveSupport class TestCase @@ -130,7 +130,7 @@ module ActiveSupport # when the owner of the changset has their data not marked as public def assert_require_public_data(msg = "Shouldn't be able to use API when the user's data is not public") assert_response :forbidden, msg - assert_equal @response.headers['Error'], "You must make your edits public to upload new data", "Wrong error message" + assert_equal @response.headers["Error"], "You must make your edits public to upload new data", "Wrong error message" end # Not sure this is the best response we could give @@ -172,7 +172,7 @@ module ActiveSupport def openid_request(openid_request_uri) openid_response = Net::HTTP.get_response(URI.parse(openid_request_uri)) - openid_response_uri = URI(openid_response['Location']) + openid_response_uri = URI(openid_response["Location"]) openid_response_qs = Rack::Utils.parse_query(openid_response_uri.query) openid_response_qs