Skip to content
This repository
Browse code

Cleaning up more tests and code that needed to work in both old and n…

…ew base
  • Loading branch information...
commit 65102c8f1a55c8d73e44b62eed5e689017ace7cd 1 parent 55ee0ba
Yehuda Katz + Carl Lerche authored
1  actionpack/lib/action_view.rb
@@ -48,6 +48,7 @@ def self.load_all!
48 48 autoload :TemplateHandlers, 'action_view/template/handlers'
49 49 autoload :TextTemplate, 'action_view/template/text'
50 50 autoload :Helpers, 'action_view/helpers'
  51 + autoload :FileSystemResolverWithFallback, 'action_view/template/resolver'
51 52 end
52 53
53 54 class ERB
6 actionpack/test/controller/base_test.rb
@@ -146,11 +146,7 @@ def test_get_on_priv_should_show_selector
146 146 def test_method_missing_is_not_an_action_name
147 147 use_controller MethodMissingController
148 148
149   - if defined?(ActionController::Http)
150   - assert ! @controller.__send__(:action_method?, 'method_missing')
151   - else
152   - assert ! @controller.__send__(:action_methods).include?('method_missing')
153   - end
  149 + assert ! @controller.__send__(:action_method?, 'method_missing')
154 150
155 151 get :method_missing
156 152 assert_response :success
68 actionpack/test/controller/filters_test.rb
@@ -9,24 +9,20 @@ class << self
9 9 end unless method_defined?(pending)
10 10 end
11 11
12   - if defined?(ActionController::Http)
13   - def before_filters
14   - filters = _process_action_callbacks.select { |c| c.kind == :before }
15   - filters.map! { |c| c.instance_variable_get(:@raw_filter) }
16   - end
  12 + def before_filters
  13 + filters = _process_action_callbacks.select { |c| c.kind == :before }
  14 + filters.map! { |c| c.instance_variable_get(:@raw_filter) }
17 15 end
18 16 end
19 17
20   - if defined?(ActionController::Http)
21   - def assigns(key = nil)
22   - assigns = {}
23   - instance_variable_names.each do |ivar|
24   - next if ActionController::Base.protected_instance_variables.include?(ivar)
25   - assigns[ivar[1..-1]] = instance_variable_get(ivar)
26   - end
27   -
28   - key.nil? ? assigns : assigns[key.to_s]
  18 + def assigns(key = nil)
  19 + assigns = {}
  20 + instance_variable_names.each do |ivar|
  21 + next if ActionController::Base.protected_instance_variables.include?(ivar)
  22 + assigns[ivar[1..-1]] = instance_variable_get(ivar)
29 23 end
  24 +
  25 + key.nil? ? assigns : assigns[key.to_s]
30 26 end
31 27 end
32 28
@@ -598,22 +594,11 @@ def test_having_properties_in_around_filter
598 594 assert_equal "before and after", assigns["execution_log"]
599 595 end
600 596
601   - for_tag(:old_base) do
602   - def test_prepending_and_appending_around_filter
603   - controller = test_process(MixedFilterController)
604   - assert_equal " before aroundfilter before procfilter before appended aroundfilter " +
605   - " after appended aroundfilter after aroundfilter after procfilter ",
606   - MixedFilterController.execution_log
607   - end
608   - end
609   -
610   - for_tag(:new_base) do
611   - def test_prepending_and_appending_around_filter
612   - controller = test_process(MixedFilterController)
613   - assert_equal " before aroundfilter before procfilter before appended aroundfilter " +
614   - " after appended aroundfilter after procfilter after aroundfilter ",
615   - MixedFilterController.execution_log
616   - end
  597 + def test_prepending_and_appending_around_filter
  598 + controller = test_process(MixedFilterController)
  599 + assert_equal " before aroundfilter before procfilter before appended aroundfilter " +
  600 + " after appended aroundfilter after procfilter after aroundfilter ",
  601 + MixedFilterController.execution_log
617 602 end
618 603
619 604 def test_rendering_breaks_filtering_chain
@@ -876,14 +861,6 @@ def test_with_instance
876 861 assert_raise(After) { test_process(controller,'raises_after') }
877 862 end
878 863
879   - for_tag(:old_base) do
880   - def test_with_method
881   - controller = ControllerWithFilterMethod
882   - assert_nothing_raised { test_process(controller,'no_raise') }
883   - assert_raise(After) { test_process(controller,'raises_after') }
884   - end
885   - end
886   -
887 864 def test_with_proc
888 865 test_process(ControllerWithProcFilter,'no_raise')
889 866 assert assigns['before']
@@ -906,18 +883,9 @@ def test_nested_filters
906 883 end
907 884 end
908 885
909   - for_tag(:old_base) do
910   - def test_filter_order_with_all_filter_types
911   - test_process(ControllerWithAllTypesOfFilters,'no_raise')
912   - assert_equal 'before around (before yield) around_again (before yield) around_again (after yield) around (after yield) after', assigns['ran_filter'].join(' ')
913   - end
914   - end
915   -
916   - for_tag(:new_base) do
917   - def test_filter_order_with_all_filter_types
918   - test_process(ControllerWithAllTypesOfFilters,'no_raise')
919   - assert_equal 'before around (before yield) around_again (before yield) around_again (after yield) after around (after yield)', assigns['ran_filter'].join(' ')
920   - end
  886 + def test_filter_order_with_all_filter_types
  887 + test_process(ControllerWithAllTypesOfFilters,'no_raise')
  888 + assert_equal 'before around (before yield) around_again (before yield) around_again (after yield) after around (after yield)', assigns['ran_filter'].join(' ')
921 889 end
922 890
923 891 def test_filter_order_with_skip_filter_method
19 actionpack/test/controller/helper_test.rb
@@ -127,11 +127,7 @@ def test_helper_for_acronym_controller
127 127 end
128 128
129 129 def test_all_helpers
130   - methods = if defined?(ActionController::Http)
131   - AllHelpersController._helpers.instance_methods.map {|m| m.to_s}
132   - else
133   - AllHelpersController.master_helper_module.instance_methods.map {|m| m.to_s}
134   - end
  130 + methods = AllHelpersController._helpers.instance_methods.map {|m| m.to_s}
135 131
136 132 # abc_helper.rb
137 133 assert methods.include?('bare_a')
@@ -147,12 +143,7 @@ def test_all_helpers_with_alternate_helper_dir
147 143 @controller_class.helpers_dir = File.dirname(__FILE__) + '/../fixtures/alternate_helpers'
148 144
149 145 # Reload helpers
150   - if defined?(ActionController::Http)
151   - @controller_class._helpers = Module.new
152   - else
153   - @controller_class.master_helper_module = Module.new
154   - end
155   -
  146 + @controller_class._helpers = Module.new
156 147 @controller_class.helper :all
157 148
158 149 # helpers/abc_helper.rb should not be included
@@ -184,11 +175,7 @@ def expected_helper_methods
184 175 end
185 176
186 177 def master_helper_methods
187   - if defined?(ActionController::Http)
188   - @controller_class._helpers.instance_methods.map {|m| m.to_s }
189   - else
190   - @controller_class.master_helper_module.instance_methods.map {|m| m.to_s }
191   - end
  178 + @controller_class._helpers.instance_methods.map {|m| m.to_s }
192 179 end
193 180
194 181 def missing_methods
16 actionpack/test/controller/mime_responds_test.rb
@@ -519,16 +519,14 @@ def test_missing_layout_renders_properly
519 519 assert_equal 'Hello iPhone', @response.body
520 520 end
521 521
522   - for_tag(:old_base) do
523   - def test_format_with_inherited_layouts
524   - @controller = SuperPostController.new
  522 + def test_format_with_inherited_layouts
  523 + @controller = SuperPostController.new
525 524
526   - get :index
527   - assert_equal 'Super Firefox', @response.body
  525 + get :index
  526 + assert_equal '<html><div id="html">Super Firefox</div></html>', @response.body
528 527
529   - @request.accept = "text/iphone"
530   - get :index
531   - assert_equal '<html><div id="super_iphone">Super iPhone</div></html>', @response.body
532   - end
  528 + @request.accept = "text/iphone"
  529 + get :index
  530 + assert_equal '<html><div id="super_iphone">Super iPhone</div></html>', @response.body
533 531 end
534 532 end
4 actionpack/test/controller/send_file_test.rb
@@ -45,8 +45,8 @@ def test_file_nostream
45 45 assert_equal file_data, response.body
46 46 end
47 47
48   - for_tag(:old_base) do
49   - def test_file_stream
  48 + def test_file_stream
  49 + pending do
50 50 response = nil
51 51 assert_nothing_raised { response = process('file') }
52 52 assert_not_nil response
13 actionpack/test/template/body_parts_test.rb
@@ -4,9 +4,8 @@ class BodyPartsTest < ActionController::TestCase
4 4 RENDERINGS = [Object.new, Object.new, Object.new]
5 5
6 6 class TestController < ActionController::Base
7   - def performed?
8   - defined?(ActionController::Http) ? true : super
9   - end
  7 + def performed?() true end
  8 +
10 9 def index
11 10 RENDERINGS.each do |rendering|
12 11 @template.punctuate_body! rendering
@@ -19,11 +18,9 @@ def index
19 18
20 19 def test_body_parts
21 20 get :index
22   - pending(:old_base) do
23   - # TestProcess buffers body_parts into body
24   - # TODO: Rewrite test w/o going through process
25   - assert_equal RENDERINGS, @response.body_parts
26   - end
  21 + # TestProcess buffers body_parts into body
  22 + # TODO: Rewrite test w/o going through process
  23 + assert_equal RENDERINGS, @response.body_parts
27 24 assert_equal RENDERINGS.join, @response.body
28 25 end
29 26 end

0 comments on commit 65102c8

Please sign in to comment.
Something went wrong with that request. Please try again.