aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--actionpack/lib/action_dispatch/middleware/public_exceptions.rb7
-rw-r--r--actionpack/test/controller/show_exceptions_test.rb18
-rw-r--r--activerecord/Rakefile10
-rw-r--r--activerecord/lib/active_record/attribute_assignment.rb2
-rw-r--r--activerecord/test/cases/connection_pool_test.rb4
-rw-r--r--activerecord/test/cases/mass_assignment_security_test.rb6
-rw-r--r--activerecord/test/cases/query_cache_test.rb5
-rw-r--r--activesupport/lib/active_support/core_ext/load_error.rb12
-rw-r--r--activesupport/lib/active_support/file_update_checker.rb19
-rw-r--r--activesupport/lib/active_support/i18n_railtie.rb23
-rw-r--r--guides/source/contributing_to_ruby_on_rails.textile2
11 files changed, 37 insertions, 71 deletions
diff --git a/actionpack/lib/action_dispatch/middleware/public_exceptions.rb b/actionpack/lib/action_dispatch/middleware/public_exceptions.rb
index bf9149ebf2..204f3f7fb3 100644
--- a/actionpack/lib/action_dispatch/middleware/public_exceptions.rb
+++ b/actionpack/lib/action_dispatch/middleware/public_exceptions.rb
@@ -3,9 +3,8 @@ module ActionDispatch
class PublicExceptions
attr_accessor :public_path
- def initialize(public_path, consider_all_requests_local = false)
+ def initialize(public_path)
@public_path = public_path
- @consider_all_requests_local = consider_all_requests_local
end
def call(env)
@@ -13,7 +12,7 @@ module ActionDispatch
status = env["PATH_INFO"][1..-1]
request = ActionDispatch::Request.new(env)
content_type = request.formats.first
- format = (mime = Mime[content_type]) && "to_#{mime.to_sym}"
+ format = content_type && "to_#{content_type.to_sym}"
body = { :status => status, :error => exception.message }
render(status, body, :format => format, :content_type => content_type)
@@ -24,7 +23,7 @@ module ActionDispatch
def render(status, body, options)
format = options[:format]
- if !@consider_all_requests_local && format && body.respond_to?(format)
+ if format && body.respond_to?(format)
render_format(status, body.public_send(format), options)
else
render_html(status)
diff --git a/actionpack/test/controller/show_exceptions_test.rb b/actionpack/test/controller/show_exceptions_test.rb
index ce7b6b0dc6..351b9c4cfa 100644
--- a/actionpack/test/controller/show_exceptions_test.rb
+++ b/actionpack/test/controller/show_exceptions_test.rb
@@ -22,14 +22,6 @@ module ShowExceptions
end
end
- class ShowLocalExceptionsController < ActionController::Base
- use ActionDispatch::ShowExceptions, ActionDispatch::PublicExceptions.new("#{FIXTURE_LOAD_PATH}/public", true)
-
- def boom
- raise 'boom!'
- end
- end
-
class ShowExceptionsTest < ActionDispatch::IntegrationTest
test 'show error page from a remote ip' do
@app = ShowExceptionsController.action(:boom)
@@ -101,14 +93,4 @@ module ShowExceptions
assert_equal 'text/html', response.content_type.to_s
end
end
-
- class ShowExceptionsFormatsTest < ActionDispatch::IntegrationTest
- def test_render_formatted_exception_in_development
- @app = ShowLocalExceptionsController.action(:boom)
- get "/", {}, 'HTTP_ACCEPT' => 'application/xml'
-
- assert_response :internal_server_error
- assert_equal 'text/html', response.content_type.to_s
- end
- end
end
diff --git a/activerecord/Rakefile b/activerecord/Rakefile
index 7feb0b75a0..a29d7b0e99 100644
--- a/activerecord/Rakefile
+++ b/activerecord/Rakefile
@@ -114,6 +114,16 @@ namespace :postgresql do
config = ARTest.config['connections']['postgresql']
%x( createdb -E UTF8 #{config['arunit']['database']} )
%x( createdb -E UTF8 #{config['arunit2']['database']} )
+
+ # prepare hstore
+ version = %x( createdb --version ).strip.gsub(/(.*)(\d\.\d\.\d)$/, "\\2")
+ %w(arunit arunit2).each do |db|
+ if version < "9.1.0"
+ puts "Please prepare hstore data type. See http://www.postgresql.org/docs/9.0/static/hstore.html"
+ else
+ %x( psql #{config[db]['database']} -c "CREATE EXTENSION hstore;" )
+ end
+ end
end
desc 'Drop the PostgreSQL test databases'
diff --git a/activerecord/lib/active_record/attribute_assignment.rb b/activerecord/lib/active_record/attribute_assignment.rb
index e0bf80142a..abc2fa546a 100644
--- a/activerecord/lib/active_record/attribute_assignment.rb
+++ b/activerecord/lib/active_record/attribute_assignment.rb
@@ -64,7 +64,7 @@ module ActiveRecord
# user.name # => "Josh"
# user.is_admin? # => true
def assign_attributes(new_attributes, options = {})
- return unless new_attributes
+ return if new_attributes.blank?
attributes = new_attributes.stringify_keys
multi_parameter_attributes = []
diff --git a/activerecord/test/cases/connection_pool_test.rb b/activerecord/test/cases/connection_pool_test.rb
index aa1f5e6bad..8287b35aaf 100644
--- a/activerecord/test/cases/connection_pool_test.rb
+++ b/activerecord/test/cases/connection_pool_test.rb
@@ -225,7 +225,7 @@ module ActiveRecord
threads = expected.map do |i|
t = Thread.new {
begin
- conn = @pool.checkout # never checked back in
+ @pool.checkout # never checked back in
mutex.synchronize { order << i }
rescue => e
mutex.synchronize { errors << e }
@@ -262,7 +262,7 @@ module ActiveRecord
make_thread = proc do |i|
t = Thread.new {
begin
- conn = @pool.checkout # never checked back in
+ @pool.checkout # never checked back in
mutex.synchronize { successes << i }
rescue => e
mutex.synchronize { errors << e }
diff --git a/activerecord/test/cases/mass_assignment_security_test.rb b/activerecord/test/cases/mass_assignment_security_test.rb
index 1b5421c25e..214546802a 100644
--- a/activerecord/test/cases/mass_assignment_security_test.rb
+++ b/activerecord/test/cases/mass_assignment_security_test.rb
@@ -95,7 +95,11 @@ class MassAssignmentSecurityTest < ActiveRecord::TestCase
end
def test_mass_assigning_does_not_choke_on_nil
- Firm.new.assign_attributes(nil)
+ assert_nil Firm.new.assign_attributes(nil)
+ end
+
+ def test_mass_assigning_does_not_choke_on_empty_hash
+ assert_nil Firm.new.assign_attributes({})
end
def test_assign_attributes_uses_default_role_when_no_role_is_provided
diff --git a/activerecord/test/cases/query_cache_test.rb b/activerecord/test/cases/query_cache_test.rb
index f36e879305..08f655d7fa 100644
--- a/activerecord/test/cases/query_cache_test.rb
+++ b/activerecord/test/cases/query_cache_test.rb
@@ -151,11 +151,6 @@ class QueryCacheTest < ActiveRecord::TestCase
end
def test_cache_does_not_wrap_string_results_in_arrays
- if current_adapter?(:SQLite3Adapter)
- require 'sqlite3/version'
- sqlite3_version = RUBY_PLATFORM =~ /java/ ? Jdbc::SQLite3::VERSION : SQLite3::VERSION
- end
-
Task.cache do
# Oracle adapter returns count() as Fixnum or Float
if current_adapter?(:OracleAdapter)
diff --git a/activesupport/lib/active_support/core_ext/load_error.rb b/activesupport/lib/active_support/core_ext/load_error.rb
index 8bdfa0c5bc..fe24f3716d 100644
--- a/activesupport/lib/active_support/core_ext/load_error.rb
+++ b/activesupport/lib/active_support/core_ext/load_error.rb
@@ -6,12 +6,14 @@ class LoadError
/^cannot load such file -- (.+)$/i,
]
- def path
- @path ||= begin
- REGEXPS.find do |regex|
- message =~ regex
+ unless method_defined?(:path)
+ def path
+ @path ||= begin
+ REGEXPS.find do |regex|
+ message =~ regex
+ end
+ $1
end
- $1
end
end
diff --git a/activesupport/lib/active_support/file_update_checker.rb b/activesupport/lib/active_support/file_update_checker.rb
index 8860636168..48c39d9370 100644
--- a/activesupport/lib/active_support/file_update_checker.rb
+++ b/activesupport/lib/active_support/file_update_checker.rb
@@ -35,22 +35,11 @@ module ActiveSupport
# have directories as keys and the value is an array of extensions to be
# watched under that directory.
#
- # This method must also receive a block that will be called once a path changes.
- #
- # == Implementation details
- #
- # This particular implementation checks for added, updated, and removed
- # files. Directories lookup are compiled to a glob for performance.
- # Therefore, while someone can add new files to the +files+ array after
- # initialization (and parts of Rails do depend on this feature), adding
- # new directories after initialization is not supported.
- #
- # Notice that other objects that implement the FileUpdateChecker API may
- # not even allow new files to be added after initialization. If this
- # is the case, we recommend freezing the +files+ after initialization to
- # avoid changes that won't make effect.
+ # This method must also receive a block that will be called once a path
+ # changes. The array of files and list of directories cannot be changed
+ # after FileUpdateChecker has been initialized.
def initialize(files, dirs={}, &block)
- @files = files
+ @files = files.freeze
@glob = compile_glob(dirs)
@block = block
diff --git a/activesupport/lib/active_support/i18n_railtie.rb b/activesupport/lib/active_support/i18n_railtie.rb
index bbeb8d82c6..f67b221024 100644
--- a/activesupport/lib/active_support/i18n_railtie.rb
+++ b/activesupport/lib/active_support/i18n_railtie.rb
@@ -9,25 +9,6 @@ module I18n
config.i18n.load_path = []
config.i18n.fallbacks = ActiveSupport::OrderedOptions.new
- def self.reloader
- @reloader ||= ActiveSupport::FileUpdateChecker.new(reloader_paths){ I18n.reload! }
- end
-
- def self.reloader_paths
- @reloader_paths ||= []
- end
-
- # Add <tt>I18n::Railtie.reloader</tt> to ActionDispatch callbacks. Since, at this
- # point, no path was added to the reloader, I18n.reload! is not triggered
- # on to_prepare callbacks. This will only happen on the config.after_initialize
- # callback below.
- initializer "i18n.callbacks" do |app|
- app.reloaders << I18n::Railtie.reloader
- ActionDispatch::Reloader.to_prepare do
- I18n::Railtie.reloader.execute_if_updated
- end
- end
-
# Set the i18n configuration after initialization since a lot of
# configuration is still usually done in application initializers.
config.after_initialize do |app|
@@ -63,7 +44,9 @@ module I18n
init_fallbacks(fallbacks) if fallbacks && validate_fallbacks(fallbacks)
- reloader_paths.concat I18n.load_path
+ reloader = ActiveSupport::FileUpdateChecker.new(I18n.load_path.dup){ I18n.reload! }
+ app.reloaders << reloader
+ ActionDispatch::Reloader.to_prepare { reloader.execute_if_updated }
reloader.execute
@i18n_inited = true
diff --git a/guides/source/contributing_to_ruby_on_rails.textile b/guides/source/contributing_to_ruby_on_rails.textile
index acf75d41cd..92c607b6f5 100644
--- a/guides/source/contributing_to_ruby_on_rails.textile
+++ b/guides/source/contributing_to_ruby_on_rails.textile
@@ -190,6 +190,8 @@ $ rake postgresql:build_databases
NOTE: Using the rake task to create the test databases ensures they have the correct character set and collation.
+NOTE: You'll see the following warning (or localized warning) during activating HStore extension in PostgreSQL 9.1.x or earlier: "WARNING: => is deprecated as an operator".
+
If you’re using another database, check the files under +activerecord/test/connections+ for default connection information. You can edit these files to provide different credentials on your machine if you must, but obviously you should not push any such changes back to Rails.
You can now run the tests as you did for +sqlite3+. The tasks are respectively