diff options
-rw-r--r-- | actioncable/lib/action_cable/subscription_adapter/redis.rb | 8 | ||||
-rw-r--r-- | actionview/CHANGELOG.md | 6 | ||||
-rw-r--r-- | actionview/lib/action_view/log_subscriber.rb | 18 | ||||
-rw-r--r-- | actionview/test/template/log_subscriber_test.rb | 9 | ||||
-rw-r--r-- | guides/source/debugging_rails_applications.md | 2 | ||||
-rw-r--r-- | railties/lib/rails/generators/app_base.rb | 2 | ||||
-rw-r--r-- | railties/lib/rails/generators/rails/app/templates/Gemfile | 2 | ||||
-rw-r--r-- | railties/lib/rails/tasks/dev.rake | 2 | ||||
-rw-r--r-- | railties/test/generators/app_generator_test.rb | 5 |
9 files changed, 46 insertions, 8 deletions
diff --git a/actioncable/lib/action_cable/subscription_adapter/redis.rb b/actioncable/lib/action_cable/subscription_adapter/redis.rb index ba4934a264..6b4236e7d3 100644 --- a/actioncable/lib/action_cable/subscription_adapter/redis.rb +++ b/actioncable/lib/action_cable/subscription_adapter/redis.rb @@ -33,7 +33,7 @@ module ActionCable end def redis_connection_for_subscriptions - ::Redis.new(@server.config.cable) + redis_connection end private @@ -43,10 +43,14 @@ module ActionCable def redis_connection_for_broadcasts @redis_connection_for_broadcasts || @server.mutex.synchronize do - @redis_connection_for_broadcasts ||= self.class.redis_connector.call(@server.config.cable) + @redis_connection_for_broadcasts ||= redis_connection end end + def redis_connection + self.class.redis_connector.call(@server.config.cable) + end + class Listener < SubscriberMap def initialize(adapter) super() diff --git a/actionview/CHANGELOG.md b/actionview/CHANGELOG.md index d084f2b1e0..6b77fd44f1 100644 --- a/actionview/CHANGELOG.md +++ b/actionview/CHANGELOG.md @@ -1,3 +1,9 @@ +* Added log "Rendering ...", when starting to render a template to log that + we have started rendering something. This helps to easily identify the origin + of queries in the log whether they came from controller or views. + + *Vipul A M and Prem Sichanugrist* + ## Rails 5.0.0.beta3 (February 24, 2016) ## * Collection rendering can cache and fetch multiple partials at once. diff --git a/actionview/lib/action_view/log_subscriber.rb b/actionview/lib/action_view/log_subscriber.rb index aa38db2a3a..5a29c68214 100644 --- a/actionview/lib/action_view/log_subscriber.rb +++ b/actionview/lib/action_view/log_subscriber.rb @@ -30,6 +30,14 @@ module ActionView end end + def start(name, id, payload) + if name == "render_template.action_view" + log_rendering_start(payload) + end + + super + end + def logger ActionView::Base.logger end @@ -54,6 +62,16 @@ module ActionView "[#{payload[:count]} times]" end end + + private + + def log_rendering_start(payload) + info do + message = " Rendering #{from_rails_root(payload[:identifier])}" + message << " within #{from_rails_root(payload[:layout])}" if payload[:layout] + message + end + end end end diff --git a/actionview/test/template/log_subscriber_test.rb b/actionview/test/template/log_subscriber_test.rb index 93a0701dcc..7683444bf0 100644 --- a/actionview/test/template/log_subscriber_test.rb +++ b/actionview/test/template/log_subscriber_test.rb @@ -35,7 +35,8 @@ class AVLogSubscriberTest < ActiveSupport::TestCase @view.render(:file => "test/hello_world") wait - assert_equal 1, @logger.logged(:info).size + assert_equal 2, @logger.logged(:info).size + assert_match(/Rendering test\/hello_world\.erb/, @logger.logged(:info).first) assert_match(/Rendered test\/hello_world\.erb/, @logger.logged(:info).last) end end @@ -45,7 +46,8 @@ class AVLogSubscriberTest < ActiveSupport::TestCase @view.render(:text => "TEXT") wait - assert_equal 1, @logger.logged(:info).size + assert_equal 2, @logger.logged(:info).size + assert_match(/Rendering text template/, @logger.logged(:info).first) assert_match(/Rendered text template/, @logger.logged(:info).last) end end @@ -55,7 +57,8 @@ class AVLogSubscriberTest < ActiveSupport::TestCase @view.render(:inline => "<%= 'TEXT' %>") wait - assert_equal 1, @logger.logged(:info).size + assert_equal 2, @logger.logged(:info).size + assert_match(/Rendering inline template/, @logger.logged(:info).first) assert_match(/Rendered inline template/, @logger.logged(:info).last) end end diff --git a/guides/source/debugging_rails_applications.md b/guides/source/debugging_rails_applications.md index 713d95a3c1..faf475c294 100644 --- a/guides/source/debugging_rails_applications.md +++ b/guides/source/debugging_rails_applications.md @@ -109,7 +109,7 @@ It can also be useful to save information to log files at runtime. Rails maintai Rails makes use of the `ActiveSupport::Logger` class to write log information. Other loggers, such as `Log4r`, may also be substituted. -You can specify an alternative logger in `config/application.rb`, for example: +You can specify an alternative logger in `config/application.rb` or any other environment file, for example: ```ruby config.logger = Logger.new(STDOUT) diff --git a/railties/lib/rails/generators/app_base.rb b/railties/lib/rails/generators/app_base.rb index ed4e73fb90..89341e6fa2 100644 --- a/railties/lib/rails/generators/app_base.rb +++ b/railties/lib/rails/generators/app_base.rb @@ -181,7 +181,7 @@ module Rails def webserver_gemfile_entry return [] if options[:skip_puma] comment = 'Use Puma as the app server' - GemfileEntry.new('puma', nil, comment) + GemfileEntry.new('puma', '~> 3.0', comment) end def include_all_railties? diff --git a/railties/lib/rails/generators/rails/app/templates/Gemfile b/railties/lib/rails/generators/rails/app/templates/Gemfile index f3bc9d9734..e8ec214b28 100644 --- a/railties/lib/rails/generators/rails/app/templates/Gemfile +++ b/railties/lib/rails/generators/rails/app/templates/Gemfile @@ -26,7 +26,7 @@ source 'https://rubygems.org' <% if RUBY_ENGINE == 'ruby' -%> group :development, :test do # Call 'byebug' anywhere in the code to stop execution and get a debugger console - gem 'byebug' + gem 'byebug', platform: :mri end group :development do diff --git a/railties/lib/rails/tasks/dev.rake b/railties/lib/rails/tasks/dev.rake index 4593100465..ff2de264ce 100644 --- a/railties/lib/rails/tasks/dev.rake +++ b/railties/lib/rails/tasks/dev.rake @@ -1,6 +1,8 @@ namespace :dev do desc 'Toggle development mode caching on/off' task :cache do + FileUtils.mkdir_p('tmp') + if File.exist? 'tmp/caching-dev.txt' File.delete 'tmp/caching-dev.txt' puts 'Development mode is no longer being cached.' diff --git a/railties/test/generators/app_generator_test.rb b/railties/test/generators/app_generator_test.rb index ec8ec4787f..c5f9e11ad3 100644 --- a/railties/test/generators/app_generator_test.rb +++ b/railties/test/generators/app_generator_test.rb @@ -366,6 +366,11 @@ class AppGeneratorTest < Rails::Generators::TestCase end end + def test_generator_defaults_to_puma_version + run_generator [destination_root] + assert_gem "puma", "'~> 3.0'" + end + def test_generator_if_skip_puma_is_given run_generator [destination_root, "--skip-puma"] assert_no_file "config/puma.rb" |