aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--actionpack/lib/action_controller/metal/strong_parameters.rb28
-rw-r--r--actionpack/test/controller/parameters/serialization_test.rb55
-rw-r--r--activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb1
-rw-r--r--activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb2
-rw-r--r--activerecord/lib/active_record/null_relation.rb36
-rw-r--r--activesupport/CHANGELOG.md12
-rw-r--r--activesupport/lib/active_support/core_ext/object.rb1
-rw-r--r--activesupport/lib/active_support/core_ext/object/exclusion.rb15
-rw-r--r--activesupport/test/core_ext/object/exclusion_test.rb53
-rw-r--r--guides/source/active_support_core_extensions.md2
-rw-r--r--guides/source/command_line.md8
-rw-r--r--guides/source/configuring.md4
-rw-r--r--guides/source/debugging_rails_applications.md7
-rw-r--r--railties/lib/rails/application/configuration.rb1
-rw-r--r--railties/lib/rails/generators/app_base.rb10
-rw-r--r--railties/test/railties/engine_test.rb8
16 files changed, 108 insertions, 135 deletions
diff --git a/actionpack/lib/action_controller/metal/strong_parameters.rb b/actionpack/lib/action_controller/metal/strong_parameters.rb
index 26794c67b7..f101c7b836 100644
--- a/actionpack/lib/action_controller/metal/strong_parameters.rb
+++ b/actionpack/lib/action_controller/metal/strong_parameters.rb
@@ -7,6 +7,7 @@ require 'action_dispatch/http/upload'
require 'rack/test'
require 'stringio'
require 'set'
+require 'yaml'
module ActionController
# Raised when a required parameter is missing.
@@ -591,6 +592,33 @@ module ActionController
"<#{self.class} #{@parameters} permitted: #{@permitted}>"
end
+ def self.hook_into_yaml_loading # :nodoc:
+ # Wire up YAML format compatibility with Rails 4.2 and Psych 2.0.8 and 2.0.9+.
+ # Makes the YAML parser call `init_with` when it encounters the keys below
+ # instead of trying its own parsing routines.
+ YAML.load_tags['!ruby/hash-with-ivars:ActionController::Parameters'] = name
+ YAML.load_tags['!ruby/hash:ActionController::Parameters'] = name
+ end
+ hook_into_yaml_loading
+
+ def init_with(coder) # :nodoc:
+ case coder.tag
+ when '!ruby/hash:ActionController::Parameters'
+ # YAML 2.0.8's format where hash instance variables weren't stored.
+ @parameters = coder.map.with_indifferent_access
+ @permitted = false
+ when '!ruby/hash-with-ivars:ActionController::Parameters'
+ # YAML 2.0.9's Hash subclass format where keys and values
+ # were stored under an elements hash and `permitted` within an ivars hash.
+ @parameters = coder.map['elements'].with_indifferent_access
+ @permitted = coder.map['ivars'][:@permitted]
+ when '!ruby/object:ActionController::Parameters'
+ # YAML's Object format. Only needed because of the format
+ # backwardscompability above, otherwise equivalent to YAML's initialization.
+ @parameters, @permitted = coder.map['parameters'], coder.map['permitted']
+ end
+ end
+
def method_missing(method_sym, *args, &block)
if @parameters.respond_to?(method_sym)
message = <<-DEPRECATE.squish
diff --git a/actionpack/test/controller/parameters/serialization_test.rb b/actionpack/test/controller/parameters/serialization_test.rb
new file mode 100644
index 0000000000..c9d38c1f48
--- /dev/null
+++ b/actionpack/test/controller/parameters/serialization_test.rb
@@ -0,0 +1,55 @@
+require 'abstract_unit'
+require 'action_controller/metal/strong_parameters'
+require 'active_support/core_ext/string/strip'
+
+class ParametersSerializationTest < ActiveSupport::TestCase
+ setup do
+ @old_permitted_parameters = ActionController::Parameters.permit_all_parameters
+ ActionController::Parameters.permit_all_parameters = false
+ end
+
+ teardown do
+ ActionController::Parameters.permit_all_parameters = @old_permitted_parameters
+ end
+
+ test 'yaml serialization' do
+ params = ActionController::Parameters.new(key: :value)
+ assert_equal <<-end_of_yaml.strip_heredoc, YAML.dump(params)
+ --- !ruby/object:ActionController::Parameters
+ parameters: !ruby/hash:ActiveSupport::HashWithIndifferentAccess
+ key: :value
+ permitted: false
+ end_of_yaml
+ end
+
+ test 'yaml deserialization' do
+ params = ActionController::Parameters.new(key: :value)
+ roundtripped = YAML.load(YAML.dump(params))
+
+ assert_equal params, roundtripped
+ assert_not roundtripped.permitted?
+ end
+
+ test 'yaml backwardscompatible with psych 2.0.8 format' do
+ params = YAML.load <<-end_of_yaml.strip_heredoc
+ --- !ruby/hash:ActionController::Parameters
+ key: :value
+ end_of_yaml
+
+ assert_equal :value, params[:key]
+ assert_not params.permitted?
+ end
+
+ test 'yaml backwardscompatible with psych 2.0.9+ format' do
+ params = YAML.load(<<-end_of_yaml.strip_heredoc)
+ --- !ruby/hash-with-ivars:ActionController::Parameters
+ elements:
+ key: :value
+ ivars:
+ :@permitted: false
+ end_of_yaml
+
+ assert_equal :value, params[:key]
+ assert_not params.permitted?
+ end
+end
diff --git a/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb b/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb
index dc5b305843..526adc9efe 100644
--- a/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb
+++ b/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb
@@ -848,7 +848,6 @@ module ActiveRecord
spec = resolver.spec(config)
remove_connection(spec.name)
- owner_to_pool[spec.name] = ConnectionAdapters::ConnectionPool.new(spec)
message_bus = ActiveSupport::Notifications.instrumenter
payload = {
diff --git a/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb b/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
index 353cae0f3d..19c265db6e 100644
--- a/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
+++ b/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
@@ -785,7 +785,7 @@ module ActiveRecord
# [<tt>:type</tt>]
# The reference column type. Defaults to +:integer+.
# [<tt>:index</tt>]
- # Add an appropriate index. Defaults to false.
+ # Add an appropriate index. Defaults to true.
# See #add_index for usage of this option.
# [<tt>:foreign_key</tt>]
# Add an appropriate foreign key constraint. Defaults to false.
diff --git a/activerecord/lib/active_record/null_relation.rb b/activerecord/lib/active_record/null_relation.rb
index 1ab4e0404f..254550c378 100644
--- a/activerecord/lib/active_record/null_relation.rb
+++ b/activerecord/lib/active_record/null_relation.rb
@@ -1,9 +1,5 @@
module ActiveRecord
module NullRelation # :nodoc:
- def exec_queries
- @records = [].freeze
- end
-
def pluck(*column_names)
[]
end
@@ -20,10 +16,6 @@ module ActiveRecord
0
end
- def size
- calculate :size, nil
- end
-
def empty?
true
end
@@ -48,28 +40,8 @@ module ActiveRecord
""
end
- def count(*)
- calculate :count, nil
- end
-
- def sum(*)
- calculate :sum, nil
- end
-
- def average(*)
- calculate :average, nil
- end
-
- def minimum(*)
- calculate :minimum, nil
- end
-
- def maximum(*)
- calculate :maximum, nil
- end
-
def calculate(operation, _column_name)
- if [:count, :sum, :size].include? operation
+ if [:count, :sum].include? operation
group_values.any? ? Hash.new : 0
elsif [:average, :minimum, :maximum].include?(operation) && group_values.any?
Hash.new
@@ -85,5 +57,11 @@ module ActiveRecord
def or(other)
other.spawn
end
+
+ private
+
+ def exec_queries
+ @records = [].freeze
+ end
end
end
diff --git a/activesupport/CHANGELOG.md b/activesupport/CHANGELOG.md
index b39ef7bfb9..280620df1c 100644
--- a/activesupport/CHANGELOG.md
+++ b/activesupport/CHANGELOG.md
@@ -1,15 +1,3 @@
-* Introduce `not_in?` on `Object`.
-
- As an opposite method for `in?`, `not_in?` provides equivalent support for exclusion. This turns this:
-
- [1,2].exclude?(user_id)
-
- ...into this:
-
- user_id.not_in?([1,2])
-
- *Jon McCartie*
-
* Defines `Regexp.match?` for Ruby versions prior to 2.4. The predicate
has the same interface, but it does not have the performance boost. Its
purpose is to be able to write 2.4 compatible code.
diff --git a/activesupport/lib/active_support/core_ext/object.rb b/activesupport/lib/active_support/core_ext/object.rb
index a2c5a472f5..f4f9152d6a 100644
--- a/activesupport/lib/active_support/core_ext/object.rb
+++ b/activesupport/lib/active_support/core_ext/object.rb
@@ -4,7 +4,6 @@ require 'active_support/core_ext/object/duplicable'
require 'active_support/core_ext/object/deep_dup'
require 'active_support/core_ext/object/try'
require 'active_support/core_ext/object/inclusion'
-require 'active_support/core_ext/object/exclusion'
require 'active_support/core_ext/object/conversions'
require 'active_support/core_ext/object/instance_variables'
diff --git a/activesupport/lib/active_support/core_ext/object/exclusion.rb b/activesupport/lib/active_support/core_ext/object/exclusion.rb
deleted file mode 100644
index 58dfb649e5..0000000000
--- a/activesupport/lib/active_support/core_ext/object/exclusion.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-class Object
- # Returns true if this object is excluded in the argument. Argument must be
- # any object which responds to +#include?+. Usage:
- #
- # characters = ["Konata", "Kagami", "Tsukasa"]
- # "MoshiMoshi".not_in?(characters) # => true
- #
- # This will throw an +ArgumentError+ if the argument doesn't respond
- # to +#include?+.
- def not_in?(another_object)
- !another_object.include?(self)
- rescue NoMethodError
- raise ArgumentError.new("The parameter passed to #not_in? must respond to #include?")
- end
-end \ No newline at end of file
diff --git a/activesupport/test/core_ext/object/exclusion_test.rb b/activesupport/test/core_ext/object/exclusion_test.rb
deleted file mode 100644
index 487c97d255..0000000000
--- a/activesupport/test/core_ext/object/exclusion_test.rb
+++ /dev/null
@@ -1,53 +0,0 @@
-require 'abstract_unit'
-require 'active_support/core_ext/object/exclusion'
-
-class NotInTest < ActiveSupport::TestCase
- def test_not_in_array
- assert 1.not_in?([2, 3])
- assert_not 2.not_in?([1,2])
- end
-
- def test_not_in_hash
- h = { "a" => 100, "b" => 200 }
- assert "z".not_in?(h)
- assert_not "a".not_in?(h)
- end
-
- def test_not_in_string
- assert "ol".not_in?("hello")
- assert_not "lo".not_in?("hello")
- assert ?z.not_in?("hello")
- end
-
- def test_not_in_range
- assert 75.not_in?(1..50)
- assert_not 25.not_in?(1..50)
- end
-
- def test_not_in_set
- s = Set.new([1,2])
- assert 3.not_in?(s)
- assert_not 1.not_in?(s)
- end
-
- module A
- end
- class B
- include A
- end
- class C < B
- end
- class D
- end
-
- def test_not_in_module
- assert A.not_in?(D)
- assert A.not_in?(A)
- assert_not A.not_in?(B)
- assert_not A.not_in?(C)
- end
-
- def test_no_method_catching
- assert_raise(ArgumentError) { 1.not_in?(1) }
- end
-end
diff --git a/guides/source/active_support_core_extensions.md b/guides/source/active_support_core_extensions.md
index 27478b21a0..aba4c6a97b 100644
--- a/guides/source/active_support_core_extensions.md
+++ b/guides/source/active_support_core_extensions.md
@@ -368,7 +368,7 @@ account.to_query('company[name]')
so its output is ready to be used in a query string.
-Arrays return the result of applying `to_query` to each element with `_key_[]` as key, and join the result with "&":
+Arrays return the result of applying `to_query` to each element with `key[]` as key, and join the result with "&":
```ruby
[3.4, -45.6].to_query('sample')
diff --git a/guides/source/command_line.md b/guides/source/command_line.md
index 42276bcb90..9d7ecce947 100644
--- a/guides/source/command_line.md
+++ b/guides/source/command_line.md
@@ -497,7 +497,13 @@ app/models/article.rb:
NOTE. When using specific annotations and custom annotations, the annotation name (FIXME, BUG etc) is not displayed in the output lines.
-By default, `rails notes` will look in the `app`, `config`, `db`, `lib` and `test` directories. If you would like to search other directories, you can provide them as a comma separated list in an environment variable `SOURCE_ANNOTATION_DIRECTORIES`.
+By default, `rails notes` will look in the `app`, `config`, `db`, `lib` and `test` directories. If you would like to search other directories, you can configure them using `config.annotations.register_directories` option.
+
+```ruby
+config.annotations.register_directories("spec", "vendor")
+```
+
+You can also provide them as a comma separated list in the environment variable `SOURCE_ANNOTATION_DIRECTORIES`.
```bash
$ export SOURCE_ANNOTATION_DIRECTORIES='spec,vendor'
diff --git a/guides/source/configuring.md b/guides/source/configuring.md
index ed5975f31d..572993a36b 100644
--- a/guides/source/configuring.md
+++ b/guides/source/configuring.md
@@ -181,6 +181,8 @@ pipeline is enabled. It is set to `true` by default.
* `config.assets.logger` accepts a logger conforming to the interface of Log4r or the default Ruby `Logger` class. Defaults to the same configured at `config.logger`. Setting `config.assets.logger` to `false` will turn off served assets logging.
+* `config.assets.quiet` disables logging of assets requests. Set to `true` by default in `development.rb`.
+
### Configuring Generators
Rails allows you to alter what generators are used with the `config.generators` method. This method takes a block:
@@ -602,7 +604,7 @@ There are a few configuration options available in Active Support:
* `config.active_support.time_precision` sets the precision of JSON encoded time values. Defaults to `3`.
-* `ActiveSupport.halt_callback_chains_on_return_false` specifies whether Active Record and Active Model callback chains can be halted by returning `false` in a 'before' callback. When set to `false`, callback chains are halted only when explicitly done so with `throw(:abort)`. When set to `true`, callback chains are halted when a callback returns `false` (the previous behavior before Rails 5) and a deprecation warning is given. Defaults to `true` during the deprecation period. New Rails 5 apps generate an initializer file called `callback_terminator.rb` which sets the value to `false`. This file is *not* added when running `rails app:update`, so returning `false` will still work on older apps ported to Rails 5 and display a deprecation warning to prompt users to update their code.
+* `ActiveSupport.halt_callback_chains_on_return_false` specifies whether Active Record and Active Model callback chains can be halted by returning `false` in a 'before' callback. When set to `false`, callback chains are halted only when explicitly done so with `throw(:abort)`. When set to `true`, callback chains are halted when a callback returns `false` (the previous behavior before Rails 5) and a deprecation warning is given. Defaults to `true` during the deprecation period. New Rails 5 apps generate an initializer file called `new_framework_defaults.rb` which sets the value to `false`. This file is *not* added when running `rails app:update`, so returning `false` will still work on older apps ported to Rails 5 and display a deprecation warning to prompt users to update their code.
* `ActiveSupport::Logger.silencer` is set to `false` to disable the ability to silence logging in a block. The default is `true`.
diff --git a/guides/source/debugging_rails_applications.md b/guides/source/debugging_rails_applications.md
index f0d0f9753a..e4fc7f4743 100644
--- a/guides/source/debugging_rails_applications.md
+++ b/guides/source/debugging_rails_applications.md
@@ -950,12 +950,5 @@ more.
References
----------
-* [ruby-debug Homepage](http://bashdb.sourceforge.net/ruby-debug/home-page.html)
-* [debugger Homepage](https://github.com/cldwalker/debugger)
* [byebug Homepage](https://github.com/deivid-rodriguez/byebug)
* [web-console Homepage](https://github.com/rails/web-console)
-* [Article: Debugging a Rails application with ruby-debug](http://www.sitepoint.com/debug-rails-app-ruby-debug/)
-* [Ryan Bates' debugging ruby (revised) screencast](http://railscasts.com/episodes/54-debugging-ruby-revised)
-* [Ryan Bates' stack trace screencast](http://railscasts.com/episodes/24-the-stack-trace)
-* [Ryan Bates' logger screencast](http://railscasts.com/episodes/56-the-logger)
-* [Debugging with ruby-debug](http://bashdb.sourceforge.net/ruby-debug.html)
diff --git a/railties/lib/rails/application/configuration.rb b/railties/lib/rails/application/configuration.rb
index 7d0c3daa23..285a63d4c6 100644
--- a/railties/lib/rails/application/configuration.rb
+++ b/railties/lib/rails/application/configuration.rb
@@ -34,6 +34,7 @@ module Rails
@public_file_server.index_name = "index"
@force_ssl = false
@ssl_options = {}
+ @session_store = nil
@time_zone = "UTC"
@beginning_of_week = :monday
@log_level = nil
diff --git a/railties/lib/rails/generators/app_base.rb b/railties/lib/rails/generators/app_base.rb
index 8d4056c202..3e0fedb7d2 100644
--- a/railties/lib/rails/generators/app_base.rb
+++ b/railties/lib/rails/generators/app_base.rb
@@ -10,7 +10,7 @@ require 'active_support/core_ext/array/extract_options'
module Rails
module Generators
class AppBase < Base # :nodoc:
- DATABASES = %w( mysql oracle postgresql sqlite3 frontbase ibm_db sqlserver )
+ DATABASES = %w( mysql postgresql sqlite3 oracle frontbase ibm_db sqlserver )
JDBC_DATABASES = %w( jdbcmysql jdbcsqlite3 jdbcpostgresql jdbc )
DATABASES.concat(JDBC_DATABASES)
@@ -266,12 +266,12 @@ module Rails
end
def gem_for_database
- # %w( mysql oracle postgresql sqlite3 frontbase ibm_db sqlserver jdbcmysql jdbcsqlite3 jdbcpostgresql )
+ # %w( mysql postgresql sqlite3 oracle frontbase ibm_db sqlserver jdbcmysql jdbcsqlite3 jdbcpostgresql )
case options[:database]
- when "oracle" then ["ruby-oci8", nil]
+ when "mysql" then ["mysql2", [">= 0.3.18", "< 0.5"]]
when "postgresql" then ["pg", ["~> 0.18"]]
+ when "oracle" then ["ruby-oci8", nil]
when "frontbase" then ["ruby-frontbase", nil]
- when "mysql" then ["mysql2", [">= 0.3.18", "< 0.5"]]
when "sqlserver" then ["activerecord-sqlserver-adapter", nil]
when "jdbcmysql" then ["activerecord-jdbcmysql-adapter", nil]
when "jdbcsqlite3" then ["activerecord-jdbcsqlite3-adapter", nil]
@@ -284,9 +284,9 @@ module Rails
def convert_database_option_for_jruby
if defined?(JRUBY_VERSION)
case options[:database]
- when "oracle" then options[:database].replace "jdbc"
when "postgresql" then options[:database].replace "jdbcpostgresql"
when "mysql" then options[:database].replace "jdbcmysql"
+ when "oracle" then options[:database].replace "jdbc"
when "sqlite3" then options[:database].replace "jdbcsqlite3"
end
end
diff --git a/railties/test/railties/engine_test.rb b/railties/test/railties/engine_test.rb
index 0eaa5bc351..fb8de84e1b 100644
--- a/railties/test/railties/engine_test.rb
+++ b/railties/test/railties/engine_test.rb
@@ -36,8 +36,6 @@ module RailtiesTest
add_to_env_config "development", "config.assets.digest = false"
boot_rails
- require 'rack/test'
- extend Rack::Test::Methods
get "/assets/engine.js"
assert_match "alert()", last_response.body
@@ -321,8 +319,6 @@ module RailtiesTest
RUBY
boot_rails
- require 'rack/test'
- extend Rack::Test::Methods
get "/sprokkit"
assert_equal "I am a Sprokkit", last_response.body
@@ -359,8 +355,6 @@ module RailtiesTest
RUBY
boot_rails
- require 'rack/test'
- extend Rack::Test::Methods
get '/foo'
assert_equal 'foo', last_response.body
@@ -449,8 +443,6 @@ YAML
RUBY
boot_rails
- require 'rack/test'
- extend Rack::Test::Methods
get "/admin/foo/bar"
assert_equal 200, last_response.status