Skip to content

Commit 9142da0

Browse files
author
Francesco Rodriguez
committed
move metal/caching_test into controller/caching_test
1 parent aca3942 commit 9142da0

File tree

2 files changed

+42
-37
lines changed

2 files changed

+42
-37
lines changed

actionpack/test/controller/caching_test.rb

Lines changed: 42 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,43 @@
55
CACHE_DIR = 'test_cache'
66
# Don't change '/../temp/' cavalierly or you might hose something you don't want hosed
77
FILE_STORE_PATH = File.join(File.dirname(__FILE__), '/../temp/', CACHE_DIR)
8+
9+
class CachingMetalController < ActionController::Metal
10+
abstract!
11+
12+
include ActionController::Caching
13+
14+
self.page_cache_directory = FILE_STORE_PATH
15+
self.cache_store = :file_store, FILE_STORE_PATH
16+
end
17+
18+
class PageCachingMetalTestController < CachingMetalController
19+
caches_page :ok
20+
21+
def ok
22+
self.response_body = 'ok'
23+
end
24+
end
25+
26+
class PageCachingMetalTest < ActionController::TestCase
27+
tests PageCachingMetalTestController
28+
29+
def setup
30+
FileUtils.rm_rf(File.dirname(FILE_STORE_PATH))
31+
FileUtils.mkdir_p(FILE_STORE_PATH)
32+
end
33+
34+
def teardown
35+
FileUtils.rm_rf(File.dirname(FILE_STORE_PATH))
36+
end
37+
38+
def test_should_cache_get_with_ok_status
39+
get :ok
40+
assert_response :ok
41+
assert File.exist?("#{FILE_STORE_PATH}/page_caching_metal_test/ok.html"), 'get with ok status should have been cached'
42+
end
43+
end
44+
845
ActionController::Base.page_cache_directory = FILE_STORE_PATH
946

1047
class CachingController < ActionController::Base
@@ -862,7 +899,7 @@ def test_fragment_caching_in_partials
862899
get :html_fragment_cached_with_partial
863900
assert_response :success
864901
assert_match(/Old fragment caching in a partial/, @response.body)
865-
902+
866903
assert_match("Old fragment caching in a partial",
867904
@store.read("views/test.host/functional_caching/html_fragment_cached_with_partial/#{template_digest("functional_caching/_partial", "html")}"))
868905
end
@@ -872,7 +909,7 @@ def test_render_inline_before_fragment_caching
872909
assert_response :success
873910
assert_match(/Some inline content/, @response.body)
874911
assert_match(/Some cached content/, @response.body)
875-
assert_match("Some cached content",
912+
assert_match("Some cached content",
876913
@store.read("views/test.host/functional_caching/inline_fragment_cached/#{template_digest("functional_caching/inline_fragment_cached", "html")}"))
877914
end
878915

@@ -883,7 +920,7 @@ def test_html_formatted_fragment_caching
883920

884921
assert_equal expected_body, @response.body
885922

886-
assert_equal "<p>ERB</p>",
923+
assert_equal "<p>ERB</p>",
887924
@store.read("views/test.host/functional_caching/formatted_fragment_cached/#{template_digest("functional_caching/formatted_fragment_cached", "html")}")
888925
end
889926

@@ -897,7 +934,7 @@ def test_xml_formatted_fragment_caching
897934
assert_equal " <p>Builder</p>\n",
898935
@store.read("views/test.host/functional_caching/formatted_fragment_cached/#{template_digest("functional_caching/formatted_fragment_cached", "xml")}")
899936
end
900-
937+
901938
private
902939
def template_digest(name, format)
903940
ActionView::Digestor.digest(name, format, @controller.lookup_context)
@@ -949,5 +986,5 @@ def test_safe_buffer
949986
cache_helper.send :fragment_for, 'Test fragment name', 'Test fragment', &Proc.new{ nil }
950987
end
951988
end
952-
953989
end
990+

actionpack/test/metal/caching_test.rb

Lines changed: 0 additions & 32 deletions
This file was deleted.

0 commit comments

Comments
 (0)