aboutsummaryrefslogtreecommitdiffstats
path: root/railties
diff options
context:
space:
mode:
authorlifo <lifo@null.lan>2009-04-17 14:06:26 +0100
committerlifo <lifo@null.lan>2009-04-17 14:06:26 +0100
commit20401783cf26f903d7020cb7136b1e78e60e71ea (patch)
tree5bb029802ade6dda33e051adf74915dc0a8d1fe5 /railties
parentf99e9f627b6e4ab7fe72bc759426312ec0c7a2cd (diff)
parentabb899c54e8777428b7a607774370ba29a5573bd (diff)
downloadrails-20401783cf26f903d7020cb7136b1e78e60e71ea.tar.gz
rails-20401783cf26f903d7020cb7136b1e78e60e71ea.tar.bz2
rails-20401783cf26f903d7020cb7136b1e78e60e71ea.zip
Merge commit 'mainstream/master'
Conflicts: actionpack/lib/action_controller/base.rb railties/guides/source/caching_with_rails.textile
Diffstat (limited to 'railties')
-rw-r--r--railties/builtin/rails_info/rails/info_controller.rb2
-rw-r--r--railties/environments/production.rb1
-rw-r--r--railties/environments/test.rb1
-rw-r--r--railties/guides/source/caching_with_rails.textile14
-rw-r--r--railties/guides/source/rails_on_rack.textile2
-rw-r--r--railties/lib/dispatcher.rb2
-rw-r--r--railties/lib/initializer.rb9
-rw-r--r--railties/lib/test_help.rb4
-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
11 files changed, 60 insertions, 56 deletions
diff --git a/railties/builtin/rails_info/rails/info_controller.rb b/railties/builtin/rails_info/rails/info_controller.rb
index 05745d606d..47e87c5bf5 100644
--- a/railties/builtin/rails_info/rails/info_controller.rb
+++ b/railties/builtin/rails_info/rails/info_controller.rb
@@ -3,7 +3,7 @@ class Rails::InfoController < ActionController::Base
if consider_all_requests_local || local_request?
render :inline => Rails::Info.to_html
else
- render :text => '<p>For security purposes, this information is only available to local requests.</p>', :status => 500
+ render :text => '<p>For security purposes, this information is only available to local requests.</p>', :status => :forbidden
end
end
end
diff --git a/railties/environments/production.rb b/railties/environments/production.rb
index 27119d2d18..1fc9f6b923 100644
--- a/railties/environments/production.rb
+++ b/railties/environments/production.rb
@@ -7,7 +7,6 @@ config.cache_classes = true
# Full error reports are disabled and caching is turned on
config.action_controller.consider_all_requests_local = false
config.action_controller.perform_caching = true
-config.action_view.cache_template_loading = true
# See everything in the log (default is :info)
# config.log_level = :debug
diff --git a/railties/environments/test.rb b/railties/environments/test.rb
index d6f80a4080..496eb9572b 100644
--- a/railties/environments/test.rb
+++ b/railties/environments/test.rb
@@ -12,7 +12,6 @@ config.whiny_nils = true
# Show full error reports and disable caching
config.action_controller.consider_all_requests_local = true
config.action_controller.perform_caching = false
-config.action_view.cache_template_loading = true
# Disable request forgery protection in test environment
config.action_controller.allow_forgery_protection = false
diff --git a/railties/guides/source/caching_with_rails.textile b/railties/guides/source/caching_with_rails.textile
index dd1b76bbc4..f1ad7b820d 100644
--- a/railties/guides/source/caching_with_rails.textile
+++ b/railties/guides/source/caching_with_rails.textile
@@ -2,7 +2,7 @@ h2. Caching with Rails: An overview
Everyone caches. This guide will teach you what you need to know about
avoiding that expensive round-trip to your database and returning what you
-need to return to those hungry web clients in the shortest time possible.
+need to return to those hungry web clients in the shortest time possible.
After reading this guide, you should be able to use and configure:
@@ -18,7 +18,7 @@ h3. Basic Caching
This is an introduction to the three types of caching techniques that Rails
provides by default without the use of any third party plugins.
-To start playing with testing you'll want to ensure that
+To start playing with testing you'll want to ensure that
+config.action_controller.perform_caching+ is set
to +true+ if you're running in development mode. This flag is normally set in the
corresponding config/environments/*.rb and caching is disabled by default
@@ -244,7 +244,7 @@ class ProductSweeper < ActionController::Caching::Sweeper
end
</ruby>
-You may notice that the actual product gets passed to the sweeper, so if we
+You may notice that the actual product gets passed to the sweeper, so if we
were caching the edit action for each product, we could add a expire method
which specifies the page we want to expire:
@@ -264,7 +264,7 @@ class ProductsController < ActionController
caches_action :index
cache_sweeper :product_sweeper
- def index
+ def index
@products = Product.all
end
@@ -296,12 +296,12 @@ class ProductsController < ActionController
end
</ruby>
-The second time the same query is run against the database, it's not actually
+The second time the same query is run against the database, it's not actually
going to hit the database. The first time the result is returned from the query
it is stored in the query cache (in memory) and the second time it's pulled from memory.
However, it's important to note that query caches are created at the start of an action and destroyed at the end of
-that action and thus persist only for the duration of the action. If you'd like to store query results in a more
+that action and thus persist only for the duration of the action. If you'd like to store query results in a more
persistent fashion, you can in Rails by using low level caching.
h4. Cache stores
@@ -499,7 +499,7 @@ Also the new "Cache money":http://github.com/nkallen/cache-money/tree/master plu
h3. References
-* "Scaling Rails Screencasts":http://railslab.newrelic.com/scaling-rails
+* "Scaling Rails Screencasts":http://railslab.newrelic.com/scaling-rails
* "RailsEnvy, Rails Caching Tutorial, Part 1":http://www.railsenvy.com/2007/2/28/rails-caching-tutorial
* "RailsEnvy, Rails Caching Tutorial, Part 1":http://www.railsenvy.com/2007/3/20/ruby-on-rails-caching-tutorial-part-2
* "ActiveSupport::Cache documentation":http://api.rubyonrails.org/classes/ActiveSupport/Cache.html
diff --git a/railties/guides/source/rails_on_rack.textile b/railties/guides/source/rails_on_rack.textile
index 05581f943f..1164ed821d 100644
--- a/railties/guides/source/rails_on_rack.textile
+++ b/railties/guides/source/rails_on_rack.textile
@@ -101,7 +101,7 @@ use Rack::Lock
use ActionController::Failsafe
use ActionController::Session::CookieStore, , {:secret=>"<secret>", :session_key=>"_<app>_session"}
use Rails::Rack::Metal
-use ActionController::RewindableInput
+use ActionDispatch::RewindableInput
use ActionController::ParamsParser
use Rack::MethodOverride
use Rack::Head
diff --git a/railties/lib/dispatcher.rb b/railties/lib/dispatcher.rb
index 9f8b59aa3d..7f9a6221d9 100644
--- a/railties/lib/dispatcher.rb
+++ b/railties/lib/dispatcher.rb
@@ -20,5 +20,5 @@
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#++
-require 'action_controller/dispatcher'
+require 'action_controller/dispatch/dispatcher'
Dispatcher = ActionController::Dispatcher
diff --git a/railties/lib/initializer.rb b/railties/lib/initializer.rb
index a04405a7c2..a03be59a2b 100644
--- a/railties/lib/initializer.rb
+++ b/railties/lib/initializer.rb
@@ -378,8 +378,11 @@ Run `rake gems:install` to install the missing gems.
def load_view_paths
if configuration.frameworks.include?(:action_view)
- ActionController::Base.view_paths.load! if configuration.frameworks.include?(:action_controller)
- ActionMailer::Base.view_paths.load! if configuration.frameworks.include?(:action_mailer)
+ if configuration.cache_classes
+ view_path = ActionView::Template::FileSystemPath.new(configuration.view_path)
+ ActionController::Base.view_paths = view_path if configuration.frameworks.include?(:action_controller)
+ ActionMailer::Base.template_root = view_path if configuration.frameworks.include?(:action_mailer)
+ end
end
end
@@ -565,7 +568,7 @@ Run `rake gems:install` to install the missing gems.
Rails::Rack::Metal.metal_paths += plugin_loader.engine_metal_paths
configuration.middleware.insert_before(
- :"ActionController::RewindableInput",
+ :"ActionDispatch::RewindableInput",
Rails::Rack::Metal, :if => Rails::Rack::Metal.metals.any?)
end
diff --git a/railties/lib/test_help.rb b/railties/lib/test_help.rb
index ee24ea3a45..94e089a624 100644
--- a/railties/lib/test_help.rb
+++ b/railties/lib/test_help.rb
@@ -3,9 +3,9 @@
silence_warnings { RAILS_ENV = "test" }
require 'test/unit'
-require 'action_controller/test_case'
+require 'action_controller/testing/test_case'
require 'action_view/test_case'
-require 'action_controller/integration'
+require 'action_controller/testing/integration'
require 'action_mailer/test_case' if defined?(ActionMailer)
if defined?(ActiveRecord)
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