aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/test')
-rw-r--r--actionpack/test/abstract/helper_test.rb7
-rw-r--r--actionpack/test/controller/routing_test.rb10
-rw-r--r--actionpack/test/controller/show_exceptions_test.rb18
-rw-r--r--actionpack/test/dispatch/request/query_string_parsing_test.rb8
-rw-r--r--actionpack/test/metal/caching_test.rb32
5 files changed, 54 insertions, 21 deletions
diff --git a/actionpack/test/abstract/helper_test.rb b/actionpack/test/abstract/helper_test.rb
index 9a7445de7b..e79008fa9d 100644
--- a/actionpack/test/abstract/helper_test.rb
+++ b/actionpack/test/abstract/helper_test.rb
@@ -69,7 +69,12 @@ module AbstractController
end
def test_declare_missing_helper
- assert_raise(MissingSourceFile) { AbstractHelpers.helper :missing }
+ begin
+ AbstractHelpers.helper :missing
+ flunk "should have raised an exception"
+ rescue LoadError => e
+ assert_equal "helpers/missing_helper.rb", e.path
+ end
end
def test_helpers_with_module_through_block
diff --git a/actionpack/test/controller/routing_test.rb b/actionpack/test/controller/routing_test.rb
index 2f552c3a5a..306b8a93da 100644
--- a/actionpack/test/controller/routing_test.rb
+++ b/actionpack/test/controller/routing_test.rb
@@ -270,6 +270,16 @@ class LegacyRouteSetTests < ActiveSupport::TestCase
end
end
+ def test_specific_controller_action_failure
+ @rs.draw do
+ mount lambda {} => "/foo"
+ end
+
+ assert_raises(ActionController::RoutingError) do
+ url_for(@rs, :controller => "omg", :action => "lol")
+ end
+ end
+
def test_default_setup
@rs.draw { get '/:controller(/:action(/:id))' }
assert_equal({:controller => "content", :action => 'index'}, rs.recognize_path("/content"))
diff --git a/actionpack/test/controller/show_exceptions_test.rb b/actionpack/test/controller/show_exceptions_test.rb
index ce7b6b0dc6..351b9c4cfa 100644
--- a/actionpack/test/controller/show_exceptions_test.rb
+++ b/actionpack/test/controller/show_exceptions_test.rb
@@ -22,14 +22,6 @@ module ShowExceptions
end
end
- class ShowLocalExceptionsController < ActionController::Base
- use ActionDispatch::ShowExceptions, ActionDispatch::PublicExceptions.new("#{FIXTURE_LOAD_PATH}/public", true)
-
- def boom
- raise 'boom!'
- end
- end
-
class ShowExceptionsTest < ActionDispatch::IntegrationTest
test 'show error page from a remote ip' do
@app = ShowExceptionsController.action(:boom)
@@ -101,14 +93,4 @@ module ShowExceptions
assert_equal 'text/html', response.content_type.to_s
end
end
-
- class ShowExceptionsFormatsTest < ActionDispatch::IntegrationTest
- def test_render_formatted_exception_in_development
- @app = ShowLocalExceptionsController.action(:boom)
- get "/", {}, 'HTTP_ACCEPT' => 'application/xml'
-
- assert_response :internal_server_error
- assert_equal 'text/html', response.content_type.to_s
- end
- end
end
diff --git a/actionpack/test/dispatch/request/query_string_parsing_test.rb b/actionpack/test/dispatch/request/query_string_parsing_test.rb
index 6ea66f9d32..3cb430d83d 100644
--- a/actionpack/test/dispatch/request/query_string_parsing_test.rb
+++ b/actionpack/test/dispatch/request/query_string_parsing_test.rb
@@ -84,11 +84,15 @@ class QueryStringParsingTest < ActionDispatch::IntegrationTest
assert_parses({"action" => nil}, "action")
assert_parses({"action" => {"foo" => nil}}, "action[foo]")
assert_parses({"action" => {"foo" => { "bar" => nil }}}, "action[foo][bar]")
- assert_parses({"action" => {"foo" => { "bar" => nil }}}, "action[foo][bar][]")
- assert_parses({"action" => {"foo" => nil}}, "action[foo][]")
+ assert_parses({"action" => {"foo" => { "bar" => [] }}}, "action[foo][bar][]")
+ assert_parses({"action" => {"foo" => []}}, "action[foo][]")
assert_parses({"action"=>{"foo"=>[{"bar"=>nil}]}}, "action[foo][][bar]")
end
+ def test_array_parses_without_nil
+ assert_parses({"action" => ['1']}, "action[]=1&action[]")
+ end
+
test "query string with empty key" do
assert_parses(
{ "action" => "create_customer", "full_name" => "David Heinemeier Hansson" },
diff --git a/actionpack/test/metal/caching_test.rb b/actionpack/test/metal/caching_test.rb
new file mode 100644
index 0000000000..a2b6763754
--- /dev/null
+++ b/actionpack/test/metal/caching_test.rb
@@ -0,0 +1,32 @@
+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