From 940124a22676f51540402e538fff626ef73b1d99 Mon Sep 17 00:00:00 2001 From: Kasper Timm Hansen Date: Wed, 27 Apr 2016 22:24:28 +0200 Subject: Respect gospel of Railties Gods: no on_load with after. We don't need no stinking `on_load` where we're going! Because people far wiser than me (@rafaelfranca and @jeremy) know that passing `:after` means the lib is already loaded. --- actionview/lib/action_view/railtie.rb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'actionview/lib') diff --git a/actionview/lib/action_view/railtie.rb b/actionview/lib/action_view/railtie.rb index 67c80d22d8..09ce693aff 100644 --- a/actionview/lib/action_view/railtie.rb +++ b/actionview/lib/action_view/railtie.rb @@ -38,9 +38,7 @@ module ActionView end initializer "action_view.collection_caching", after: "action_controller.set_configs" do |app| - ActiveSupport.on_load(:action_controller) do - PartialRenderer.collection_cache = app.config.action_controller.cache_store - end + PartialRenderer.collection_cache = app.config.action_controller.cache_store end initializer "action_view.per_request_digest_cache" do |app| -- cgit v1.2.3 From f7a986012a6099445e20b6414d253ee0fc039118 Mon Sep 17 00:00:00 2001 From: eileencodes Date: Wed, 27 Apr 2016 15:47:22 -0500 Subject: Prep Rails 5 beta 4 --- actionview/lib/action_view/gem_version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'actionview/lib') diff --git a/actionview/lib/action_view/gem_version.rb b/actionview/lib/action_view/gem_version.rb index efb565bf59..7f86994fd4 100644 --- a/actionview/lib/action_view/gem_version.rb +++ b/actionview/lib/action_view/gem_version.rb @@ -8,7 +8,7 @@ module ActionView MAJOR = 5 MINOR = 0 TINY = 0 - PRE = "beta3" + PRE = "beta4" STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".") end -- cgit v1.2.3 From 31458a94a6ee5c96cbdcdaafc6720fe2dc459ed6 Mon Sep 17 00:00:00 2001 From: Vipul A M Date: Thu, 28 Apr 2016 02:51:10 +0530 Subject: Push action_view.collection_caching to be called towards the end, since it depends on being called after action_controller.set_configs. This causes, other AV initializers after it to be called after all of AC initializers, which get pulled in before since action_controller.set_configs gets called. Hence, push initializer depending on after hook, to be called after all initializers for this railtie are done. --- actionview/lib/action_view/railtie.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'actionview/lib') diff --git a/actionview/lib/action_view/railtie.rb b/actionview/lib/action_view/railtie.rb index 09ce693aff..c83614c89a 100644 --- a/actionview/lib/action_view/railtie.rb +++ b/actionview/lib/action_view/railtie.rb @@ -37,10 +37,6 @@ module ActionView end end - initializer "action_view.collection_caching", after: "action_controller.set_configs" do |app| - PartialRenderer.collection_cache = app.config.action_controller.cache_store - end - initializer "action_view.per_request_digest_cache" do |app| ActiveSupport.on_load(:action_view) do if app.config.consider_all_requests_local @@ -55,6 +51,10 @@ module ActionView end end + initializer "action_view.collection_caching", after: "action_controller.set_configs" do |app| + PartialRenderer.collection_cache = app.config.action_controller.cache_store + end + rake_tasks do |app| unless app.config.api_only load "action_view/tasks/cache_digests.rake" -- cgit v1.2.3 From fbdcf5221ad7ea3d40ad09651962fc85d101dd67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Fri, 6 May 2016 16:54:40 -0500 Subject: Preparing for 5.0.0.rc1 release --- actionview/lib/action_view/gem_version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'actionview/lib') diff --git a/actionview/lib/action_view/gem_version.rb b/actionview/lib/action_view/gem_version.rb index 7f86994fd4..36eb33fbd9 100644 --- a/actionview/lib/action_view/gem_version.rb +++ b/actionview/lib/action_view/gem_version.rb @@ -8,7 +8,7 @@ module ActionView MAJOR = 5 MINOR = 0 TINY = 0 - PRE = "beta4" + PRE = "rc1" STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".") end -- cgit v1.2.3 From 8ecc5ab1d88532a239f17c7520ed922c7579b01c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Tue, 10 May 2016 01:07:09 -0300 Subject: Start Rails 5.1 development :tada: --- actionview/lib/action_view/gem_version.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'actionview/lib') diff --git a/actionview/lib/action_view/gem_version.rb b/actionview/lib/action_view/gem_version.rb index 36eb33fbd9..5fc4f3f1b9 100644 --- a/actionview/lib/action_view/gem_version.rb +++ b/actionview/lib/action_view/gem_version.rb @@ -6,9 +6,9 @@ module ActionView module VERSION MAJOR = 5 - MINOR = 0 + MINOR = 1 TINY = 0 - PRE = "rc1" + PRE = "alpha" STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".") end -- cgit v1.2.3 From 23b6a9c0fcb8992e18450d6fe0680bf09685b7db Mon Sep 17 00:00:00 2001 From: Kasper Timm Hansen Date: Mon, 16 May 2016 21:34:16 +0200 Subject: Replace middleware with executor callback. Per request digest caches were added before we had hooks into different units of work that Rails performs. As such the most reliable way to prevent stale cache digests was with a middleware. The middleware prevented staleness in Action Controller requests. However, the executor is superior because it should also prevent staleness when running just Active Job jobs or broadcasting through Action Cable's server. --- actionview/lib/action_view/digestor.rb | 7 ------- actionview/lib/action_view/railtie.rb | 2 +- 2 files changed, 1 insertion(+), 8 deletions(-) (limited to 'actionview/lib') diff --git a/actionview/lib/action_view/digestor.rb b/actionview/lib/action_view/digestor.rb index b99d1af998..53baf044f1 100644 --- a/actionview/lib/action_view/digestor.rb +++ b/actionview/lib/action_view/digestor.rb @@ -6,13 +6,6 @@ module ActionView class Digestor @@digest_mutex = Mutex.new - class PerRequestDigestCacheExpiry < Struct.new(:app) # :nodoc: - def call(env) - ActionView::LookupContext::DetailsKey.clear - app.call(env) - end - end - class << self # Supported options: # diff --git a/actionview/lib/action_view/railtie.rb b/actionview/lib/action_view/railtie.rb index c83614c89a..dfb99f4ea9 100644 --- a/actionview/lib/action_view/railtie.rb +++ b/actionview/lib/action_view/railtie.rb @@ -40,7 +40,7 @@ module ActionView initializer "action_view.per_request_digest_cache" do |app| ActiveSupport.on_load(:action_view) do if app.config.consider_all_requests_local - app.middleware.use ActionView::Digestor::PerRequestDigestCacheExpiry + app.executor.to_run { ActionView::LookupContext::DetailsKey.clear } end end end -- cgit v1.2.3 From bd49a4b175e056c77610c78ac109eab0c3411af8 Mon Sep 17 00:00:00 2001 From: Kasper Timm Hansen Date: Mon, 16 May 2016 21:38:01 +0200 Subject: Remove extranous spaces from assignment. Leftover from an earlier commit, chose to fix because I was just down in this file. --- actionview/lib/action_view/digestor.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'actionview/lib') diff --git a/actionview/lib/action_view/digestor.rb b/actionview/lib/action_view/digestor.rb index 53baf044f1..b91e61da18 100644 --- a/actionview/lib/action_view/digestor.rb +++ b/actionview/lib/action_view/digestor.rb @@ -4,7 +4,7 @@ require 'monitor' module ActionView class Digestor - @@digest_mutex = Mutex.new + @@digest_mutex = Mutex.new class << self # Supported options: -- cgit v1.2.3 From 7aedae6de58195efb1e2d79af212d1c7290f2f73 Mon Sep 17 00:00:00 2001 From: Jon Moss Date: Mon, 16 May 2016 17:56:37 -0400 Subject: [Action View] Don't create middleman `DetailsKey` instance All of this is `nodoc`'ed, so we shouldn't have to worry about breaking changes, if there are any -- all internal API :). --- actionview/lib/action_view/lookup_context.rb | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'actionview/lib') diff --git a/actionview/lib/action_view/lookup_context.rb b/actionview/lib/action_view/lookup_context.rb index 626c4b8f5e..9db1460ee7 100644 --- a/actionview/lib/action_view/lookup_context.rb +++ b/actionview/lib/action_view/lookup_context.rb @@ -63,7 +63,7 @@ module ActionView details = details.dup details[:formats] &= Template::Types.symbols end - @details_keys[details] ||= new + @details_keys[details] ||= Concurrent::Map.new end def self.clear @@ -71,13 +71,7 @@ module ActionView end def self.digest_caches - @details_keys.values.map(&:digest_cache) - end - - attr_reader :digest_cache - - def initialize - @digest_cache = Concurrent::Map.new + @details_keys.values end end @@ -236,7 +230,7 @@ module ActionView end def digest_cache - details_key.digest_cache + details_key end def initialize_details(target, details) -- cgit v1.2.3 From d6bac046922fcee05366d26d75349dde70d25f6b Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Tue, 17 May 2016 11:28:40 -0700 Subject: keep layouts + locals from bloating the cache Using locals will cause layouts to be cached multiple times in the template cache. This commit removes locals from consideration when looking up the layout. --- .../lib/action_view/renderer/template_renderer.rb | 6 +++--- actionview/lib/action_view/template/resolver.rb | 17 +++++++++++++++++ 2 files changed, 20 insertions(+), 3 deletions(-) (limited to 'actionview/lib') diff --git a/actionview/lib/action_view/renderer/template_renderer.rb b/actionview/lib/action_view/renderer/template_renderer.rb index 9d15bbfca7..1d6afb90fe 100644 --- a/actionview/lib/action_view/renderer/template_renderer.rb +++ b/actionview/lib/action_view/renderer/template_renderer.rb @@ -84,13 +84,13 @@ module ActionView when String begin if layout =~ /^\// - with_fallbacks { find_template(layout, nil, false, keys, details) } + with_fallbacks { find_template(layout, nil, false, [], details) } else - find_template(layout, nil, false, keys, details) + find_template(layout, nil, false, [], details) end rescue ActionView::MissingTemplate all_details = @details.merge(:formats => @lookup_context.default_formats) - raise unless template_exists?(layout, nil, false, keys, all_details) + raise unless template_exists?(layout, nil, false, [], all_details) end when Proc resolve_layout(layout.call(formats), keys, formats) diff --git a/actionview/lib/action_view/template/resolver.rb b/actionview/lib/action_view/template/resolver.rb index c5e69b1833..bf68e93c58 100644 --- a/actionview/lib/action_view/template/resolver.rb +++ b/actionview/lib/action_view/template/resolver.rb @@ -88,6 +88,23 @@ module ActionView @query_cache.clear end + # Get the cache size. Do not call this + # method. This method is not guaranteed to be here ever. + def size # :nodoc: + size = 0 + @data.each_value do |v1| + v1.each_value do |v2| + v2.each_value do |v3| + v3.each_value do |v4| + size += v4.size + end + end + end + end + + size + @query_cache.size + end + private def canonical_no_templates(templates) -- cgit v1.2.3 From 9cd790d77d30b0f2759cec6a8dcd31ac5c7c8c55 Mon Sep 17 00:00:00 2001 From: Jon Moss Date: Tue, 17 May 2016 15:44:57 -0400 Subject: `md5` --> `MD5` Sorry, I missed a few places in my last PR. This should be the last of 'em :grimacing: --- actionview/lib/action_view/helpers/cache_helper.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'actionview/lib') diff --git a/actionview/lib/action_view/helpers/cache_helper.rb b/actionview/lib/action_view/helpers/cache_helper.rb index 4c7c4b91c6..4eaaa239e2 100644 --- a/actionview/lib/action_view/helpers/cache_helper.rb +++ b/actionview/lib/action_view/helpers/cache_helper.rb @@ -41,11 +41,11 @@ module ActionView # # ==== \Template digest # - # The template digest that's added to the cache key is computed by taking an md5 of the + # The template digest that's added to the cache key is computed by taking an MD5 of the # contents of the entire template file. This ensures that your caches will automatically # expire when you change the template file. # - # Note that the md5 is taken of the entire template file, not just what's within the + # Note that the MD5 is taken of the entire template file, not just what's within the # cache do/end call. So it's possible that changing something outside of that call will # still expire the cache. # @@ -118,7 +118,7 @@ module ActionView # # If you use a helper method, for example, inside a cached block and # you then update that helper, you'll have to bump the cache as well. - # It doesn't really matter how you do it, but the md5 of the template file + # It doesn't really matter how you do it, but the MD5 of the template file # must change. One recommendation is to simply be explicit in a comment, like: # # <%# Helper Dependency Updated: May 6, 2012 at 6pm %> -- cgit v1.2.3 From 0ce7eae7418f1b9bb06b351c1f26d50c3674c0d0 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Tue, 17 May 2016 16:53:20 -0700 Subject: Make sure the cache is always populated This way we don't have to make multiple calls on anonymous controllers --- actionview/lib/action_view/test_case.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'actionview/lib') diff --git a/actionview/lib/action_view/test_case.rb b/actionview/lib/action_view/test_case.rb index 120962b5aa..ec16b0609e 100644 --- a/actionview/lib/action_view/test_case.rb +++ b/actionview/lib/action_view/test_case.rb @@ -14,7 +14,7 @@ module ActionView attr_accessor :request, :response, :params class << self - attr_writer :controller_path + attr_accessor :controller_path end def controller_path=(path) -- cgit v1.2.3 From e3b239cc1a8626c24f4a642e9261bad4a97c6cac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Fri, 20 May 2016 23:28:00 -0300 Subject: Revert "Make sure the cache is always populated" This reverts commit 0ce7eae7418f1b9bb06b351c1f26d50c3674c0d0. Tests were broken https://travis-ci.org/rails/rails/jobs/131850726#L520 --- actionview/lib/action_view/test_case.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'actionview/lib') diff --git a/actionview/lib/action_view/test_case.rb b/actionview/lib/action_view/test_case.rb index ec16b0609e..120962b5aa 100644 --- a/actionview/lib/action_view/test_case.rb +++ b/actionview/lib/action_view/test_case.rb @@ -14,7 +14,7 @@ module ActionView attr_accessor :request, :response, :params class << self - attr_accessor :controller_path + attr_writer :controller_path end def controller_path=(path) -- cgit v1.2.3 From 9bfd968bed1a76888ec82e0f7b524a989d0e1108 Mon Sep 17 00:00:00 2001 From: Vipul A M Date: Mon, 9 May 2016 02:36:58 +0530 Subject: Confirm with the specification when generating emtpy option for select with `include_blank: true` option. We now generate option with empty label, example: `` for include_blank: true. This is only done, if content is missing on the option, and we providing the value from this option. Fixes #24816 --- actionview/lib/action_view/helpers/form_tag_helper.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'actionview/lib') diff --git a/actionview/lib/action_view/helpers/form_tag_helper.rb b/actionview/lib/action_view/helpers/form_tag_helper.rb index cfff0bef5d..82f2fd30c7 100644 --- a/actionview/lib/action_view/helpers/form_tag_helper.rb +++ b/actionview/lib/action_view/helpers/form_tag_helper.rb @@ -134,13 +134,15 @@ module ActionView if options.include?(:include_blank) include_blank = options.delete(:include_blank) + options_for_blank_options_tag = { value: '' } if include_blank == true include_blank = '' + options_for_blank_options_tag[:label] = ' ' end if include_blank - option_tags = content_tag("option".freeze, include_blank, value: '').safe_concat(option_tags) + option_tags = content_tag("option".freeze, include_blank, options_for_blank_options_tag).safe_concat(option_tags) end end -- cgit v1.2.3