aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/activerecord/controller_runtime_test.rb
diff options
context:
space:
mode:
authorPiotr Sarnacki <drogus@gmail.com>2013-04-17 00:06:11 +0200
committerŁukasz Strzałkowski <lukasz.strzalkowski@gmail.com>2013-06-20 17:23:16 +0200
commiteb23754ebbfbf2d465cc0f900720704fb3703633 (patch)
tree5bd1764233b59075341611b1e857d418c794d812 /actionpack/test/activerecord/controller_runtime_test.rb
parent5bcdf4faa6da7acb762dab680372f8520a0533c2 (diff)
downloadrails-eb23754ebbfbf2d465cc0f900720704fb3703633.tar.gz
rails-eb23754ebbfbf2d465cc0f900720704fb3703633.tar.bz2
rails-eb23754ebbfbf2d465cc0f900720704fb3703633.zip
Move template tests from actionpack to actionview
Diffstat (limited to 'actionpack/test/activerecord/controller_runtime_test.rb')
-rw-r--r--actionpack/test/activerecord/controller_runtime_test.rb95
1 files changed, 0 insertions, 95 deletions
diff --git a/actionpack/test/activerecord/controller_runtime_test.rb b/actionpack/test/activerecord/controller_runtime_test.rb
deleted file mode 100644
index 368bec1c70..0000000000
--- a/actionpack/test/activerecord/controller_runtime_test.rb
+++ /dev/null
@@ -1,95 +0,0 @@
-require 'active_record_unit'
-require 'active_record/railties/controller_runtime'
-require 'fixtures/project'
-require 'active_support/log_subscriber/test_helper'
-require 'action_controller/log_subscriber'
-
-ActionController::Base.send :include, ActiveRecord::Railties::ControllerRuntime
-
-class ControllerRuntimeLogSubscriberTest < ActionController::TestCase
- class LogSubscriberController < ActionController::Base
- respond_to :html
-
- def show
- render :inline => "<%= Project.all %>"
- end
-
- def zero
- render :inline => "Zero DB runtime"
- end
-
- def create
- ActiveRecord::LogSubscriber.runtime += 100
- project = Project.last
- respond_with(project, location: url_for(action: :show))
- end
-
- def redirect
- Project.all
- redirect_to :action => 'show'
- end
-
- def db_after_render
- render :inline => "Hello world"
- Project.all
- ActiveRecord::LogSubscriber.runtime += 100
- end
- end
-
- include ActiveSupport::LogSubscriber::TestHelper
- tests LogSubscriberController
-
- def setup
- super
- @old_logger = ActionController::Base.logger
- ActionController::LogSubscriber.attach_to :action_controller
- end
-
- def teardown
- super
- ActiveSupport::LogSubscriber.log_subscribers.clear
- ActionController::Base.logger = @old_logger
- end
-
- def set_logger(logger)
- ActionController::Base.logger = logger
- end
-
- def test_log_with_active_record
- get :show
- wait
-
- assert_equal 2, @logger.logged(:info).size
- assert_match(/\(Views: [\d.]+ms \| ActiveRecord: [\d.]+ms\)/, @logger.logged(:info)[1])
- end
-
- def test_runtime_reset_before_requests
- ActiveRecord::LogSubscriber.runtime += 12345
- get :zero
- wait
-
- assert_equal 2, @logger.logged(:info).size
- assert_match(/\(Views: [\d.]+ms \| ActiveRecord: 0.0ms\)/, @logger.logged(:info)[1])
- end
-
- def test_log_with_active_record_when_post
- post :create
- wait
- assert_match(/ActiveRecord: ([1-9][\d.]+)ms\)/, @logger.logged(:info)[2])
- end
-
- def test_log_with_active_record_when_redirecting
- get :redirect
- wait
- assert_equal 3, @logger.logged(:info).size
- assert_match(/\(ActiveRecord: [\d.]+ms\)/, @logger.logged(:info)[2])
- end
-
- def test_include_time_query_time_after_rendering
- get :db_after_render
- wait
-
- assert_equal 2, @logger.logged(:info).size
- assert_match(/\(Views: [\d.]+ms \| ActiveRecord: ([1-9][\d.]+)ms\)/, @logger.logged(:info)[1])
- end
-end