Permalink
Browse files

Merge branch 'master' into preload

* master: (62 commits)
  Getting Started Guide: Hello Rails! -> Hello, Rails! and wrap code tag
  Add CHANGELOG entry for #12344
  Add regression test to #12343
  Fix typo in number_to_human docs: you -> your
  [Documentation] Add a missing validation to I18n docs
  Use the given name in html_options for the hidden field in collection_check_boxes
  assign_attributes should return if argument is blank.
  No need the else clause
  Use join to concat the both side of the AST
  Add a CHANGELOG entry about Web Console inclusion
  added column type to example in section 2.3
  Include web-console in new projects Gemfile
  ActiveRecord::ConnectionAdapters::Column.string_to_time method respects string with timezone. Closes #12278.
  add test_scoped_root_as_name
  Getting Started Guide: update RubyGems Guides link [ci skip]
  Deprecate unused quoted_locking_column method.
  Update references to wycats/thor to erikhuda/thor.
  bcrypt-ruby v3.1.2 supports Ruby 2.0 on Windows
  Fix the model name in the association basics guides
  We shouldn't override PostgreSQLAdapter's superclass inheritance while monkeypatching
  ...
  • Loading branch information...
2 parents 70e48a6 + f398285 commit e2fd64fe469037644711a65a00270bea15ee2955 @tenderlove tenderlove committed Sep 25, 2013
Showing with 735 additions and 201 deletions.
  1. +2 −2 .travis.yml
  2. +1 −1 Gemfile
  3. +10 −0 actionpack/CHANGELOG.md
  4. +20 −19 actionpack/lib/action_controller/metal/redirecting.rb
  5. +3 −0 actionpack/lib/action_controller/metal/request_forgery_protection.rb
  6. +3 −1 actionpack/lib/action_dispatch/journey/router/utils.rb
  7. +22 −23 actionpack/lib/action_dispatch/journey/visitors.rb
  8. +13 −0 actionpack/lib/action_dispatch/routing/polymorphic_routes.rb
  9. +5 −15 actionpack/lib/action_dispatch/testing/assertions/response.rb
  10. +18 −0 actionpack/test/controller/action_pack_assertions_test.rb
  11. +10 −0 actionpack/test/controller/request_forgery_protection_test.rb
  12. +13 −0 actionpack/test/dispatch/routing_test.rb
  13. +29 −0 actionview/CHANGELOG.md
  14. +4 −1 actionview/lib/action_view/digestor.rb
  15. +13 −4 actionview/lib/action_view/helpers/form_options_helper.rb
  16. +2 −1 actionview/lib/action_view/helpers/tags/base.rb
  17. +2 −1 actionview/lib/action_view/helpers/tags/collection_check_boxes.rb
  18. +2 −1 actionview/lib/action_view/helpers/tags/collection_helpers.rb
  19. +1 −0 actionview/lib/action_view/helpers/tags/label.rb
  20. +2 −1 actionview/lib/action_view/helpers/tags/select.rb
  21. +3 −2 actionview/lib/action_view/helpers/url_helper.rb
  22. +0 −5 actionview/test/fixtures/helpers/fun/games_helper.rb
  23. +0 −5 actionview/test/fixtures/helpers/fun/pdf_helper.rb
  24. +0 −3 actionview/test/fixtures/helpers/just_me_helper.rb
  25. +0 −3 actionview/test/fixtures/helpers/me_too_helper.rb
  26. +29 −1 actionview/test/template/digestor_test.rb
  27. +7 −0 actionview/test/template/form_collections_helper_test.rb
  28. +36 −0 actionview/test/template/form_helper_test.rb
  29. +31 −0 actionview/test/template/form_options_helper_test.rb
  30. +6 −0 activemodel/CHANGELOG.md
  31. +28 −10 activemodel/lib/active_model/dirty.rb
  32. +3 −3 activemodel/lib/active_model/secure_password.rb
  33. +1 −2 activemodel/test/cases/dirty_test.rb
  34. +36 −0 activerecord/CHANGELOG.md
  35. +3 −3 activerecord/lib/active_record/associations/collection_association.rb
  36. +3 −0 activerecord/lib/active_record/attribute_assignment.rb
  37. +6 −9 activerecord/lib/active_record/attribute_methods/dirty.rb
  38. +11 −3 activerecord/lib/active_record/connection_adapters/column.rb
  39. +6 −3 activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
  40. +11 −5 activerecord/lib/active_record/core.rb
  41. +1 −0 activerecord/lib/active_record/locking/optimistic.rb
  42. +1 −1 activerecord/lib/active_record/persistence.rb
  43. +16 −5 activerecord/lib/active_record/schema_dumper.rb
  44. +28 −26 activerecord/test/cases/adapters/postgresql/statement_pool_test.rb
  45. +41 −0 activerecord/test/cases/adapters/postgresql/uuid_test.rb
  46. +1 −1 activerecord/test/cases/attribute_methods_test.rb
  47. +10 −0 activerecord/test/cases/column_test.rb
  48. +5 −0 activerecord/test/cases/forbidden_attributes_protection_test.rb
  49. +4 −0 activerecord/test/cases/locking_test.rb
  50. +11 −4 activerecord/test/cases/persistence_test.rb
  51. +1 −1 activerecord/test/cases/schema_dumper_test.rb
  52. +32 −0 activesupport/CHANGELOG.md
  53. +0 −6 activesupport/bin/generate_tables
  54. +1 −0 activesupport/lib/active_support/core_ext/range.rb
  55. +24 −0 activesupport/lib/active_support/core_ext/range/each.rb
  56. +1 −2 activesupport/lib/active_support/multibyte/chars.rb
  57. +7 −0 activesupport/lib/active_support/multibyte/unicode.rb
  58. +1 −1 activesupport/lib/active_support/number_helper.rb
  59. +25 −2 activesupport/lib/active_support/subscriber.rb
  60. +22 −0 activesupport/test/core_ext/range_ext_test.rb
  61. +40 −0 activesupport/test/subscriber_test.rb
  62. +1 −1 guides/code/getting_started/Gemfile
  63. +0 −2 guides/source/3_0_release_notes.md
  64. +1 −1 guides/source/active_model_basics.md
  65. +4 −1 guides/source/association_basics.md
  66. +0 −2 guides/source/command_line.md
  67. +11 −0 guides/source/configuring.md
  68. +6 −2 guides/source/engines.md
  69. +3 −3 guides/source/generators.md
  70. +3 −3 guides/source/getting_started.md
  71. +1 −0 guides/source/i18n.md
  72. +2 −1 guides/source/migrations.md
  73. +6 −4 guides/source/testing.md
  74. +9 −0 railties/CHANGELOG.md
  75. +3 −2 railties/lib/rails/commands/server.rb
  76. +2 −2 railties/lib/rails/generators/rails/app/app_generator.rb
  77. +4 −1 railties/lib/rails/generators/rails/app/templates/Gemfile
  78. +2 −0 railties/lib/rails/generators/rails/app/templates/config/databases/postgresql.yml
  79. +10 −0 railties/test/commands/server_test.rb
View
@@ -4,7 +4,7 @@ before_install:
rvm:
- 1.9.3
- 2.0.0
- - jruby-19mode
+ - jruby-head
- rbx-19mode
env:
- "GEM=railties"
@@ -15,7 +15,7 @@ env:
- "GEM=ar:postgresql"
matrix:
allow_failures:
- - rvm: jruby-19mode
+ - rvm: jruby-head
- rvm: rbx-19mode
notifications:
email: false
View
@@ -8,7 +8,7 @@ gemspec
gem 'mocha', '~> 0.14', require: false
gem 'rack-cache', '~> 1.2'
-gem 'bcrypt-ruby', '~> 3.1.0'
+gem 'bcrypt-ruby', '~> 3.1.2'
gem 'jquery-rails', '~> 2.2.0'
gem 'turbolinks'
gem 'coffee-rails', '~> 4.0.0'
@@ -1,3 +1,13 @@
+* Fix regex used to detect URI schemes in `redirect_to` to be consistent with
+ RFC 3986.
+
+ *Derek Prior*
+
+* Fix incorrect `assert_redirected_to` failure message for protocol-relative
+ URLs.
+
+ *Derek Prior*
+
* Fix an issue where router can't recognize downcased url encoding path.
Fixes #12269
@@ -71,6 +71,26 @@ def redirect_to(options = {}, response_status = {}) #:doc:
self.response_body = "<html><body>You are being <a href=\"#{ERB::Util.h(location)}\">redirected</a>.</body></html>"
end
+ def _compute_redirect_to_location(options) #:nodoc:
+ case options
+ # The scheme name consist of a letter followed by any combination of
+ # letters, digits, and the plus ("+"), period ("."), or hyphen ("-")
+ # characters; and is terminated by a colon (":").
+ # See http://tools.ietf.org/html/rfc3986#section-3.1
+ # The protocol relative scheme starts with a double slash "//".
+ when /\A([a-z][a-z\d\-+\.]*:|\/\/).*/i
+ options
+ when String
+ request.protocol + request.host_with_port + options
+ when :back
+ request.headers["Referer"] or raise RedirectBackError
+ when Proc
+ _compute_redirect_to_location options.call
+ else
+ url_for(options)
+ end.delete("\0\r\n")
+ end
+
private
def _extract_redirect_to_status(options, response_status)
if options.is_a?(Hash) && options.key?(:status)
@@ -81,24 +101,5 @@ def _extract_redirect_to_status(options, response_status)
302
end
end
-
- def _compute_redirect_to_location(options)
- case options
- # The scheme name consist of a letter followed by any combination of
- # letters, digits, and the plus ("+"), period ("."), or hyphen ("-")
- # characters; and is terminated by a colon (":").
- # The protocol relative scheme starts with a double slash "//"
- when %r{\A(\w[\w+.-]*:|//).*}
- options
- when String
- request.protocol + request.host_with_port + options
- when :back
- request.headers["Referer"] or raise RedirectBackError
- when Proc
- _compute_redirect_to_location options.call
- else
- url_for(options)
- end.delete("\0\r\n")
- end
end
end
@@ -124,6 +124,9 @@ def initialize(env)
@loaded = true
end
+ # no-op
+ def destroy; end
+
def exists?
true
end
@@ -7,11 +7,13 @@ class Utils # :nodoc:
# Normalizes URI path.
#
# Strips off trailing slash and ensures there is a leading slash.
+ # Also converts downcase url encoded string to uppercase.
#
# normalize_path("/foo") # => "/foo"
# normalize_path("/foo/") # => "/foo"
# normalize_path("foo") # => "/foo"
# normalize_path("") # => "/"
+ # normalize_path("/%ab") # => "/%AB"
def self.normalize_path(path)
path = "/#{path}"
path.squeeze!('/')
@@ -36,7 +38,7 @@ module UriEscape # :nodoc:
UNSAFE_FRAGMENT = Regexp.new("[^#{safe_fragment}]", false).freeze
end
- Parser = URI.const_defined?(:Parser) ? URI::Parser.new : URI
+ Parser = URI::Parser.new
def self.escape_path(path)
Parser.escape(path.to_s, UriEscape::UNSAFE_SEGMENT)
@@ -84,44 +84,43 @@ def visit_GROUP(node)
# Used for formatting urls (url_for)
class Formatter < Visitor # :nodoc:
- attr_reader :options, :consumed
+ attr_reader :options
def initialize(options)
@options = options
- @consumed = {}
end
private
- def visit_GROUP(node)
- if consumed == options
- nil
- else
- route = visit(node.left)
- route.include?("\0") ? nil : route
+ def visit(node, optional = false)
+ case node.type
+ when :LITERAL, :SLASH, :DOT
+ node.left
+ when :STAR
+ visit(node.left)
+ when :GROUP
+ visit(node.left, true)
+ when :CAT
+ visit_CAT(node, optional)
+ when :SYMBOL
+ visit_SYMBOL(node)
end
end
- def terminal(node)
- node.left
- end
-
- def binary(node)
- [visit(node.left), visit(node.right)].join
- end
+ def visit_CAT(node, optional)
+ left = visit(node.left, optional)
+ right = visit(node.right, optional)
- def nary(node)
- node.children.map { |c| visit(c) }.join
+ if optional && !(right && left)
+ ""
+ else
+ [left, right].join
+ end
end
def visit_SYMBOL(node)
- key = node.to_sym
-
- if value = options[key]
- consumed[key] = value
+ if value = options[node.to_sym]
Router::Utils.escape_path(value)
- else
- "\0"
end
end
end
@@ -74,6 +74,19 @@ module PolymorphicRoutes
# * <tt>:routing_type</tt> - Allowed values are <tt>:path</tt> or <tt>:url</tt>.
# Default is <tt>:url</tt>.
#
+ # Also includes all the options from <tt>url_for</tt>. These include such
+ # things as <tt>:anchor</tt> or <tt>:trailing_slash</tt>. Example usage
+ # is given below:
+ #
+ # polymorphic_url([blog, post], anchor: 'my_anchor')
+ # # => "http://example.com/blogs/1/posts/1#my_anchor"
+ # polymorphic_url([blog, post], anchor: 'my_anchor', script_name: "/my_app")
+ # # => "http://example.com/my_app/blogs/1/posts/1#my_anchor"
+ #
+ # For all of these options, see the documentation for <tt>url_for</tt>.
+ #
+ # ==== Functionality
+ #
# # an Article record
# polymorphic_url(record) # same as article_url(record)
#
@@ -67,21 +67,11 @@ def parameterize(value)
end
def normalize_argument_to_redirection(fragment)
- normalized = case fragment
- when Regexp
- fragment
- when %r{^\w[A-Za-z\d+.-]*:.*}
- fragment
- when String
- @request.protocol + @request.host_with_port + fragment
- when :back
- raise RedirectBackError unless refer = @request.headers["Referer"]
- refer
- else
- @controller.url_for(fragment)
- end
-
- normalized.respond_to?(:delete) ? normalized.delete("\0\r\n") : normalized
+ if Regexp === fragment
+ fragment
+ else
+ @controller._compute_redirect_to_location(fragment)
+ end
end
end
end
@@ -39,6 +39,8 @@ def redirect_to_named_route() redirect_to route_one_url end
def redirect_external() redirect_to "http://www.rubyonrails.org"; end
+ def redirect_external_protocol_relative() redirect_to "//www.rubyonrails.org"; end
+
def response404() head '404 AWOL' end
def response500() head '500 Sorry' end
@@ -258,6 +260,19 @@ def test_assert_redirected_to_top_level_named_route_with_same_controller_name_in
end
end
+ def test_assert_redirect_failure_message_with_protocol_relative_url
+ begin
+ process :redirect_external_protocol_relative
+ assert_redirected_to "/foo"
+ rescue ActiveSupport::TestCase::Assertion => ex
+ assert_no_match(
+ /#{request.protocol}#{request.host}\/\/www.rubyonrails.org/,
+ ex.message,
+ 'protocol relative url was incorrectly normalized'
+ )
+ end
+ end
+
def test_template_objects_exist
process :assign_this
assert !@controller.instance_variable_defined?(:"@hi")
@@ -309,6 +324,9 @@ def test_redirection_location
process :redirect_external
assert_equal 'http://www.rubyonrails.org', @response.redirect_url
+
+ process :redirect_external_protocol_relative
+ assert_equal '//www.rubyonrails.org', @response.redirect_url
end
def test_no_redirect_url
@@ -78,6 +78,11 @@ def encrypted
cookies.encrypted[:foo] = 'bar'
render :nothing => true
end
+
+ def try_to_reset_session
+ reset_session
+ render :nothing => true
+ end
end
class FreeCookieController < RequestForgeryProtectionControllerUsingResetSession
@@ -320,6 +325,11 @@ def setup
post :encrypted
assert_response :ok
end
+
+ test 'should allow reset_session' do
+ post :try_to_reset_session
+ assert_response :ok
+ end
end
class RequestForgeryProtectionControllerUsingExceptionTest < ActionController::TestCase
@@ -1102,6 +1102,19 @@ def test_scoped_root
assert_equal 'projects#index', @response.body
end
+ def test_scoped_root_as_name
+ draw do
+ scope '(:locale)', :locale => /en|pl/ do
+ root :to => 'projects#index', :as => 'projects'
+ end
+ end
+
+ assert_equal '/en', projects_path(:locale => 'en')
+ assert_equal '/', projects_path
+ get '/en'
+ assert_equal 'projects#index', @response.body
+ end
+
def test_scope_with_format_option
draw do
get "direct/index", as: :no_format_direct, format: false
@@ -1,3 +1,26 @@
+* Fix `collection_check_boxes` generated hidden input to use the name attribute provided
+ in the options hash.
+
+ *Angel N. Sciortino*
+
+* Fix some edge cases for AV `select` helper with `:selected` option
+
+ *Bogdan Gusiev*
+
+* Ability to pass block to `select` helper
+
+ <%= select(report, "campaign_ids") do %>
+ <% available_campaigns.each do |c| -%>
+ <%= content_tag(:option, c.name, value: c.id, data: { tags: c.tags.to_json }) %>
+ <% end -%>
+ <% end -%>
+
+ *Bogdan Gusiev*
+
+* Handle `:namespace` form option in collection labels
+
+ *Vasiliy Ermolovich*
+
* Fix `form_for` when both `namespace` and `as` options are present
`as` option no longer overwrites `namespace` option when generating
@@ -13,6 +36,12 @@
*Josh Lauer*, *Justin Ridgewell*
+* Fixed a bug where the lookup details were not being taken into account
+ when caching the digest of a template - changes to the details now
+ cause a different cache key to be used.
+
+ *Daniel Schierbeck*
+
* Added an `extname` hash option for `javascript_include_tag` method.
Before:
@@ -10,7 +10,10 @@ class Digestor
class << self
def digest(name, format, finder, options = {})
- cache_key = ([name, format] + Array.wrap(options[:dependencies])).join('.')
+ details_key = finder.details_key.hash
+ dependencies = Array.wrap(options[:dependencies])
+ cache_key = ([name, details_key, format] + dependencies).join('.')
+
# this is a correctly done double-checked locking idiom
# (ThreadSafe::Cache's lookups have volatile semantics)
@@cache[cache_key] || @@digest_monitor.synchronize do
Oops, something went wrong. Retry.

0 comments on commit e2fd64f

Please sign in to comment.