aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/CHANGELOG.md16
-rw-r--r--actionpack/lib/action_controller/metal/conditional_get.rb9
-rw-r--r--actionpack/lib/action_controller/metal/instrumentation.rb1
-rw-r--r--actionpack/lib/action_view/digestor.rb8
-rw-r--r--actionpack/test/fixtures/digestor/messages/_form.html.erb0
-rw-r--r--actionpack/test/fixtures/digestor/messages/edit.html.erb5
-rw-r--r--actionpack/test/template/digestor_test.rb35
7 files changed, 57 insertions, 17 deletions
diff --git a/actionpack/CHANGELOG.md b/actionpack/CHANGELOG.md
index 9469e5b488..1232370439 100644
--- a/actionpack/CHANGELOG.md
+++ b/actionpack/CHANGELOG.md
@@ -2,15 +2,15 @@
* Added controller-level etag additions that will be part of the action etag computation *Jeremy Kemper/DHH*
- class InvoicesController < ApplicationController
- etag { current_user.try :id }
-
- def show
- # Etag will differ even for the same invoice when it's viewed by a different current_user
- @invoice = Invoice.find(params[:id])
- fresh_when(@invoice)
+ class InvoicesController < ApplicationController
+ etag { current_user.try :id }
+
+ def show
+ # Etag will differ even for the same invoice when it's viewed by a different current_user
+ @invoice = Invoice.find(params[:id])
+ fresh_when(@invoice)
+ end
end
- end
* Add automatic template digests to all CacheHelper#cache calls (originally spiked in the cache_digests plugin) *DHH*
diff --git a/actionpack/lib/action_controller/metal/conditional_get.rb b/actionpack/lib/action_controller/metal/conditional_get.rb
index 1445b3e383..7521deaaca 100644
--- a/actionpack/lib/action_controller/metal/conditional_get.rb
+++ b/actionpack/lib/action_controller/metal/conditional_get.rb
@@ -1,3 +1,5 @@
+require 'active_support/core_ext/class/attribute'
+
module ActionController
module ConditionalGet
extend ActiveSupport::Concern
@@ -5,7 +7,10 @@ module ActionController
include RackDelegation
include Head
- included { cattr_accessor(:etaggers) { Array.new } }
+ included do
+ class_attribute :etaggers
+ self.etaggers = []
+ end
module ClassMethods
# Allows you to consider additional controller-wide information when generating an etag.
@@ -161,7 +166,7 @@ module ActionController
private
def combine_etags(etag)
- [ etag, *etaggers.map { |etagger| instance_exec &etagger }.compact ]
+ [ etag, *etaggers.map { |etagger| instance_exec(&etagger) }.compact ]
end
end
end
diff --git a/actionpack/lib/action_controller/metal/instrumentation.rb b/actionpack/lib/action_controller/metal/instrumentation.rb
index 640ebf5f00..ca4ae532ca 100644
--- a/actionpack/lib/action_controller/metal/instrumentation.rb
+++ b/actionpack/lib/action_controller/metal/instrumentation.rb
@@ -11,6 +11,7 @@ module ActionController
extend ActiveSupport::Concern
include AbstractController::Logger
+ include ActionController::RackDelegation
attr_internal :view_runtime
diff --git a/actionpack/lib/action_view/digestor.rb b/actionpack/lib/action_view/digestor.rb
index cfa864cdd4..899100d06c 100644
--- a/actionpack/lib/action_view/digestor.rb
+++ b/actionpack/lib/action_view/digestor.rb
@@ -15,10 +15,10 @@ module ActionView
# render(topics) => render("topics/topic")
# render(message.topics) => render("topics/topic")
RENDER_DEPENDENCY = /
- render\s? # render, followed by an optional space
- \(? # start a optional parenthesis for the render call
- (partial:)?\s? # naming the partial, used with collection -- 1st capture
- ([@a-z"'][@a-z_\/\."']+) # the template name itself -- 2nd capture
+ render\s* # render, followed by optional whitespace
+ \(? # start an optional parenthesis for the render call
+ (partial:|:partial\s+=>)?\s* # naming the partial, used with collection -- 1st capture
+ ([@a-z"'][@a-z_\/\."']+) # the template name itself -- 2nd capture
/x
cattr_accessor(:cache) { Hash.new }
diff --git a/actionpack/test/fixtures/digestor/messages/_form.html.erb b/actionpack/test/fixtures/digestor/messages/_form.html.erb
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/actionpack/test/fixtures/digestor/messages/_form.html.erb
diff --git a/actionpack/test/fixtures/digestor/messages/edit.html.erb b/actionpack/test/fixtures/digestor/messages/edit.html.erb
new file mode 100644
index 0000000000..a9e0a88e32
--- /dev/null
+++ b/actionpack/test/fixtures/digestor/messages/edit.html.erb
@@ -0,0 +1,5 @@
+<%= render "header" %>
+<%= render partial: "form" %>
+<%= render @message %>
+<%= render ( @message.events ) %>
+<%= render :partial => "comments/comment", :collection => @message.comments %>
diff --git a/actionpack/test/template/digestor_test.rb b/actionpack/test/template/digestor_test.rb
index 067ab500f5..9c84f3107f 100644
--- a/actionpack/test/template/digestor_test.rb
+++ b/actionpack/test/template/digestor_test.rb
@@ -16,7 +16,7 @@ class FixtureFinder
TMP_DIR = "#{File.dirname(__FILE__)}/../tmp"
def find(logical_name, keys, partial, options)
- FixtureTemplate.new("#{TMP_DIR}/#{partial ? logical_name.gsub(%r|/([^/]+)$|, '/_\1') : logical_name}.#{options[:formats].first}.erb")
+ FixtureTemplate.new("#{TMP_DIR}/digestor/#{partial ? logical_name.gsub(%r|/([^/]+)$|, '/_\1') : logical_name}.#{options[:formats].first}.erb")
end
end
@@ -26,7 +26,7 @@ class TemplateDigestorTest < ActionView::TestCase
end
def teardown
- FileUtils.rm_r FixtureFinder::TMP_DIR
+ FileUtils.rm_r File.join(FixtureFinder::TMP_DIR, "digestor")
ActionView::Digestor.cache.clear
end
@@ -92,6 +92,35 @@ class TemplateDigestorTest < ActionView::TestCase
end
end
+ def test_extra_whitespace_in_render_partial
+ assert_digest_difference("messages/edit") do
+ change_template("messages/_form")
+ end
+ end
+
+ def test_extra_whitespace_in_render_named_partial
+ assert_digest_difference("messages/edit") do
+ change_template("messages/_header")
+ end
+ end
+
+ def test_extra_whitespace_in_render_record
+ assert_digest_difference("messages/edit") do
+ change_template("messages/_message")
+ end
+ end
+
+ def test_extra_whitespace_in_render_with_parenthesis
+ assert_digest_difference("messages/edit") do
+ change_template("events/_event")
+ end
+ end
+
+ def test_old_style_hash_in_render_invocation
+ assert_digest_difference("messages/edit") do
+ change_template("comments/_comment")
+ end
+ end
private
def assert_logged(message)
@@ -121,7 +150,7 @@ class TemplateDigestorTest < ActionView::TestCase
end
def change_template(template_name)
- File.open("#{FixtureFinder::TMP_DIR}/#{template_name}.html.erb", "w") do |f|
+ File.open("#{FixtureFinder::TMP_DIR}/digestor/#{template_name}.html.erb", "w") do |f|
f.write "\nTHIS WAS CHANGED!"
end
end