aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/controller
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/test/controller')
-rw-r--r--actionpack/test/controller/action_pack_assertions_test.rb24
-rw-r--r--actionpack/test/controller/base_test.rb6
-rw-r--r--actionpack/test/controller/filters_test.rb68
-rw-r--r--actionpack/test/controller/helper_test.rb19
-rw-r--r--actionpack/test/controller/layout_test.rb22
-rw-r--r--actionpack/test/controller/mime_responds_test.rb32
-rw-r--r--actionpack/test/controller/record_identifier_test.rb2
-rw-r--r--actionpack/test/controller/redirect_test.rb1
-rw-r--r--actionpack/test/controller/render_test.rb14
-rw-r--r--actionpack/test/controller/send_file_test.rb4
10 files changed, 66 insertions, 126 deletions
diff --git a/actionpack/test/controller/action_pack_assertions_test.rb b/actionpack/test/controller/action_pack_assertions_test.rb
index 24686ab4b6..ecbaba39d1 100644
--- a/actionpack/test/controller/action_pack_assertions_test.rb
+++ b/actionpack/test/controller/action_pack_assertions_test.rb
@@ -13,6 +13,18 @@ class ActionPackAssertionsController < ActionController::Base
# a standard template
def hello_xml_world() render :template => "test/hello_xml_world"; end
+ # a standard template rendering PDF
+ def hello_xml_world_pdf
+ self.content_type = "application/pdf"
+ render :template => "test/hello_xml_world"
+ end
+
+ # a standard template rendering PDF
+ def hello_xml_world_pdf_header
+ response.headers["Content-Type"] = "application/pdf; charset=utf-8"
+ render :template => "test/hello_xml_world"
+ end
+
# a standard partial
def partial() render :partial => 'test/partial'; end
@@ -537,11 +549,13 @@ class ActionPackHeaderTest < ActionController::TestCase
end
def test_rendering_xml_respects_content_type
- pending do
- @response.headers['type'] = 'application/pdf'
- process :hello_xml_world
- assert_equal('application/pdf; charset=utf-8', @response.headers['Content-Type'])
- end
+ process :hello_xml_world_pdf
+ assert_equal('application/pdf; charset=utf-8', @response.headers['Content-Type'])
+ end
+
+ def test_rendering_xml_respects_content_type_when_set_in_the_header
+ process :hello_xml_world_pdf_header
+ assert_equal('application/pdf; charset=utf-8', @response.headers['Content-Type'])
end
def test_render_text_with_custom_content_type
diff --git a/actionpack/test/controller/base_test.rb b/actionpack/test/controller/base_test.rb
index 03fd98a85c..8877057070 100644
--- a/actionpack/test/controller/base_test.rb
+++ b/actionpack/test/controller/base_test.rb
@@ -146,11 +146,7 @@ class PerformActionTest < ActionController::TestCase
def test_method_missing_is_not_an_action_name
use_controller MethodMissingController
- if defined?(ActionController::Http)
- assert ! @controller.__send__(:action_method?, 'method_missing')
- else
- assert ! @controller.__send__(:action_methods).include?('method_missing')
- end
+ assert ! @controller.__send__(:action_method?, 'method_missing')
get :method_missing
assert_response :success
diff --git a/actionpack/test/controller/filters_test.rb b/actionpack/test/controller/filters_test.rb
index b930ff4997..2da97a9d86 100644
--- a/actionpack/test/controller/filters_test.rb
+++ b/actionpack/test/controller/filters_test.rb
@@ -9,24 +9,20 @@ class ActionController::Base
end unless method_defined?(pending)
end
- if defined?(ActionController::Http)
- def before_filters
- filters = _process_action_callbacks.select { |c| c.kind == :before }
- filters.map! { |c| c.instance_variable_get(:@raw_filter) }
- end
+ def before_filters
+ filters = _process_action_callbacks.select { |c| c.kind == :before }
+ filters.map! { |c| c.instance_variable_get(:@raw_filter) }
end
end
- if defined?(ActionController::Http)
- def assigns(key = nil)
- assigns = {}
- instance_variable_names.each do |ivar|
- next if ActionController::Base.protected_instance_variables.include?(ivar)
- assigns[ivar[1..-1]] = instance_variable_get(ivar)
- end
-
- key.nil? ? assigns : assigns[key.to_s]
+ def assigns(key = nil)
+ assigns = {}
+ instance_variable_names.each do |ivar|
+ next if ActionController::Base.protected_instance_variables.include?(ivar)
+ assigns[ivar[1..-1]] = instance_variable_get(ivar)
end
+
+ key.nil? ? assigns : assigns[key.to_s]
end
end
@@ -598,22 +594,11 @@ class FilterTest < ActionController::TestCase
assert_equal "before and after", assigns["execution_log"]
end
- for_tag(:old_base) do
- def test_prepending_and_appending_around_filter
- controller = test_process(MixedFilterController)
- assert_equal " before aroundfilter before procfilter before appended aroundfilter " +
- " after appended aroundfilter after aroundfilter after procfilter ",
- MixedFilterController.execution_log
- end
- end
-
- for_tag(:new_base) do
- def test_prepending_and_appending_around_filter
- controller = test_process(MixedFilterController)
- assert_equal " before aroundfilter before procfilter before appended aroundfilter " +
- " after appended aroundfilter after procfilter after aroundfilter ",
- MixedFilterController.execution_log
- end
+ def test_prepending_and_appending_around_filter
+ controller = test_process(MixedFilterController)
+ assert_equal " before aroundfilter before procfilter before appended aroundfilter " +
+ " after appended aroundfilter after procfilter after aroundfilter ",
+ MixedFilterController.execution_log
end
def test_rendering_breaks_filtering_chain
@@ -876,14 +861,6 @@ class YieldingAroundFiltersTest < ActionController::TestCase
assert_raise(After) { test_process(controller,'raises_after') }
end
- for_tag(:old_base) do
- def test_with_method
- controller = ControllerWithFilterMethod
- assert_nothing_raised { test_process(controller,'no_raise') }
- assert_raise(After) { test_process(controller,'raises_after') }
- end
- end
-
def test_with_proc
test_process(ControllerWithProcFilter,'no_raise')
assert assigns['before']
@@ -906,18 +883,9 @@ class YieldingAroundFiltersTest < ActionController::TestCase
end
end
- for_tag(:old_base) do
- def test_filter_order_with_all_filter_types
- test_process(ControllerWithAllTypesOfFilters,'no_raise')
- assert_equal 'before around (before yield) around_again (before yield) around_again (after yield) around (after yield) after', assigns['ran_filter'].join(' ')
- end
- end
-
- for_tag(:new_base) do
- def test_filter_order_with_all_filter_types
- test_process(ControllerWithAllTypesOfFilters,'no_raise')
- assert_equal 'before around (before yield) around_again (before yield) around_again (after yield) after around (after yield)', assigns['ran_filter'].join(' ')
- end
+ def test_filter_order_with_all_filter_types
+ test_process(ControllerWithAllTypesOfFilters,'no_raise')
+ assert_equal 'before around (before yield) around_again (before yield) around_again (after yield) after around (after yield)', assigns['ran_filter'].join(' ')
end
def test_filter_order_with_skip_filter_method
diff --git a/actionpack/test/controller/helper_test.rb b/actionpack/test/controller/helper_test.rb
index 515c4c9f52..23149fee27 100644
--- a/actionpack/test/controller/helper_test.rb
+++ b/actionpack/test/controller/helper_test.rb
@@ -127,11 +127,7 @@ class HelperTest < Test::Unit::TestCase
end
def test_all_helpers
- methods = if defined?(ActionController::Http)
- AllHelpersController._helpers.instance_methods.map {|m| m.to_s}
- else
- AllHelpersController.master_helper_module.instance_methods.map {|m| m.to_s}
- end
+ methods = AllHelpersController._helpers.instance_methods.map {|m| m.to_s}
# abc_helper.rb
assert methods.include?('bare_a')
@@ -147,12 +143,7 @@ class HelperTest < Test::Unit::TestCase
@controller_class.helpers_dir = File.dirname(__FILE__) + '/../fixtures/alternate_helpers'
# Reload helpers
- if defined?(ActionController::Http)
- @controller_class._helpers = Module.new
- else
- @controller_class.master_helper_module = Module.new
- end
-
+ @controller_class._helpers = Module.new
@controller_class.helper :all
# helpers/abc_helper.rb should not be included
@@ -184,11 +175,7 @@ class HelperTest < Test::Unit::TestCase
end
def master_helper_methods
- if defined?(ActionController::Http)
- @controller_class._helpers.instance_methods.map {|m| m.to_s }
- else
- @controller_class.master_helper_module.instance_methods.map {|m| m.to_s }
- end
+ @controller_class._helpers.instance_methods.map {|m| m.to_s }
end
def missing_methods
diff --git a/actionpack/test/controller/layout_test.rb b/actionpack/test/controller/layout_test.rb
index c3d7b0778d..feb2f81cc1 100644
--- a/actionpack/test/controller/layout_test.rb
+++ b/actionpack/test/controller/layout_test.rb
@@ -165,26 +165,10 @@ class LayoutSetInResponseTest < ActionController::TestCase
assert_nil @controller.template.layout
end
- for_tag(:old_base) do
- # exempt_from_layout is deprecated
- def test_exempt_from_layout_honored_by_render_template
- ActionController::Base.exempt_from_layout :erb
- @controller = RenderWithTemplateOptionController.new
-
- get :hello
- assert_equal "alt/hello.rhtml", @response.body.strip
-
- ensure
- ActionController::Base.exempt_from_layout.delete(ERB)
- end
- end
-
def test_layout_is_picked_from_the_controller_instances_view_path
- pending do
- @controller = PrependsViewPathController.new
- get :hello
- assert_equal 'layouts/alt', @controller.template.layout
- end
+ @controller = PrependsViewPathController.new
+ get :hello
+ assert @controller.template.layout =~ /layouts\/alt\.\w+/
end
def test_absolute_pathed_layout
diff --git a/actionpack/test/controller/mime_responds_test.rb b/actionpack/test/controller/mime_responds_test.rb
index 0c6822a5b1..93ca34c41c 100644
--- a/actionpack/test/controller/mime_responds_test.rb
+++ b/actionpack/test/controller/mime_responds_test.rb
@@ -375,11 +375,9 @@ class MimeControllerTest < ActionController::TestCase
end
def test_rjs_type_skips_layout
- pending(:new_base) do
- @request.accept = "text/javascript"
- get :all_types_with_layout
- assert_equal 'RJS for all_types_with_layout', @response.body
- end
+ @request.accept = "text/javascript"
+ get :all_types_with_layout
+ assert_equal 'RJS for all_types_with_layout', @response.body
end
def test_html_type_with_layout
@@ -467,14 +465,6 @@ class MimeControllerTest < ActionController::TestCase
assert_equal '<html><div id="iphone">Hello iPhone future from iPhone!</div></html>', @response.body
assert_equal "text/html", @response.content_type
end
-
- def test_format_with_custom_response_type_and_request_headers_with_only_one_layout_present
- get :iphone_with_html_response_type_without_layout
- assert_equal '<html><div id="html_missing">Hello future from Firefox!</div></html>', @response.body
-
- @request.accept = "text/iphone"
- assert_raise(ActionView::MissingTemplate) { get :iphone_with_html_response_type_without_layout }
- end
end
class AbstractPostController < ActionController::Base
@@ -529,16 +519,14 @@ class MimeControllerLayoutsTest < ActionController::TestCase
assert_equal 'Hello iPhone', @response.body
end
- for_tag(:old_base) do
- def test_format_with_inherited_layouts
- @controller = SuperPostController.new
+ def test_format_with_inherited_layouts
+ @controller = SuperPostController.new
- get :index
- assert_equal 'Super Firefox', @response.body
+ get :index
+ assert_equal '<html><div id="html">Super Firefox</div></html>', @response.body
- @request.accept = "text/iphone"
- get :index
- assert_equal '<html><div id="super_iphone">Super iPhone</div></html>', @response.body
- end
+ @request.accept = "text/iphone"
+ get :index
+ assert_equal '<html><div id="super_iphone">Super iPhone</div></html>', @response.body
end
end
diff --git a/actionpack/test/controller/record_identifier_test.rb b/actionpack/test/controller/record_identifier_test.rb
index 12c1eaea69..28bc608d47 100644
--- a/actionpack/test/controller/record_identifier_test.rb
+++ b/actionpack/test/controller/record_identifier_test.rb
@@ -1,6 +1,8 @@
require 'abstract_unit'
class Comment
+ extend ActiveModel::Naming
+
attr_reader :id
def save; @id = 1 end
def new_record?; @id.nil? end
diff --git a/actionpack/test/controller/redirect_test.rb b/actionpack/test/controller/redirect_test.rb
index 13247f2d08..453a77e7bc 100644
--- a/actionpack/test/controller/redirect_test.rb
+++ b/actionpack/test/controller/redirect_test.rb
@@ -4,6 +4,7 @@ class WorkshopsController < ActionController::Base
end
class Workshop
+ extend ActiveModel::Naming
attr_accessor :id, :new_record
def initialize(id, new_record)
diff --git a/actionpack/test/controller/render_test.rb b/actionpack/test/controller/render_test.rb
index 9e42d1738a..9934639d21 100644
--- a/actionpack/test/controller/render_test.rb
+++ b/actionpack/test/controller/render_test.rb
@@ -301,6 +301,9 @@ class TestController < ActionController::Base
def render_implicit_html_template_from_xhr_request
end
+ def render_implicit_js_template_without_layout
+ end
+
def formatted_html_erb
end
@@ -928,16 +931,13 @@ class RenderTest < ActionController::TestCase
end
def test_should_implicitly_render_html_template_from_xhr_request
- pending
- # xhr :get, :render_implicit_html_template_from_xhr_request
- # assert_equal "XHR!\nHello HTML!", @response.body
+ xhr :get, :render_implicit_html_template_from_xhr_request
+ assert_equal "XHR!\nHello HTML!", @response.body
end
def test_should_implicitly_render_js_template_without_layout
- pending do
- get :render_implicit_js_template_without_layout, :format => :js
- assert_no_match %r{<html>}, @response.body
- end
+ get :render_implicit_js_template_without_layout, :format => :js
+ assert_no_match %r{<html>}, @response.body
end
def test_should_render_formatted_template
diff --git a/actionpack/test/controller/send_file_test.rb b/actionpack/test/controller/send_file_test.rb
index 4134da3b9e..d88d5c5dac 100644
--- a/actionpack/test/controller/send_file_test.rb
+++ b/actionpack/test/controller/send_file_test.rb
@@ -45,8 +45,8 @@ class SendFileTest < ActionController::TestCase
assert_equal file_data, response.body
end
- for_tag(:old_base) do
- def test_file_stream
+ def test_file_stream
+ pending do
response = nil
assert_nothing_raised { response = process('file') }
assert_not_nil response