Rails:
Enabled: true
+Layout/ExtraSpacing:
+ AllowForAlignment: true
+
Style/BracesAroundHashParameters:
EnforcedStyle: context_dependent
-Style/ExtraSpacing:
- AllowForAlignment: true
-
Style/FileName:
Exclude:
- 'script/deliver-message'
- 'script/locale/reload-languages'
- 'script/update-spam-blocks'
+Style/FormatStringToken:
+ EnforcedStyle: template
+
Style/IfInsideElse:
Enabled: false
Style/StringLiterals:
EnforcedStyle: double_quotes
+Style/SymbolArray:
+ EnforcedStyle: brackets
+
+Rails/ApplicationRecord:
+ Enabled: false
+
Rails/HttpPositionalArguments:
Enabled: false
def map_layout
append_content_security_policy_directives(
- :connect_src => %w(nominatim.openstreetmap.org overpass-api.de router.project-osrm.org valhalla.mapzen.com),
- :script_src => %w(graphhopper.com open.mapquestapi.com),
- :img_src => %w(developer.mapquest.com)
+ :connect_src => %w[nominatim.openstreetmap.org overpass-api.de router.project-osrm.org valhalla.mapzen.com],
+ :script_src => %w[graphhopper.com open.mapquestapi.com],
+ :img_src => %w[developer.mapquest.com]
)
if STATUS == :database_offline || STATUS == :api_offline
return
end
else
- @entries = DiaryEntry.joins(:user).where(:users => { :status => %w(active confirmed) })
+ @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
return
end
else
- @entries = DiaryEntry.joins(:user).where(:users => { :status => %w(active confirmed) })
+ @entries = DiaryEntry.joins(:user).where(:users => { :status => %w[active confirmed] })
if params[:language]
@entries = @entries.where(:language_code => params[:language])
else
@token.oob? ? @token.client_application.callback_url : @token.callback_url
end
- @redirect_url = URI.parse(callback_url) unless callback_url.blank?
+ @redirect_url = URI.parse(callback_url) if callback_url.present?
if @redirect_url.to_s.blank?
render :action => "authorize_success"
require_user
end
- if editor == "potlatch" || editor == "potlatch2"
+ if %w[potlatch potlatch2].include?(editor)
append_content_security_policy_directives(
- :object_src => %w(*),
- :plugin_types => %w(application/x-shockwave-flash),
- :script_src => %w('unsafe-inline')
+ :object_src => %w[*],
+ :plugin_types => %w[application/x-shockwave-flash],
+ :script_src => %w['unsafe-inline']
)
end
def id
append_content_security_policy_directives(
- :connect_src => %w(taginfo.openstreetmap.org *.mapillary.com),
- :img_src => %w(*),
- :script_src => %w(dev.virtualearth.net)
+ :connect_src => %w[taginfo.openstreetmap.org *.mapillary.com],
+ :img_src => %w[*],
+ :script_src => %w[dev.virtualearth.net]
)
render "id", :layout => false
def list
# from display name, pick up user id if one user's traces only
display_name = params[:display_name]
- unless display_name.blank?
+ if display_name.present?
target_user = User.active.where(:display_name => display_name).first
if target_user.nil?
render_unknown_user display_name
@user.terms_agreed = Time.now.getutc
@user.terms_seen = true
- if @user.auth_uid.nil? || @user.auth_uid.empty?
+ if @user.auth_uid.blank?
@user.auth_provider = nil
@user.auth_uid = nil
end
private
- ICON_TAGS = %w(aeroway amenity barrier building highway historic landuse leisure man_made natural railway shop tourism waterway).freeze
+ ICON_TAGS = %w[aeroway amenity barrier building highway historic landuse leisure man_made natural railway shop tourism waterway].freeze
def icon_tags(object)
object.tags.find_all { |k, _v| ICON_TAGS.include? k }.sort
# this is the set of permissions that the client can ask for. clients
# have to say up-front what permissions they want and when users sign up they
# can agree or not agree to each of them.
- PERMISSIONS = [:allow_read_prefs, :allow_write_prefs, :allow_write_diary,
- :allow_write_api, :allow_read_gpx, :allow_write_gpx,
- :allow_write_notes].freeze
+ PERMISSIONS = [:allow_read_prefs, :allow_write_prefs, :allow_write_diary, :allow_write_api, :allow_read_gpx, :allow_write_gpx, :allow_write_notes].freeze
def generate_keys
self.key = OAuth::Helper.generate_key(40)[0, 40]
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"
+ has_many :visible_comments, -> { joins(:user).where(:visible => true, :users => { :status => %w[active confirmed] }).order(:id) }, :class_name => "DiaryComment"
has_many :subscriptions, :class_name => "DiaryEntrySubscription"
has_many :subscribers, :through => :subscriptions, :source => :user
:numericality => { :on => :update, :integer_only => true }
validates :latitude, :longitude, :numericality => { :only_integer => true }
validates :closed_at, :presence => true, :if => proc { :status == "closed" }
- validates :status, :inclusion => %w(open closed hidden)
+ validates :status, :inclusion => %w[open closed hidden]
validate :validate_position
validates :note, :presence => true, :associated => true
validates :visible, :inclusion => [true, false]
validates :author, :associated => true
- validates :event, :inclusion => %w(opened closed reopened commented hidden)
+ validates :event, :inclusion => %w[opened closed reopened commented hidden]
validates :body, :format => /\A[^\x00-\x08\x0b-\x0c\x0e-\x1f\x7f\ufffe\uffff]*\z/
# Return the comment text
has_many :old_relations
validates :description, :presence => true
- validates :description_format, :inclusion => { :in => %w(text html markdown) }
+ validates :description_format, :inclusion => { :in => %w[text html markdown] }
# this method overrides the AR default to provide the rich
# text object for the description field.
scope :ways, ->(*ids) { joins(:relation_members).where(:current_relation_members => { :member_type => "Way", :member_id => ids.flatten }) }
scope :relations, ->(*ids) { joins(:relation_members).where(:current_relation_members => { :member_type => "Relation", :member_id => ids.flatten }) }
- TYPES = %w(node way relation).freeze
+ TYPES = %w[node way relation].freeze
def self.from_xml(xml, create = false)
p = XML::Parser.string(xml, :options => XML::Parser::Options::NOERROR)
scope :visible, -> { where(:visible => true) }
scope :visible_to, ->(u) { visible.where("visibility IN ('public', 'identifiable') OR user_id = ?", u) }
- scope :visible_to_all, -> { where(:visibility => %w(public identifiable)) }
+ scope :visible_to_all, -> { where(:visibility => %w[public identifiable]) }
scope :tagged, ->(t) { joins(:tags).where(:gpx_file_tags => { :tag => t }) }
validates :user, :presence => true, :associated => true
validates :name, :presence => true, :length => 1..255
validates :description, :presence => { :on => :create }, :length => 1..255
validates :timestamp, :presence => true
- validates :visibility, :inclusion => %w(private public trackable identifiable)
+ validates :visibility, :inclusion => %w[private public trackable identifiable]
def destroy
super
def tagstring=(s)
self.tags = if s.include? ","
- s.split(/\s*,\s*/).select { |tag| tag !~ /^\s*$/ }.collect do |tag|
+ s.split(/\s*,\s*/).reject { |tag| tag =~ /^\s*$/ }.collect do |tag|
tt = Tracetag.new
tt.tag = tag
tt
has_many :messages, -> { where(:to_user_visible => true).order(:sent_on => :desc).preload(:sender, :recipient) }, :foreign_key => :to_user_id
has_many :new_messages, -> { where(:to_user_visible => true, :message_read => false).order(:sent_on => :desc) }, :class_name => "Message", :foreign_key => :to_user_id
has_many :sent_messages, -> { where(:from_user_visible => true).order(:sent_on => :desc).preload(:sender, :recipient) }, :class_name => "Message", :foreign_key => :from_user_id
- has_many :friends, -> { joins(:befriendee).where(:users => { :status => %w(active confirmed) }) }
+ has_many :friends, -> { joins(:befriendee).where(:users => { :status => %w[active confirmed] }) }
has_many :friend_users, :through => :friends, :source => :befriendee
has_many :tokens, :class_name => "UserToken"
has_many :preferences, :class_name => "UserPreference"
has_many :roles, :class_name => "UserRole"
- scope :visible, -> { where(:status => %w(pending active confirmed)) }
- scope :active, -> { where(:status => %w(active confirmed)) }
+ scope :visible, -> { where(:status => %w[pending active confirmed]) }
+ scope :active, -> { where(:status => %w[active confirmed]) }
scope :identifiable, -> { where(:data_public => true) }
has_attached_file :image,
:styles => { :large => "100x100>", :small => "50x50>" }
validates :display_name, :presence => true, :allow_nil => true, :length => 3..255,
- :exclusion => %w(new terms save confirm confirm-email go_public reset-password forgot-password suspended)
+ :exclusion => %w[new terms save confirm confirm-email go_public reset-password forgot-password suspended]
validates :display_name, :if => proc { |u| u.display_name_changed? },
:uniqueness => { :case_sensitive => false }
validates :display_name, :if => proc { |u| u.display_name_changed? },
##
# returns true if a user is visible
def visible?
- %w(pending active confirmed).include? status
+ %w[pending active confirmed].include? status
end
##
# returns true if a user is active
def active?
- %w(active confirmed).include? status
+ %w[active confirmed].include? status
end
##
belongs_to :user
belongs_to :granter, :class_name => "User"
- ALL_ROLES = %w(administrator moderator).freeze
+ ALL_ROLES = %w[administrator moderator].freeze
validates :role, :inclusion => ALL_ROLES, :uniqueness => { :scope => :user_id }
end
config.active_record.raise_in_transactional_callbacks = true unless STATUS == :database_offline
# Custom directories with classes and modules you want to be autoloadable.
- config.autoload_paths += %W(#{config.root}/lib)
+ config.autoload_paths += %W[#{config.root}/lib]
# Use SQL instead of Active Record's schema dumper when creating the database.
# This is necessary if your schema can't be completely dumped by the schema dumper,
# Precompile additional assets.
# application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
-Rails.application.config.assets.precompile += %w(index.js browse.js welcome.js fixthemap.js)
-Rails.application.config.assets.precompile += %w(user.js login.js diary_entry.js edit/*.js)
-Rails.application.config.assets.precompile += %w(screen-ltr.css print-ltr.css)
-Rails.application.config.assets.precompile += %w(screen-rtl.css print-rtl.css)
-Rails.application.config.assets.precompile += %w(leaflet-all.css leaflet.ie.css)
-Rails.application.config.assets.precompile += %w(id.js id.css)
-Rails.application.config.assets.precompile += %w(embed.js embed.css)
-Rails.application.config.assets.precompile += %w(html5shiv.js)
-Rails.application.config.assets.precompile += %w(images/marker-*.png img/*-handle.png)
-Rails.application.config.assets.precompile += %w(swfobject.js expressInstall.swf)
-Rails.application.config.assets.precompile += %w(potlatch2.swf)
-Rails.application.config.assets.precompile += %w(potlatch2/assets.zip)
-Rails.application.config.assets.precompile += %w(potlatch2/FontLibrary.swf)
-Rails.application.config.assets.precompile += %w(potlatch2/locales/*.swf)
-Rails.application.config.assets.precompile += %w(help/introduction.*)
-Rails.application.config.assets.precompile += %w(iD/img/*.svg iD/img/*.png iD/img/*.gif)
-Rails.application.config.assets.precompile += %w(iD/img/pattern/*.png)
-Rails.application.config.assets.precompile += %w(iD/locales/*.json)
-Rails.application.config.assets.precompile += %w(iD/traffico/stylesheets/traffico.css)
-Rails.application.config.assets.precompile += %w(iD/traffico/fonts/traffico_*)
-Rails.application.config.assets.precompile += %w(iD/traffico/string-maps/*.json)
+Rails.application.config.assets.precompile += %w[index.js browse.js welcome.js fixthemap.js]
+Rails.application.config.assets.precompile += %w[user.js login.js diary_entry.js edit/*.js]
+Rails.application.config.assets.precompile += %w[screen-ltr.css print-ltr.css]
+Rails.application.config.assets.precompile += %w[screen-rtl.css print-rtl.css]
+Rails.application.config.assets.precompile += %w[leaflet-all.css leaflet.ie.css]
+Rails.application.config.assets.precompile += %w[id.js id.css]
+Rails.application.config.assets.precompile += %w[embed.js embed.css]
+Rails.application.config.assets.precompile += %w[html5shiv.js]
+Rails.application.config.assets.precompile += %w[images/marker-*.png img/*-handle.png]
+Rails.application.config.assets.precompile += %w[swfobject.js expressInstall.swf]
+Rails.application.config.assets.precompile += %w[potlatch2.swf]
+Rails.application.config.assets.precompile += %w[potlatch2/assets.zip]
+Rails.application.config.assets.precompile += %w[potlatch2/FontLibrary.swf]
+Rails.application.config.assets.precompile += %w[potlatch2/locales/*.swf]
+Rails.application.config.assets.precompile += %w[help/introduction.*]
+Rails.application.config.assets.precompile += %w[iD/img/*.svg iD/img/*.png iD/img/*.gif]
+Rails.application.config.assets.precompile += %w[iD/img/pattern/*.png]
+Rails.application.config.assets.precompile += %w[iD/locales/*.json]
+Rails.application.config.assets.precompile += %w[iD/traffico/stylesheets/traffico.css]
+Rails.application.config.assets.precompile += %w[iD/traffico/fonts/traffico_*]
+Rails.application.config.assets.precompile += %w[iD/traffico/string-maps/*.json]
Sanitize::Config::OSM = Sanitize::Config::RELAXED.dup
-Sanitize::Config::OSM[:elements] -= %w(div style)
+Sanitize::Config::OSM[:elements] -= %w[div style]
Sanitize::Config::OSM[:add_attributes] = { "a" => { "rel" => "nofollow" } }
-Sanitize::Config::OSM[:remove_contents] = %w(script style)
+Sanitize::Config::OSM[:remove_contents] = %w[script style]
if defined?(CSP_REPORT_URL)
policy = {
- :default_src => %w('self'),
- :child_src => %w('self'),
- :connect_src => %w('self'),
- :font_src => %w('none'),
- :form_action => %w('self'),
- :frame_ancestors => %w('self'),
- :img_src => %w('self' data: www.gravatar.com *.wp.com *.tile.openstreetmap.org *.tile.thunderforest.com *.openstreetmap.fr),
- :media_src => %w('none'),
- :object_src => %w('self'),
- :plugin_types => %w('none'),
- :script_src => %w('self'),
- :style_src => %w('self' 'unsafe-inline'),
+ :default_src => %w['self'],
+ :child_src => %w['self'],
+ :connect_src => %w['self'],
+ :font_src => %w['none'],
+ :form_action => %w['self'],
+ :frame_ancestors => %w['self'],
+ :img_src => %w['self' data: www.gravatar.com *.wp.com *.tile.openstreetmap.org *.tile.thunderforest.com *.openstreetmap.fr],
+ :media_src => %w['none'],
+ :object_src => %w['self'],
+ :plugin_types => %w['none'],
+ :script_src => %w['self'],
+ :style_src => %w['self' 'unsafe-inline'],
:report_uri => [CSP_REPORT_URL]
}
end
add_index "current_nodes", ["id"], :name => "current_nodes_id_idx"
- add_index "current_nodes", %w(latitude longitude), :name => "current_nodes_lat_lon_idx"
+ add_index "current_nodes", %w[latitude longitude], :name => "current_nodes_lat_lon_idx"
add_index "current_nodes", ["timestamp"], :name => "current_nodes_timestamp_idx"
create_table "current_segments", :id => false do |t|
t.column "timestamp", :datetime
end
- add_index "current_segments", %w(id visible), :name => "current_segments_id_visible_idx"
+ add_index "current_segments", %w[id visible], :name => "current_segments_id_visible_idx"
add_index "current_segments", ["node_a"], :name => "current_segments_a_idx"
add_index "current_segments", ["node_b"], :name => "current_segments_b_idx"
t.column "timestamp", :datetime
end
- add_index "gps_points", %w(latitude longitude user_id), :name => "points_idx"
+ add_index "gps_points", %w[latitude longitude user_id], :name => "points_idx"
add_index "gps_points", ["user_id"], :name => "points_uid_idx"
add_index "gps_points", ["gpx_id"], :name => "points_gpxid_idx"
end
add_index "gpx_files", ["timestamp"], :name => "gpx_files_timestamp_idx"
- add_index "gpx_files", %w(visible public), :name => "gpx_files_visible_public_idx"
+ add_index "gpx_files", %w[visible public], :name => "gpx_files_visible_public_idx"
create_table "gpx_pending_files", :id => false do |t|
t.column "originalname", :string
end
add_index "nodes", ["id"], :name => "nodes_uid_idx"
- add_index "nodes", %w(latitude longitude), :name => "nodes_latlon_idx"
+ add_index "nodes", %w[latitude longitude], :name => "nodes_latlon_idx"
create_table "segments", :id => false do |t|
t.column "id", :bigint
t.column "sequence_id", :bigint, :null => false
end
- add_primary_key "way_segments", %w(id version sequence_id)
+ add_primary_key "way_segments", %w[id version sequence_id]
create_table "way_tags", :id => false do |t|
t.column "id", :bigint, :default => 0, :null => false
t.column "version", :bigint
end
- add_index "way_tags", %w(id version), :name => "way_tags_id_version_idx"
+ add_index "way_tags", %w[id version], :name => "way_tags_id_version_idx"
create_table "ways", :id => false do |t|
t.column "id", :bigint, :default => 0, :null => false
t.column "visible", :boolean, :default => true
end
- add_primary_key "ways", %w(id version)
+ add_primary_key "ways", %w[id version]
add_index "ways", ["id"], :name => "ways_id_version_idx"
end
change_column "current_way_segments", "id", :bigint, :null => false
change_column "current_way_segments", "segment_id", :bigint, :null => false
change_column "current_way_segments", "sequence_id", :bigint, :null => false
- add_primary_key "current_way_segments", %w(id sequence_id)
+ add_primary_key "current_way_segments", %w[id sequence_id]
remove_index "current_way_segments", :name => "current_way_segments_id_idx"
change_column "current_way_tags", "id", :bigint, :null => false
remove_index "gps_points", :name => "points_uid_idx"
remove_index "gps_points", :name => "points_idx"
remove_column "gps_points", "user_id"
- add_index "gps_points", %w(latitude longitude), :name => "points_idx"
+ add_index "gps_points", %w[latitude longitude], :name => "points_idx"
change_column "gps_points", "trackid", :integer, :null => false
change_column "gps_points", "latitude", :integer, :null => false
change_column "gps_points", "longitude", :integer, :null => false
change_column "current_way_segments", "segment_id", :bigint
change_column "current_way_segments", "id", :bigint
- add_index "current_segments", %w(id visible), :name => "current_segments_id_visible_idx"
+ add_index "current_segments", %w[id visible], :name => "current_segments_id_visible_idx"
remove_primary_key "current_segments"
change_column "current_segments", "timestamp", :datetime
change_column "current_segments", "visible", :boolean
t.column "v", :string, :null => false
end
- add_primary_key "user_preferences", %w(user_id k)
+ add_primary_key "user_preferences", %w[user_id k]
create_table "user_tokens", :id => false do |t|
t.column "id", :bigserial, :primary_key => true, :null => false
def self.down
Tracepoint.update_all("latitude = latitude / 10, longitude = longitude / 10")
- add_index "gps_points", %w(latitude longitude), :name => "points_idx"
+ add_index "gps_points", %w[latitude longitude], :name => "points_idx"
remove_index "gps_points", :name => "points_tile_idx"
remove_column "gps_points", "tile"
end
t.column "timestamp", :datetime, :null => false
end
- add_index "current_nodes", %w(latitude longitude), :name => "current_nodes_lat_lon_idx"
+ add_index "current_nodes", %w[latitude longitude], :name => "current_nodes_lat_lon_idx"
add_index "current_nodes", ["timestamp"], :name => "current_nodes_timestamp_idx"
downgrade_table "current_nodes_v6", "current_nodes"
end
add_index "nodes", ["id"], :name => "nodes_uid_idx"
- add_index "nodes", %w(latitude longitude), :name => "nodes_latlon_idx"
+ add_index "nodes", %w[latitude longitude], :name => "nodes_latlon_idx"
add_index "nodes", ["timestamp"], :name => "nodes_timestamp_idx"
downgrade_table "nodes_v6", "nodes"
class AddRelations < ActiveRecord::Migration
def self.up
# enums work like strings but are more efficient
- create_enumeration :nwr_enum, %w(Node Way Relation)
+ create_enumeration :nwr_enum, %w[Node Way Relation]
# a relation can have members much like a way can have nodes.
# differences:
t.column "member_role", :string
end
- add_primary_key "current_relation_members", %w(id member_type member_id member_role)
- add_index "current_relation_members", %w(member_type member_id), :name => "current_relation_members_member_idx"
+ add_primary_key "current_relation_members", %w[id member_type member_id member_role]
+ add_index "current_relation_members", %w[member_type member_id], :name => "current_relation_members_member_idx"
# the following is obsolete given the primary key, is it not?
# add_index "current_relation_members", ["id"], :name => "current_relation_members_id_idx"
create_table "current_relation_tags", :id => false do |t|
t.column "version", :bigint, :default => 0, :null => false
end
- add_primary_key "relation_members", %w(id version member_type member_id member_role)
- add_index "relation_members", %w(member_type member_id), :name => "relation_members_member_idx"
+ add_primary_key "relation_members", %w[id version member_type member_id member_role]
+ add_index "relation_members", %w[member_type member_id], :name => "relation_members_member_idx"
create_table "relation_tags", :id => false do |t|
t.column "id", :bigint, :default => 0, :null => false
t.column "version", :bigint, :null => false
end
- add_index "relation_tags", %w(id version), :name => "relation_tags_id_version_idx"
+ add_index "relation_tags", %w[id version], :name => "relation_tags_id_version_idx"
create_table "relations", :id => false do |t|
t.column "id", :bigint, :null => false, :default => 0
t.column "visible", :boolean, :null => false, :default => true
end
- add_primary_key "relations", %w(id version)
+ add_primary_key "relations", %w[id version]
add_index "relations", ["timestamp"], :name => "relations_timestamp_idx"
end
args = conn_opts.map(&:to_s) + [prefix]
raise "#{cmd} failed" unless system cmd, *args
- tempfiles = %w(ways way_nodes way_tags relations relation_members relation_tags)
+ tempfiles = %w[ways way_nodes way_tags relations relation_members relation_tags]
.map { |base| prefix + base }
ways, way_nodes, way_tags,
relations, relation_members, relation_tags = tempfiles
t.column "updated_at", :datetime, :null => false
end
- add_index "diary_comments", %w(diary_entry_id id), :name => "diary_comments_entry_id_idx", :unique => true
+ add_index "diary_comments", %w[diary_entry_id id], :name => "diary_comments_entry_id_idx", :unique => true
end
def self.down
args = conn_opts.map(&:to_s) + [prefix]
raise "#{cmd} failed" unless system cmd, *args
- tempfiles = %w(nodes node_tags current_nodes current_node_tags)
+ tempfiles = %w[nodes node_tags current_nodes current_node_tags]
.map { |base| prefix + base }
nodes, node_tags, current_nodes, current_node_tags = tempfiles
end
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)
+ @conv_tables = %w[nodes ways way_tags way_nodes current_way_tags relation_members relations relation_tags current_relation_tags]
- @ver_tbl = %w(nodes ways relations)
+ @ver_tbl = %w[nodes ways relations]
def self.up
remove_index :current_way_tags, :name => :current_way_tags_v_idx
require "migrate"
class AddChangesets < ActiveRecord::Migration
- @conv_user_tables = %w(current_nodes current_relations current_ways nodes relations ways)
+ @conv_user_tables = %w[current_nodes current_relations current_ways nodes relations ways]
def self.up
create_table "changesets", :id => false do |t|
def self.up
add_index "changesets", ["created_at"], :name => "changesets_created_at_idx"
add_index "changesets", ["closed_at"], :name => "changesets_closed_at_idx"
- add_index "changesets", %w(min_lat max_lat min_lon max_lon), :name => "changesets_bbox_idx", :using => "GIST"
+ add_index "changesets", %w[min_lat max_lat min_lon max_lon], :name => "changesets_bbox_idx", :using => "GIST"
end
def self.down
class AddMoreControlsToGpxFiles < ActiveRecord::Migration
def self.up
- create_enumeration :gpx_visibility_enum, %w(private public trackable identifiable)
+ create_enumeration :gpx_visibility_enum, %w[private public trackable identifiable]
add_column :gpx_files, :visibility, :gpx_visibility_enum, :default => "public", :null => false
Trace.where(:public => false).update_all(:visibility => "private")
add_index :gpx_files, [:visible, :visibility], :name => "gpx_files_visible_visibility_idx"
class AddFineOAuthPermissions < ActiveRecord::Migration
- PERMISSIONS = [:allow_read_prefs, :allow_write_prefs, :allow_write_diary,
- :allow_write_api, :allow_read_gpx, :allow_write_gpx].freeze
+ PERMISSIONS = [:allow_read_prefs, :allow_write_prefs, :allow_write_diary, :allow_write_api, :allow_read_gpx, :allow_write_gpx].freeze
def self.up
PERMISSIONS.each do |perm|
class CreateUserRoles < ActiveRecord::Migration
def self.up
- create_enumeration :user_role_enum, %w(administrator moderator)
+ create_enumeration :user_role_enum, %w[administrator moderator]
create_table :user_roles do |t|
t.column :user_id, :bigint, :null => false
class AddStatusToUser < ActiveRecord::Migration
def self.up
- create_enumeration :user_status_enum, %w(pending active confirmed suspended deleted)
+ create_enumeration :user_status_enum, %w[pending active confirmed suspended deleted]
add_column :users, :status, :user_status_enum, :null => false, :default => "pending"
class AddMapBugTables < ActiveRecord::Migration
def self.up
- create_enumeration :map_bug_status_enum, %w(open closed hidden)
+ create_enumeration :map_bug_status_enum, %w[open closed hidden]
create_table :map_bugs do |t|
t.integer :latitude, :null => false
class AddMapBugCommentEvent < ActiveRecord::Migration
def self.up
- create_enumeration :map_bug_event_enum, %w(opened closed reopened commented hidden)
+ create_enumeration :map_bug_event_enum, %w[opened closed reopened commented hidden]
add_column :map_bug_comment, :event, :map_bug_event_enum
end
class AddTextFormat < ActiveRecord::Migration
def up
- create_enumeration :format_enum, %w(html markdown text)
+ create_enumeration :format_enum, %w[html markdown text]
add_column :users, :description_format, :format_enum, :null => false, :default => "html"
add_column :user_blocks, :reason_format, :format_enum, :null => false, :default => "html"
add_column :diary_entries, :body_format, :format_enum, :null => false, :default => "html"
module Editors
- ALL_EDITORS = %w(potlatch potlatch2 id remote).freeze
- RECOMMENDED_EDITORS = %w(id potlatch2 remote).freeze
+ ALL_EDITORS = %w[potlatch potlatch2 id remote].freeze
+ RECOMMENDED_EDITORS = %w[id potlatch2 remote].freeze
end
begin
ActiveRecord::Base.transaction do
- user_count = User.where(:status => %w(active confirmed suspended)).count
+ user_count = User.where(:status => %w[active confirmed suspended]).count
tracepoint_count = Tracepoint.count
node_count = Node.where(:visible => true).count
way_count = Way.where(:visible => true).count
addresses = User.count(
:conditions => {
- :status => %w(suspended deleted),
+ :status => %w[suspended deleted],
:creation_time => Time.now - 28.days..Time.now
},
:group => :creation_ip
end
def test_getpresets
- user_en_de = create(:user, :languages => %w(en de))
- user_de = create(:user, :languages => %w(de))
+ user_en_de = create(:user, :languages => %w[en de])
+ user_de = create(:user, :languages => %w[de])
[user_en_de, user_de].each do |user|
amf_content "getpresets", "/1", ["#{user.email}:test", ""]
post :amf_read
class ApiControllerTest < ActionController::TestCase
def setup
super
- @badbigbbox = %w(-0.1,-0.1,1.1,1.1 10,10,11,11)
- @badmalformedbbox = %w(-0.1 hello
- 10N2W10.1N2.1W)
- @badlatmixedbbox = %w(0,0.1,0.1,0 -0.1,80,0.1,70 0.24,54.34,0.25,54.33)
- @badlonmixedbbox = %w(80,-0.1,70,0.1 54.34,0.24,54.33,0.25)
+ @badbigbbox = %w[-0.1,-0.1,1.1,1.1 10,10,11,11]
+ @badmalformedbbox = %w[-0.1 hello
+ 10N2W10.1N2.1W]
+ @badlatmixedbbox = %w[0,0.1,0.1,0 -0.1,80,0.1,70 0.24,54.34,0.25,54.33]
+ @badlonmixedbbox = %w[80,-0.1,70,0.1 54.34,0.24,54.33,0.25]
# @badlatlonoutboundsbbox = %w{ 191,-0.1,193,0.1 -190.1,89.9,-190,90 }
- @goodbbox = %w(-0.1,-0.1,0.1,0.1 51.1,-0.1,51.2,0
- -0.1,%20-0.1,%200.1,%200.1 -0.1edcd,-0.1d,0.1,0.1 -0.1E,-0.1E,0.1S,0.1N S0.1,W0.1,N0.1,E0.1)
+ @goodbbox = %w[-0.1,-0.1,0.1,0.1 51.1,-0.1,51.2,0
+ -0.1,%20-0.1,%200.1,%200.1 -0.1edcd,-0.1d,0.1,0.1 -0.1E,-0.1E,0.1S,0.1N S0.1,W0.1,N0.1,E0.1]
# That last item in the goodbbox really shouldn't be there, as the API should
# reall reject it, however this is to test to see if the api changes.
end
end
def test_map_without_bbox
- %w(trackpoints map).each do |tq|
+ %w[trackpoints map].each do |tq|
get tq
assert_response :bad_request
assert_equal "The parameter bbox is required, and must be of the form min_lon,min_lat,max_lon,max_lat", @response.body, "A bbox param was expected"
def test_bbox_too_big
@badbigbbox.each do |bbox|
- %w(trackpoints map).each do |tq|
+ %w[trackpoints map].each do |tq|
get tq, :bbox => bbox
assert_response :bad_request, "The bbox:#{bbox} was expected to be too big"
assert_equal "The maximum bbox size is #{MAX_REQUEST_AREA}, and your request was too large. Either request a smaller area, or use planet.osm", @response.body, "bbox: #{bbox}"
def test_bbox_malformed
@badmalformedbbox.each do |bbox|
- %w(trackpoints map).each do |tq|
+ %w[trackpoints map].each do |tq|
get tq, :bbox => bbox
assert_response :bad_request, "The bbox:#{bbox} was expected to be malformed"
assert_equal "The parameter bbox is required, and must be of the form min_lon,min_lat,max_lon,max_lat", @response.body, "bbox: #{bbox}"
def test_bbox_lon_mixedup
@badlonmixedbbox.each do |bbox|
- %w(trackpoints map).each do |tq|
+ %w[trackpoints map].each do |tq|
get tq, :bbox => bbox
assert_response :bad_request, "The bbox:#{bbox} was expected to have the longitude mixed up"
assert_equal "The minimum longitude must be less than the maximum longitude, but it wasn't", @response.body, "bbox: #{bbox}"
def test_bbox_lat_mixedup
@badlatmixedbbox.each do |bbox|
- %w(trackpoints map).each do |tq|
+ %w[trackpoints map].each do |tq|
get tq, :bbox => bbox
assert_response :bad_request, "The bbox:#{bbox} was expected to have the latitude mixed up"
assert_equal "The minimum latitude must be less than the maximum latitude, but it wasn't", @response.body, "bbox: #{bbox}"
end
def test_changes_zoom_invalid
- zoom_to_test = %w(p -1 0 17 one two)
+ zoom_to_test = %w[p -1 0 17 one two]
zoom_to_test.each do |zoom|
get :changes, :zoom => zoom
assert_response :bad_request
end
def test_changes_hours_invalid
- invalid = %w(-21 335 -1 0 25 26 100 one two three ping pong :)
+ invalid = %w[-21 335 -1 0 25 26 100 one two three ping pong :]
invalid.each do |hour|
get :changes, :hours => hour
assert_response :bad_request, "Problem with the hour: #{hour}"
# simple diff to change a node, way and relation by removing
# their tags
- diff = <<EOF
-<osmChange>
- <modify>
- <node id='#{node.id}' lon='0' lat='0' changeset='#{changeset_id}' version='1'/>
- <way id='#{way.id}' changeset='#{changeset_id}' version='1'>
- <nd ref='#{node.id}'/>
- </way>
- </modify>
- <modify>
- <relation id='#{relation.id}' changeset='#{changeset_id}' version='1'>
- <member type='way' role='some' ref='#{way.id}'/>
- <member type='node' role='some' ref='#{node.id}'/>
- <member type='relation' role='some' ref='#{other_relation.id}'/>
- </relation>
- </modify>
-</osmChange>
+ diff = <<EOF.strip_heredoc
+ <osmChange>
+ <modify>
+ <node id='#{node.id}' lon='0' lat='0' changeset='#{changeset_id}' version='1'/>
+ <way id='#{way.id}' changeset='#{changeset_id}' version='1'>
+ <nd ref='#{node.id}'/>
+ </way>
+ </modify>
+ <modify>
+ <relation id='#{relation.id}' changeset='#{changeset_id}' version='1'>
+ <member type='way' role='some' ref='#{way.id}'/>
+ <member type='node' role='some' ref='#{node.id}'/>
+ <member type='relation' role='some' ref='#{other_relation.id}'/>
+ </relation>
+ </modify>
+ </osmChange>
EOF
# upload it
# simple diff to change a node, way and relation by removing
# their tags
- diff = <<EOF
-<osmChange>
- <modify>
- <node id='#{node.id}' lon='0' lat='0' changeset='#{changeset_id}' version='1'/>
- <way id='#{way.id}' changeset='#{changeset_id}' version='1'>
- <nd ref='#{node.id}'/>
- </way>
- </modify>
- <modify>
- <relation id='#{relation.id}' changeset='#{changeset_id}' version='1'>
- <member type='way' role='some' ref='#{way.id}'/>
- <member type='node' role='some' ref='#{node.id}'/>
- <member type='relation' role='some' ref='#{other_relation.id}'/>
- </relation>
- </modify>
-</osmChange>
+ diff = <<EOF.strip_heredoc
+ <osmChange>
+ <modify>
+ <node id='#{node.id}' lon='0' lat='0' changeset='#{changeset_id}' version='1'/>
+ <way id='#{way.id}' changeset='#{changeset_id}' version='1'>
+ <nd ref='#{node.id}'/>
+ </way>
+ </modify>
+ <modify>
+ <relation id='#{relation.id}' changeset='#{changeset_id}' version='1'>
+ <member type='way' role='some' ref='#{way.id}'/>
+ <member type='node' role='some' ref='#{node.id}'/>
+ <member type='relation' role='some' ref='#{other_relation.id}'/>
+ </relation>
+ </modify>
+ </osmChange>
EOF
# upload it
# simple diff to change a node, way and relation by removing
# their tags
- diff = <<EOF
-<osmChange>
- <modify>
- <node id='#{node.id}' lon='0' lat='0' changeset='#{changeset_id}' version='1'/>
- <way id='#{way.id}' changeset='#{changeset_id}' version='1'>
- <nd ref='#{node.id}'/>
- </way>
- </modify>
- <modify>
- <relation id='#{relation.id}' changeset='#{changeset_id}' version='1'>
- <member type='way' role='some' ref='#{way.id}'/>
- <member type='node' role='some' ref='#{node.id}'/>
- <member type='relation' role='some' ref='#{other_relation.id}'/>
- </relation>
- </modify>
-</osmChange>
+ diff = <<EOF.strip_heredoc
+ <osmChange>
+ <modify>
+ <node id='#{node.id}' lon='0' lat='0' changeset='#{changeset_id}' version='1'/>
+ <way id='#{way.id}' changeset='#{changeset_id}' version='1'>
+ <nd ref='#{node.id}'/>
+ </way>
+ </modify>
+ <modify>
+ <relation id='#{relation.id}' changeset='#{changeset_id}' version='1'>
+ <member type='way' role='some' ref='#{way.id}'/>
+ <member type='node' role='some' ref='#{node.id}'/>
+ <member type='relation' role='some' ref='#{other_relation.id}'/>
+ </relation>
+ </modify>
+ </osmChange>
EOF
# upload it
basic_authorization user.email, "test"
# simple diff to create a node way and relation using placeholders
- diff = <<EOF
-<osmChange>
- <create>
- <node id='-1' lon='0' lat='0' changeset='#{changeset.id}'>
- <tag k='foo' v='bar'/>
- <tag k='baz' v='bat'/>
- </node>
- <way id='-1' changeset='#{changeset.id}'>
- <nd ref='#{node.id}'/>
- </way>
- </create>
- <create>
- <relation id='-1' changeset='#{changeset.id}'>
- <member type='way' role='some' ref='#{way.id}'/>
- <member type='node' role='some' ref='#{node.id}'/>
- <member type='relation' role='some' ref='#{relation.id}'/>
- </relation>
- </create>
-</osmChange>
+ diff = <<EOF.strip_heredoc
+ <osmChange>
+ <create>
+ <node id='-1' lon='0' lat='0' changeset='#{changeset.id}'>
+ <tag k='foo' v='bar'/>
+ <tag k='baz' v='bat'/>
+ </node>
+ <way id='-1' changeset='#{changeset.id}'>
+ <nd ref='#{node.id}'/>
+ </way>
+ </create>
+ <create>
+ <relation id='-1' changeset='#{changeset.id}'>
+ <member type='way' role='some' ref='#{way.id}'/>
+ <member type='node' role='some' ref='#{node.id}'/>
+ <member type='relation' role='some' ref='#{relation.id}'/>
+ </relation>
+ </create>
+ </osmChange>
EOF
# upload it
delete << used_node.to_xml_node
# update the changeset to one that this user owns
- %w(node way relation).each do |type|
+ %w[node way relation].each do |type|
delete.find("//osmChange/delete/#{type}").each do |n|
n["changeset"] = changeset.id.to_s
end
# upload some widely-spaced nodes, spiralling positive and negative to cause
# largest bbox over-expansion possible.
- diff = <<EOF
-<osmChange>
- <create>
- <node id='-1' lon='-20' lat='-10' changeset='#{changeset_id}'/>
- <node id='-10' lon='20' lat='10' changeset='#{changeset_id}'/>
- <node id='-2' lon='-40' lat='-20' changeset='#{changeset_id}'/>
- <node id='-11' lon='40' lat='20' changeset='#{changeset_id}'/>
- <node id='-3' lon='-60' lat='-30' changeset='#{changeset_id}'/>
- <node id='-12' lon='60' lat='30' changeset='#{changeset_id}'/>
- <node id='-4' lon='-80' lat='-40' changeset='#{changeset_id}'/>
- <node id='-13' lon='80' lat='40' changeset='#{changeset_id}'/>
- <node id='-5' lon='-100' lat='-50' changeset='#{changeset_id}'/>
- <node id='-14' lon='100' lat='50' changeset='#{changeset_id}'/>
- <node id='-6' lon='-120' lat='-60' changeset='#{changeset_id}'/>
- <node id='-15' lon='120' lat='60' changeset='#{changeset_id}'/>
- <node id='-7' lon='-140' lat='-70' changeset='#{changeset_id}'/>
- <node id='-16' lon='140' lat='70' changeset='#{changeset_id}'/>
- <node id='-8' lon='-160' lat='-80' changeset='#{changeset_id}'/>
- <node id='-17' lon='160' lat='80' changeset='#{changeset_id}'/>
- <node id='-9' lon='-179.9' lat='-89.9' changeset='#{changeset_id}'/>
- <node id='-18' lon='179.9' lat='89.9' changeset='#{changeset_id}'/>
- </create>
-</osmChange>
+ diff = <<EOF.strip_heredoc
+ <osmChange>
+ <create>
+ <node id='-1' lon='-20' lat='-10' changeset='#{changeset_id}'/>
+ <node id='-10' lon='20' lat='10' changeset='#{changeset_id}'/>
+ <node id='-2' lon='-40' lat='-20' changeset='#{changeset_id}'/>
+ <node id='-11' lon='40' lat='20' changeset='#{changeset_id}'/>
+ <node id='-3' lon='-60' lat='-30' changeset='#{changeset_id}'/>
+ <node id='-12' lon='60' lat='30' changeset='#{changeset_id}'/>
+ <node id='-4' lon='-80' lat='-40' changeset='#{changeset_id}'/>
+ <node id='-13' lon='80' lat='40' changeset='#{changeset_id}'/>
+ <node id='-5' lon='-100' lat='-50' changeset='#{changeset_id}'/>
+ <node id='-14' lon='100' lat='50' changeset='#{changeset_id}'/>
+ <node id='-6' lon='-120' lat='-60' changeset='#{changeset_id}'/>
+ <node id='-15' lon='120' lat='60' changeset='#{changeset_id}'/>
+ <node id='-7' lon='-140' lat='-70' changeset='#{changeset_id}'/>
+ <node id='-16' lon='140' lat='70' changeset='#{changeset_id}'/>
+ <node id='-8' lon='-160' lat='-80' changeset='#{changeset_id}'/>
+ <node id='-17' lon='160' lat='80' changeset='#{changeset_id}'/>
+ <node id='-9' lon='-179.9' lat='-89.9' changeset='#{changeset_id}'/>
+ <node id='-18' lon='179.9' lat='89.9' changeset='#{changeset_id}'/>
+ </create>
+ </osmChange>
EOF
# upload it, which used to cause an error like "PGError: ERROR:
delete << used_node.to_xml_node
# update the changeset to one that this user owns
- %w(node way relation).each do |type|
+ %w[node way relation].each do |type|
delete.find("//osmChange/delete/#{type}").each do |n|
n["changeset"] = changeset.id.to_s
end
delete << used_node.to_xml_node
# update the changeset to one that this user owns
- %w(node way relation).each do |type|
+ %w[node way relation].each do |type|
delete.find("//osmChange/delete/#{type}").each do |n|
n["changeset"] = changeset.id.to_s
end
basic_authorization changeset.user.email, "test"
# simple diff to create a node way and relation using placeholders
- diff = <<EOF
-<osmChange>
- <create>
- <node id='-1' lon='0' lat='0' changeset='#{changeset.id}'>
- <tag k='foo' v='#{'x' * 256}'/>
- </node>
- </create>
-</osmChange>
+ diff = <<EOF.strip_heredoc
+ <osmChange>
+ <create>
+ <node id='-1' lon='0' lat='0' changeset='#{changeset.id}'>
+ <tag k='foo' v='#{'x' * 256}'/>
+ </node>
+ </create>
+ </osmChange>
EOF
# upload it
basic_authorization changeset.user.email, "test"
# simple diff to create a node way and relation using placeholders
- diff = <<EOF
-<osmChange>
- <create>
- <node id='-1' lon='0' lat='0' changeset='#{changeset.id}'>
- <tag k='foo' v='bar'/>
- <tag k='baz' v='bat'/>
- </node>
- </create>
- <modify>
- <way id='#{way.id}' changeset='#{changeset.id}' version='1'>
- <nd ref='-1'/>
- <nd ref='#{node.id}'/>
- </way>
- <relation id='#{relation.id}' changeset='#{changeset.id}' version='1'>
- <member type='way' role='some' ref='#{way.id}'/>
- <member type='node' role='some' ref='-1'/>
- <member type='relation' role='some' ref='#{relation.id}'/>
- </relation>
- </modify>
-</osmChange>
+ diff = <<EOF.strip_heredoc
+ <osmChange>
+ <create>
+ <node id='-1' lon='0' lat='0' changeset='#{changeset.id}'>
+ <tag k='foo' v='bar'/>
+ <tag k='baz' v='bat'/>
+ </node>
+ </create>
+ <modify>
+ <way id='#{way.id}' changeset='#{changeset.id}' version='1'>
+ <nd ref='-1'/>
+ <nd ref='#{node.id}'/>
+ </way>
+ <relation id='#{relation.id}' changeset='#{changeset.id}' version='1'>
+ <member type='way' role='some' ref='#{way.id}'/>
+ <member type='node' role='some' ref='-1'/>
+ <member type='relation' role='some' ref='#{relation.id}'/>
+ </relation>
+ </modify>
+ </osmChange>
EOF
# upload it
basic_authorization changeset.user.email, "test"
# simple diff to create a node way and relation using placeholders
- diff = <<EOF
-<osmChange>
- <modify>
- <node id='#{node.id}' lon='0' lat='0' changeset='#{changeset.id}' version='1'/>
- <way id='#{way.id}' changeset='#{changeset.id}' version='1'>
- <nd ref='#{node.id}'/>
- </way>
- </modify>
- <modify>
- <relation id='#{relation.id}' changeset='#{changeset.id}' version='1'>
- <member type='way' role='some' ref='#{way.id}'/>
- <member type='node' role='some' ref='#{node.id}'/>
- <member type='relation' role='some' ref='#{other_relation.id}'/>
- </relation>
- </modify>
- <create>
- <node id='-1' lon='0' lat='0' changeset='#{other_changeset.id}'>
- <tag k='foo' v='bar'/>
- <tag k='baz' v='bat'/>
- </node>
- </create>
-</osmChange>
+ diff = <<EOF.strip_heredoc
+ <osmChange>
+ <modify>
+ <node id='#{node.id}' lon='0' lat='0' changeset='#{changeset.id}' version='1'/>
+ <way id='#{way.id}' changeset='#{changeset.id}' version='1'>
+ <nd ref='#{node.id}'/>
+ </way>
+ </modify>
+ <modify>
+ <relation id='#{relation.id}' changeset='#{changeset.id}' version='1'>
+ <member type='way' role='some' ref='#{way.id}'/>
+ <member type='node' role='some' ref='#{node.id}'/>
+ <member type='relation' role='some' ref='#{other_relation.id}'/>
+ </relation>
+ </modify>
+ <create>
+ <node id='-1' lon='0' lat='0' changeset='#{other_changeset.id}'>
+ <tag k='foo' v='bar'/>
+ <tag k='baz' v='bat'/>
+ </node>
+ </create>
+ </osmChange>
EOF
# upload it
# change the location of a node multiple times, each time referencing
# the last version. doesn't this depend on version numbers being
# sequential?
- diff = <<EOF
-<osmChange>
- <modify>
- <node id='#{node.id}' lon='0' lat='0' changeset='#{changeset.id}' version='1'/>
- <node id='#{node.id}' lon='1' lat='0' changeset='#{changeset.id}' version='2'/>
- <node id='#{node.id}' lon='1' lat='1' changeset='#{changeset.id}' version='3'/>
- <node id='#{node.id}' lon='1' lat='2' changeset='#{changeset.id}' version='4'/>
- <node id='#{node.id}' lon='2' lat='2' changeset='#{changeset.id}' version='5'/>
- <node id='#{node.id}' lon='3' lat='2' changeset='#{changeset.id}' version='6'/>
- <node id='#{node.id}' lon='3' lat='3' changeset='#{changeset.id}' version='7'/>
- <node id='#{node.id}' lon='9' lat='9' changeset='#{changeset.id}' version='8'/>
- </modify>
-</osmChange>
+ diff = <<EOF.strip_heredoc
+ <osmChange>
+ <modify>
+ <node id='#{node.id}' lon='0' lat='0' changeset='#{changeset.id}' version='1'/>
+ <node id='#{node.id}' lon='1' lat='0' changeset='#{changeset.id}' version='2'/>
+ <node id='#{node.id}' lon='1' lat='1' changeset='#{changeset.id}' version='3'/>
+ <node id='#{node.id}' lon='1' lat='2' changeset='#{changeset.id}' version='4'/>
+ <node id='#{node.id}' lon='2' lat='2' changeset='#{changeset.id}' version='5'/>
+ <node id='#{node.id}' lon='3' lat='2' changeset='#{changeset.id}' version='6'/>
+ <node id='#{node.id}' lon='3' lat='3' changeset='#{changeset.id}' version='7'/>
+ <node id='#{node.id}' lon='9' lat='9' changeset='#{changeset.id}' version='8'/>
+ </modify>
+ </osmChange>
EOF
# upload it
basic_authorization changeset.user.email, "test"
- diff = <<EOF
-<osmChange>
- <modify>
- <node id='#{node.id}' lon='0' lat='0' changeset='#{changeset.id}' version='1'/>
- <node id='#{node.id}' lon='1' lat='1' changeset='#{changeset.id}' version='1'/>
- </modify>
-</osmChange>
+ diff = <<EOF.strip_heredoc
+ <osmChange>
+ <modify>
+ <node id='#{node.id}' lon='0' lat='0' changeset='#{changeset.id}' version='1'/>
+ <node id='#{node.id}' lon='1' lat='1' changeset='#{changeset.id}' version='1'/>
+ </modify>
+ </osmChange>
EOF
# upload it
basic_authorization changeset.user.email, "test"
- diff = <<EOF
-<osmChange>
- <modify>
- <node id='1' lon='1' lat='1' changeset='#{changeset.id}'/>
- </modify>
-</osmChange>
+ diff = <<EOF.strip_heredoc
+ <osmChange>
+ <modify>
+ <node id='1' lon='1' lat='1' changeset='#{changeset.id}'/>
+ </modify>
+ </osmChange>
EOF
# upload it
basic_authorization changeset.user.email, "test"
- diff = <<EOF
-<osmChange>
- <ping>
- <node id='1' lon='1' lat='1' changeset='#{changeset.id}' />
- </ping>
-</osmChange>
+ diff = <<EOF.strip_heredoc
+ <osmChange>
+ <ping>
+ <node id='1' lon='1' lat='1' changeset='#{changeset.id}' />
+ </ping>
+ </osmChange>
EOF
content diff
post :upload, :id => changeset.id
basic_authorization changeset.user.email, "test"
- diff = <<EOF
-<osmChange>
- <modify><node id='#{node.id}' lon='0' lat='0' changeset='#{changeset.id}'
- version='1'></node>
- <node id='#{node.id}' lon='1' lat='1' changeset='#{changeset.id}' version='2'><tag k='k' v='v'/></node></modify>
- <modify>
- <relation id='#{relation.id}' changeset='#{changeset.id}' version='1'><member
- type='way' role='some' ref='#{way.id}'/><member
- type='node' role='some' ref='#{node.id}'/>
- <member type='relation' role='some' ref='#{other_relation.id}'/>
- </relation>
- </modify></osmChange>
+ diff = <<EOF.strip_heredoc
+ <osmChange>
+ <modify><node id='#{node.id}' lon='0' lat='0' changeset='#{changeset.id}'
+ version='1'></node>
+ <node id='#{node.id}' lon='1' lat='1' changeset='#{changeset.id}' version='2'><tag k='k' v='v'/></node></modify>
+ <modify>
+ <relation id='#{relation.id}' changeset='#{changeset.id}' version='1'><member
+ type='way' role='some' ref='#{way.id}'/><member
+ type='node' role='some' ref='#{node.id}'/>
+ <member type='relation' role='some' ref='#{other_relation.id}'/>
+ </relation>
+ </modify></osmChange>
EOF
# upload it
basic_authorization changeset.user.email, "test"
- diff = <<EOF
-<osmChange>
- <create>
- <node id='-1' lon='0' lat='0' changeset='#{changeset.id}'>
- <tag k="foo" v="bar"/>
- </node>
- </create>
- <modify>
- <node id='-1' lon='1' lat='1' changeset='#{changeset.id}' version='1'/>
- </modify>
- <delete>
- <node id='-1' lon='2' lat='2' changeset='#{changeset.id}' version='2'/>
- </delete>
-</osmChange>
+ diff = <<EOF.strip_heredoc
+ <osmChange>
+ <create>
+ <node id='-1' lon='0' lat='0' changeset='#{changeset.id}'>
+ <tag k="foo" v="bar"/>
+ </node>
+ </create>
+ <modify>
+ <node id='-1' lon='1' lat='1' changeset='#{changeset.id}' version='1'/>
+ </modify>
+ <delete>
+ <node id='-1' lon='2' lat='2' changeset='#{changeset.id}' version='2'/>
+ </delete>
+ </osmChange>
EOF
# upload it
basic_authorization changeset.user.email, "test"
- diff = <<EOF
-<osmChange>
- <create>
- <node id='-1' lon='0' lat='0' changeset='#{changeset.id}' version='1'/>
- <node id='-1' lon='1' lat='1' changeset='#{changeset.id}' version='1'/>
- <node id='-1' lon='2' lat='2' changeset='#{changeset.id}' version='2'/>
- </create>
-</osmChange>
+ diff = <<EOF.strip_heredoc
+ <osmChange>
+ <create>
+ <node id='-1' lon='0' lat='0' changeset='#{changeset.id}' version='1'/>
+ <node id='-1' lon='1' lat='1' changeset='#{changeset.id}' version='1'/>
+ <node id='-1' lon='2' lat='2' changeset='#{changeset.id}' version='2'/>
+ </create>
+ </osmChange>
EOF
# upload it
basic_authorization changeset.user.email, "test"
- diff = <<EOF
-<osmChange>
- <create>
- <node id="-1" lon="0" lat="0" changeset="#{changeset.id}" version="1"/>
- <node id="-2" lon="1" lat="1" changeset="#{changeset.id}" version="1"/>
- <node id="-3" lon="2" lat="2" changeset="#{changeset.id}" version="1"/>
- <way id="-1" changeset="#{changeset.id}" version="1">
- <nd ref="-1"/>
- <nd ref="-2"/>
- <nd ref="-3"/>
- <nd ref="-4"/>
- </way>
- </create>
-</osmChange>
+ diff = <<EOF.strip_heredoc
+ <osmChange>
+ <create>
+ <node id="-1" lon="0" lat="0" changeset="#{changeset.id}" version="1"/>
+ <node id="-2" lon="1" lat="1" changeset="#{changeset.id}" version="1"/>
+ <node id="-3" lon="2" lat="2" changeset="#{changeset.id}" version="1"/>
+ <way id="-1" changeset="#{changeset.id}" version="1">
+ <nd ref="-1"/>
+ <nd ref="-2"/>
+ <nd ref="-3"/>
+ <nd ref="-4"/>
+ </way>
+ </create>
+ </osmChange>
EOF
# upload it
assert_equal "Placeholder node not found for reference -4 in way -1", @response.body
# the same again, but this time use an existing way
- diff = <<EOF
-<osmChange>
- <create>
- <node id="-1" lon="0" lat="0" changeset="#{changeset.id}" version="1"/>
- <node id="-2" lon="1" lat="1" changeset="#{changeset.id}" version="1"/>
- <node id="-3" lon="2" lat="2" changeset="#{changeset.id}" version="1"/>
- <way id="#{way.id}" changeset="#{changeset.id}" version="1">
- <nd ref="-1"/>
- <nd ref="-2"/>
- <nd ref="-3"/>
- <nd ref="-4"/>
- </way>
- </create>
-</osmChange>
+ diff = <<EOF.strip_heredoc
+ <osmChange>
+ <create>
+ <node id="-1" lon="0" lat="0" changeset="#{changeset.id}" version="1"/>
+ <node id="-2" lon="1" lat="1" changeset="#{changeset.id}" version="1"/>
+ <node id="-3" lon="2" lat="2" changeset="#{changeset.id}" version="1"/>
+ <way id="#{way.id}" changeset="#{changeset.id}" version="1">
+ <nd ref="-1"/>
+ <nd ref="-2"/>
+ <nd ref="-3"/>
+ <nd ref="-4"/>
+ </way>
+ </create>
+ </osmChange>
EOF
# upload it
basic_authorization changeset.user.email, "test"
- diff = <<EOF
-<osmChange>
- <create>
- <node id="-1" lon="0" lat="0" changeset="#{changeset.id}" version="1"/>
- <node id="-2" lon="1" lat="1" changeset="#{changeset.id}" version="1"/>
- <node id="-3" lon="2" lat="2" changeset="#{changeset.id}" version="1"/>
- <relation id="-1" changeset="#{changeset.id}" version="1">
- <member type="node" role="foo" ref="-1"/>
- <member type="node" role="foo" ref="-2"/>
- <member type="node" role="foo" ref="-3"/>
- <member type="node" role="foo" ref="-4"/>
- </relation>
- </create>
-</osmChange>
+ diff = <<EOF.strip_heredoc
+ <osmChange>
+ <create>
+ <node id="-1" lon="0" lat="0" changeset="#{changeset.id}" version="1"/>
+ <node id="-2" lon="1" lat="1" changeset="#{changeset.id}" version="1"/>
+ <node id="-3" lon="2" lat="2" changeset="#{changeset.id}" version="1"/>
+ <relation id="-1" changeset="#{changeset.id}" version="1">
+ <member type="node" role="foo" ref="-1"/>
+ <member type="node" role="foo" ref="-2"/>
+ <member type="node" role="foo" ref="-3"/>
+ <member type="node" role="foo" ref="-4"/>
+ </relation>
+ </create>
+ </osmChange>
EOF
# upload it
assert_equal "Placeholder Node not found for reference -4 in relation -1.", @response.body
# the same again, but this time use an existing relation
- diff = <<EOF
-<osmChange>
- <create>
- <node id="-1" lon="0" lat="0" changeset="#{changeset.id}" version="1"/>
- <node id="-2" lon="1" lat="1" changeset="#{changeset.id}" version="1"/>
- <node id="-3" lon="2" lat="2" changeset="#{changeset.id}" version="1"/>
- <relation id="#{relation.id}" changeset="#{changeset.id}" version="1">
- <member type="node" role="foo" ref="-1"/>
- <member type="node" role="foo" ref="-2"/>
- <member type="node" role="foo" ref="-3"/>
- <member type="way" role="bar" ref="-1"/>
- </relation>
- </create>
-</osmChange>
+ diff = <<EOF.strip_heredoc
+ <osmChange>
+ <create>
+ <node id="-1" lon="0" lat="0" changeset="#{changeset.id}" version="1"/>
+ <node id="-2" lon="1" lat="1" changeset="#{changeset.id}" version="1"/>
+ <node id="-3" lon="2" lat="2" changeset="#{changeset.id}" version="1"/>
+ <relation id="#{relation.id}" changeset="#{changeset.id}" version="1">
+ <member type="node" role="foo" ref="-1"/>
+ <member type="node" role="foo" ref="-2"/>
+ <member type="node" role="foo" ref="-3"/>
+ <member type="way" role="bar" ref="-1"/>
+ </relation>
+ </create>
+ </osmChange>
EOF
# upload it
changeset_id = @response.body.to_i
# add a diff to it
- diff = <<EOF
-<osmChange>
- <modify>
- <node id='#{node.id}' lon='0' lat='0' changeset='#{changeset_id}' version='1'/>
- <node id='#{node.id}' lon='1' lat='0' changeset='#{changeset_id}' version='2'/>
- <node id='#{node.id}' lon='1' lat='1' changeset='#{changeset_id}' version='3'/>
- <node id='#{node.id}' lon='1' lat='2' changeset='#{changeset_id}' version='4'/>
- <node id='#{node.id}' lon='2' lat='2' changeset='#{changeset_id}' version='5'/>
- <node id='#{node.id}' lon='3' lat='2' changeset='#{changeset_id}' version='6'/>
- <node id='#{node.id}' lon='3' lat='3' changeset='#{changeset_id}' version='7'/>
- <node id='#{node.id}' lon='9' lat='9' changeset='#{changeset_id}' version='8'/>
- </modify>
-</osmChange>
+ diff = <<EOF.strip_heredoc
+ <osmChange>
+ <modify>
+ <node id='#{node.id}' lon='0' lat='0' changeset='#{changeset_id}' version='1'/>
+ <node id='#{node.id}' lon='1' lat='0' changeset='#{changeset_id}' version='2'/>
+ <node id='#{node.id}' lon='1' lat='1' changeset='#{changeset_id}' version='3'/>
+ <node id='#{node.id}' lon='1' lat='2' changeset='#{changeset_id}' version='4'/>
+ <node id='#{node.id}' lon='2' lat='2' changeset='#{changeset_id}' version='5'/>
+ <node id='#{node.id}' lon='3' lat='2' changeset='#{changeset_id}' version='6'/>
+ <node id='#{node.id}' lon='3' lat='3' changeset='#{changeset_id}' version='7'/>
+ <node id='#{node.id}' lon='9' lat='9' changeset='#{changeset_id}' version='8'/>
+ </modify>
+ </osmChange>
EOF
# upload it
assert_response :success
changeset_id = @response.body.to_i
- diff = <<OSMFILE
-<osmChange version="0.6" generator="JOSM">
-<create version="0.6" generator="JOSM">
- <node id='-1' visible='true' changeset='#{changeset_id}' lat='51.49619982187321' lon='-0.18722061869438314' />
- <node id='-2' visible='true' changeset='#{changeset_id}' lat='51.496359883909605' lon='-0.18653093576241928' />
- <node id='-3' visible='true' changeset='#{changeset_id}' lat='51.49598132358285' lon='-0.18719613290981638' />
- <node id='-4' visible='true' changeset='#{changeset_id}' lat='51.4961591711078' lon='-0.18629015888084607' />
- <node id='-5' visible='true' changeset='#{changeset_id}' lat='51.49582126021711' lon='-0.18708186591517145' />
- <node id='-6' visible='true' changeset='#{changeset_id}' lat='51.49591018437858' lon='-0.1861432441734455' />
- <node id='-7' visible='true' changeset='#{changeset_id}' lat='51.49560784152179' lon='-0.18694719410005425' />
- <node id='-8' visible='true' changeset='#{changeset_id}' lat='51.49567389979617' lon='-0.1860289771788006' />
- <node id='-9' visible='true' changeset='#{changeset_id}' lat='51.49543761398892' lon='-0.186820684213126' />
- <way id='-10' action='modiy' visible='true' changeset='#{changeset_id}'>
- <nd ref='-1' />
- <nd ref='-2' />
- <nd ref='-3' />
- <nd ref='-4' />
- <nd ref='-5' />
- <nd ref='-6' />
- <nd ref='-7' />
- <nd ref='-8' />
- <nd ref='-9' />
- <tag k='highway' v='residential' />
- <tag k='name' v='Foobar Street' />
- </way>
-</create>
-</osmChange>
+ diff = <<OSMFILE.strip_heredoc
+ <osmChange version="0.6" generator="JOSM">
+ <create version="0.6" generator="JOSM">
+ <node id='-1' visible='true' changeset='#{changeset_id}' lat='51.49619982187321' lon='-0.18722061869438314' />
+ <node id='-2' visible='true' changeset='#{changeset_id}' lat='51.496359883909605' lon='-0.18653093576241928' />
+ <node id='-3' visible='true' changeset='#{changeset_id}' lat='51.49598132358285' lon='-0.18719613290981638' />
+ <node id='-4' visible='true' changeset='#{changeset_id}' lat='51.4961591711078' lon='-0.18629015888084607' />
+ <node id='-5' visible='true' changeset='#{changeset_id}' lat='51.49582126021711' lon='-0.18708186591517145' />
+ <node id='-6' visible='true' changeset='#{changeset_id}' lat='51.49591018437858' lon='-0.1861432441734455' />
+ <node id='-7' visible='true' changeset='#{changeset_id}' lat='51.49560784152179' lon='-0.18694719410005425' />
+ <node id='-8' visible='true' changeset='#{changeset_id}' lat='51.49567389979617' lon='-0.1860289771788006' />
+ <node id='-9' visible='true' changeset='#{changeset_id}' lat='51.49543761398892' lon='-0.186820684213126' />
+ <way id='-10' action='modiy' visible='true' changeset='#{changeset_id}'>
+ <nd ref='-1' />
+ <nd ref='-2' />
+ <nd ref='-3' />
+ <nd ref='-4' />
+ <nd ref='-5' />
+ <nd ref='-6' />
+ <nd ref='-7' />
+ <nd ref='-8' />
+ <nd ref='-9' />
+ <tag k='highway' v='residential' />
+ <tag k='name' v='Foobar Street' />
+ </way>
+ </create>
+ </osmChange>
OSMFILE
# upload it
changeset_id = @response.body.to_i
# add a diff to it
- diff = <<EOF
-<osmChange>
- <delete>
- <node id='#{node.id}' lon='0' lat='0' changeset='#{changeset_id}' version='1'/>
- </delete>
- <create>
- <node id='-1' lon='9' lat='9' changeset='#{changeset_id}' version='0'/>
- <node id='-2' lon='8' lat='9' changeset='#{changeset_id}' version='0'/>
- <node id='-3' lon='7' lat='9' changeset='#{changeset_id}' version='0'/>
- </create>
- <modify>
- <node id='#{node2.id}' lon='20' lat='15' changeset='#{changeset_id}' version='1'/>
- <way id='#{way.id}' changeset='#{changeset_id}' version='1'>
- <nd ref='#{node2.id}'/>
- <nd ref='-1'/>
- <nd ref='-2'/>
- <nd ref='-3'/>
- </way>
- </modify>
-</osmChange>
+ diff = <<EOF.strip_heredoc
+ <osmChange>
+ <delete>
+ <node id='#{node.id}' lon='0' lat='0' changeset='#{changeset_id}' version='1'/>
+ </delete>
+ <create>
+ <node id='-1' lon='9' lat='9' changeset='#{changeset_id}' version='0'/>
+ <node id='-2' lon='8' lat='9' changeset='#{changeset_id}' version='0'/>
+ <node id='-3' lon='7' lat='9' changeset='#{changeset_id}' version='0'/>
+ </create>
+ <modify>
+ <node id='#{node2.id}' lon='20' lat='15' changeset='#{changeset_id}' version='1'/>
+ <way id='#{way.id}' changeset='#{changeset_id}' version='1'>
+ <nd ref='#{node2.id}'/>
+ <nd ref='-1'/>
+ <nd ref='-2'/>
+ <nd ref='-3'/>
+ </way>
+ </modify>
+ </osmChange>
EOF
# upload it
].each do |code|
post :search, :query => code
assert_response :success
- assert_equal %w(us_postcode osm_nominatim), assigns(:sources)
+ assert_equal %w[us_postcode osm_nominatim], assigns(:sources)
end
end
"CR2 6XH",
"DN55 1PT"
].each do |code|
- search_check code, %w(uk_postcode osm_nominatim)
+ search_check code, %w[uk_postcode osm_nominatim]
end
end
##
# 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", %w(osm_nominatim geonames)
+ search_check "foo bar baz", %w[osm_nominatim geonames]
end
##
assert_response :success
assert_template :search
assert_template :layout => "map"
- assert_equal %w(latlon osm_nominatim_reverse geonames_reverse), assigns(:sources)
+ assert_equal %w[latlon osm_nominatim_reverse geonames_reverse], assigns(:sources)
assert_nil @controller.params[:query]
assert_in_delta lat, @controller.params[:lat]
assert_in_delta lon, @controller.params[:lon]
assert_response :success
assert_template :search
assert_template :layout => "xhr"
- assert_equal %w(latlon osm_nominatim_reverse geonames_reverse), assigns(:sources)
+ assert_equal %w[latlon osm_nominatim_reverse geonames_reverse], assigns(:sources)
assert_nil @controller.params[:query]
assert_in_delta lat, @controller.params[:lat]
assert_in_delta lon, @controller.params[:lon]
basic_authorization(user.email, "test")
- doc_str = <<OSM
-<osm>
- <relation changeset='#{changeset.id}'>
- <member ref='#{node1.id}' type='node' role='first'/>
- <member ref='#{node2.id}' type='node' role='second'/>
- <member ref='#{way1.id}' type='way' role='third'/>
- <member ref='#{way2.id}' type='way' role='fourth'/>
- </relation>
-</osm>
+ doc_str = <<OSM.strip_heredoc
+ <osm>
+ <relation changeset='#{changeset.id}'>
+ <member ref='#{node1.id}' type='node' role='first'/>
+ <member ref='#{node2.id}' type='node' role='second'/>
+ <member ref='#{way1.id}' type='way' role='third'/>
+ <member ref='#{way2.id}' type='way' role='fourth'/>
+ </relation>
+ </osm>
OSM
doc = XML::Parser.string(doc_str).parse
node1 = create(:node)
node2 = create(:node)
- doc_str = <<OSM
-<osm>
- <relation changeset='#{changeset.id}'>
- <member ref='#{node1.id}' type='node' role='forward'/>
- <member ref='#{node2.id}' type='node' role='forward'/>
- <member ref='#{node1.id}' type='node' role='forward'/>
- <member ref='#{node2.id}' type='node' role='forward'/>
- </relation>
-</osm>
+ doc_str = <<OSM.strip_heredoc
+ <osm>
+ <relation changeset='#{changeset.id}'>
+ <member ref='#{node1.id}' type='node' role='forward'/>
+ <member ref='#{node2.id}' type='node' role='forward'/>
+ <member ref='#{node1.id}' type='node' role='forward'/>
+ <member ref='#{node2.id}' type='node' role='forward'/>
+ </relation>
+ </osm>
OSM
doc = XML::Parser.string(doc_str).parse
node3 = create(:node)
node4 = create(:node)
- doc_str = <<OSM
-<osm>
- <relation changeset='#{changeset.id}'>
- <member ref='#{node1.id}' type='node' role='forward'/>
- <member ref='#{node4.id}' type='node' role='forward'/>
- <member ref='#{node3.id}' type='node' role='forward'/>
- <member ref='#{node2.id}' type='node' role='forward'/>
- </relation>
-</osm>
+ doc_str = <<OSM.strip_heredoc
+ <osm>
+ <relation changeset='#{changeset.id}'>
+ <member ref='#{node1.id}' type='node' role='forward'/>
+ <member ref='#{node4.id}' type='node' role='forward'/>
+ <member ref='#{node3.id}' type='node' role='forward'/>
+ <member ref='#{node2.id}' type='node' role='forward'/>
+ </relation>
+ </osm>
OSM
doc = XML::Parser.string(doc_str).parse
basic_authorization(user.email, "test")
trace = Trace.order(:id => :desc).first
assert_equal "a.gpx", trace.name
assert_equal "New Trace", trace.description
- assert_equal %w(new trace), trace.tags.order(:tag).collect(&:tag)
+ assert_equal %w[new trace], trace.tags.order(:tag).collect(&:tag)
assert_equal "trackable", trace.visibility
assert_equal false, trace.inserted
assert_equal File.new(fixture).read, File.new(trace.trace_name).read
trace = Trace.find(response.body.to_i)
assert_equal "a.gpx", trace.name
assert_equal "New Trace", trace.description
- assert_equal %w(new trace), trace.tags.order(:tag).collect(&:tag)
+ assert_equal %w[new trace], trace.tags.order(:tag).collect(&:tag)
assert_equal "trackable", trace.visibility
assert_equal false, trace.inserted
assert_equal File.new(fixture).read, File.new(trace.trace_name).read
trace = Trace.find(response.body.to_i)
assert_equal "a.gpx", trace.name
assert_equal "New Trace", trace.description
- assert_equal %w(new trace), trace.tags.order(:tag).collect(&:tag)
+ assert_equal %w[new trace], trace.tags.order(:tag).collect(&:tag)
assert_equal "public", trace.visibility
assert_equal false, trace.inserted
assert_equal File.new(fixture).read, File.new(trace.trace_name).read
trace = Trace.find(response.body.to_i)
assert_equal "a.gpx", trace.name
assert_equal "New Trace", trace.description
- assert_equal %w(new trace), trace.tags.order(:tag).collect(&:tag)
+ assert_equal %w[new trace], trace.tags.order(:tag).collect(&:tag)
assert_equal "private", trace.visibility
assert_equal false, trace.inserted
assert_equal File.new(fixture).read, File.new(trace.trace_name).read
end
def test_linkify
- %w(http://example.com/test ftp://example.com/test https://example.com/test).each do |link|
+ %w[http://example.com/test ftp://example.com/test https://example.com/test].each do |link|
text = "Test #{link} is made into a link"
html = linkify(text)
assert_dom_equal "Test <a href=\"#{link}\" rel=\"nofollow\">#{link}</a> is made into a link", html
end
- %w(test@example.com mailto:test@example.com).each do |link|
+ %w[test@example.com mailto:test@example.com].each do |link|
text = "Test #{link} is not made into a link"
html = linkify(text)
tags = icon_tags(node)
assert_equal 3, tags.count
- assert tags.include?(%w(building yes))
- assert tags.include?(%w(tourism museum))
- assert tags.include?(%w(shop gift))
+ assert tags.include?(%w[building yes])
+ assert tags.include?(%w[tourism museum])
+ assert tags.include?(%w[shop gift])
add_old_tags_selection(node_v2)
add_old_tags_selection(node_v1)
tags = icon_tags(node_v2)
assert_equal 3, tags.count
- assert tags.include?(%w(building yes))
- assert tags.include?(%w(tourism museum))
- assert tags.include?(%w(shop gift))
+ assert tags.include?(%w[building yes])
+ assert tags.include?(%w[tourism museum])
+ assert tags.include?(%w[shop gift])
tags = icon_tags(node_v1)
assert_equal 3, tags.count
- assert tags.include?(%w(building yes))
- assert tags.include?(%w(tourism museum))
- assert tags.include?(%w(shop gift))
+ assert tags.include?(%w[building yes])
+ assert tags.include?(%w[tourism museum])
+ assert tags.include?(%w[shop gift])
end
def test_wiki_link
# coding: utf-8
+
require "test_helper"
class TitleHelperTest < ActionView::TestCase
assert_select "html[lang=?]", "en"
get "/diary/new", {}, { "HTTP_ACCEPT_LANGUAGE" => "fr, en" }
- assert_equal %w(fr en), User.find(user.id).languages
+ assert_equal %w[fr en], User.find(user.id).languages
assert_select "html[lang=?]", "fr"
end
@max_lon = 3.0
@max_lat = 4.0
- @bad_positive_boundary_bbox = %w(181,91,0,0 0,0,181,91)
- @bad_negative_boundary_bbox = %w(-181,-91,0,0 0,0,-181,-91)
- @bad_big_bbox = %w(-0.1,-0.1,1.1,1.1 10,10,11,11)
- @bad_malformed_bbox = %w(-0.1 hello 10N2W10.1N2.1W)
- @bad_lat_mixed_bbox = %w(0,0.1,0.1,0 -0.1,80,0.1,70 0.24,54.34,0.25,54.33)
- @bad_lon_mixed_bbox = %w(80,-0.1,70,0.1 54.34,0.24,54.33,0.25)
- @bad_limit_bbox = %w(-180.1,-90,180,90 -180,-90.1,180,90 -180,-90,180.1,90 -180,-90,180,90.1)
- @good_bbox = %w(-0.1,-0.1,0.1,0.1 51.1,-0.1,51.2,0 -0.1,%20-0.1,%200.1,%200.1
- -0.1edcd,-0.1d,0.1,0.1 -0.1E,-0.1E,0.1S,0.1N S0.1,W0.1,N0.1,E0.1)
-
- @expand_min_lon_array = %w(2,10,10,10 1,10,10,10 0,10,10,10 -1,10,10,10 -2,10,10,10 -8,10,10,10)
- @expand_min_lat_array = %w(10,2,10,10 10,1,10,10 10,0,10,10 10,-1,10,10 10,-2,10,10 10,-8,10,10)
- @expand_max_lon_array = %w(-2,-2,-1,-2 -2,-2,0,-2 -2,-2,1,-2 -2,-2,2,-2)
- @expand_max_lat_array = %w(-2,-2,-2,-1 -2,-2,-2,0 -2,-2,-2,1 -2,-2,-2,2)
+ @bad_positive_boundary_bbox = %w[181,91,0,0 0,0,181,91]
+ @bad_negative_boundary_bbox = %w[-181,-91,0,0 0,0,-181,-91]
+ @bad_big_bbox = %w[-0.1,-0.1,1.1,1.1 10,10,11,11]
+ @bad_malformed_bbox = %w[-0.1 hello 10N2W10.1N2.1W]
+ @bad_lat_mixed_bbox = %w[0,0.1,0.1,0 -0.1,80,0.1,70 0.24,54.34,0.25,54.33]
+ @bad_lon_mixed_bbox = %w[80,-0.1,70,0.1 54.34,0.24,54.33,0.25]
+ @bad_limit_bbox = %w[-180.1,-90,180,90 -180,-90.1,180,90 -180,-90,180.1,90 -180,-90,180,90.1]
+ @good_bbox = %w[-0.1,-0.1,0.1,0.1 51.1,-0.1,51.2,0 -0.1,%20-0.1,%200.1,%200.1
+ -0.1edcd,-0.1d,0.1,0.1 -0.1E,-0.1E,0.1S,0.1N S0.1,W0.1,N0.1,E0.1]
+
+ @expand_min_lon_array = %w[2,10,10,10 1,10,10,10 0,10,10,10 -1,10,10,10 -2,10,10,10 -8,10,10,10]
+ @expand_min_lat_array = %w[10,2,10,10 10,1,10,10 10,0,10,10 10,-1,10,10 10,-2,10,10 10,-8,10,10]
+ @expand_max_lon_array = %w[-2,-2,-1,-2 -2,-2,0,-2 -2,-2,1,-2 -2,-2,2,-2]
+ @expand_max_lat_array = %w[-2,-2,-2,-1 -2,-2,-2,0 -2,-2,-2,1 -2,-2,-2,2]
@expand_min_lon_margin_response = [[2, 10, 10, 10], [-7, 10, 10, 10], [-7, 10, 10, 10], [-7, 10, 10, 10], [-7, 10, 10, 10], [-25, 10, 10, 10]]
@expand_min_lat_margin_response = [[10, 2, 10, 10], [10, -7, 10, 10], [10, -7, 10, 10], [10, -7, 10, 10], [10, -7, 10, 10], [10, -25, 10, 10]]
@expand_max_lon_margin_response = [[-2, -2, -1, -2], [-2, -2, 1, -2], [-2, -2, 1, -2], [-2, -2, 5, -2]]
end
end
- assert %w(ltr rtl).include?(I18n.t("html.dir", :locale => locale)), "html.dir must be ltr or rtl"
+ assert %w[ltr rtl].include?(I18n.t("html.dir", :locale => locale)), "html.dir must be ltr or rtl"
end
end
end
def test_body_valid
- ok = %W(Name vergrößern foo\nbar
- ルシステムにも対応します 輕觸搖晃的遊戲)
+ ok = %W[Name vergrößern foo\nbar
+ ルシステムにも対応します 輕觸搖晃的遊戲]
bad = ["foo\x00bar", "foo\x08bar", "foo\x1fbar", "foo\x7fbar",
"foo\ufffebar", "foo\uffffbar"]
# coding: utf-8
+
require "test_helper"
class LanguageTest < ActiveSupport::TestCase
# its OK to accept invalid UTF-8 as long as we return it unmodified.
db_msg = msg.class.find(msg.id)
assert_equal char, db_msg.title, "Database silently truncated message title"
-
rescue ArgumentError => ex
assert_equal ex.to_s, "invalid byte sequence in UTF-8"
-
end
end
end
class NoteCommentTest < ActiveSupport::TestCase
def test_event_valid
- ok = %w(opened closed reopened commented hidden)
- bad = %w(expropriated fubared)
+ ok = %w[opened closed reopened commented hidden]
+ bad = %w[expropriated fubared]
ok.each do |event|
note_comment = create(:note_comment)
end
def test_body_valid
- ok = %W(Name vergrößern foo\nbar
- ルシステムにも対応します 輕觸搖晃的遊戲)
+ ok = %W[Name vergrößern foo\nbar
+ ルシステムにも対応します 輕觸搖晃的遊戲]
bad = ["foo\x00bar", "foo\x08bar", "foo\x1fbar", "foo\x7fbar",
"foo\ufffebar", "foo\uffffbar"]
class NoteTest < ActiveSupport::TestCase
def test_status_valid
- ok = %w(open closed hidden)
- bad = %w(expropriated fubared)
+ ok = %w[open closed hidden]
+ bad = %w[expropriated fubared]
ok.each do |status|
note = create(:note)
assert user.errors[:pass_crypt].any?
assert user.errors[:display_name].any?
assert user.errors[:email].any?
- assert !user.errors[:home_lat].any?
- assert !user.errors[:home_lon].any?
- assert !user.errors[:home_zoom].any?
+ assert user.errors[:home_lat].none?
+ assert user.errors[:home_lon].none?
+ assert user.errors[:home_zoom].none?
end
def test_unique_email
end
def test_email_valid
- ok = %w(a@s.com test@shaunmcdonald.me.uk hello_local@ping-d.ng
- test_local@openstreetmap.org test-local@example.com)
- bad = %w(hi ht@ n@ @.com help@.me.uk help"hi.me.uk も対@応します
- 輕觸搖晃的遊戲@ah.com も対応します@s.name)
+ ok = %w[a@s.com test@shaunmcdonald.me.uk hello_local@ping-d.ng
+ test_local@openstreetmap.org test-local@example.com]
+ bad = %w[hi ht@ n@ @.com help@.me.uk help"hi.me.uk も対@応します
+ 輕觸搖晃的遊戲@ah.com も対応します@s.name]
ok.each do |name|
user = build(:user)
user = create(:user, :languages => ["en"])
assert_equal ["en"], user.languages
- user.languages = %w(de fr en)
- assert_equal %w(de fr en), user.languages
- user.languages = %w(fr de sl)
+ user.languages = %w[de fr en]
+ assert_equal %w[de fr en], user.languages
+ user.languages = %w[fr de sl]
assert_equal "de", user.preferred_language
- assert_equal %w(fr de sl), user.preferred_languages.map(&:to_s)
- user = create(:user, :languages => %w(en de))
- assert_equal %w(en de), user.languages
+ assert_equal %w[fr de sl], user.preferred_languages.map(&:to_s)
+ user = create(:user, :languages => %w[en de])
+ assert_equal %w[en de], user.languages
end
def test_visible?