aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/controller
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/test/controller')
-rw-r--r--actionpack/test/controller/caching_test.rb20
-rw-r--r--actionpack/test/controller/log_subscriber_test.rb8
-rw-r--r--actionpack/test/controller/mime_responds_test.rb1
-rw-r--r--actionpack/test/controller/new_base/content_type_test.rb18
-rw-r--r--actionpack/test/controller/test_test.rb16
5 files changed, 37 insertions, 26 deletions
diff --git a/actionpack/test/controller/caching_test.rb b/actionpack/test/controller/caching_test.rb
index 217260fdcd..115cc91467 100644
--- a/actionpack/test/controller/caching_test.rb
+++ b/actionpack/test/controller/caching_test.rb
@@ -53,16 +53,16 @@ class PageCachingTest < ActionController::TestCase
def setup
super
- ActionController::Base.perform_caching = true
-
@request = ActionController::TestRequest.new
@request.host = 'hostname.com'
@request.env.delete('PATH_INFO')
- @response = ActionController::TestResponse.new
@controller = PageCachingTestController.new
+ @controller.perform_caching = true
@controller.cache_store = :file_store, FILE_STORE_PATH
+ @response = ActionController::TestResponse.new
+
@params = {:controller => 'posts', :action => 'index', :only_path => true}
FileUtils.rm_rf(File.dirname(FILE_STORE_PATH))
@@ -71,7 +71,7 @@ class PageCachingTest < ActionController::TestCase
def teardown
FileUtils.rm_rf(File.dirname(FILE_STORE_PATH))
- ActionController::Base.perform_caching = false
+ @controller.perform_caching = false
end
def test_page_caching_resources_saves_to_correct_path_with_extension_even_if_default_route
@@ -538,9 +538,9 @@ end
class FragmentCachingTest < ActionController::TestCase
def setup
super
- ActionController::Base.perform_caching = true
@store = ActiveSupport::Cache::MemoryStore.new
@controller = FragmentCachingTestController.new
+ @controller.perform_caching = true
@controller.cache_store = @store
@params = {:controller => 'posts', :action => 'index'}
@request = ActionController::TestRequest.new
@@ -564,7 +564,7 @@ class FragmentCachingTest < ActionController::TestCase
end
def test_read_fragment_with_caching_disabled
- ActionController::Base.perform_caching = false
+ @controller.perform_caching = false
@store.write('views/name', 'value')
assert_nil @controller.read_fragment('name')
end
@@ -576,7 +576,7 @@ class FragmentCachingTest < ActionController::TestCase
end
def test_fragment_exist_with_caching_disabled
- ActionController::Base.perform_caching = false
+ @controller.perform_caching = false
@store.write('views/name', 'value')
assert !@controller.fragment_exist?('name')
assert !@controller.fragment_exist?('other_name')
@@ -590,7 +590,7 @@ class FragmentCachingTest < ActionController::TestCase
def test_write_fragment_with_caching_disabled
assert_nil @store.read('views/name')
- ActionController::Base.perform_caching = false
+ @controller.perform_caching = false
assert_equal 'value', @controller.write_fragment('name', 'value')
assert_nil @store.read('views/name')
end
@@ -614,7 +614,7 @@ class FragmentCachingTest < ActionController::TestCase
end
def test_fragment_for_with_disabled_caching
- ActionController::Base.perform_caching = false
+ @controller.perform_caching = false
@store.write('views/expensive', 'fragment content')
fragment_computed = false
@@ -688,9 +688,9 @@ end
class FunctionalFragmentCachingTest < ActionController::TestCase
def setup
super
- ActionController::Base.perform_caching = true
@store = ActiveSupport::Cache::MemoryStore.new
@controller = FunctionalCachingController.new
+ @controller.perform_caching = true
@controller.cache_store = @store
@request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new
diff --git a/actionpack/test/controller/log_subscriber_test.rb b/actionpack/test/controller/log_subscriber_test.rb
index 20d3e77b6e..b11eba2f89 100644
--- a/actionpack/test/controller/log_subscriber_test.rb
+++ b/actionpack/test/controller/log_subscriber_test.rb
@@ -143,7 +143,7 @@ class ACLogSubscriberTest < ActionController::TestCase
end
def test_with_fragment_cache
- ActionController::Base.perform_caching = true
+ @controller.config.perform_caching = true
get :with_fragment_cache
wait
@@ -151,11 +151,11 @@ class ACLogSubscriberTest < ActionController::TestCase
assert_match /Exist fragment\? views\/foo/, logs[1]
assert_match /Write fragment views\/foo/, logs[2]
ensure
- ActionController::Base.perform_caching = true
+ @controller.config.perform_caching = true
end
def test_with_page_cache
- ActionController::Base.perform_caching = true
+ @controller.config.perform_caching = true
get :with_page_cache
wait
@@ -163,7 +163,7 @@ class ACLogSubscriberTest < ActionController::TestCase
assert_match /Write page/, logs[1]
assert_match /\/index\.html/, logs[1]
ensure
- ActionController::Base.perform_caching = true
+ @controller.config.perform_caching = true
end
def logs
diff --git a/actionpack/test/controller/mime_responds_test.rb b/actionpack/test/controller/mime_responds_test.rb
index 53cd3f0801..c8ba8bcaf3 100644
--- a/actionpack/test/controller/mime_responds_test.rb
+++ b/actionpack/test/controller/mime_responds_test.rb
@@ -1,5 +1,6 @@
require 'abstract_unit'
require 'controller/fake_models'
+require 'active_support/core_ext/hash/conversions'
class RespondToController < ActionController::Base
layout :set_layout
diff --git a/actionpack/test/controller/new_base/content_type_test.rb b/actionpack/test/controller/new_base/content_type_test.rb
index 700b71a7f3..33c2e442f0 100644
--- a/actionpack/test/controller/new_base/content_type_test.rb
+++ b/actionpack/test/controller/new_base/content_type_test.rb
@@ -21,17 +21,11 @@ module ContentType
self.view_paths = [ActionView::FixtureResolver.new(
"content_type/implied/i_am_html_erb.html.erb" => "Hello world!",
- "content_type/implied/i_am_xml_erb.xml.erb" => "<xml>Hello world!</xml>",
+ "content_type/implied/i_am_xml_erb.xml.erb" => "<xml>Hello world!</xml>",
"content_type/implied/i_am_html_builder.html.builder" => "xml.p 'Hello'",
- "content_type/implied/i_am_xml_builder.xml.builder" => "xml.awesome 'Hello'",
- "content_type/implied/i_am_rjs_in_html.html.erb" => "<%= render 'i_am_rjs_partial' %>",
- "content_type/implied/_i_am_rjs_partial.js.rjs" => ""
+ "content_type/implied/i_am_xml_builder.xml.builder" => "xml.awesome 'Hello'",
+ "content_type/implied/i_am_js_rjs.js.rjs" => "page.alert 'hello'"
)]
-
- def i_am_html_erb() end
- def i_am_xml_erb() end
- def i_am_html_builder() end
- def i_am_xml_builder() end
end
class CharsetController < ActionController::Base
@@ -94,10 +88,10 @@ module ContentType
assert_header "Content-Type", "application/xml; charset=utf-8"
end
- test "sets Content-Type as text/html when rendering *.html.erb with a RJS partial" do
- get "/content_type/implied/i_am_rjs_in_html"
+ test "sets Content-Type as text/javascript when rendering *.js" do
+ get "/content_type/implied/i_am_js_rjs", "format" => "js"
- assert_header "Content-Type", "text/html; charset=utf-8"
+ assert_header "Content-Type", "text/javascript; charset=utf-8"
end
end
diff --git a/actionpack/test/controller/test_test.rb b/actionpack/test/controller/test_test.rb
index 6f1ce2fef7..f9fc7a0976 100644
--- a/actionpack/test/controller/test_test.rb
+++ b/actionpack/test/controller/test_test.rb
@@ -113,6 +113,11 @@ XML
render :nothing => true
end
+ def test_assigns
+ @foo = "foo"
+ render :nothing => true
+ end
+
private
def rescue_action(e)
raise e
@@ -230,6 +235,17 @@ XML
assert_equal "OK", @response.body
end
+ def test_assigns
+ process :test_assigns
+ # assigns can be accessed using assigns(key)
+ # or assigns[key], where key is a string or
+ # a symbol
+ assert_equal "foo", assigns(:foo)
+ assert_equal "foo", assigns("foo")
+ assert_equal "foo", assigns[:foo]
+ assert_equal "foo", assigns["foo"]
+ end
+
def test_assert_tag_tag
process :test_html_output