Permalink
Browse files

Merge branch 'master' into nested_has_many_through

Conflicts:
	activerecord/CHANGELOG
	activerecord/lib/active_record/association_preload.rb
	activerecord/lib/active_record/associations.rb
	activerecord/test/schema/schema.rb
  • Loading branch information...
2 parents 8e53e05 + 6a3d6b7 commit fc276e5635821e65c04b8961170cc6bd3c11b923 @jonleighton jonleighton committed Oct 28, 2010
Showing with 6,546 additions and 632 deletions.
  1. +1 −2 Gemfile
  2. +1 −1 actionmailer/actionmailer.gemspec
  3. +1 −2 actionpack/actionpack.gemspec
  4. +5 −5 actionpack/lib/abstract_controller/rendering.rb
  5. +0 −9 actionpack/lib/action_dispatch/http/rack_cache.rb
  6. +1 −6 actionpack/lib/action_dispatch/http/url.rb
  7. +11 −3 actionpack/lib/action_dispatch/middleware/cookies.rb
  8. +0 −1 actionpack/lib/action_dispatch/testing/performance_test.rb
  9. +0 −11 actionpack/lib/action_view/helpers/date_helper.rb
  10. +5 −4 actionpack/lib/action_view/helpers/tag_helper.rb
  11. +5 −0 actionpack/test/abstract_unit.rb
  12. +23 −0 actionpack/test/dispatch/cookies_test.rb
  13. +18 −0 actionpack/test/template/url_helper_test.rb
  14. +1 −1 activemodel/activemodel.gemspec
  15. +3 −0 activerecord/CHANGELOG
  16. +0 −2 activerecord/lib/active_record/association_preload.rb
  17. +16 −16 activerecord/lib/active_record/associations.rb
  18. +10 −1 activerecord/lib/active_record/autosave_association.rb
  19. +22 −27 activerecord/lib/active_record/base.rb
  20. +23 −3 activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb
  21. +7 −15 activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb
  22. +15 −1 activerecord/lib/active_record/connection_adapters/abstract_adapter.rb
  23. +112 −23 activerecord/lib/active_record/connection_adapters/mysql_adapter.rb
  24. +67 −5 activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
  25. +47 −14 activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb
  26. +3 −3 activerecord/lib/active_record/named_scope.rb
  27. +2 −2 activerecord/lib/active_record/reflection.rb
  28. +2 −2 activerecord/lib/active_record/relation.rb
  29. +6 −1 activerecord/lib/active_record/relation/finder_methods.rb
  30. +13 −4 activerecord/lib/active_record/relation/query_methods.rb
  31. +11 −7 activerecord/lib/active_record/relation/spawn_methods.rb
  32. +30 −0 activerecord/lib/active_record/result.rb
  33. +58 −0 activerecord/test/cases/adapters/mysql/connection_test.rb
  34. +51 −0 activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb
  35. +31 −1 activerecord/test/cases/adapters/postgresql/schema_authorization_test.rb
  36. +54 −8 activerecord/test/cases/adapters/sqlite3/sqlite3_adapter_test.rb
  37. +2 −2 activerecord/test/cases/associations/callbacks_test.rb
  38. +3 −3 activerecord/test/cases/attribute_methods_test.rb
  39. +20 −0 activerecord/test/cases/autosave_association_test.rb
  40. +7 −0 activerecord/test/cases/base_test.rb
  41. +8 −0 activerecord/test/cases/helper.rb
  42. +4 −4 activerecord/test/cases/migration_test.rb
  43. +6 −0 activerecord/test/cases/named_scope_test.rb
  44. +7 −1 activerecord/test/cases/query_cache_test.rb
  45. +46 −0 activerecord/test/cases/relation_scoping_test.rb
  46. +9 −7 activerecord/test/cases/relations_test.rb
  47. +2 −2 activerecord/test/cases/schema_dumper_test.rb
  48. +1 −1 activerecord/test/cases/transactions_test.rb
  49. +2 −2 activerecord/test/connections/native_oracle/connection.rb
  50. +37 −0 activerecord/test/models/eye.rb
  51. +6 −0 activerecord/test/models/post.rb
  52. +7 −0 activerecord/test/models/topic.rb
  53. +61 −52 activerecord/test/schema/schema.rb
  54. +6 −0 activesupport/lib/active_support/core_ext/string/output_safety.rb
  55. +4 −3 activesupport/lib/active_support/multibyte/chars.rb
  56. +11 −11 ci/ci_build.rb
  57. +0 −188 railties/guides/assets/javascripts/code_highlighter.js
  58. +0 −90 railties/guides/assets/javascripts/highlighters.js
  59. +59 −0 railties/guides/assets/javascripts/syntaxhighlighter/shBrushAS3.js
  60. +75 −0 railties/guides/assets/javascripts/syntaxhighlighter/shBrushAppleScript.js
  61. +59 −0 railties/guides/assets/javascripts/syntaxhighlighter/shBrushBash.js
  62. +65 −0 railties/guides/assets/javascripts/syntaxhighlighter/shBrushCSharp.js
  63. +100 −0 railties/guides/assets/javascripts/syntaxhighlighter/shBrushColdFusion.js
  64. +97 −0 railties/guides/assets/javascripts/syntaxhighlighter/shBrushCpp.js
  65. +91 −0 railties/guides/assets/javascripts/syntaxhighlighter/shBrushCss.js
  66. +55 −0 railties/guides/assets/javascripts/syntaxhighlighter/shBrushDelphi.js
  67. +41 −0 railties/guides/assets/javascripts/syntaxhighlighter/shBrushDiff.js
  68. +52 −0 railties/guides/assets/javascripts/syntaxhighlighter/shBrushErlang.js
  69. +67 −0 railties/guides/assets/javascripts/syntaxhighlighter/shBrushGroovy.js
  70. +52 −0 railties/guides/assets/javascripts/syntaxhighlighter/shBrushJScript.js
  71. +57 −0 railties/guides/assets/javascripts/syntaxhighlighter/shBrushJava.js
  72. +58 −0 railties/guides/assets/javascripts/syntaxhighlighter/shBrushJavaFX.js
  73. +72 −0 railties/guides/assets/javascripts/syntaxhighlighter/shBrushPerl.js
  74. +88 −0 railties/guides/assets/javascripts/syntaxhighlighter/shBrushPhp.js
  75. +33 −0 railties/guides/assets/javascripts/syntaxhighlighter/shBrushPlain.js
  76. +74 −0 railties/guides/assets/javascripts/syntaxhighlighter/shBrushPowerShell.js
  77. +64 −0 railties/guides/assets/javascripts/syntaxhighlighter/shBrushPython.js
  78. +55 −0 railties/guides/assets/javascripts/syntaxhighlighter/shBrushRuby.js
  79. +94 −0 railties/guides/assets/javascripts/syntaxhighlighter/shBrushSass.js
  80. +51 −0 railties/guides/assets/javascripts/syntaxhighlighter/shBrushScala.js
  81. +66 −0 railties/guides/assets/javascripts/syntaxhighlighter/shBrushSql.js
  82. +56 −0 railties/guides/assets/javascripts/syntaxhighlighter/shBrushVb.js
  83. +69 −0 railties/guides/assets/javascripts/syntaxhighlighter/shBrushXml.js
  84. +17 −0 railties/guides/assets/javascripts/syntaxhighlighter/shCore.js
  85. +6 −13 railties/guides/assets/stylesheets/main.css
  86. +0 −31 railties/guides/assets/stylesheets/syntax.css
  87. +226 −0 railties/guides/assets/stylesheets/syntaxhighlighter/shCore.css
  88. +328 −0 railties/guides/assets/stylesheets/syntaxhighlighter/shCoreDefault.css
  89. +331 −0 railties/guides/assets/stylesheets/syntaxhighlighter/shCoreDjango.css
  90. +339 −0 railties/guides/assets/stylesheets/syntaxhighlighter/shCoreEclipse.css
  91. +324 −0 railties/guides/assets/stylesheets/syntaxhighlighter/shCoreEmacs.css
  92. +328 −0 railties/guides/assets/stylesheets/syntaxhighlighter/shCoreFadeToGrey.css
  93. +324 −0 railties/guides/assets/stylesheets/syntaxhighlighter/shCoreMDUltra.css
  94. +324 −0 railties/guides/assets/stylesheets/syntaxhighlighter/shCoreMidnight.css
  95. +324 −0 railties/guides/assets/stylesheets/syntaxhighlighter/shCoreRDark.css
  96. +117 −0 railties/guides/assets/stylesheets/syntaxhighlighter/shThemeDefault.css
  97. +120 −0 railties/guides/assets/stylesheets/syntaxhighlighter/shThemeDjango.css
  98. +128 −0 railties/guides/assets/stylesheets/syntaxhighlighter/shThemeEclipse.css
  99. +113 −0 railties/guides/assets/stylesheets/syntaxhighlighter/shThemeEmacs.css
  100. +117 −0 railties/guides/assets/stylesheets/syntaxhighlighter/shThemeFadeToGrey.css
  101. +113 −0 railties/guides/assets/stylesheets/syntaxhighlighter/shThemeMDUltra.css
  102. +113 −0 railties/guides/assets/stylesheets/syntaxhighlighter/shThemeMidnight.css
  103. +113 −0 railties/guides/assets/stylesheets/syntaxhighlighter/shThemeRDark.css
  104. +116 −0 railties/guides/assets/stylesheets/syntaxhighlighter/shThemeRailsGuides.css
  105. +21 −3 railties/guides/rails_guides/generator.rb
  106. +1 −1 railties/guides/source/action_mailer_basics.textile
  107. +1 −1 railties/guides/source/active_record_validations_callbacks.textile
  108. +1 −1 railties/guides/source/api_documentation_guidelines.textile
  109. +1 −3 railties/guides/source/debugging_rails_applications.textile
  110. +12 −6 railties/guides/source/form_helpers.textile
  111. +1 −1 railties/guides/source/generators.textile
  112. +1 −1 railties/guides/source/getting_started.textile
  113. +12 −5 railties/guides/source/layout.html.erb
  114. +10 −10 railties/guides/source/layouts_and_rendering.textile
  115. +8 −8 railties/guides/source/plugins.textile
  116. +2 −2 railties/guides/source/routing.textile
View
@@ -46,8 +46,7 @@ platforms :ruby do
group :db do
gem "pg", ">= 0.9.0"
gem "mysql", ">= 2.8.1"
- # gem "mysql2", ">= 0.2.4"
- gem "mysql2", :git => "git://github.com/brianmario/mysql2.git"
+ gem "mysql2", ">= 0.2.6"
end
end
@@ -20,5 +20,5 @@ Gem::Specification.new do |s|
s.has_rdoc = true
s.add_dependency('actionpack', version)
- s.add_dependency('mail', '~> 2.2.6.1')
+ s.add_dependency('mail', '~> 2.2.9')
end
@@ -22,9 +22,8 @@ Gem::Specification.new do |s|
s.add_dependency('activesupport', version)
s.add_dependency('activemodel', version)
s.add_dependency('rack-cache', '~> 0.5.3')
- s.add_dependency('rack-cache-purge', '~> 0.0.1')
s.add_dependency('builder', '~> 2.1.2')
- s.add_dependency('i18n', '~> 0.4.1')
+ s.add_dependency('i18n', '~> 0.4.2')
s.add_dependency('rack', '~> 1.2.1')
s.add_dependency('rack-test', '~> 0.5.6')
s.add_dependency('rack-mount', '~> 0.6.13')
@@ -46,14 +46,14 @@ def view_context_class
@view_context_class ||= begin
controller = self
Class.new(ActionView::Base) do
+ if controller.respond_to?(:_routes) && controller._routes
+ include controller._routes.url_helpers
+ include controller._routes.mounted_helpers
+ end
+
if controller.respond_to?(:_helpers)
include controller._helpers
- if controller.respond_to?(:_routes) && controller._routes
- include controller._routes.url_helpers
- include controller._routes.mounted_helpers
- end
-
# TODO: Fix RJS to not require this
self.helpers = controller._helpers
end
@@ -21,11 +21,6 @@ def write(key, value)
@store.write(key, value)
end
- def purge(key)
- @store.delete(key)
- nil
- end
-
::Rack::Cache::MetaStore::RAILS = self
end
@@ -58,10 +53,6 @@ def write(body)
[key, size]
end
- def purge(key)
- @store.delete(key)
- end
-
::Rack::Cache::EntityStore::RAILS = self
end
end
@@ -8,11 +8,6 @@ def url
protocol + host_with_port + fullpath
end
- # Returns 'https' if this is an SSL request and 'http' otherwise.
- def scheme
- ssl? ? 'https' : 'http'
- end
-
# Returns 'https://' if this is an SSL request and 'http://' otherwise.
def protocol
@protocol ||= ssl? ? 'https://' : 'http://'
@@ -99,4 +94,4 @@ def named_host?(host)
end
end
end
-end
+end
@@ -98,17 +98,19 @@ class CookieJar < Hash #:nodoc:
def self.build(request)
secret = request.env[TOKEN_KEY]
host = request.host
+ secure = request.ssl?
- new(secret, host).tap do |hash|
+ new(secret, host, secure).tap do |hash|
hash.update(request.cookies)
end
end
- def initialize(secret = nil, host = nil)
+ def initialize(secret = nil, host = nil, secure = false)
@secret = secret
@set_cookies = {}
@delete_cookies = {}
@host = host
+ @secure = secure
super()
end
@@ -193,9 +195,15 @@ def signed
end
def write(headers)
- @set_cookies.each { |k, v| ::Rack::Utils.set_cookie_header!(headers, k, v) }
+ @set_cookies.each { |k, v| ::Rack::Utils.set_cookie_header!(headers, k, v) if write_cookie?(v) }
@delete_cookies.each { |k, v| ::Rack::Utils.delete_cookie_header!(headers, k, v) }
end
+
+ private
+
+ def write_cookie?(cookie)
+ @secure || !cookie[:secure] || defined?(Rails.env) && Rails.env.development?
+ end
end
class PermanentCookieJar < CookieJar #:nodoc:
@@ -1,5 +1,4 @@
require 'active_support/testing/performance'
-require 'active_support/testing/default'
begin
module ActionDispatch
@@ -215,21 +215,10 @@ def date_select(object_name, method, options = {}, html_options = {})
# # Creates a time select tag that, when POSTed, will be stored in the post variable in the sunrise attribute
# time_select("post", "sunrise")
#
- # # Creates a time select tag that, when POSTed, will be stored in the order variable in the submitted
- # # attribute
- # time_select("order", "submitted")
- #
- # # Creates a time select tag that, when POSTed, will be stored in the mail variable in the sent_at attribute
- # time_select("mail", "sent_at")
- #
# # Creates a time select tag with a seconds field that, when POSTed, will be stored in the post variables in
# # the sunrise attribute.
# time_select("post", "start_time", :include_seconds => true)
#
- # # Creates a time select tag with a seconds field that, when POSTed, will be stored in the entry variables in
- # # the submission_time attribute.
- # time_select("entry", "submission_time", :include_seconds => true)
- #
# # You can set the :minute_step to 15 which will give you: 00, 15, 30 and 45.
# time_select 'game', 'game_time', {:minute_step => 15}
#
@@ -24,16 +24,17 @@ module TagHelper
# escaping.
#
# ==== Options
+ # You can use symbols or strings for the attribute names.
+ #
# Use +true+ with boolean attributes that can render with no value, like
# +disabled+ and +readonly+.
#
# HTML5 <tt>data-*</tt> attributes can be set with a single +data+ key
# pointing to a hash of sub-attributes.
#
- # Sub-attribute keys may be strings or symbols. To play nicely with
- # JavaScript conventions +dataset+ they will be dasherized so that a key
- # +user_id+ would render as <tt>data-user-id</tt> and thus accessed as
- # <tt>dataset.userId</tt>.
+ # To play nicely with JavaScript conventions sub-attributes are dasherized.
+ # For example, a key +user_id+ would render as <tt>data-user-id</tt> and
+ # thus accessed as <tt>dataset.userId</tt>.
#
# Values are encoded to JSON, with the exception of strings and symbols.
# This may come in handy when using jQuery's HTML5-aware <tt>.data()<tt>
@@ -47,6 +47,11 @@
require 'pp' # require 'pp' early to prevent hidden_methods from not picking up the pretty-print methods until too late
module Rails
+ class << self
+ def env
+ @_env ||= ActiveSupport::StringInquirer.new(ENV["RAILS_ENV"] || ENV["RACK_ENV"] || "test")
+ end
+ end
end
ActiveSupport::Dependencies.hook!
@@ -135,11 +135,25 @@ def test_setting_cookie_with_http_only
end
def test_setting_cookie_with_secure
+ @request.env["HTTPS"] = "on"
get :authenticate_with_secure
assert_cookie_header "user_name=david; path=/; secure"
assert_equal({"user_name" => "david"}, @response.cookies)
end
+ def test_setting_cookie_with_secure_in_development
+ Rails.env.stubs(:development?).returns(true)
+ get :authenticate_with_secure
+ assert_cookie_header "user_name=david; path=/; secure"
+ assert_equal({"user_name" => "david"}, @response.cookies)
+ end
+
+ def test_not_setting_cookie_with_secure
+ get :authenticate_with_secure
+ assert_not_cookie_header "user_name=david; path=/; secure"
+ assert_not_equal({"user_name" => "david"}, @response.cookies)
+ end
+
def test_multiple_cookies
get :set_multiple_cookies
assert_equal 2, @response.cookies.size
@@ -286,4 +300,13 @@ def assert_cookie_header(expected)
assert_equal expected.split("\n"), header
end
end
+
+ def assert_not_cookie_header(expected)
+ header = @response.headers["Set-Cookie"]
+ if header.respond_to?(:to_str)
+ assert_not_equal expected.split("\n").sort, header.split("\n").sort
+ else
+ assert_not_equal expected.split("\n"), header
+ end
+ end
end
@@ -433,6 +433,10 @@ class UrlHelperController < ActionController::Base
match 'url_helper_controller_test/url_helper/normalize_recall_params',
:to => UrlHelperController.action(:normalize_recall),
:as => :normalize_recall_params
+
+ match '/url_helper_controller_test/url_helper/override_url_helper/default',
+ :to => 'url_helper_controller_test/url_helper#override_url_helper',
+ :as => :override_url_helper
end
def show
@@ -468,6 +472,15 @@ def recall_params_not_changed
end
def rescue_action(e) raise e end
+
+ def override_url_helper
+ render :inline => '<%= override_url_helper_path %>'
+ end
+
+ def override_url_helper_path
+ '/url_helper_controller_test/url_helper/override_url_helper/override'
+ end
+ helper_method :override_url_helper_path
end
tests UrlHelperController
@@ -527,6 +540,11 @@ def test_recall_params_should_normalize_id
get :show, :name => '123'
assert_equal 'ok', @response.body
end
+
+ def test_url_helper_can_be_overriden
+ get :override_url_helper
+ assert_equal '/url_helper_controller_test/url_helper/override_url_helper/override', @response.body
+ end
end
class TasksController < ActionController::Base
@@ -21,5 +21,5 @@ Gem::Specification.new do |s|
s.add_dependency('activesupport', version)
s.add_dependency('builder', '~> 2.1.2')
- s.add_dependency('i18n', '~> 0.4.1')
+ s.add_dependency('i18n', '~> 0.4.2')
end
@@ -2,6 +2,9 @@
* Associations with a :through option can now use *any* association as the through or source association, including other associations which have a :through option and has_and_belongs_to_many associations #1812 [Jon Leighton]
+* has_one maintains the association with separate after_create/after_update instead
+ of a single after_save. [fxn]
+
* The following code:
Model.limit(10).scoping { Model.count }
@@ -254,8 +254,6 @@ def preload_has_one_or_has_many_association(records, reflection, preload_options
alias_method :preload_has_many_association, :preload_has_one_or_has_many_association
def preload_through_records(records, reflection, through_association)
- through_reflection = reflections[through_association]
-
# If the same through record is loaded twice, we want to return exactly the same
# object in the result, rather than two separate instances representing the same
# record. This is so that we can preload the source association for each record,
Oops, something went wrong.

0 comments on commit fc276e5

Please sign in to comment.