From 5b33f3f8e31c62bc3e5db1d5b120533c3afdde68 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Thu, 1 Jun 2017 23:46:53 +0100 Subject: [PATCH] Fix rubocop warnings --- .rubocop.yml | 15 +- app/controllers/application_controller.rb | 6 +- app/controllers/diary_entry_controller.rb | 4 +- app/controllers/oauth_controller.rb | 2 +- app/controllers/site_controller.rb | 14 +- app/controllers/trace_controller.rb | 2 +- app/controllers/user_controller.rb | 2 +- app/helpers/browse_helper.rb | 2 +- app/models/client_application.rb | 4 +- app/models/diary_entry.rb | 2 +- app/models/note.rb | 2 +- app/models/note_comment.rb | 2 +- app/models/redaction.rb | 2 +- app/models/relation.rb | 2 +- app/models/trace.rb | 6 +- app/models/user.rb | 12 +- app/models/user_role.rb | 2 +- config/application.rb | 2 +- config/initializers/assets.rb | 42 +- config/initializers/sanitize.rb | 4 +- config/initializers/secure_headers.rb | 24 +- db/migrate/001_create_osm_db.rb | 16 +- db/migrate/002_cleanup_osm_db.rb | 6 +- db/migrate/004_user_enhancements.rb | 2 +- db/migrate/005_tile_tracepoints.rb | 2 +- db/migrate/006_tile_nodes.rb | 4 +- db/migrate/007_add_relations.rb | 14 +- db/migrate/008_remove_segments.rb | 2 +- db/migrate/010_diary_comments.rb | 2 +- .../020_populate_node_tags_and_remove.rb | 2 +- db/migrate/021_move_to_innodb.rb | 4 +- db/migrate/023_add_changesets.rb | 2 +- db/migrate/028_add_more_changeset_indexes.rb | 2 +- .../039_add_more_controls_to_gpx_files.rb | 2 +- db/migrate/041_add_fine_o_auth_permissions.rb | 3 +- db/migrate/044_create_user_roles.rb | 2 +- db/migrate/051_add_status_to_user.rb | 2 +- db/migrate/053_add_map_bug_tables.rb | 2 +- db/migrate/057_add_map_bug_comment_event.rb | 2 +- db/migrate/20120214210114_add_text_format.rb | 2 +- lib/editors.rb | 4 +- script/statistics | 2 +- script/update-spam-blocks | 2 +- test/controllers/amf_controller_test.rb | 4 +- test/controllers/api_controller_test.rb | 28 +- test/controllers/changeset_controller_test.rb | 650 +++++++++--------- test/controllers/geocoder_controller_test.rb | 12 +- test/controllers/relation_controller_test.rb | 54 +- test/controllers/trace_controller_test.rb | 8 +- test/helpers/application_helper_test.rb | 4 +- test/helpers/browse_helper_test.rb | 18 +- test/helpers/title_helper_test.rb | 1 + test/integration/page_locale_test.rb | 2 +- test/lib/bounding_box_test.rb | 28 +- test/lib/i18n_test.rb | 2 +- test/models/changeset_comment_test.rb | 4 +- test/models/language_test.rb | 1 + test/models/message_test.rb | 2 - test/models/note_comment_test.rb | 8 +- test/models/note_test.rb | 4 +- test/models/user_test.rb | 26 +- 61 files changed, 548 insertions(+), 542 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index a31adf03b..e1f1724e0 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -24,18 +24,21 @@ AllCops: 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 @@ -55,6 +58,12 @@ Style/HashSyntax: Style/StringLiterals: EnforcedStyle: double_quotes +Style/SymbolArray: + EnforcedStyle: brackets + +Rails/ApplicationRecord: + Enabled: false + Rails/HttpPositionalArguments: Enabled: false diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 2ceeda7be..ebad7c2c6 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -410,9 +410,9 @@ class ApplicationController < ActionController::Base 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 diff --git a/app/controllers/diary_entry_controller.rb b/app/controllers/diary_entry_controller.rb index 6fb255a36..8863e2fd9 100644 --- a/app/controllers/diary_entry_controller.rb +++ b/app/controllers/diary_entry_controller.rb @@ -128,7 +128,7 @@ class DiaryEntryController < ApplicationController 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 @@ -162,7 +162,7 @@ class DiaryEntryController < ApplicationController 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]) diff --git a/app/controllers/oauth_controller.rb b/app/controllers/oauth_controller.rb index 2e847fcd5..4bb129ba4 100644 --- a/app/controllers/oauth_controller.rb +++ b/app/controllers/oauth_controller.rb @@ -49,7 +49,7 @@ class OauthController < ApplicationController 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" diff --git a/app/controllers/site_controller.rb b/app/controllers/site_controller.rb index b0552322e..48b847cdd 100644 --- a/app/controllers/site_controller.rb +++ b/app/controllers/site_controller.rb @@ -69,11 +69,11 @@ class SiteController < ApplicationController 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 @@ -120,9 +120,9 @@ class SiteController < ApplicationController 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 diff --git a/app/controllers/trace_controller.rb b/app/controllers/trace_controller.rb index 8d9b670c5..f63c86540 100644 --- a/app/controllers/trace_controller.rb +++ b/app/controllers/trace_controller.rb @@ -21,7 +21,7 @@ class TraceController < ApplicationController 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 diff --git a/app/controllers/user_controller.rb b/app/controllers/user_controller.rb index 197b28914..a79121b03 100644 --- a/app/controllers/user_controller.rb +++ b/app/controllers/user_controller.rb @@ -81,7 +81,7 @@ class UserController < ApplicationController @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 diff --git a/app/helpers/browse_helper.rb b/app/helpers/browse_helper.rb index ef7b3f554..998ea405f 100644 --- a/app/helpers/browse_helper.rb +++ b/app/helpers/browse_helper.rb @@ -99,7 +99,7 @@ module BrowseHelper 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 diff --git a/app/models/client_application.rb b/app/models/client_application.rb index 152b3912d..85b6ba68a 100644 --- a/app/models/client_application.rb +++ b/app/models/client_application.rb @@ -75,9 +75,7 @@ class ClientApplication < ActiveRecord::Base # 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] diff --git a/app/models/diary_entry.rb b/app/models/diary_entry.rb index e756432fd..143ddc1dc 100644 --- a/app/models/diary_entry.rb +++ b/app/models/diary_entry.rb @@ -3,7 +3,7 @@ class DiaryEntry < ActiveRecord::Base 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 diff --git a/app/models/note.rb b/app/models/note.rb index 73207af0f..d2c36071d 100644 --- a/app/models/note.rb +++ b/app/models/note.rb @@ -7,7 +7,7 @@ class Note < ActiveRecord::Base :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 diff --git a/app/models/note_comment.rb b/app/models/note_comment.rb index 31ee6f99b..aa8635aad 100644 --- a/app/models/note_comment.rb +++ b/app/models/note_comment.rb @@ -7,7 +7,7 @@ class NoteComment < ActiveRecord::Base 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 diff --git a/app/models/redaction.rb b/app/models/redaction.rb index 49de3177a..04f002e36 100644 --- a/app/models/redaction.rb +++ b/app/models/redaction.rb @@ -15,7 +15,7 @@ class Redaction < ActiveRecord::Base 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. diff --git a/app/models/relation.rb b/app/models/relation.rb index b78c95ce4..899460dbb 100644 --- a/app/models/relation.rb +++ b/app/models/relation.rb @@ -33,7 +33,7 @@ class Relation < ActiveRecord::Base 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) diff --git a/app/models/trace.rb b/app/models/trace.rb index 2d055fd28..8179dad22 100644 --- a/app/models/trace.rb +++ b/app/models/trace.rb @@ -7,14 +7,14 @@ class Trace < ActiveRecord::Base 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 @@ -29,7 +29,7 @@ class Trace < ActiveRecord::Base 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 diff --git a/app/models/user.rb b/app/models/user.rb index 3d5e71ea2..3ce48e7cd 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -9,7 +9,7 @@ class User < ActiveRecord::Base 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" @@ -28,8 +28,8 @@ class User < ActiveRecord::Base 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, @@ -37,7 +37,7 @@ class User < ActiveRecord::Base :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? }, @@ -161,13 +161,13 @@ class User < ActiveRecord::Base ## # 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 ## diff --git a/app/models/user_role.rb b/app/models/user_role.rb index 4f80f1952..967850145 100644 --- a/app/models/user_role.rb +++ b/app/models/user_role.rb @@ -2,7 +2,7 @@ class UserRole < ActiveRecord::Base 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 diff --git a/config/application.rb b/config/application.rb index 5ff166beb..ff9ac1602 100644 --- a/config/application.rb +++ b/config/application.rb @@ -34,7 +34,7 @@ module OpenStreetMap 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, diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb index b60edd633..f61171450 100644 --- a/config/initializers/assets.rb +++ b/config/initializers/assets.rb @@ -11,24 +11,24 @@ Rails.application.config.assets.paths << Rails.root.join("config") # 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] diff --git a/config/initializers/sanitize.rb b/config/initializers/sanitize.rb index c7be1380f..240f1e315 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[: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] diff --git a/config/initializers/secure_headers.rb b/config/initializers/secure_headers.rb index e53ea6cef..59fe4225d 100644 --- a/config/initializers/secure_headers.rb +++ b/config/initializers/secure_headers.rb @@ -1,17 +1,17 @@ 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] } diff --git a/db/migrate/001_create_osm_db.rb b/db/migrate/001_create_osm_db.rb index ddbfe259d..3935fb6b0 100644 --- a/db/migrate/001_create_osm_db.rb +++ b/db/migrate/001_create_osm_db.rb @@ -13,7 +13,7 @@ class CreateOsmDb < ActiveRecord::Migration 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| @@ -26,7 +26,7 @@ class CreateOsmDb < ActiveRecord::Migration 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" @@ -82,7 +82,7 @@ class CreateOsmDb < ActiveRecord::Migration 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" @@ -109,7 +109,7 @@ class CreateOsmDb < ActiveRecord::Migration 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 @@ -148,7 +148,7 @@ class CreateOsmDb < ActiveRecord::Migration 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 @@ -193,7 +193,7 @@ class CreateOsmDb < ActiveRecord::Migration 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 @@ -202,7 +202,7 @@ class CreateOsmDb < ActiveRecord::Migration 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 @@ -212,7 +212,7 @@ class CreateOsmDb < ActiveRecord::Migration 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 diff --git a/db/migrate/002_cleanup_osm_db.rb b/db/migrate/002_cleanup_osm_db.rb index 866b1ae51..0710417e3 100644 --- a/db/migrate/002_cleanup_osm_db.rb +++ b/db/migrate/002_cleanup_osm_db.rb @@ -21,7 +21,7 @@ class CleanupOsmDb < ActiveRecord::Migration 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 @@ -40,7 +40,7 @@ class CleanupOsmDb < ActiveRecord::Migration 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 @@ -204,7 +204,7 @@ class CleanupOsmDb < ActiveRecord::Migration 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 diff --git a/db/migrate/004_user_enhancements.rb b/db/migrate/004_user_enhancements.rb index 4d53d0382..f45d441ab 100644 --- a/db/migrate/004_user_enhancements.rb +++ b/db/migrate/004_user_enhancements.rb @@ -12,7 +12,7 @@ class UserEnhancements < ActiveRecord::Migration 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 diff --git a/db/migrate/005_tile_tracepoints.rb b/db/migrate/005_tile_tracepoints.rb index f77d34959..00e5af293 100644 --- a/db/migrate/005_tile_tracepoints.rb +++ b/db/migrate/005_tile_tracepoints.rb @@ -20,7 +20,7 @@ class TileTracepoints < ActiveRecord::Migration 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 diff --git a/db/migrate/006_tile_nodes.rb b/db/migrate/006_tile_nodes.rb index fd9dbfb67..29200d06a 100644 --- a/db/migrate/006_tile_nodes.rb +++ b/db/migrate/006_tile_nodes.rb @@ -96,7 +96,7 @@ class TileNodes < ActiveRecord::Migration 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" @@ -116,7 +116,7 @@ class TileNodes < ActiveRecord::Migration 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" diff --git a/db/migrate/007_add_relations.rb b/db/migrate/007_add_relations.rb index 78270f103..12684abc8 100644 --- a/db/migrate/007_add_relations.rb +++ b/db/migrate/007_add_relations.rb @@ -3,7 +3,7 @@ require "migrate" 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: @@ -16,8 +16,8 @@ class AddRelations < ActiveRecord::Migration 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| @@ -44,8 +44,8 @@ class AddRelations < ActiveRecord::Migration 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 @@ -54,7 +54,7 @@ class AddRelations < ActiveRecord::Migration 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 @@ -64,7 +64,7 @@ class AddRelations < ActiveRecord::Migration 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 diff --git a/db/migrate/008_remove_segments.rb b/db/migrate/008_remove_segments.rb index 8ca894d92..62f618abf 100644 --- a/db/migrate/008_remove_segments.rb +++ b/db/migrate/008_remove_segments.rb @@ -19,7 +19,7 @@ class RemoveSegments < ActiveRecord::Migration 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 diff --git a/db/migrate/010_diary_comments.rb b/db/migrate/010_diary_comments.rb index 4e95b1976..ac0f5e23a 100644 --- a/db/migrate/010_diary_comments.rb +++ b/db/migrate/010_diary_comments.rb @@ -11,7 +11,7 @@ class DiaryComments < ActiveRecord::Migration 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 diff --git a/db/migrate/020_populate_node_tags_and_remove.rb b/db/migrate/020_populate_node_tags_and_remove.rb index 640019b15..0fd1dc564 100644 --- a/db/migrate/020_populate_node_tags_and_remove.rb +++ b/db/migrate/020_populate_node_tags_and_remove.rb @@ -18,7 +18,7 @@ class PopulateNodeTagsAndRemove < ActiveRecord::Migration 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 diff --git a/db/migrate/021_move_to_innodb.rb b/db/migrate/021_move_to_innodb.rb index edfecdfd9..6ef3587d1 100644 --- a/db/migrate/021_move_to_innodb.rb +++ b/db/migrate/021_move_to_innodb.rb @@ -1,9 +1,9 @@ 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 diff --git a/db/migrate/023_add_changesets.rb b/db/migrate/023_add_changesets.rb index 3cf268dd0..933a62cd5 100644 --- a/db/migrate/023_add_changesets.rb +++ b/db/migrate/023_add_changesets.rb @@ -1,7 +1,7 @@ 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| diff --git a/db/migrate/028_add_more_changeset_indexes.rb b/db/migrate/028_add_more_changeset_indexes.rb index b64c9caf0..8fc9345a3 100644 --- a/db/migrate/028_add_more_changeset_indexes.rb +++ b/db/migrate/028_add_more_changeset_indexes.rb @@ -4,7 +4,7 @@ class AddMoreChangesetIndexes < ActiveRecord::Migration 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 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 c1e20ffd7..5a905c044 100644 --- a/db/migrate/039_add_more_controls_to_gpx_files.rb +++ b/db/migrate/039_add_more_controls_to_gpx_files.rb @@ -2,7 +2,7 @@ require "migrate" 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" diff --git a/db/migrate/041_add_fine_o_auth_permissions.rb b/db/migrate/041_add_fine_o_auth_permissions.rb index 598cb3c04..c37dc2c1b 100644 --- a/db/migrate/041_add_fine_o_auth_permissions.rb +++ b/db/migrate/041_add_fine_o_auth_permissions.rb @@ -1,6 +1,5 @@ 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| diff --git a/db/migrate/044_create_user_roles.rb b/db/migrate/044_create_user_roles.rb index bae5a3cad..e5cf07cd3 100644 --- a/db/migrate/044_create_user_roles.rb +++ b/db/migrate/044_create_user_roles.rb @@ -2,7 +2,7 @@ require "migrate" 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 diff --git a/db/migrate/051_add_status_to_user.rb b/db/migrate/051_add_status_to_user.rb index f98cfd1eb..f3a550c60 100644 --- a/db/migrate/051_add_status_to_user.rb +++ b/db/migrate/051_add_status_to_user.rb @@ -2,7 +2,7 @@ require "migrate" 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" diff --git a/db/migrate/053_add_map_bug_tables.rb b/db/migrate/053_add_map_bug_tables.rb index 52d190424..0ad968d0a 100644 --- a/db/migrate/053_add_map_bug_tables.rb +++ b/db/migrate/053_add_map_bug_tables.rb @@ -2,7 +2,7 @@ require "migrate" 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 diff --git a/db/migrate/057_add_map_bug_comment_event.rb b/db/migrate/057_add_map_bug_comment_event.rb index d5e77f499..6ba2b5a76 100644 --- a/db/migrate/057_add_map_bug_comment_event.rb +++ b/db/migrate/057_add_map_bug_comment_event.rb @@ -2,7 +2,7 @@ require "migrate" 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 diff --git a/db/migrate/20120214210114_add_text_format.rb b/db/migrate/20120214210114_add_text_format.rb index 3f82c3292..165524d2c 100644 --- a/db/migrate/20120214210114_add_text_format.rb +++ b/db/migrate/20120214210114_add_text_format.rb @@ -2,7 +2,7 @@ require "migrate" 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" diff --git a/lib/editors.rb b/lib/editors.rb index 21f646228..6c0428724 100644 --- a/lib/editors.rb +++ b/lib/editors.rb @@ -1,4 +1,4 @@ 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 diff --git a/script/statistics b/script/statistics index 912302c2e..8b79523b7 100755 --- a/script/statistics +++ b/script/statistics @@ -15,7 +15,7 @@ puts "

OpenStreetMap stats report run at #{start_time}

" 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 diff --git a/script/update-spam-blocks b/script/update-spam-blocks index 4367fd8da..f14905b90 100755 --- a/script/update-spam-blocks +++ b/script/update-spam-blocks @@ -5,7 +5,7 @@ require "generator" addresses = User.count( :conditions => { - :status => %w(suspended deleted), + :status => %w[suspended deleted], :creation_time => Time.now - 28.days..Time.now }, :group => :creation_ip diff --git a/test/controllers/amf_controller_test.rb b/test/controllers/amf_controller_test.rb index 5fee80d9f..83ef03bbf 100644 --- a/test/controllers/amf_controller_test.rb +++ b/test/controllers/amf_controller_test.rb @@ -17,8 +17,8 @@ class AmfControllerTest < ActionController::TestCase 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 diff --git a/test/controllers/api_controller_test.rb b/test/controllers/api_controller_test.rb index 6501ba3bc..61763d128 100644 --- a/test/controllers/api_controller_test.rb +++ b/test/controllers/api_controller_test.rb @@ -4,14 +4,14 @@ require "api_controller" 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 @@ -217,7 +217,7 @@ class ApiControllerTest < ActionController::TestCase 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" @@ -238,7 +238,7 @@ class ApiControllerTest < ActionController::TestCase 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}" @@ -248,7 +248,7 @@ class ApiControllerTest < ActionController::TestCase 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}" @@ -258,7 +258,7 @@ class ApiControllerTest < ActionController::TestCase 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}" @@ -268,7 +268,7 @@ class ApiControllerTest < ActionController::TestCase 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}" @@ -333,7 +333,7 @@ class ApiControllerTest < ActionController::TestCase 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 @@ -354,7 +354,7 @@ class ApiControllerTest < ActionController::TestCase 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}" diff --git a/test/controllers/changeset_controller_test.rb b/test/controllers/changeset_controller_test.rb index db0ee5e96..c12f1d902 100644 --- a/test/controllers/changeset_controller_test.rb +++ b/test/controllers/changeset_controller_test.rb @@ -327,22 +327,22 @@ class ChangesetControllerTest < ActionController::TestCase # simple diff to change a node, way and relation by removing # their tags - diff = < - - - - - - - - - - - - - - + diff = < + + + + + + + + + + + + + + EOF # upload it @@ -357,22 +357,22 @@ EOF # simple diff to change a node, way and relation by removing # their tags - diff = < - - - - - - - - - - - - - - + diff = < + + + + + + + + + + + + + + EOF # upload it @@ -387,22 +387,22 @@ EOF # simple diff to change a node, way and relation by removing # their tags - diff = < - - - - - - - - - - - - - - + diff = < + + + + + + + + + + + + + + EOF # upload it @@ -429,25 +429,25 @@ EOF basic_authorization user.email, "test" # simple diff to create a node way and relation using placeholders - diff = < - - - - - - - - - - - - - - - - - + diff = < + + + + + + + + + + + + + + + + + EOF # upload it @@ -509,7 +509,7 @@ EOF 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 @@ -582,29 +582,29 @@ EOF # upload some widely-spaced nodes, spiralling positive and negative to cause # largest bbox over-expansion possible. - diff = < - - - - - - - - - - - - - - - - - - - - - + diff = < + + + + + + + + + + + + + + + + + + + + + EOF # upload it, which used to cause an error like "PGError: ERROR: @@ -645,7 +645,7 @@ EOF 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 @@ -689,7 +689,7 @@ EOF 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 @@ -739,14 +739,14 @@ EOF basic_authorization changeset.user.email, "test" # simple diff to create a node way and relation using placeholders - diff = < - - - - - - + diff = < + + + + + + EOF # upload it @@ -770,26 +770,26 @@ EOF basic_authorization changeset.user.email, "test" # simple diff to create a node way and relation using placeholders - diff = < - - - - - - - - - - - - - - - - - - + diff = < + + + + + + + + + + + + + + + + + + EOF # upload it @@ -832,28 +832,28 @@ EOF basic_authorization changeset.user.email, "test" # simple diff to create a node way and relation using placeholders - diff = < - - - - - - - - - - - - - - - - - - - - + diff = < + + + + + + + + + + + + + + + + + + + + EOF # upload it @@ -878,19 +878,19 @@ EOF # change the location of a node multiple times, each time referencing # the last version. doesn't this depend on version numbers being # sequential? - diff = < - - - - - - - - - - - + diff = < + + + + + + + + + + + EOF # upload it @@ -914,13 +914,13 @@ EOF basic_authorization changeset.user.email, "test" - diff = < - - - - - + diff = < + + + + + EOF # upload it @@ -937,12 +937,12 @@ EOF basic_authorization changeset.user.email, "test" - diff = < - - - - + diff = < + + + + EOF # upload it @@ -959,12 +959,12 @@ EOF basic_authorization changeset.user.email, "test" - diff = < - - - - + diff = < + + + + EOF content diff post :upload, :id => changeset.id @@ -985,18 +985,18 @@ EOF basic_authorization changeset.user.email, "test" - diff = < - - - - - - - + diff = < + + + + + + + EOF # upload it @@ -1021,20 +1021,20 @@ EOF basic_authorization changeset.user.email, "test" - diff = < - - - - - - - - - - - - + diff = < + + + + + + + + + + + + EOF # upload it @@ -1056,14 +1056,14 @@ EOF basic_authorization changeset.user.email, "test" - diff = < - - - - - - + diff = < + + + + + + EOF # upload it @@ -1082,20 +1082,20 @@ EOF basic_authorization changeset.user.email, "test" - diff = < - - - - - - - - - - - - + diff = < + + + + + + + + + + + + EOF # upload it @@ -1106,20 +1106,20 @@ EOF 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 = < - - - - - - - - - - - - + diff = < + + + + + + + + + + + + EOF # upload it @@ -1139,20 +1139,20 @@ EOF basic_authorization changeset.user.email, "test" - diff = < - - - - - - - - - - - - + diff = < + + + + + + + + + + + + EOF # upload it @@ -1163,20 +1163,20 @@ EOF 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 = < - - - - - - - - - - - - + diff = < + + + + + + + + + + + + EOF # upload it @@ -1342,19 +1342,19 @@ EOF changeset_id = @response.body.to_i # add a diff to it - diff = < - - - - - - - - - - - + diff = < + + + + + + + + + + + EOF # upload it @@ -1387,33 +1387,33 @@ EOF assert_response :success changeset_id = @response.body.to_i - diff = < - - - - - - - - - - - - - - - - - - - - - - - - - + diff = < + + + + + + + + + + + + + + + + + + + + + + + + + OSMFILE # upload it @@ -1450,26 +1450,26 @@ OSMFILE changeset_id = @response.body.to_i # add a diff to it - diff = < - - - - - - - - - - - - - - - - - - + diff = < + + + + + + + + + + + + + + + + + + EOF # upload it diff --git a/test/controllers/geocoder_controller_test.rb b/test/controllers/geocoder_controller_test.rb index 57d5a10f1..c64efa4e5 100644 --- a/test/controllers/geocoder_controller_test.rb +++ b/test/controllers/geocoder_controller_test.rb @@ -253,7 +253,7 @@ class GeocoderControllerTest < ActionController::TestCase ].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 @@ -269,20 +269,20 @@ class GeocoderControllerTest < ActionController::TestCase "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 ## @@ -467,7 +467,7 @@ class GeocoderControllerTest < ActionController::TestCase 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] @@ -476,7 +476,7 @@ class GeocoderControllerTest < ActionController::TestCase 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] diff --git a/test/controllers/relation_controller_test.rb b/test/controllers/relation_controller_test.rb index 7dfc58dec..6aafa3aab 100644 --- a/test/controllers/relation_controller_test.rb +++ b/test/controllers/relation_controller_test.rb @@ -741,15 +741,15 @@ class RelationControllerTest < ActionController::TestCase basic_authorization(user.email, "test") - doc_str = < - - - - - - - + doc_str = < + + + + + + + OSM doc = XML::Parser.string(doc_str).parse @@ -801,15 +801,15 @@ OSM node1 = create(:node) node2 = create(:node) - doc_str = < - - - - - - - + doc_str = < + + + + + + + OSM doc = XML::Parser.string(doc_str).parse @@ -844,15 +844,15 @@ OSM node3 = create(:node) node4 = create(:node) - doc_str = < - - - - - - - + doc_str = < + + + + + + + OSM doc = XML::Parser.string(doc_str).parse basic_authorization(user.email, "test") diff --git a/test/controllers/trace_controller_test.rb b/test/controllers/trace_controller_test.rb index 9821352e1..bac53e74c 100644 --- a/test/controllers/trace_controller_test.rb +++ b/test/controllers/trace_controller_test.rb @@ -539,7 +539,7 @@ class TraceControllerTest < ActionController::TestCase 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 @@ -817,7 +817,7 @@ class TraceControllerTest < ActionController::TestCase 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 @@ -835,7 +835,7 @@ class TraceControllerTest < ActionController::TestCase 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 @@ -854,7 +854,7 @@ class TraceControllerTest < ActionController::TestCase 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 diff --git a/test/helpers/application_helper_test.rb b/test/helpers/application_helper_test.rb index 0cb1b5ad9..720113e65 100644 --- a/test/helpers/application_helper_test.rb +++ b/test/helpers/application_helper_test.rb @@ -10,7 +10,7 @@ class ApplicationHelperTest < ActionView::TestCase 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) @@ -22,7 +22,7 @@ class ApplicationHelperTest < ActionView::TestCase assert_dom_equal "Test #{link} 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) diff --git a/test/helpers/browse_helper_test.rb b/test/helpers/browse_helper_test.rb index 4031c3de1..277433356 100644 --- a/test/helpers/browse_helper_test.rb +++ b/test/helpers/browse_helper_test.rb @@ -145,24 +145,24 @@ class BrowseHelperTest < ActionView::TestCase 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 diff --git a/test/helpers/title_helper_test.rb b/test/helpers/title_helper_test.rb index 523313eaf..7d8355430 100644 --- a/test/helpers/title_helper_test.rb +++ b/test/helpers/title_helper_test.rb @@ -1,4 +1,5 @@ # coding: utf-8 + require "test_helper" class TitleHelperTest < ActionView::TestCase diff --git a/test/integration/page_locale_test.rb b/test/integration/page_locale_test.rb index fffe83acc..c5e0d0ae3 100644 --- a/test/integration/page_locale_test.rb +++ b/test/integration/page_locale_test.rb @@ -20,7 +20,7 @@ class PageLocaleTest < ActionDispatch::IntegrationTest 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 diff --git a/test/lib/bounding_box_test.rb b/test/lib/bounding_box_test.rb index dc62531f5..dda8b0e67 100644 --- a/test/lib/bounding_box_test.rb +++ b/test/lib/bounding_box_test.rb @@ -19,20 +19,20 @@ class BoundingBoxTest < ActiveSupport::TestCase @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]] diff --git a/test/lib/i18n_test.rb b/test/lib/i18n_test.rb index c18c2f346..3ead036eb 100644 --- a/test/lib/i18n_test.rb +++ b/test/lib/i18n_test.rb @@ -49,7 +49,7 @@ class I18nTest < ActiveSupport::TestCase 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 diff --git a/test/models/changeset_comment_test.rb b/test/models/changeset_comment_test.rb index 0999ea505..a7eafbef5 100644 --- a/test/models/changeset_comment_test.rb +++ b/test/models/changeset_comment_test.rb @@ -37,8 +37,8 @@ class ChangesetCommentTest < ActiveSupport::TestCase 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"] diff --git a/test/models/language_test.rb b/test/models/language_test.rb index 9b2ef72c1..f6a6e3234 100644 --- a/test/models/language_test.rb +++ b/test/models/language_test.rb @@ -1,4 +1,5 @@ # coding: utf-8 + require "test_helper" class LanguageTest < ActiveSupport::TestCase diff --git a/test/models/message_test.rb b/test/models/message_test.rb index 84c466649..0c0f0e3eb 100644 --- a/test/models/message_test.rb +++ b/test/models/message_test.rb @@ -65,10 +65,8 @@ class MessageTest < 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 diff --git a/test/models/note_comment_test.rb b/test/models/note_comment_test.rb index 6f3d6c3aa..6bda0ee7d 100644 --- a/test/models/note_comment_test.rb +++ b/test/models/note_comment_test.rb @@ -3,8 +3,8 @@ require "test_helper" 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) @@ -20,8 +20,8 @@ class NoteCommentTest < ActiveSupport::TestCase 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"] diff --git a/test/models/note_test.rb b/test/models/note_test.rb index 847efe97c..0abd0136e 100644 --- a/test/models/note_test.rb +++ b/test/models/note_test.rb @@ -3,8 +3,8 @@ require "test_helper" 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) diff --git a/test/models/user_test.rb b/test/models/user_test.rb index 387c75ec9..57c136475 100644 --- a/test/models/user_test.rb +++ b/test/models/user_test.rb @@ -11,9 +11,9 @@ class UserTest < ActiveSupport::TestCase 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 @@ -45,10 +45,10 @@ class UserTest < ActiveSupport::TestCase 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) @@ -217,13 +217,13 @@ class UserTest < ActiveSupport::TestCase 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? -- 2.43.2