Permalink
Browse files

Merge branch 'master' into feature/public-fragment_name_with_digest

  • Loading branch information...
rgarver committed Oct 2, 2012
2 parents 3fdb712 + df08271 commit 4cb50a3f571234b1202f9a0dffe39b445ecf807d
Showing with 1,086 additions and 650 deletions.
  1. +1 −0 Gemfile
  2. +5 −0 actionmailer/CHANGELOG.md
  3. +3 −0 actionmailer/lib/action_mailer/base.rb
  4. +4 −2 actionmailer/lib/action_mailer/log_subscriber.rb
  5. +7 −0 actionmailer/test/base_test.rb
  6. +53 −3 actionpack/CHANGELOG.md
  7. +0 −1 actionpack/actionpack.gemspec
  8. +5 −5 actionpack/lib/action_controller/caching.rb
  9. +13 −13 actionpack/lib/action_controller/caching/actions.rb
  10. +18 −18 actionpack/lib/action_controller/caching/fragments.rb
  11. +52 −39 actionpack/lib/action_controller/caching/pages.rb
  12. +15 −12 actionpack/lib/action_controller/caching/sweeping.rb
  13. +11 −6 actionpack/lib/action_controller/log_subscriber.rb
  14. +31 −27 actionpack/lib/action_controller/metal/conditional_get.rb
  15. +10 −10 actionpack/lib/action_controller/metal/strong_parameters.rb
  16. +31 −24 actionpack/lib/action_controller/test_case.rb
  17. +3 −3 actionpack/lib/action_dispatch/middleware/show_exceptions.rb
  18. +2 −2 actionpack/lib/action_dispatch/routing/mapper.rb
  19. +2 −2 actionpack/lib/action_view/helpers/asset_tag_helper.rb
  20. +5 −2 actionpack/lib/action_view/log_subscriber.rb
  21. +4 −3 actionpack/lib/action_view/test_case.rb
  22. +22 −0 actionpack/test/controller/action_pack_assertions_test.rb
  23. +42 −5 actionpack/test/controller/caching_test.rb
  24. +16 −0 actionpack/test/controller/show_exceptions_test.rb
  25. +1 −1 actionpack/test/controller/spec_type_test.rb
  26. +20 −0 actionpack/test/dispatch/routing_test.rb
  27. +1 −0 actionpack/test/dispatch/session/cache_store_test.rb
  28. +1 −0 actionpack/test/fixtures/test/hello/hello.erb
  29. +0 −32 actionpack/test/metal/caching_test.rb
  30. +1 −1 actionpack/test/template/spec_type_test.rb
  31. +38 −0 activerecord/CHANGELOG.md
  32. +2 −2 activerecord/Rakefile
  33. +8 −24 activerecord/lib/active_record/associations/collection_proxy.rb
  34. +5 −5 activerecord/lib/active_record/attribute_methods.rb
  35. +21 −7 activerecord/lib/active_record/attribute_methods/dirty.rb
  36. +15 −11 activerecord/lib/active_record/attribute_methods/primary_key.rb
  37. +7 −5 activerecord/lib/active_record/attribute_methods/read.rb
  38. +11 −18 activerecord/lib/active_record/attribute_methods/serialization.rb
  39. +0 −15 activerecord/lib/active_record/attribute_methods/time_zone_conversion.rb
  40. +3 −2 activerecord/lib/active_record/attribute_methods/write.rb
  41. +2 −4 activerecord/lib/active_record/coders/yaml_column.rb
  42. +1 −1 activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb
  43. +8 −0 activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb
  44. +4 −0 activerecord/lib/active_record/connection_adapters/column.rb
  45. +0 −4 activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb
  46. +7 −2 activerecord/lib/active_record/counter_cache.rb
  47. +1 −1 activerecord/lib/active_record/fixtures/file.rb
  48. +6 −4 activerecord/lib/active_record/log_subscriber.rb
  49. +2 −5 activerecord/lib/active_record/model.rb
  50. +2 −2 activerecord/lib/active_record/persistence.rb
  51. +2 −2 activerecord/lib/active_record/railtie.rb
  52. +2 −2 activerecord/lib/active_record/railties/controller_runtime.rb
  53. +29 −26 activerecord/lib/active_record/scoping/default.rb
  54. +48 −65 activerecord/lib/active_record/scoping/named.rb
  55. +12 −11 activerecord/lib/active_record/validations.rb
  56. +1 −1 activerecord/lib/active_record/validations/associated.rb
  57. +8 −9 activerecord/lib/active_record/validations/presence.rb
  58. +9 −11 activerecord/lib/active_record/validations/uniqueness.rb
  59. +14 −1 activerecord/test/cases/counter_cache_test.rb
  60. +25 −0 activerecord/test/cases/dirty_test.rb
  61. +54 −0 activerecord/test/cases/hot_compatibility_test.rb
  62. +1 −1 activerecord/test/cases/store_test.rb
  63. +1 −1 activerecord/test/models/admin/user.rb
  64. +1 −1 activerecord/test/models/subscription.rb
  65. +1 −0 activerecord/test/schema/schema.rb
  66. +4 −0 activesupport/CHANGELOG.md
  67. +1 −1 activesupport/activesupport.gemspec
  68. +85 −63 activesupport/lib/active_support/cache.rb
  69. +1 −0 activesupport/lib/active_support/cache/memory_store.rb
  70. +11 −1 activesupport/lib/active_support/core_ext/string/conversions.rb
  71. +11 −1 activesupport/lib/active_support/notifications.rb
  72. +54 −39 activesupport/test/caching_test.rb
  73. +2 −2 activesupport/test/test_test.rb
  74. +9 −1 guides/source/4_0_release_notes.md
  75. +0 −1 guides/source/action_mailer_basics.md
  76. +0 −3 guides/source/active_record_querying.md
  77. +1 −1 guides/source/asset_pipeline.md
  78. +7 −13 guides/source/command_line.md
  79. +1 −55 guides/source/debugging_rails_applications.md
  80. +5 −1 guides/source/i18n.md
  81. +12 −0 guides/source/routing.md
  82. +15 −1 guides/source/upgrading_ruby_on_rails.md
  83. +0 −3 railties/Rakefile
  84. +6 −0 railties/lib/rails/application.rb
  85. +1 −1 railties/lib/rails/application/configuration.rb
  86. +4 −0 railties/lib/rails/generators/rails/app/templates/Gemfile
  87. +41 −4 railties/lib/rails/generators/rails/resource_route/resource_route_generator.rb
  88. +3 −1 railties/lib/rails/tasks/tmp.rake
  89. +2 −1 railties/test/application/assets_test.rb
  90. +5 −0 railties/test/generators/app_generator_test.rb
  91. +74 −2 railties/test/generators/namespaced_generators_test.rb
  92. +1 −1 railties/test/generators/scaffold_generator_test.rb
View
@@ -6,6 +6,7 @@ gem 'arel', github: 'rails/arel', branch: 'master'
gem 'mocha', '>= 0.11.2', :require => false
gem 'rack-test', github: 'brynary/rack-test'
+gem 'rack-cache', "~> 1.2"
gem 'bcrypt-ruby', '~> 3.0.0'
gem 'jquery-rails'
@@ -1,5 +1,10 @@
## Rails 4.0.0 (unreleased) ##
+* Support `Mailer.deliver_foo(*args)` as a synonym for
+ `Mailer.foo(*args).deliver`. This makes it easy to write e.g.
+ `Mailer.expects(:deliver_foo)` when testing code that calls
+ the mailer. *Jon Leighton*
+
* Allow delivery method options to be set per mail instance *Aditya Sanghi*
If your smtp delivery settings are dynamic,
@@ -142,6 +142,7 @@ module ActionMailer
# for delivery later:
#
# Notifier.welcome(david).deliver # sends the email
+ # Notifier.deliver_welcome(david) # synonym for the former
# mail = Notifier.welcome(david) # => a Mail::Message object
# mail.deliver # sends the email
#
@@ -487,6 +488,8 @@ def set_payload_for_mail(payload, mail) #:nodoc:
def method_missing(method_name, *args)
if action_methods.include?(method_name.to_s)
QueuedMessage.new(queue, self, method_name, *args)
+ elsif method_name.to_s =~ /^deliver_(.+)$/ && action_methods.include?($1)
+ public_send($1, *args).deliver
else
super
end
@@ -1,13 +1,15 @@
module ActionMailer
class LogSubscriber < ActiveSupport::LogSubscriber
def deliver(event)
+ return unless logger.info?
recipients = Array(event.payload[:to]).join(', ')
- info("\nSent mail to #{recipients} (%1.fms)" % event.duration)
+ info("\nSent mail to #{recipients} (#{event.duration.round(1)}ms)")
debug(event.payload[:mail])
end
def receive(event)
- info("\nReceived mail (%.1fms)" % event.duration)
+ return unless logger.info?
+ info("\nReceived mail (#{event.duration.round(1)}ms)")
debug(event.payload[:mail])
end
@@ -662,6 +662,13 @@ def welcome
assert_equal ["robert.pankowecki@gmail.com"], DefaultFromMailer.welcome.from
end
+ test "Mailer.deliver_welcome calls Mailer.welcome.deliver" do
+ BaseMailer.deliveries.clear
+ BaseMailer.deliver_welcome(subject: 'omg')
+ assert_equal 1, BaseMailer.deliveries.length
+ assert_equal 'omg', BaseMailer.deliveries.first.subject
+ end
+
protected
# Execute the block setting the given values and restoring old values after
View
@@ -1,5 +1,56 @@
## Rails 4.0.0 (unreleased) ##
+* Failsafe exception returns text/plain. *Steve Klabnik*
+
+* Remove actionpack's rack-cache dependency and declare the
+ dependency in the Gemfile.
+
+ *Guillermo Iguarán*
+
+* Rename internal variables on ActionController::TemplateAssertions to prevent
+ naming collisions. @partials, @templates and @layouts are now prefixed with an underscore.
+ Fix #7459
+
+ *Yves Senn*
+
+* `resource` and `resources` don't modify the passed options hash
+ Fix #7777
+
+ *Yves Senn*
+
+* Precompiled assets include aliases from foo.js to foo/index.js and vice versa.
+
+ # Precompiles phone-<digest>.css and aliases phone/index.css to phone.css.
+ config.assets.precompile = [ 'phone.css' ]
+
+ # Precompiles phone/index-<digest>.css and aliases phone.css to phone/index.css.
+ config.assets.precompile = [ 'phone/index.css' ]
+
+ # Both of these work with either precompile thanks to their aliases.
+ <%= stylesheet_link_tag 'phone', media: 'all' %>
+ <%= stylesheet_link_tag 'phone/index', media: 'all' %>
+
+ *Jeremy Kemper*
+
+* `assert_template` is no more passing with what ever string that matches
+ with the template name.
+
+ Before when we have a template `/layout/hello.html.erb`, `assert_template`
+ was passing with any string that matches. This behavior allowed false
+ positive like:
+
+ assert_template "layout"
+ assert_template "out/hello"
+
+ Now it only passes with:
+
+ assert_template "layout/hello"
+ assert_template "hello"
+
+ Fixes #3849.
+
+ *Hugolnx*
+
* `image_tag` will set the same width and height for image if numerical value
passed to `size` option.
@@ -44,9 +95,8 @@
*Luiz Felipe Garcia Pereira*
-* Sprockets integration has been extracted from Action Pack and the `sprockets-rails`
- gem should be added to Gemfile (under the assets group) in order to use Rails asset
- pipeline in future versions of Rails.
+* Sprockets integration has been extracted from Action Pack to the `sprockets-rails`
+ gem. `rails` gem is depending on `sprockets-rails` by default.
*Guillermo Iguaran*
@@ -18,7 +18,6 @@ Gem::Specification.new do |s|
s.requirements << 'none'
s.add_dependency('activesupport', version)
- s.add_dependency('rack-cache', '~> 1.2')
s.add_dependency('builder', '~> 3.1.0')
s.add_dependency('rack', '~> 1.4.1')
s.add_dependency('rack-test', '~> 0.6.1')
@@ -23,10 +23,10 @@ module ActionController #:nodoc:
# Configuration examples (MemoryStore is the default):
#
# config.action_controller.cache_store = :memory_store
- # config.action_controller.cache_store = :file_store, "/path/to/cache/directory"
- # config.action_controller.cache_store = :mem_cache_store, "localhost"
- # config.action_controller.cache_store = :mem_cache_store, Memcached::Rails.new("localhost:11211")
- # config.action_controller.cache_store = MyOwnStore.new("parameter")
+ # config.action_controller.cache_store = :file_store, '/path/to/cache/directory'
+ # config.action_controller.cache_store = :mem_cache_store, 'localhost'
+ # config.action_controller.cache_store = :mem_cache_store, Memcached::Rails.new('localhost:11211')
+ # config.action_controller.cache_store = MyOwnStore.new('parameter')
module Caching
extend ActiveSupport::Concern
extend ActiveSupport::Autoload
@@ -73,7 +73,7 @@ def caching_allowed?
end
protected
- # Convenience accessor
+ # Convenience accessor.
def cache(key, options = {}, &block)
if cache_configured?
cache_store.fetch(ActiveSupport::Cache.expand_cache_key(key, :controller), options, &block)
@@ -1,16 +1,16 @@
require 'set'
-module ActionController #:nodoc:
+module ActionController
module Caching
# Action caching is similar to page caching by the fact that the entire
# output of the response is cached, but unlike page caching, every
# request still goes through Action Pack. The key benefit of this is
# that filters run before the cache is served, which allows for
# authentication and other restrictions on whether someone is allowed
- # to execute such action. Example:
+ # to execute such action.
#
# class ListsController < ApplicationController
- # before_filter :authenticate, :except => :public
+ # before_filter :authenticate, except: :public
#
# caches_page :public
# caches_action :index, :show
@@ -35,8 +35,8 @@ module Caching
# <tt>http://david.example.com/lists.xml</tt>
# are treated like separate requests and so are cached separately.
# Keep in mind when expiring an action cache that
- # <tt>:action => 'lists'</tt> is not the same as
- # <tt>:action => 'list', :format => :xml</tt>.
+ # <tt>action: 'lists'</tt> is not the same as
+ # <tt>action: 'list', format: :xml</tt>.
#
# You can modify the default action cache path by passing a
# <tt>:cache_path</tt> option. This will be passed directly to
@@ -53,18 +53,18 @@ module Caching
# The following example depicts some of the points made above:
#
# class ListsController < ApplicationController
- # before_filter :authenticate, :except => :public
+ # before_filter :authenticate, except: :public
#
# caches_page :public
#
- # caches_action :index, :if => Proc.new do
+ # caches_action :index, if: Proc.new do
# !request.format.json? # cache if is not a JSON request
# end
#
- # caches_action :show, :cache_path => { :project => 1 },
- # :expires_in => 1.hour
+ # caches_action :show, cache_path: { project: 1 },
+ # expires_in: 1.hour
#
- # caches_action :feed, :cache_path => Proc.new do
+ # caches_action :feed, cache_path: Proc.new do
# if params[:user_id]
# user_list_url(params[:user_id, params[:id])
# else
@@ -73,7 +73,7 @@ module Caching
# end
# end
#
- # If you pass <tt>:layout => false</tt>, it will only cache your action
+ # If you pass <tt>layout: false</tt>, it will only cache your action
# content. That's useful when your layout has dynamic information.
#
# Warning: If the format of the request is determined by the Accept HTTP
@@ -162,9 +162,9 @@ def around(controller)
class ActionCachePath
attr_reader :path, :extension
- # If +infer_extension+ is true, the cache path extension is looked up from the request's
+ # If +infer_extension+ is +true+, the cache path extension is looked up from the request's
# path and format. This is desirable when reading and writing the cache, but not when
- # expiring the cache - expire_action should expire the same files regardless of the
+ # expiring the cache - +expire_action+ should expire the same files regardless of the
# request format.
def initialize(controller, options = {}, infer_extension = true)
if infer_extension
@@ -1,29 +1,29 @@
-module ActionController #:nodoc:
+module ActionController
module Caching
- # Fragment caching is used for caching various blocks within
+ # Fragment caching is used for caching various blocks within
# views without caching the entire action as a whole. This is
- # useful when certain elements of an action change frequently or
- # depend on complicated state while other parts rarely change or
+ # useful when certain elements of an action change frequently or
+ # depend on complicated state while other parts rarely change or
# can be shared amongst multiple parties. The caching is done using
- # the <tt>cache</tt> helper available in the Action View. See
+ # the +cache+ helper available in the Action View. See
# ActionView::Helpers::CacheHelper for more information.
#
# While it's strongly recommended that you use key-based cache
# expiration (see links in CacheHelper for more information),
# it is also possible to manually expire caches. For example:
#
- # expire_fragment("name_of_cache")
+ # expire_fragment('name_of_cache')
module Fragments
- # Given a key (as described in <tt>expire_fragment</tt>), returns
- # a key suitable for use in reading, writing, or expiring a
+ # Given a key (as described in +expire_fragment+), returns
+ # a key suitable for use in reading, writing, or expiring a
# cached fragment. All keys are prefixed with <tt>views/</tt> and uses
# ActiveSupport::Cache.expand_cache_key for the expansion.
def fragment_cache_key(key)
ActiveSupport::Cache.expand_cache_key(key.is_a?(Hash) ? url_for(key).split("://").last : key, :views)
end
- # Writes <tt>content</tt> to the location signified by
- # <tt>key</tt> (see <tt>expire_fragment</tt> for acceptable formats).
+ # Writes +content+ to the location signified by
+ # +key+ (see +expire_fragment+ for acceptable formats).
def write_fragment(key, content, options = nil)
return content unless cache_configured?
@@ -35,8 +35,8 @@ def write_fragment(key, content, options = nil)
content
end
- # Reads a cached fragment from the location signified by <tt>key</tt>
- # (see <tt>expire_fragment</tt> for acceptable formats).
+ # Reads a cached fragment from the location signified by +key+
+ # (see +expire_fragment+ for acceptable formats).
def read_fragment(key, options = nil)
return unless cache_configured?
@@ -47,8 +47,8 @@ def read_fragment(key, options = nil)
end
end
- # Check if a cached fragment from the location signified by
- # <tt>key</tt> exists (see <tt>expire_fragment</tt> for acceptable formats)
+ # Check if a cached fragment from the location signified by
+ # +key+ exists (see +expire_fragment+ for acceptable formats).
def fragment_exist?(key, options = nil)
return unless cache_configured?
key = fragment_cache_key(key)
@@ -65,7 +65,7 @@ def fragment_exist?(key, options = nil)
# * String - This would normally take the form of a path, like
# <tt>pages/45/notes</tt>.
# * Hash - Treated as an implicit call to +url_for+, like
- # <tt>{:controller => "pages", :action => "notes", :id => 45}</tt>
+ # <tt>{ controller: 'pages', action: 'notes', id: 45}</tt>
# * Regexp - Will remove any fragment that matches, so
# <tt>%r{pages/\d*/notes}</tt> might remove all notes. Make sure you
# don't use anchors in the regex (<tt>^</tt> or <tt>$</tt>) because
@@ -74,8 +74,8 @@ def fragment_exist?(key, options = nil)
# only supported on caches that can iterate over all keys (unlike
# memcached).
#
- # +options+ is passed through to the cache store's <tt>delete</tt>
- # method (or <tt>delete_matched</tt>, for Regexp keys.)
+ # +options+ is passed through to the cache store's +delete+
+ # method (or <tt>delete_matched</tt>, for Regexp keys).
def expire_fragment(key, options = nil)
return unless cache_configured?
key = fragment_cache_key(key) unless key.is_a?(Regexp)
@@ -89,7 +89,7 @@ def expire_fragment(key, options = nil)
end
end
- def instrument_fragment_cache(name, key)
+ def instrument_fragment_cache(name, key) # :nodoc:
ActiveSupport::Notifications.instrument("#{name}.action_controller", :key => key){ yield }
end
end
Oops, something went wrong.

0 comments on commit 4cb50a3

Please sign in to comment.