diff options
author | Carlhuda <carlhuda@engineyard.com> | 2010-03-18 15:52:43 -0700 |
---|---|---|
committer | Carlhuda <carlhuda@engineyard.com> | 2010-03-18 15:52:43 -0700 |
commit | 71c9337f45f9c5461cbc6ddf6cab764ad0f82c3b (patch) | |
tree | 4e4a89ceca056d7ee4fcf329ecb56bbc0547d553 /actionpack/test | |
parent | 523d0f3700f5bb68cdd3d549eaad63d8a88c2aef (diff) | |
download | rails-71c9337f45f9c5461cbc6ddf6cab764ad0f82c3b.tar.gz rails-71c9337f45f9c5461cbc6ddf6cab764ad0f82c3b.tar.bz2 rails-71c9337f45f9c5461cbc6ddf6cab764ad0f82c3b.zip |
All tests pass without memoizing view_context
Diffstat (limited to 'actionpack/test')
-rw-r--r-- | actionpack/test/controller/caching_test.rb | 8 | ||||
-rw-r--r-- | actionpack/test/controller/render_test.rb | 8 | ||||
-rw-r--r-- | actionpack/test/template/capture_helper_test.rb | 2 | ||||
-rw-r--r-- | actionpack/test/template/output_buffer_test.rb | 15 | ||||
-rw-r--r-- | actionpack/test/template/render_test.rb | 2 |
5 files changed, 23 insertions, 12 deletions
diff --git a/actionpack/test/controller/caching_test.rb b/actionpack/test/controller/caching_test.rb index f6264c0954..5157454be0 100644 --- a/actionpack/test/controller/caching_test.rb +++ b/actionpack/test/controller/caching_test.rb @@ -616,8 +616,10 @@ class FragmentCachingTest < ActionController::TestCase @store.write('views/expensive', 'fragment content') fragment_computed = false + view_context = @controller.view_context + buffer = 'generated till now -> '.html_safe - buffer << @controller.fragment_for('expensive') { fragment_computed = true } + buffer << view_context.send(:fragment_for, 'expensive') { fragment_computed = true } assert fragment_computed assert_equal 'generated till now -> ', buffer @@ -627,8 +629,10 @@ class FragmentCachingTest < ActionController::TestCase @store.write('views/expensive', 'fragment content') fragment_computed = false + view_context = @controller.view_context + buffer = 'generated till now -> '.html_safe - buffer << @controller.fragment_for('expensive') { fragment_computed = true } + buffer << view_context.send(:fragment_for, 'expensive') { fragment_computed = true } assert !fragment_computed assert_equal 'generated till now -> fragment content', buffer diff --git a/actionpack/test/controller/render_test.rb b/actionpack/test/controller/render_test.rb index 1d7692f0a8..24817a93d2 100644 --- a/actionpack/test/controller/render_test.rb +++ b/actionpack/test/controller/render_test.rb @@ -18,6 +18,13 @@ class TestController < ActionController::Base layout :determine_layout + def name + nil + end + + private :name + helper_method :name + def hello_world end @@ -418,7 +425,6 @@ class TestController < ActionController::Base def rendering_with_conflicting_local_vars @name = "David" - def view_context.name() nil end render :action => "potential_conflicts" end diff --git a/actionpack/test/template/capture_helper_test.rb b/actionpack/test/template/capture_helper_test.rb index 2216e6b578..bf541c17d3 100644 --- a/actionpack/test/template/capture_helper_test.rb +++ b/actionpack/test/template/capture_helper_test.rb @@ -114,7 +114,7 @@ class CaptureHelperTest < ActionView::TestCase end def view_with_controller - returning(ActionView::Base.for_controller(TestController.new)) do |view| + returning(TestController.new.view_context) do |view| view.output_buffer = ActionView::OutputBuffer.new end end diff --git a/actionpack/test/template/output_buffer_test.rb b/actionpack/test/template/output_buffer_test.rb index 9016b74489..bd49a11af1 100644 --- a/actionpack/test/template/output_buffer_test.rb +++ b/actionpack/test/template/output_buffer_test.rb @@ -10,6 +10,7 @@ class OutputBufferTest < ActionController::TestCase tests TestController def setup + @vc = @controller.view_context get :index assert_equal ['foo'], body_parts end @@ -25,15 +26,15 @@ class OutputBufferTest < ActionController::TestCase end test 'flushing ignores empty output buffer' do - @controller.view_context.output_buffer = '' - @controller.view_context.flush_output_buffer + @vc.output_buffer = '' + @vc.flush_output_buffer assert_equal '', output_buffer assert_equal ['foo'], body_parts end test 'flushing appends the output buffer to the body parts' do - @controller.view_context.output_buffer = 'bar' - @controller.view_context.flush_output_buffer + @vc.output_buffer = 'bar' + @vc.flush_output_buffer assert_equal '', output_buffer assert_equal ['foo', 'bar'], body_parts end @@ -41,8 +42,8 @@ class OutputBufferTest < ActionController::TestCase if '1.9'.respond_to?(:force_encoding) test 'flushing preserves output buffer encoding' do original_buffer = ' '.force_encoding(Encoding::EUC_JP) - @controller.view_context.output_buffer = original_buffer - @controller.view_context.flush_output_buffer + @vc.output_buffer = original_buffer + @vc.flush_output_buffer assert_equal ['foo', original_buffer], body_parts assert_not_equal original_buffer, output_buffer assert_equal Encoding::EUC_JP, output_buffer.encoding @@ -51,7 +52,7 @@ class OutputBufferTest < ActionController::TestCase protected def output_buffer - @controller.view_context.output_buffer + @vc.output_buffer end def body_parts diff --git a/actionpack/test/template/render_test.rb b/actionpack/test/template/render_test.rb index e66202e8fe..e54ebfbf8d 100644 --- a/actionpack/test/template/render_test.rb +++ b/actionpack/test/template/render_test.rb @@ -9,7 +9,7 @@ module RenderTestCases def setup_view(paths) @assigns = { :secret => 'in the sauce' } @view = ActionView::Base.new(paths, @assigns) - @controller_view = ActionView::Base.for_controller(TestController.new) + @controller_view = TestController.new.view_context # Reload and register danish language for testing I18n.reload! |