Permalink
Browse files

Merge branch 'master' into joindep

* master: (23 commits)
  Escape the parentheses in the default function regexp
  Update docs on Tilt::Template in Asset Pipeline guide
  Fix loading a sql structure file on postgres when the file's path has whitespace in it
  remove trailing whitespace added with b057765 [ci skip].
  Allow unscope to work with `where.not`
  Raise an exception when model without primary key calls .find_with_ids
  Process sub-query relation's binding values
  Instrument the generation of Action Mailer messages
  Remove extra variable creation and merge.
  In Relation#empty? use #exists? instead of #count.
  [ci skip] avoid deprecation warning in sample code
  Convert Fixnum into String the port number in MySQL
  Fix some indentation on autosave association
  Make define_non_cyclic_method simpler
  Add Sass gobbling info to asset pipeline docs
  Ensure the state is clean after one failure
  Fix typo in form_helper.rb
  add a new local variable to track if digests are being stored, to ensure the cleanup works correctly
  [ci skip] Fix number of methods added by association.
  update digestor code based on review
  ...
  • Loading branch information...
2 parents 6546cf2 + b98c10c commit 8f5647e9c55f46aeeb01baef31d696c7a4415104 @tenderlove tenderlove committed Oct 21, 2013
@@ -1,3 +1,8 @@
+* Instrument the generation of Action Mailer messages. The time it takes to
+ generate a message is written to the log.
+
+ *Daniel Schierbeck*
+
* invoke mailer defaults as procs only if they are procs, do not convert
with to_proc. That an object is convertible to a proc does not mean it's
meant to be always used as a proc. Fixes #11533
@@ -511,11 +511,18 @@ def initialize(method_name=nil, *args)
process(method_name, *args) if method_name
end
- def process(*args) #:nodoc:
- lookup_context.skip_default_locale!
+ def process(method_name, *args) #:nodoc:
+ payload = {
+ :mailer => self.class.name,
+ :action => method_name
+ }
- super
- @_message = NullMail.new unless @_mail_was_called
+ ActiveSupport::Notifications.instrument("process.action_mailer", payload) do
+ lookup_context.skip_default_locale!
+
+ super
+ @_message = NullMail.new unless @_mail_was_called
+ end
end
class NullMail #:nodoc:
@@ -685,9 +692,9 @@ def mail(headers = {}, &block)
content_type = headers[:content_type]
# Call all the procs (if any)
- class_default = self.class.default
- default_values = class_default.merge(class_default) do |k,v|
- v.is_a?(Proc) ? instance_eval(&v) : v
+ default_values = {}
+ self.class.default.each do |k,v|
+ default_values[k] = v.is_a?(Proc) ? instance_eval(&v) : v
end
# Handle defaults
@@ -19,6 +19,13 @@ def receive(event)
debug(event.payload[:mail])
end
+ # An email was generated.
+ def process(event)
+ mailer = event.payload[:mailer]
+ action = event.payload[:action]
+ debug("\n#{mailer}##{action}: processed outbound mail in #{event.duration.round(1)}ms")
+ end
+
# Use the logger configured for ActionMailer::Base
def logger
ActionMailer::Base.logger
@@ -24,10 +24,13 @@ def set_logger(logger)
def test_deliver_is_notified
BaseMailer.welcome.deliver
wait
+
assert_equal(1, @logger.logged(:info).size)
assert_match(/Sent mail to system@test.lindsaar.net/, @logger.logged(:info).first)
- assert_equal(1, @logger.logged(:debug).size)
- assert_match(/Welcome/, @logger.logged(:debug).first)
+
+ assert_equal(2, @logger.logged(:debug).size)
+ assert_match(/BaseMailer#welcome: processed outbound mail in [\d.]+ms/, @logger.logged(:debug).first)
+ assert_match(/Welcome/, @logger.logged(:debug).second)
end
def test_receive_is_notified
@@ -39,4 +42,4 @@ def test_receive_is_notified
assert_equal(1, @logger.logged(:debug).size)
assert_match(/Jamis/, @logger.logged(:debug).first)
end
-end
+end
@@ -1,3 +1,8 @@
+* Ensure ActionView::Digestor.cache is correctly cleaned up when
+ combining recursive templates with ActionView::Resolver.caching = false
+
+ *wyaeld*
+
* Fix `collection_check_boxes` generated hidden input to use the name attribute provided
in the options hash.
@@ -35,13 +35,13 @@ def compute_and_store_digest(cache_key, name, format, finder, options) # called
Digestor
end
+ digest = klass.new(name, format, finder, options).digest
# Store the actual digest if config.cache_template_loading is true
- klass.new(name, format, finder, options).digest.tap do |digest|
- @@cache[cache_key] = digest if ActionView::Resolver.caching?
- end
- rescue Exception
- @@cache.delete_pair(cache_key, false) if pre_stored # something went wrong, make sure not to corrupt the @@cache
- raise
+ @@cache[cache_key] = stored_digest = digest if ActionView::Resolver.caching?
+ digest
+ ensure
+ # something went wrong or ActionView::Resolver.caching? is false, make sure not to corrupt the @@cache
+ @@cache.delete_pair(cache_key, false) if pre_stored && !stored_digest
end
end
@@ -1173,7 +1173,7 @@ def default_form_builder
# methods in the +FormHelper+ module. This class, however, allows you to
# call methods with the model object you are building the form for.
#
- # You can create your own custom FormBuilder templates by subclasses this
+ # You can create your own custom FormBuilder templates by subclassing this
# class. For example:
#
# class MyFormBuilder < ActionView::Helpers::FormBuilder
@@ -217,6 +217,31 @@ def test_cache_template_loading
ActionView::Resolver.caching = resolver_before
end
+ def test_digest_cache_cleanup_with_recursion
+ first_digest = digest("level/_recursion")
+ second_digest = digest("level/_recursion")
+
+ assert first_digest
+
+ # If the cache is cleaned up correctly, subsequent digests should return the same
+ assert_equal first_digest, second_digest
+ end
+
+ def test_digest_cache_cleanup_with_recursion_and_template_caching_off
+ resolver_before = ActionView::Resolver.caching
+ ActionView::Resolver.caching = false
+
+ first_digest = digest("level/_recursion")
+ second_digest = digest("level/_recursion")
+
+ assert first_digest
+
+ # If the cache is cleaned up correctly, subsequent digests should return the same
+ assert_equal first_digest, second_digest
+ ensure
+ ActionView::Resolver.caching = resolver_before
+ end
+
private
def assert_logged(message)
old_logger = ActionView::Base.logger
@@ -1,3 +1,37 @@
+* Sub-query generated for `Relation` passed as array condition did not take in account
+ bind values and have invalid syntax.
+
+ Generate sub-query with inline bind values.
+
+ Fixes: #12586
+
+ *Paul Nikitochkin*
+
+* Fix a bug where rake db:structure:load crashed when the path contained
+ spaces.
+
+ *Kevin Mook*
+
+* `ActiveRecord::QueryMethods#unscope` unscopes negative equality
+
+ Allows you to call `#unscope` on a relation with negative equality
+ operators, i.e. `Arel::Nodes::NotIn` and `Arel::Nodes::NotEqual` that have
+ been generated through the use of `where.not`.
+
+ *Eric Hankins*
+
+* Raise an exception when model without primary key calls `.find_with_ids`.
+
+ *Shimpei Makimoto*
+
+* Make `Relation#empty?` use `exists?` instead of `count`.
+
+ *Szymon Nowak*
+
+* `rake db:structure:dump` no longer crashes when the port was specified as `Fixnum`.
+
+ *Kenta Okamoto*
+
* `NullRelation#pluck` takes a list of columns
The method signature in `NullRelation` was updated to mimic that in
Oops, something went wrong.

0 comments on commit 8f5647e

Please sign in to comment.