aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/test')
-rw-r--r--actionpack/test/controller/action_pack_assertions_test.rb22
-rw-r--r--actionpack/test/controller/caching_test.rb47
-rw-r--r--actionpack/test/controller/show_exceptions_test.rb16
-rw-r--r--actionpack/test/controller/spec_type_test.rb2
-rw-r--r--actionpack/test/dispatch/routing_test.rb20
-rw-r--r--actionpack/test/dispatch/session/cache_store_test.rb1
-rw-r--r--actionpack/test/fixtures/test/hello/hello.erb1
-rw-r--r--actionpack/test/metal/caching_test.rb32
-rw-r--r--actionpack/test/template/spec_type_test.rb2
9 files changed, 104 insertions, 39 deletions
diff --git a/actionpack/test/controller/action_pack_assertions_test.rb b/actionpack/test/controller/action_pack_assertions_test.rb
index 4ab5d92a2b..ca542eb7e2 100644
--- a/actionpack/test/controller/action_pack_assertions_test.rb
+++ b/actionpack/test/controller/action_pack_assertions_test.rb
@@ -7,6 +7,7 @@ class ActionPackAssertionsController < ActionController::Base
def nothing() head :ok end
def hello_world() render :template => "test/hello_world"; end
+ def hello_repeating_in_path() render :template => "test/hello/hello"; end
def hello_xml_world() render :template => "test/hello_xml_world"; end
@@ -464,6 +465,20 @@ class AssertTemplateTest < ActionController::TestCase
end
end
+ def test_fails_with_incorrect_string_that_matches
+ get :hello_world
+ assert_raise(ActiveSupport::TestCase::Assertion) do
+ assert_template 'est/he'
+ end
+ end
+
+ def test_fails_with_repeated_name_in_path
+ get :hello_repeating_in_path
+ assert_raise(ActiveSupport::TestCase::Assertion) do
+ assert_template 'test/hello'
+ end
+ end
+
def test_fails_with_incorrect_symbol
get :hello_world
assert_raise(ActiveSupport::TestCase::Assertion) do
@@ -471,6 +486,13 @@ class AssertTemplateTest < ActionController::TestCase
end
end
+ def test_fails_with_incorrect_symbol_that_matches
+ get :hello_world
+ assert_raise(ActiveSupport::TestCase::Assertion) do
+ assert_template :"est/he"
+ end
+ end
+
def test_fails_with_wrong_layout
get :render_with_layout
assert_raise(ActiveSupport::TestCase::Assertion) do
diff --git a/actionpack/test/controller/caching_test.rb b/actionpack/test/controller/caching_test.rb
index 2c3511f6a0..620479cb0c 100644
--- a/actionpack/test/controller/caching_test.rb
+++ b/actionpack/test/controller/caching_test.rb
@@ -5,6 +5,43 @@ require 'active_record_unit'
CACHE_DIR = 'test_cache'
# Don't change '/../temp/' cavalierly or you might hose something you don't want hosed
FILE_STORE_PATH = File.join(File.dirname(__FILE__), '/../temp/', CACHE_DIR)
+
+class CachingMetalController < ActionController::Metal
+ abstract!
+
+ include ActionController::Caching
+
+ self.page_cache_directory = FILE_STORE_PATH
+ self.cache_store = :file_store, FILE_STORE_PATH
+end
+
+class PageCachingMetalTestController < CachingMetalController
+ caches_page :ok
+
+ def ok
+ self.response_body = 'ok'
+ end
+end
+
+class PageCachingMetalTest < ActionController::TestCase
+ tests PageCachingMetalTestController
+
+ def setup
+ FileUtils.rm_rf(File.dirname(FILE_STORE_PATH))
+ FileUtils.mkdir_p(FILE_STORE_PATH)
+ end
+
+ def teardown
+ FileUtils.rm_rf(File.dirname(FILE_STORE_PATH))
+ end
+
+ def test_should_cache_get_with_ok_status
+ get :ok
+ assert_response :ok
+ assert File.exist?("#{FILE_STORE_PATH}/page_caching_metal_test/ok.html"), 'get with ok status should have been cached'
+ end
+end
+
ActionController::Base.page_cache_directory = FILE_STORE_PATH
class CachingController < ActionController::Base
@@ -862,7 +899,7 @@ CACHED
get :html_fragment_cached_with_partial
assert_response :success
assert_match(/Old fragment caching in a partial/, @response.body)
-
+
assert_match("Old fragment caching in a partial",
@store.read("views/test.host/functional_caching/html_fragment_cached_with_partial/#{template_digest("functional_caching/_partial", "html")}"))
end
@@ -872,7 +909,7 @@ CACHED
assert_response :success
assert_match(/Some inline content/, @response.body)
assert_match(/Some cached content/, @response.body)
- assert_match("Some cached content",
+ assert_match("Some cached content",
@store.read("views/test.host/functional_caching/inline_fragment_cached/#{template_digest("functional_caching/inline_fragment_cached", "html")}"))
end
@@ -883,7 +920,7 @@ CACHED
assert_equal expected_body, @response.body
- assert_equal "<p>ERB</p>",
+ assert_equal "<p>ERB</p>",
@store.read("views/test.host/functional_caching/formatted_fragment_cached/#{template_digest("functional_caching/formatted_fragment_cached", "html")}")
end
@@ -897,7 +934,7 @@ CACHED
assert_equal " <p>Builder</p>\n",
@store.read("views/test.host/functional_caching/formatted_fragment_cached/#{template_digest("functional_caching/formatted_fragment_cached", "xml")}")
end
-
+
private
def template_digest(name, format)
ActionView::Digestor.digest(name, format, @controller.lookup_context)
@@ -949,5 +986,5 @@ class CacheHelperOutputBufferTest < ActionController::TestCase
cache_helper.send :fragment_for, 'Test fragment name', 'Test fragment', &Proc.new{ nil }
end
end
-
end
+
diff --git a/actionpack/test/controller/show_exceptions_test.rb b/actionpack/test/controller/show_exceptions_test.rb
index 351b9c4cfa..ab1bd0e3b6 100644
--- a/actionpack/test/controller/show_exceptions_test.rb
+++ b/actionpack/test/controller/show_exceptions_test.rb
@@ -93,4 +93,20 @@ module ShowExceptions
assert_equal 'text/html', response.content_type.to_s
end
end
+
+ class ShowFailsafeExceptionsTest < ActionDispatch::IntegrationTest
+ def test_render_failsafe_exception
+ @app = ShowExceptionsOverridenController.action(:boom)
+ @exceptions_app = @app.instance_variable_get(:@exceptions_app)
+ @app.instance_variable_set(:@exceptions_app, nil)
+ $stderr = StringIO.new
+
+ get '/', {}, 'HTTP_ACCEPT' => 'text/json'
+ assert_response :internal_server_error
+ assert_equal 'text/plain', response.content_type.to_s
+
+ @app.instance_variable_set(:@exceptions_app, @exceptions_app)
+ $stderr = STDERR
+ end
+ end
end
diff --git a/actionpack/test/controller/spec_type_test.rb b/actionpack/test/controller/spec_type_test.rb
index caeb0fd4dd..13be8a3405 100644
--- a/actionpack/test/controller/spec_type_test.rb
+++ b/actionpack/test/controller/spec_type_test.rb
@@ -3,7 +3,7 @@ require "abstract_unit"
class ApplicationController < ActionController::Base; end
class ModelsController < ApplicationController; end
-class SpecTypeTest < ActiveSupport::TestCase
+class ActionControllerSpecTypeTest < ActiveSupport::TestCase
def assert_controller actual
assert_equal ActionController::TestCase, actual
end
diff --git a/actionpack/test/dispatch/routing_test.rb b/actionpack/test/dispatch/routing_test.rb
index 4e83ad16d7..93d89f7568 100644
--- a/actionpack/test/dispatch/routing_test.rb
+++ b/actionpack/test/dispatch/routing_test.rb
@@ -1124,6 +1124,26 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
assert_equal '/sheep/1/_it', _it_sheep_path(1)
end
+ def test_resource_does_not_modify_passed_options
+ options = {:id => /.+?/, :format => /json|xml/}
+ self.class.stub_controllers do |routes|
+ routes.draw do
+ resource :user, options
+ end
+ end
+ assert_equal({:id => /.+?/, :format => /json|xml/}, options)
+ end
+
+ def test_resources_does_not_modify_passed_options
+ options = {:id => /.+?/, :format => /json|xml/}
+ self.class.stub_controllers do |routes|
+ routes.draw do
+ resources :users, options
+ end
+ end
+ assert_equal({:id => /.+?/, :format => /json|xml/}, options)
+ end
+
def test_path_names
get '/pt/projetos'
assert_equal 'projects#index', @response.body
diff --git a/actionpack/test/dispatch/session/cache_store_test.rb b/actionpack/test/dispatch/session/cache_store_test.rb
index a74e165826..b8479e8836 100644
--- a/actionpack/test/dispatch/session/cache_store_test.rb
+++ b/actionpack/test/dispatch/session/cache_store_test.rb
@@ -1,4 +1,5 @@
require 'abstract_unit'
+require 'fixtures/session_autoload_test/session_autoload_test/foo'
class CacheStoreTest < ActionDispatch::IntegrationTest
class TestController < ActionController::Base
diff --git a/actionpack/test/fixtures/test/hello/hello.erb b/actionpack/test/fixtures/test/hello/hello.erb
new file mode 100644
index 0000000000..6769dd60bd
--- /dev/null
+++ b/actionpack/test/fixtures/test/hello/hello.erb
@@ -0,0 +1 @@
+Hello world! \ No newline at end of file
diff --git a/actionpack/test/metal/caching_test.rb b/actionpack/test/metal/caching_test.rb
deleted file mode 100644
index a2b6763754..0000000000
--- a/actionpack/test/metal/caching_test.rb
+++ /dev/null
@@ -1,32 +0,0 @@
-require 'abstract_unit'
-
-CACHE_DIR = 'test_cache'
-# Don't change '/../temp/' cavalierly or you might hose something you don't want hosed
-FILE_STORE_PATH = File.join(File.dirname(__FILE__), '/../temp/', CACHE_DIR)
-
-class CachingController < ActionController::Metal
- abstract!
-
- include ActionController::Caching
-
- self.page_cache_directory = FILE_STORE_PATH
- self.cache_store = :file_store, FILE_STORE_PATH
-end
-
-class PageCachingTestController < CachingController
- caches_page :ok
-
- def ok
- self.response_body = "ok"
- end
-end
-
-class PageCachingTest < ActionController::TestCase
- tests PageCachingTestController
-
- def test_should_cache_get_with_ok_status
- get :ok
- assert_response :ok
- assert File.exist?("#{FILE_STORE_PATH}/page_caching_test/ok.html"), "get with ok status should have been cached"
- end
-end
diff --git a/actionpack/test/template/spec_type_test.rb b/actionpack/test/template/spec_type_test.rb
index b35985d5f9..08a7bdf81d 100644
--- a/actionpack/test/template/spec_type_test.rb
+++ b/actionpack/test/template/spec_type_test.rb
@@ -1,6 +1,6 @@
require 'abstract_unit'
-class SpecTypeTest < ActiveSupport::TestCase
+class ActionViewSpecTypeTest < ActiveSupport::TestCase
def assert_view actual
assert_equal ActionView::TestCase, actual
end