aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test
diff options
context:
space:
mode:
Diffstat (limited to 'railties/test')
-rw-r--r--railties/test/initializer_test.rb8
-rw-r--r--railties/test/rails_info_controller_test.rb56
-rw-r--r--railties/test/rails_info_test.rb17
3 files changed, 42 insertions, 39 deletions
diff --git a/railties/test/initializer_test.rb b/railties/test/initializer_test.rb
index 561f7b8b54..d77a045e56 100644
--- a/railties/test/initializer_test.rb
+++ b/railties/test/initializer_test.rb
@@ -351,7 +351,7 @@ class InitializerDatabaseMiddlewareTest < Test::Unit::TestCase
def test_database_middleware_doesnt_initialize_when_session_store_is_not_active_record
store = ActionController::Base.session_store
- ActionController::Base.session_store = ActionController::Session::CookieStore
+ ActionController::Base.session_store = ActionDispatch::Session::CookieStore
# Define the class, so we don't have to actually make it load
eval("class ActiveRecord::ConnectionAdapters::ConnectionManagement; end")
@@ -380,12 +380,6 @@ class InitializerViewPathsTest < Test::Unit::TestCase
ActionMailer::Base.view_paths.expects(:load!).never
Rails::Initializer.run(:load_view_paths, @config)
end
-
- def test_load_view_paths_loads_view_paths
- ActionController::Base.view_paths.expects(:load!)
- ActionMailer::Base.view_paths.expects(:load!)
- Rails::Initializer.run(:load_view_paths, @config)
- end
end
class RailsRootTest < Test::Unit::TestCase
diff --git a/railties/test/rails_info_controller_test.rb b/railties/test/rails_info_controller_test.rb
index e274e1aa6e..ab31f3a487 100644
--- a/railties/test/rails_info_controller_test.rb
+++ b/railties/test/rails_info_controller_test.rb
@@ -1,52 +1,46 @@
require 'abstract_unit'
require 'action_controller'
-require 'action_controller/test_process'
+require 'action_controller/testing/process'
-module Rails; end
require 'rails/info'
require 'rails/info_controller'
-class Rails::InfoController < ActionController::Base
- @local_request = false
- class << self
- cattr_accessor :local_request
- end
-
- # Re-raise errors caught by the controller.
- def rescue_action(e) raise e end;
-
-protected
- def local_request?
- self.class.local_request
- end
-end
-
ActionController::Routing::Routes.draw do |map|
map.connect ':controller/:action/:id'
end
-class Rails::InfoControllerTest < ActionController::TestCase
+class InfoControllerTest < ActionController::TestCase
+ tests Rails::InfoController
+
def setup
- @controller = Rails::InfoController.new
- @request = ActionController::TestRequest.new
- @response = ActionController::TestResponse.new
+ @controller.stubs(:consider_all_requests_local => false, :local_request? => true)
+ end
+
+ test "info controller does not allow remote requests" do
+ @controller.stubs(:consider_all_requests_local => false, :local_request? => false)
+ get :properties
+ assert_response :forbidden
+ end
- ActionController::Base.consider_all_requests_local = true
+ test "info controller renders an error message when request was forbidden" do
+ @controller.stubs(:consider_all_requests_local => false, :local_request? => false)
+ get :properties
+ assert_select 'p'
+ end
+
+ test "info controller allows requests when all requests are considered local" do
+ @controller.stubs(:consider_all_requests_local => true, :local_request? => false)
+ get :properties
+ assert_response :success
end
- def test_rails_info_properties_table_rendered_for_local_request
- Rails::InfoController.local_request = true
+ test "info controller allows local requests" do
get :properties
- assert_tag :tag => 'table'
assert_response :success
end
-
- def test_rails_info_properties_error_rendered_for_non_local_request
- Rails::InfoController.local_request = false
- ActionController::Base.consider_all_requests_local = false
+ test "info controller renders a table with properties" do
get :properties
- assert_tag :tag => 'p'
- assert_response 500
+ assert_select 'table'
end
end
diff --git a/railties/test/rails_info_test.rb b/railties/test/rails_info_test.rb
index 9befd44a58..971cba89d0 100644
--- a/railties/test/rails_info_test.rb
+++ b/railties/test/rails_info_test.rb
@@ -1,9 +1,12 @@
$:.unshift File.dirname(__FILE__) + "/../lib"
$:.unshift File.dirname(__FILE__) + "/../builtin/rails_info"
$:.unshift File.dirname(__FILE__) + "/../../activesupport/lib"
+$:.unshift File.dirname(__FILE__) + "/../../actionpack/lib"
require 'test/unit'
require 'active_support'
+require 'active_support/test_case'
+require 'action_controller'
unless defined?(Rails) && defined?(Rails::Info)
module Rails
@@ -11,7 +14,7 @@ unless defined?(Rails) && defined?(Rails::Info)
end
end
-class InfoTest < Test::Unit::TestCase
+class InfoTest < ActiveSupport::TestCase
def setup
Rails.send :remove_const, :Info
silence_warnings { load 'rails/info.rb' }
@@ -72,6 +75,18 @@ EOS
end
end
+ def test_middleware_property
+ assert property_defined?('Middleware')
+ end
+
+ def test_html_includes_middleware
+ html = Rails::Info.to_html
+ assert html.include?('<tr><td class="name">Middleware</td>')
+ properties.value_for('Middleware').each do |value|
+ assert html.include?("<li>#{CGI.escapeHTML(value)}</li>")
+ end
+ end
+
protected
def svn_info=(info)
Rails::Info.module_eval do