aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test
diff options
context:
space:
mode:
authorYehuda Katz + Carl Lerche <ykatz+clerche@engineyard.com>2009-05-12 16:21:34 -0700
committerYehuda Katz + Carl Lerche <ykatz+clerche@engineyard.com>2009-05-12 16:21:34 -0700
commit216309c16519d94a9e0aebf758029a78696ab8d6 (patch)
treedb271a9f9cb8ddf9aed72e125fe867d0e10d40e0 /actionpack/test
parent72ca7c591c9eace150c0ebab1633d691a1ef12cf (diff)
downloadrails-216309c16519d94a9e0aebf758029a78696ab8d6.tar.gz
rails-216309c16519d94a9e0aebf758029a78696ab8d6.tar.bz2
rails-216309c16519d94a9e0aebf758029a78696ab8d6.zip
Implemented redirects and partial rendering in new base.
Diffstat (limited to 'actionpack/test')
-rw-r--r--actionpack/test/abstract_unit.rb4
-rw-r--r--actionpack/test/abstract_unit2.rb69
-rw-r--r--actionpack/test/controller/render_test.rb4
-rw-r--r--actionpack/test/new_base/redirect_test.rb1
4 files changed, 41 insertions, 37 deletions
diff --git a/actionpack/test/abstract_unit.rb b/actionpack/test/abstract_unit.rb
index b07e6e5f3a..825ac9a46c 100644
--- a/actionpack/test/abstract_unit.rb
+++ b/actionpack/test/abstract_unit.rb
@@ -1,3 +1,6 @@
+if ENV["new_base"]
+ require "abstract_unit2"
+else
$:.unshift(File.dirname(__FILE__) + '/../lib')
$:.unshift(File.dirname(__FILE__) + '/../../activesupport/lib')
$:.unshift(File.dirname(__FILE__) + '/fixtures/helpers')
@@ -38,3 +41,4 @@ ORIGINAL_LOCALES = I18n.available_locales.map(&:to_s).sort
FIXTURE_LOAD_PATH = File.join(File.dirname(__FILE__), 'fixtures')
ActionController::Base.view_paths = FIXTURE_LOAD_PATH
+end \ No newline at end of file
diff --git a/actionpack/test/abstract_unit2.rb b/actionpack/test/abstract_unit2.rb
index 95e7b2e273..2fdaba7342 100644
--- a/actionpack/test/abstract_unit2.rb
+++ b/actionpack/test/abstract_unit2.rb
@@ -75,7 +75,7 @@ module ActionController
end
class Base
- use ActionController::Testing
+ include ActionController::Testing
end
Base.view_paths = FIXTURE_LOAD_PATH
@@ -89,43 +89,42 @@ module ActionController
end
def assert_template(options = {}, message = nil)
- validate_response!
-
- clean_backtrace do
- case options
- when NilClass, String
- hax = @controller._action_view.instance_variable_get(:@_rendered)
- rendered = (hax[:template] || []).map { |t| t.identifier }
- msg = build_message(message,
- "expecting <?> but rendering with <?>",
- options, rendered.join(', '))
- assert_block(msg) do
- if options.nil?
- hax[:template].blank?
- else
- rendered.any? { |t| t.match(options) }
- end
+ validate_request!
+
+ hax = @controller._action_view.instance_variable_get(:@_rendered)
+
+ case options
+ when NilClass, String
+ rendered = (hax[:template] || []).map { |t| t.identifier }
+ msg = build_message(message,
+ "expecting <?> but rendering with <?>",
+ options, rendered.join(', '))
+ assert_block(msg) do
+ if options.nil?
+ hax[:template].blank?
+ else
+ rendered.any? { |t| t.match(options) }
end
- when Hash
- if expected_partial = options[:partial]
- partials = hax[:partials]
- if expected_count = options[:count]
- found = partials.detect { |p, _| p.identifier.match(expected_partial) }
- actual_count = found.nil? ? 0 : found.second
- msg = build_message(message,
- "expecting ? to be rendered ? time(s) but rendered ? time(s)",
- expected_partial, expected_count, actual_count)
- assert(actual_count == expected_count.to_i, msg)
- else
- msg = build_message(message,
- "expecting partial <?> but action rendered <?>",
- options[:partial], partials.keys)
- assert(partials.keys.any? { |p| p.identifier.match(expected_partial) }, msg)
- end
+ end
+ when Hash
+ if expected_partial = options[:partial]
+ partials = hax[:partials]
+ if expected_count = options[:count]
+ found = partials.detect { |p, _| p.identifier.match(expected_partial) }
+ actual_count = found.nil? ? 0 : found.second
+ msg = build_message(message,
+ "expecting ? to be rendered ? time(s) but rendered ? time(s)",
+ expected_partial, expected_count, actual_count)
+ assert(actual_count == expected_count.to_i, msg)
else
- assert hax[:partials].empty?,
- "Expected no partials to be rendered"
+ msg = build_message(message,
+ "expecting partial <?> but action rendered <?>",
+ options[:partial], partials.keys)
+ assert(partials.keys.any? { |p| p.identifier.match(expected_partial) }, msg)
end
+ else
+ assert hax[:partials].empty?,
+ "Expected no partials to be rendered"
end
end
end
diff --git a/actionpack/test/controller/render_test.rb b/actionpack/test/controller/render_test.rb
index a58d9b08b5..4cea050a1e 100644
--- a/actionpack/test/controller/render_test.rb
+++ b/actionpack/test/controller/render_test.rb
@@ -1,4 +1,4 @@
-require ENV['new_base'] ? 'abstract_unit2' : 'abstract_unit'
+require 'abstract_unit'
require 'controller/fake_models'
require 'pathname'
@@ -1647,7 +1647,7 @@ class EtagRenderTest < ActionController::TestCase
def test_render_against_etag_request_should_304_when_match
@request.if_none_match = etag_for("hello david")
get :render_hello_world_from_variable
- assert_equal 304, @response.status
+ assert_equal 304, @response.status.to_i
assert @response.body.empty?
end
diff --git a/actionpack/test/new_base/redirect_test.rb b/actionpack/test/new_base/redirect_test.rb
new file mode 100644
index 0000000000..e591ebd05f
--- /dev/null
+++ b/actionpack/test/new_base/redirect_test.rb
@@ -0,0 +1 @@
+require File.join(File.expand_path(File.dirname(__FILE__)), "test_helper") \ No newline at end of file