]> git.openstreetmap.org Git - rails.git/commitdiff
Merge branch 'rails41'
authorTom Hughes <tom@compton.nu>
Mon, 21 Jul 2014 07:53:44 +0000 (08:53 +0100)
committerTom Hughes <tom@compton.nu>
Mon, 21 Jul 2014 07:53:44 +0000 (08:53 +0100)
29 files changed:
Gemfile
Gemfile.lock
app/controllers/changeset_controller.rb
app/controllers/trace_controller.rb
app/controllers/user_preference_controller.rb
app/helpers/browse_helper.rb
app/models/trace.rb
app/models/user.rb
config.ru
config/application.rb
config/boot.rb
config/environment.rb
config/environments/development.rb
config/environments/production.rb
config/environments/test.rb
config/initializers/assets.rb [new file with mode: 0644]
config/initializers/cookies_serializer.rb [new file with mode: 0644]
config/initializers/postgresql_adapter.rb
config/initializers/secret_token.rb [deleted file]
config/initializers/session_store.rb
config/secrets.yml [new file with mode: 0644]
lib/migrate.rb
test/controllers/trace_controller_test.rb
test/controllers/user_blocks_controller_test.rb
test/controllers/user_preference_controller_test.rb
test/helpers/application_helper_test.rb
test/helpers/browse_helper_test.rb
test/models/trace_test.rb
test/models/user_test.rb

diff --git a/Gemfile b/Gemfile
index 0cdf8ce7fd3d6907edc66ca5c44468228845e4fb..e1874a6b0f07ee00585080c854626ec54b840b91 100644 (file)
--- a/Gemfile
+++ b/Gemfile
@@ -1,7 +1,7 @@
-source 'http://rubygems.org'
+source 'https://rubygems.org'
 
 # Require rails
-gem 'rails', '4.0.5'
+gem 'rails', '4.1.4'
 
 # Require things which have moved to gems in ruby 1.9
 gem 'bigdecimal', "~> 1.1.0", :platforms => :ruby_19
@@ -16,7 +16,7 @@ gem 'json'
 gem 'pg'
 
 # Use SCSS for stylesheets
-gem 'sass-rails', '~> 4.0.0'
+gem 'sass-rails', '~> 4.0.3'
 
 # Use Uglifier as compressor for JavaScript assets
 gem 'uglifier', '>= 1.3.0'
@@ -41,7 +41,7 @@ gem 'rinku', '>= 1.2.2', :require => 'rails_rinku'
 gem 'oauth-plugin', '>= 0.5.1'
 gem 'open_id_authentication', '>= 1.1.0'
 gem 'validates_email_format_of', '>= 1.5.1'
-gem 'composite_primary_keys', '>= 6.0.1'
+gem 'composite_primary_keys', '~> 7.0.3'
 gem 'http_accept_language', '~> 2.0.0'
 gem 'paperclip', '~> 4.0'
 gem 'deadlock_retry', '>= 1.2.0'
@@ -84,7 +84,7 @@ end
 # Gems needed for running tests
 group :test do
   gem 'timecop'
-  gem 'minitest', '~> 4.7.0', :platforms => [:ruby_19, :ruby_20]
+  gem 'minitest', '~> 5.1', :platforms => [:ruby_19, :ruby_20]
 end
 
 # Needed in development as well so rake can see konacha tasks
index fc2d4f54be3bd967bd64696e16f5c7850fe9ef6b..3bd4682a4d032044c88cd68641fd391de0dc8c71 100644 (file)
@@ -1,37 +1,39 @@
 GEM
-  remote: http://rubygems.org/
+  remote: https://rubygems.org/
   specs:
     SystemTimer (1.2.3)
-    actionmailer (4.0.5)
-      actionpack (= 4.0.5)
+    actionmailer (4.1.4)
+      actionpack (= 4.1.4)
+      actionview (= 4.1.4)
       mail (~> 2.5.4)
-    actionpack (4.0.5)
-      activesupport (= 4.0.5)
-      builder (~> 3.1.0)
-      erubis (~> 2.7.0)
+    actionpack (4.1.4)
+      actionview (= 4.1.4)
+      activesupport (= 4.1.4)
       rack (~> 1.5.2)
       rack-test (~> 0.6.2)
     actionpack-page_caching (1.0.2)
       actionpack (>= 4.0.0, < 5)
-    activemodel (4.0.5)
-      activesupport (= 4.0.5)
-      builder (~> 3.1.0)
-    activerecord (4.0.5)
-      activemodel (= 4.0.5)
-      activerecord-deprecated_finders (~> 1.0.2)
-      activesupport (= 4.0.5)
-      arel (~> 4.0.0)
-    activerecord-deprecated_finders (1.0.3)
-    activesupport (4.0.5)
+    actionview (4.1.4)
+      activesupport (= 4.1.4)
+      builder (~> 3.1)
+      erubis (~> 2.7.0)
+    activemodel (4.1.4)
+      activesupport (= 4.1.4)
+      builder (~> 3.1)
+    activerecord (4.1.4)
+      activemodel (= 4.1.4)
+      activesupport (= 4.1.4)
+      arel (~> 5.0.0)
+    activesupport (4.1.4)
       i18n (~> 0.6, >= 0.6.9)
-      minitest (~> 4.2)
-      multi_json (~> 1.3)
+      json (~> 1.7, >= 1.7.7)
+      minitest (~> 5.1)
       thread_safe (~> 0.1)
-      tzinfo (~> 0.3.37)
-    arel (4.0.2)
+      tzinfo (~> 1.1)
+    arel (5.0.1.20140414130214)
     bigdecimal (1.1.0)
-    builder (3.1.4)
-    capybara (2.2.1)
+    builder (3.2.2)
+    capybara (2.4.1)
       mime-types (>= 1.16)
       nokogiri (>= 1.3.3)
       rack (>= 1.0.0)
@@ -49,23 +51,24 @@ GEM
       coffee-script-source
       execjs
     coffee-script-source (1.7.0)
-    colorize (0.7.2)
-    composite_primary_keys (6.0.3)
-      activerecord (>= 4.0.0)
-    dalli (2.7.1)
+    colorize (0.7.3)
+    composite_primary_keys (7.0.3)
+      activerecord (~> 4.1.4)
+    crass (0.2.0)
+    dalli (2.7.2)
     deadlock_retry (1.2.0)
     dynamic_form (1.1.4)
     erubis (2.7.0)
-    execjs (2.0.2)
+    execjs (2.2.1)
     faraday (0.9.0)
       multipart-post (>= 1.2, < 3)
     hike (1.2.3)
-    htmlentities (4.3.1)
+    htmlentities (4.3.2)
     http_accept_language (2.0.1)
-    httpclient (2.3.4.1)
+    httpclient (2.4.0)
     i18n (0.6.9)
     iconv (0.1)
-    jquery-rails (3.1.0)
+    jquery-rails (3.1.1)
       railties (>= 3.0, < 5.0)
       thor (>= 0.14, < 2.0)
     json (1.8.1)
@@ -74,10 +77,9 @@ GEM
     jsonify-rails (0.3.2)
       actionpack
       jsonify (< 0.4.0)
-    jwt (0.1.13)
-      multi_json (>= 1.5)
+    jwt (1.0.0)
     kgio (2.9.2)
-    konacha (3.2.2)
+    konacha (3.2.3)
       actionpack (>= 3.1, < 5)
       capybara
       colorize
@@ -88,22 +90,24 @@ GEM
       mime-types (~> 1.16)
       treetop (~> 1.4.8)
     mime-types (1.25.1)
-    mini_portile (0.5.3)
-    minitest (4.7.5)
-    multi_json (1.10.0)
+    mini_portile (0.6.0)
+    minitest (5.3.5)
+    multi_json (1.10.1)
     multi_xml (0.5.5)
     multipart-post (2.0.0)
-    nokogiri (1.6.1)
-      mini_portile (~> 0.5.0)
+    nokogiri (1.6.2.1)
+      mini_portile (= 0.6.0)
+    nokogumbo (1.1.9)
+      nokogiri
     oauth (0.4.7)
     oauth-plugin (0.5.1)
       multi_json
       oauth (~> 0.4.4)
       oauth2 (>= 0.5.0)
       rack
-    oauth2 (0.9.3)
+    oauth2 (0.9.4)
       faraday (>= 0.8, < 0.10)
-      jwt (~> 0.1.8)
+      jwt (~> 1.0)
       multi_json (~> 1.3)
       multi_xml (~> 0.5)
       rack (~> 1.2)
@@ -117,14 +121,14 @@ GEM
       cocaine (~> 0.5.3)
       mime-types
     pg (0.17.1)
-    poltergeist (1.5.0)
+    poltergeist (1.5.1)
       capybara (~> 2.1)
       cliver (~> 0.3.1)
       multi_json (~> 1.0)
       websocket-driver (>= 0.2.0)
-    polyglot (0.3.4)
+    polyglot (0.3.5)
     psych (2.0.5)
-    r2 (0.2.3)
+    r2 (0.2.5)
     rack (1.5.2)
     rack-cors (0.2.9)
     rack-openid (1.4.2)
@@ -132,28 +136,32 @@ GEM
       ruby-openid (>= 2.1.8)
     rack-test (0.6.2)
       rack (>= 1.0)
-    rails (4.0.5)
-      actionmailer (= 4.0.5)
-      actionpack (= 4.0.5)
-      activerecord (= 4.0.5)
-      activesupport (= 4.0.5)
+    rails (4.1.4)
+      actionmailer (= 4.1.4)
+      actionpack (= 4.1.4)
+      actionview (= 4.1.4)
+      activemodel (= 4.1.4)
+      activerecord (= 4.1.4)
+      activesupport (= 4.1.4)
       bundler (>= 1.3.0, < 2.0)
-      railties (= 4.0.5)
-      sprockets-rails (~> 2.0.0)
+      railties (= 4.1.4)
+      sprockets-rails (~> 2.0)
     rails-i18n (4.0.2)
       i18n (~> 0.6)
       rails (>= 4.0)
-    railties (4.0.5)
-      actionpack (= 4.0.5)
-      activesupport (= 4.0.5)
+    railties (4.1.4)
+      actionpack (= 4.1.4)
+      activesupport (= 4.1.4)
       rake (>= 0.8.7)
       thor (>= 0.18.1, < 2.0)
-    rake (10.3.1)
-    redcarpet (3.1.1)
+    rake (10.3.2)
+    redcarpet (3.1.2)
     rinku (1.7.3)
     ruby-openid (2.5.0)
-    sanitize (2.1.0)
+    sanitize (3.0.0)
+      crass (~> 0.2.0)
       nokogiri (>= 1.4.4)
+      nokogumbo (= 1.1.9)
     sass (3.2.19)
     sass-rails (4.0.3)
       railties (>= 4.0.0, < 5.0)
@@ -166,23 +174,24 @@ GEM
       multi_json (~> 1.0)
       rack (~> 1.0)
       tilt (~> 1.1, != 1.3.0)
-    sprockets-rails (2.0.1)
+    sprockets-rails (2.1.3)
       actionpack (>= 3.0)
       activesupport (>= 3.0)
       sprockets (~> 2.8)
     thor (0.19.1)
-    thread_safe (0.3.3)
+    thread_safe (0.3.4)
     tilt (1.4.1)
     timecop (0.7.1)
     treetop (1.4.15)
       polyglot
       polyglot (>= 0.3.1)
-    tzinfo (0.3.39)
-    uglifier (2.5.0)
+    tzinfo (1.2.1)
+      thread_safe (~> 0.1)
+    uglifier (2.5.1)
       execjs (>= 0.3.0)
       json (>= 1.8.0)
     validates_email_format_of (1.5.3)
-    vendorer (0.1.15)
+    vendorer (0.1.16)
     websocket-driver (0.3.3)
     xpath (2.0.0)
       nokogiri (~> 1.3)
@@ -195,7 +204,7 @@ DEPENDENCIES
   actionpack-page_caching
   bigdecimal (~> 1.1.0)
   coffee-rails (~> 4.0.0)
-  composite_primary_keys (>= 6.0.1)
+  composite_primary_keys (~> 7.0.3)
   dalli
   deadlock_retry (>= 1.2.0)
   dynamic_form
@@ -209,7 +218,7 @@ DEPENDENCIES
   kgio
   konacha
   libxml-ruby (>= 2.0.5)
-  minitest (~> 4.7.0)
+  minitest (~> 5.1)
   oauth-plugin (>= 0.5.1)
   open_id_authentication (>= 1.1.0)
   openstreetmap-i18n-js (>= 3.0.0.rc5.3)
@@ -219,13 +228,13 @@ DEPENDENCIES
   psych
   r2
   rack-cors
-  rails (= 4.0.5)
+  rails (= 4.1.4)
   rails-i18n (~> 4.0.0)
   redcarpet
   rinku (>= 1.2.2)
   ruby-openid (>= 2.2.0)
   sanitize
-  sass-rails (~> 4.0.0)
+  sass-rails (~> 4.0.3)
   soap4r-ruby1.9
   timecop
   uglifier (>= 1.3.0)
index 735fa73a88c31a1820515aa9e4677011946be8b3..b236ba6b577b9e02a906d9a787ddf6e328f15203 100644 (file)
@@ -284,7 +284,7 @@ class ChangesetController < ApplicationController
       elsif params[:bbox]
         changesets = conditions_bbox(changesets, BoundingBox.from_bbox_params(params))
       elsif params[:friends] && @user
-        changesets = changesets.where(:user_id => @user.friend_users.public)
+        changesets = changesets.where(:user_id => @user.friend_users.identifiable)
       elsif params[:nearby] && @user
         changesets = changesets.where(:user_id => @user.nearby)
       end
index 9c4a9d8bd18952816f0f267aacec2d378a3a61fc..e1553cbb0f7ca399ed2b86b6a1fbcb7bda247eca 100644 (file)
@@ -49,13 +49,13 @@ class TraceController < ApplicationController
       if @user
         @traces = Trace.visible_to(@user) #1
       else
-        @traces = Trace.public #2
+        @traces = Trace.visible_to_all #2
       end
     else
       if @user and @user == target_user
         @traces = @user.traces #3 (check vs user id, so no join + can't pick up non-public traces by changing name)
       else
-        @traces = target_user.traces.public #4
+        @traces = target_user.traces.visible_to_all #4
       end
     end
 
@@ -206,7 +206,7 @@ class TraceController < ApplicationController
   end
 
   def georss
-    @traces = Trace.public.visible
+    @traces = Trace.visible_to_all.visible
 
     if params[:display_name]
       @traces = @traces.joins(:user).where(:users => {:display_name => params[:display_name]})
index 059f00bbe38b5a6656ba2d4d5f277bc6498aa872..a3face30d4d42af71750d4bf9ac77a038e3c2526 100644 (file)
@@ -26,7 +26,7 @@ class UserPreferenceController < ApplicationController
   ##
   # return the value for a single preference
   def read_one
-    pref = UserPreference.find(@user.id, params[:preference_key])
+    pref = UserPreference.find([@user.id, params[:preference_key]])
 
     render :text => pref.v.to_s, :content_type => "text/plain"
   end
@@ -69,7 +69,7 @@ class UserPreferenceController < ApplicationController
   # update the value of a single preference
   def update_one
     begin
-      pref = UserPreference.find(@user.id, params[:preference_key])
+      pref = UserPreference.find([@user.id, params[:preference_key]])
     rescue ActiveRecord::RecordNotFound 
       pref = UserPreference.new
       pref.user = @user
@@ -85,7 +85,7 @@ class UserPreferenceController < ApplicationController
   ##
   # delete a single preference
   def delete_one
-    UserPreference.find(@user.id, params[:preference_key]).delete
+    UserPreference.find([@user.id, params[:preference_key]]).delete
 
     render :text => "", :content_type => "text/plain"
   end
index 3574d454acade4b3b56631ebaa69ce2cc05c82ee..f4b332f7004fb44785f697fe42cd6b15d246c10d 100644 (file)
@@ -92,7 +92,7 @@ private
   ]
 
   def icon_tags(object)
-    object.tags.find_all { |k,v| ICON_TAGS.include? k }
+    object.tags.find_all { |k,v| ICON_TAGS.include? k }.sort
   end
 
   def wiki_link(type, lookup)
index df66496a2601381bc103a4fdd6f3c6e9ed82691b..bf8d3731b8e7709a348a7b469fdeef0afd52a7e3 100644 (file)
@@ -7,7 +7,7 @@ class Trace < ActiveRecord::Base
 
   scope :visible, -> { where(:visible => true) }
   scope :visible_to, ->(u) { visible.where("visibility IN ('public', 'identifiable') OR user_id = ?", u) }
-  scope :public, -> { where(:visibility => ["public", "identifiable"]) }
+  scope :visible_to_all, -> { where(:visibility => ["public", "identifiable"]) }
   scope :tagged, ->(t) { joins(:tags).where(:gpx_file_tags => { :tag => t }) }
 
   validates_presence_of :user_id, :name, :timestamp
index 81154fff7ad9dcabed5f7045da7b76b119046e68..010cdf464b3acf9a66858a8a91006e6ddb4720c4 100644 (file)
@@ -26,7 +26,7 @@ class User < ActiveRecord::Base
 
   scope :visible, -> { where(:status => ["pending", "active", "confirmed"]) }
   scope :active, -> { where(:status => ["active", "confirmed"]) }
-  scope :public, -> { where(:data_public => true) }
+  scope :identifiable, -> { where(:data_public => true) }
 
   has_attached_file :image,
     :default_url => "/assets/:class/:attachment/:style.png",
index 205abe3536eb70da0ef5fc25dbdace5e48e92a97..5bc2a619e83ea182b17e2507c5e0f2f07f7cf18c 100644 (file)
--- a/config.ru
+++ b/config.ru
@@ -1,4 +1,4 @@
 # This file is used by Rack-based servers to start the application.
 
 require ::File.expand_path('../config/environment',  __FILE__)
-run OpenStreetMap::Application
+run Rails.application
index 3cb01eabf0279340d9a663d3fb7e944a4734f3d5..a40336c3303dbe53065420e0c8c53c3bd060ccd8 100644 (file)
@@ -14,7 +14,7 @@ end
 
 # Require the gems listed in Gemfile, including any gems
 # you've limited to :test, :development, or :production.
-Bundler.require(:default, Rails.env)
+Bundler.require(*Rails.groups)
 
 module OpenStreetMap
   class Application < Rails::Application
@@ -33,9 +33,6 @@ module OpenStreetMap
     # Custom directories with classes and modules you want to be autoloadable.
     config.autoload_paths += %W(#{config.root}/lib)
 
-    # Configure the default encoding used in templates for Ruby 1.9.
-    config.encoding = "utf-8"
-
     # 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,
     # like if you have constraints or database-specific column types
@@ -43,12 +40,6 @@ module OpenStreetMap
       config.active_record.schema_format = :sql
     end
 
-    # Enable the asset pipeline
-    config.assets.enabled = true
-
-    # Version of your assets, change this if you want to expire all your assets
-    config.assets.version = '1.0'
-
     # Don't eager load models when the database is offline
     if STATUS == :database_offline
       config.paths["app/models"].skip_eager_load!
index 4489e58688ca642d8e0e9489f6896f49f9b89da6..5e5f0c1fac0bcde58936530ada4fd08abcaf5a64 100644 (file)
@@ -1,6 +1,4 @@
-require 'rubygems'
-
 # Set up gems listed in the Gemfile.
 ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
 
-require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
+require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
index b958021e8fe587a1b8f04c1f8640d5c71e99d9d4..ee8d90dc651948269f1b869953ff04774e737307 100644 (file)
@@ -1,5 +1,5 @@
-# Load the rails application
+# Load the Rails application.
 require File.expand_path('../application', __FILE__)
 
-# Initialize the rails application
-OpenStreetMap::Application.initialize!
+# Initialize the Rails application.
+Rails.application.initialize!
index 36696f8271c50b09f18ea2e3b56c2b546614abaf..a414d1490655db23aa4a00bb688b5a57664c2313 100644 (file)
@@ -19,11 +19,19 @@ OpenStreetMap::Application.configure do
   # Print deprecation notices to the Rails logger.
   config.active_support.deprecation = :log
 
-  # Raise an error on page load if there are pending migrations
+  # Raise an error on page load if there are pending migrations.
   config.active_record.migration_error = :page_load
 
   # Debug mode disables concatenation and preprocessing of assets.
   # This option may cause significant delays in view rendering with a large
   # number of complex assets.
   config.assets.debug = true
+
+  # Adds additional error checking when serving assets at runtime.
+  # Checks for improperly declared sprockets dependencies.
+  # Raises helpful error messages.
+  config.assets.raise_runtime_errors = true
+
+  # Raises error for missing translations
+  # config.action_view.raise_on_missing_translations = true
 end
index c4910d86f1b6f555b7ecbe727b6847b6cb7fcc6e..2b1587a21263813ad5dc780bf568e1c7f88eaa84 100644 (file)
@@ -5,7 +5,7 @@ OpenStreetMap::Application.configure do
   config.cache_classes = true
 
   # Eager load code on boot. This eager loads most of Rails and
-  # your application in memory, allowing both thread web servers
+  # your application in memory, allowing both threaded web servers
   # and those relying on copy on write to perform better.
   # Rake tasks automatically ignore this option for performance.
   config.eager_load = true
@@ -32,9 +32,6 @@ OpenStreetMap::Application.configure do
   # Generate digests for assets URLs.
   config.assets.digest = true
 
-  # Version of your assets, change this if you want to expire all your assets.
-  config.assets.version = '1.0'
-
   # Specifies the header that your server uses for sending files.
   # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
   # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
@@ -67,24 +64,7 @@ OpenStreetMap::Application.configure do
   # Enable serving of images, stylesheets, and JavaScripts from an asset server.
   # config.action_controller.asset_host = "http://assets.example.com"
 
-  # Precompile additional assets.
-  # application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
-  config.assets.precompile += %w( index.js browse.js welcome.js fixthemap.js )
-  config.assets.precompile += %w( user.js diary_entry.js swfobject.js )
-  config.assets.precompile += %w( large-ltr.css small-ltr.css print-ltr.css )
-  config.assets.precompile += %w( large-rtl.css small-rtl.css print-rtl.css )
-  config.assets.precompile += %w( leaflet-all.css leaflet.ie.css )
-  config.assets.precompile += %w( embed.js embed.css )
-  config.assets.precompile += %w( html5shiv.js )
-  config.assets.precompile += %w( images/marker-*.png img/*-handle.png )
-  config.assets.precompile += %w( potlatch2.swf )
-  config.assets.precompile += %w( potlatch2/assets.zip )
-  config.assets.precompile += %w( potlatch2/FontLibrary.swf )
-  config.assets.precompile += %w( potlatch2/locales/*.swf )
-  config.assets.precompile += %w( help/introduction.* )
-  config.assets.precompile += %w( iD.js iD.css )
-  config.assets.precompile += %w( iD/img/*.svg iD/img/*.png iD/img/*.gif )
-  config.assets.precompile += %w( iD/img/pattern/*.png )
+  # `config.assets.precompile` has moved to config/initializers/assets.rb
 
   # Ignore bad email addresses and do not raise email delivery errors.
   # Set this to true and configure the email server for immediate delivery to raise delivery errors.
@@ -102,4 +82,7 @@ OpenStreetMap::Application.configure do
 
   # Use default logging formatter so that PID and timestamp are not suppressed.
   config.log_formatter = ::Logger::Formatter.new
+
+  # Do not dump schema after migrations.
+  config.active_record.dump_schema_after_migration = false
 end
index ebbda583634ad7b3c1694f188a9b41b14f2c3e2f..b0ff645a0195d9813dbc3139a0ae658f29fbfa94 100644 (file)
@@ -14,7 +14,7 @@ OpenStreetMap::Application.configure do
 
   # Configure static asset server for tests with Cache-Control for performance.
   config.serve_static_assets  = true
-  config.static_cache_control = "public, max-age=3600"
+  config.static_cache_control = 'public, max-age=3600'
 
   # Show full error reports and disable caching.
   config.consider_all_requests_local       = true
@@ -33,4 +33,7 @@ OpenStreetMap::Application.configure do
 
   # Print deprecation notices to the stderr.
   config.active_support.deprecation = :stderr
+
+  # Raises error for missing translations
+  # config.action_view.raise_on_missing_translations = true
 end
diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb
new file mode 100644 (file)
index 0000000..fd6d1e4
--- /dev/null
@@ -0,0 +1,23 @@
+# Be sure to restart your server when you modify this file.
+
+# Version of your assets, change this if you want to expire all your assets.
+Rails.application.config.assets.version = '1.0'
+
+# 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 diary_entry.js swfobject.js )
+Rails.application.config.assets.precompile += %w( large-ltr.css small-ltr.css print-ltr.css )
+Rails.application.config.assets.precompile += %w( large-rtl.css small-rtl.css print-rtl.css )
+Rails.application.config.assets.precompile += %w( leaflet-all.css leaflet.ie.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( 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.js iD.css )
+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 )
diff --git a/config/initializers/cookies_serializer.rb b/config/initializers/cookies_serializer.rb
new file mode 100644 (file)
index 0000000..7a06a89
--- /dev/null
@@ -0,0 +1,3 @@
+# Be sure to restart your server when you modify this file.
+
+Rails.application.config.action_dispatch.cookies_serializer = :json
\ No newline at end of file
index 012e401d2436478ccbc4d07daefb777c3bc83dda..9dcc34fcc05e0706fb2400dec008068cff458b56 100644 (file)
@@ -2,7 +2,7 @@ if defined?(ActiveRecord::ConnectionAdapters::PostgreSQLAdapter)
   module ActiveRecord
     module ConnectionAdapters
       class PostgreSQLAdapter
-        def initialize_type_map_with_enums
+        def initialize_type_map_with_enums(type_map)
           OID.alias_type "format_enum", "text"
           OID.alias_type "gpx_visibility_enum", "text"
           OID.alias_type "note_status_enum", "text"
@@ -11,7 +11,7 @@ if defined?(ActiveRecord::ConnectionAdapters::PostgreSQLAdapter)
           OID.alias_type "user_role_enum", "text"
           OID.alias_type "user_status_enum", "text"
 
-          initialize_type_map_without_enums
+          initialize_type_map_without_enums(type_map)
         end
 
         alias_method_chain :initialize_type_map, :enums
diff --git a/config/initializers/secret_token.rb b/config/initializers/secret_token.rb
deleted file mode 100644 (file)
index ac761ae..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-# Be sure to restart your server when you modify this file.
-
-# Your secret key is used for verifying the integrity of signed cookies.
-# If you change this key, all old signed cookies will become invalid!
-
-# Make sure the secret is at least 30 characters and all random,
-# no regular words or you'll be exposed to dictionary attacks.
-# You can use `rake secret` to generate a secure secret key.
-
-# Make sure your secret_key_base is kept private
-# if you're sharing your code publicly.
-OpenStreetMap::Application.config.secret_key_base = '8be565e2e25831d88231f4bcfd83dfc3ab33957c4f33bb3cff7a279f7820ec4d0c1111f246bb347c68859c0b46b4e591be9179a53a5a7165a9936000d6d2be41'
index 17173d536612fdbba32887b1d766a651e3ffee45..97886ab3e3cf6a639a9c8e337504da417a1e42d0 100644 (file)
@@ -1,7 +1,7 @@
 # Be sure to restart your server when you modify this file.
 
 if defined?(MEMCACHE_SERVERS)
-  OpenStreetMap::Application.config.session_store :mem_cache_store, :memcache_server => MEMCACHE_SERVERS, :namespace => "rails:session", :key => "_osm_session"
+  Rails.application.config.session_store :mem_cache_store, :memcache_server => MEMCACHE_SERVERS, :namespace => "rails:session", :key => "_osm_session"
 else
-  OpenStreetMap::Application.config.session_store :cache_store, :key => '_osm_session'
+  Rails.application.config.session_store :cache_store, :key => '_osm_session'
 end
diff --git a/config/secrets.yml b/config/secrets.yml
new file mode 100644 (file)
index 0000000..253f2be
--- /dev/null
@@ -0,0 +1,22 @@
+# Be sure to restart your server when you modify this file.
+
+# Your secret key is used for verifying the integrity of signed cookies.
+# If you change this key, all old signed cookies will become invalid!
+
+# Make sure the secret is at least 30 characters and all random,
+# no regular words or you'll be exposed to dictionary attacks.
+# You can use `rake secret` to generate a secure secret key.
+
+# Make sure the secrets in this file are kept private
+# if you're sharing your code publicly.
+
+development:
+  secret_key_base: 1ce5ed17771b4fdc3f755c5b98459d67816f99ec5889ec2fa7bf2bd3cba3ad5cc453693ce3c5d121669be478fb811136f4f483e6f39ac1f0e34ba66e8acab574
+
+test:
+  secret_key_base: 10d52b1bf88c429e73ffbc5e5f58b037db21f38ea88b8b454e55d52ed8bcc6e7fe3b48a79b2f36eb78a4685224d707767d083f79c51f7d81a9d4a06d1c1e2534
+
+# Do not keep production secrets in the repository,
+# instead read values from the environment.
+production:
+  secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
index 7c14333b30af91f0ad23b6f690d65d5852d11abb..7f8d33693d921eb746660fbe0642bd3026268089 100644 (file)
@@ -1,48 +1,50 @@
 module ActiveRecord
   module ConnectionAdapters
-    module SchemaStatements
-      def quote_column_names(column_name)
-        Array(column_name).map { |e| quote_column_name(e) }.join(", ")
-      end
-
-      def add_primary_key(table_name, column_name, options = {})
-        column_names = Array(column_name)
-        quoted_column_names = column_names.map { |e| quote_column_name(e) }.join(", ")
-        execute "ALTER TABLE #{table_name} ADD PRIMARY KEY (#{quoted_column_names})"
-      end
+    class PostgreSQLAdapter
+      class SchemaCreation
+        alias_method :old_add_column_options!, :add_column_options!
 
-      def remove_primary_key(table_name)
-        execute "ALTER TABLE #{table_name} DROP PRIMARY KEY"
+        def add_column_options!(sql, options)
+          sql << " UNSIGNED" if options[:unsigned]
+          old_add_column_options!(sql, options)
+          sql << " #{options[:options]}"
+        end
       end
 
-      def add_foreign_key(table_name, column_name, reftbl, refcol = nil)
-        execute "ALTER TABLE #{table_name} ADD " +
-          "FOREIGN KEY (#{quote_column_names(column_name)}) " +
-          "REFERENCES #{reftbl} (#{quote_column_names(refcol || column_name)})"
-      end
+      module SchemaStatements
+        def quote_column_names(column_name)
+          Array(column_name).map { |e| quote_column_name(e) }.join(", ")
+        end
 
-      def remove_foreign_key(table_name, column_name, reftbl, refcol = nil)
-        execute "ALTER TABLE #{table_name} DROP " +
-          "CONSTRAINT #{table_name}_#{column_name[0]}_fkey"
-      end
+        def add_primary_key(table_name, column_name, options = {})
+          column_names = Array(column_name)
+          quoted_column_names = column_names.map { |e| quote_column_name(e) }.join(", ")
+          execute "ALTER TABLE #{table_name} ADD PRIMARY KEY (#{quoted_column_names})"
+        end
 
-      alias_method :old_options_include_default?, :options_include_default?
+        def remove_primary_key(table_name)
+          execute "ALTER TABLE #{table_name} DROP PRIMARY KEY"
+        end
 
-      def options_include_default?(options)
-        return false if options[:options] =~ /AUTO_INCREMENT/i
-        return old_options_include_default?(options)
-      end
+        def add_foreign_key(table_name, column_name, reftbl, refcol = nil)
+          execute "ALTER TABLE #{table_name} ADD " +
+            "FOREIGN KEY (#{quote_column_names(column_name)}) " +
+            "REFERENCES #{reftbl} (#{quote_column_names(refcol || column_name)})"
+        end
 
-      alias_method :old_add_column_options!, :add_column_options!
+        def remove_foreign_key(table_name, column_name, reftbl, refcol = nil)
+          execute "ALTER TABLE #{table_name} DROP " +
+            "CONSTRAINT #{table_name}_#{column_name[0]}_fkey"
+        end
 
-      def add_column_options!(sql, options)
-        sql << " UNSIGNED" if options[:unsigned]
-        old_add_column_options!(sql, options)
-        sql << " #{options[:options]}"
+#        alias_method :old_options_include_default?, :options_include_default?
+#
+#        def options_include_default?(options)
+#          return false if options[:options] =~ /AUTO_INCREMENT/i
+#          return old_options_include_default?(options)
+#        end
       end
-    end
 
-    class PostgreSQLAdapter
       alias_method :old_native_database_types, :native_database_types
 
       def native_database_types
index 8cbc14b3164fd86342919505817cac618c7695da..68cacdce3695a9443e46459f7c5082a9c776be7e 100644 (file)
@@ -163,10 +163,10 @@ class TraceControllerTest < ActionController::TestCase
   # Check that the list of changesets is displayed
   def test_list
     get :list
-    check_trace_list Trace.public
+    check_trace_list Trace.visible_to_all
 
     get :list, :tag => "London"
-    check_trace_list Trace.tagged("London").public
+    check_trace_list Trace.tagged("London").visible_to_all
   end
 
   # Check that I can get mine
@@ -188,15 +188,15 @@ class TraceControllerTest < ActionController::TestCase
   def test_list_user
     # Test a user with no traces
     get :list, :display_name => users(:second_public_user).display_name
-    check_trace_list users(:second_public_user).traces.public
+    check_trace_list users(:second_public_user).traces.visible_to_all
 
     # Test a user with some traces - should see only public ones
     get :list, :display_name => users(:public_user).display_name
-    check_trace_list users(:public_user).traces.public
+    check_trace_list users(:public_user).traces.visible_to_all
 
     # Should still see only public ones when authenticated as another user
     get :list, {:display_name => users(:public_user).display_name}, {:user => users(:normal_user).id}
-    check_trace_list users(:public_user).traces.public
+    check_trace_list users(:public_user).traces.visible_to_all
 
     # Should see all traces when authenticated as the target user
     get :list, {:display_name => users(:public_user).display_name}, {:user => users(:public_user).id}
@@ -210,16 +210,16 @@ class TraceControllerTest < ActionController::TestCase
   # Check that the rss loads
   def test_rss
     get :georss, :format => :rss
-    check_trace_feed Trace.public
+    check_trace_feed Trace.visible_to_all
 
     get :georss, :tag => "London", :format => :rss
-    check_trace_feed Trace.tagged("London").public
+    check_trace_feed Trace.tagged("London").visible_to_all
 
     get :georss, :display_name => users(:public_user).display_name, :format => :rss
-    check_trace_feed users(:public_user).traces.public
+    check_trace_feed users(:public_user).traces.visible_to_all
 
     get :georss, :display_name => users(:public_user).display_name, :tag => "Birmingham", :format => :rss
-    check_trace_feed users(:public_user).traces.tagged("Birmingham").public
+    check_trace_feed users(:public_user).traces.tagged("Birmingham").visible_to_all
   end
 
   # Test viewing a trace
index ffb5744ea25a510ef1f36fae293e826829b960b1..717f1167a20a2a501a083658a89de73c97abd9ea 100644 (file)
@@ -223,9 +223,10 @@ class UserBlocksControllerTest < ActionController::TestCase
         :user_block_period => "12",
         :user_block => { :needs_view => false, :reason => "Vandalism" }
     end
-    assert_redirected_to user_block_path(:id => 4)
+    id = UserBlock.order(:id).ids.last
+    assert_redirected_to user_block_path(:id => id)
     assert_equal "Created a block on user #{users(:unblocked_user).display_name}.", flash[:notice]
-    b = UserBlock.find(4)
+    b = UserBlock.find(id)
     assert_in_delta Time.now, b.created_at, 1
     assert_in_delta Time.now, b.updated_at, 1
     assert_in_delta Time.now + 12.hour, b.ends_at, 1
index f8cafe6a9279a46ed3b7e942b951f3a480055cc5..4966ae7485051fdeb6a02a7a4f04b31d94823caf 100644 (file)
@@ -92,10 +92,10 @@ class UserPreferenceControllerTest < ActionController::TestCase
       put :update
     end
     assert_response :unauthorized, "should be authenticated"
-    assert_equal "value", UserPreference.find(1, "key").v
-    assert_equal "some_value", UserPreference.find(1, "some_key").v
+    assert_equal "value", UserPreference.find([1, "key"]).v
+    assert_equal "some_value", UserPreference.find([1, "some_key"]).v
     assert_raises ActiveRecord::RecordNotFound do
-      UserPreference.find(1, "new_key")
+      UserPreference.find([1, "new_key"])
     end
 
     # authenticate as a user with preferences
@@ -109,10 +109,10 @@ class UserPreferenceControllerTest < ActionController::TestCase
     assert_response :success
     assert_equal "text/plain", @response.content_type
     assert_equal "", @response.body
-    assert_equal "new_value", UserPreference.find(1, "key").v
-    assert_equal "value", UserPreference.find(1, "new_key").v
+    assert_equal "new_value", UserPreference.find([1, "key"]).v
+    assert_equal "value", UserPreference.find([1, "new_key"]).v
     assert_raises ActiveRecord::RecordNotFound do
-      UserPreference.find(1, "some_key")
+      UserPreference.find([1, "some_key"])
     end
 
     # try a put with duplicate keys
@@ -123,7 +123,7 @@ class UserPreferenceControllerTest < ActionController::TestCase
     assert_response :bad_request
     assert_equal "text/plain", @response.content_type
     assert_equal "Duplicate preferences with key key", @response.body
-    assert_equal "new_value", UserPreference.find(1, "key").v
+    assert_equal "new_value", UserPreference.find([1, "key"]).v
 
     # try a put with invalid content
     assert_no_difference "UserPreference.count" do
@@ -143,7 +143,7 @@ class UserPreferenceControllerTest < ActionController::TestCase
     end
     assert_response :unauthorized, "should be authenticated"
     assert_raises ActiveRecord::RecordNotFound do
-      UserPreference.find(1, "new_key")
+      UserPreference.find([1, "new_key"])
     end
 
     # authenticate as a user with preferences
@@ -157,7 +157,7 @@ class UserPreferenceControllerTest < ActionController::TestCase
     assert_response :success
     assert_equal "text/plain", @response.content_type
     assert_equal "", @response.body
-    assert_equal "new_value", UserPreference.find(1, "new_key").v
+    assert_equal "new_value", UserPreference.find([1, "new_key"]).v
 
     # try changing the value of a preference
     assert_no_difference "UserPreference.count" do
@@ -167,7 +167,7 @@ class UserPreferenceControllerTest < ActionController::TestCase
     assert_response :success
     assert_equal "text/plain", @response.content_type
     assert_equal "", @response.body
-    assert_equal "newer_value", UserPreference.find(1, "new_key").v
+    assert_equal "newer_value", UserPreference.find([1, "new_key"]).v
   end
 
   ##
@@ -178,7 +178,7 @@ class UserPreferenceControllerTest < ActionController::TestCase
       delete :delete_one, :preference_key => "key"
     end
     assert_response :unauthorized, "should be authenticated"
-    assert_equal "value", UserPreference.find(1, "key").v
+    assert_equal "value", UserPreference.find([1, "key"]).v
 
     # authenticate as a user with preferences
     basic_authorization("test@openstreetmap.org", "test")
@@ -191,7 +191,7 @@ class UserPreferenceControllerTest < ActionController::TestCase
     assert_equal "text/plain", @response.content_type
     assert_equal "", @response.body
     assert_raises ActiveRecord::RecordNotFound do
-      UserPreference.find(1, "key")
+      UserPreference.find([1, "key"])
     end
 
     # try the delete again for the same key
@@ -200,7 +200,7 @@ class UserPreferenceControllerTest < ActionController::TestCase
     end
     assert_response :not_found
     assert_raises ActiveRecord::RecordNotFound do
-      UserPreference.find(1, "key")
+      UserPreference.find([1, "key"])
     end
   end
 end
index 46c35f950dee979e34eeb3c0c59a45a7f70ef07d..f9aeb73cc21fe8352d8b04249b9c9e621ce986b6 100644 (file)
@@ -7,6 +7,10 @@ class ApplicationHelperTest < ActionView::TestCase
     I18n.locale = "en"
   end
 
+  def setup
+    I18n.locale = "en"
+  end
+
   def test_linkify
     %w(http://example.com/test ftp://example.com/test https://example.com/test).each do |link|
       text = "Test #{link} is made into a link"
index 7bc731a0c06e081dd482dcbcad08da5ac8a2a030..d3ed3a8267c702eb6c9c31ed0d6838fc5a2ff8ee 100644 (file)
@@ -12,6 +12,10 @@ class BrowseHelperTest < ActionView::TestCase
     I18n.locale = "en"
   end
 
+  def teardown
+    I18n.locale = "en"
+  end
+
   def test_printable_name
     assert_equal "17", printable_name(current_nodes(:redacted_node))
     assert_equal "<bdi>Test Node</bdi> (<bdi>18</bdi>)", printable_name(current_nodes(:node_with_name))
index 9ec40f18f40e75c610b101cef01c0a4c5d48388d..9f713924d1dc0128e9a526feed452b7d74e3cbf4 100644 (file)
@@ -27,8 +27,8 @@ class TraceTest < ActiveSupport::TestCase
     check_query(Trace.visible_to(3), [:public_trace_file, :identifiable_trace_file])
   end
 
-  def test_public
-    check_query(Trace.public, [:public_trace_file, :identifiable_trace_file, :deleted_trace_file])
+  def test_visible_to_all
+    check_query(Trace.visible_to_all, [:public_trace_file, :identifiable_trace_file, :deleted_trace_file])
   end
 
   def test_tagged
index 5e03c7e0322c576a76cfa3c8cbe0cf7b78352fa8..93bb348ba361b4e43f3062ab5364b7a5fa2c421d 100644 (file)
@@ -180,10 +180,10 @@ class UserTest < ActiveSupport::TestCase
     end
   end
 
-  def test_public
-    assert_equal 16, User.public.count
+  def test_identifiable
+    assert_equal 16, User.identifiable.count
     assert_raise ActiveRecord::RecordNotFound do
-      User.public.find(users(:normal_user).id)
+      User.identifiable.find(users(:normal_user).id)
     end
   end