diff options
author | Carlhuda <carlhuda@engineyard.com> | 2010-03-17 16:28:05 -0700 |
---|---|---|
committer | Carlhuda <carlhuda@engineyard.com> | 2010-03-17 16:29:35 -0700 |
commit | d9375f3f302a5d1856ad57946c7263d4e6a45a2a (patch) | |
tree | 76769a45da7b1315df173976067ff37edcb59b49 /actionpack/test/template/erb | |
parent | 7872fa9a4397c450ee22c511966e149d594d153e (diff) | |
download | rails-d9375f3f302a5d1856ad57946c7263d4e6a45a2a.tar.gz rails-d9375f3f302a5d1856ad57946c7263d4e6a45a2a.tar.bz2 rails-d9375f3f302a5d1856ad57946c7263d4e6a45a2a.zip |
Modify assert_template to use notifications. Also, remove ActionController::Base#template since it is no longer needed.
Diffstat (limited to 'actionpack/test/template/erb')
-rw-r--r-- | actionpack/test/template/erb/form_for_test.rb | 11 | ||||
-rw-r--r-- | actionpack/test/template/erb/helper.rb | 30 | ||||
-rw-r--r-- | actionpack/test/template/erb/tag_helper_test.rb | 40 |
3 files changed, 44 insertions, 37 deletions
diff --git a/actionpack/test/template/erb/form_for_test.rb b/actionpack/test/template/erb/form_for_test.rb new file mode 100644 index 0000000000..482dbb0287 --- /dev/null +++ b/actionpack/test/template/erb/form_for_test.rb @@ -0,0 +1,11 @@ +require "abstract_unit" +require "template/erb/helper" + +module ERBTest + class TagHelperTest < BlockTestCase + test "form_for works" do + output = render_content "form_for(:staticpage, :url => {:controller => 'blah', :action => 'update'})", "" + assert_equal "<form action=\"/blah/update\" method=\"post\"></form>", output + end + end +end
\ No newline at end of file diff --git a/actionpack/test/template/erb/helper.rb b/actionpack/test/template/erb/helper.rb new file mode 100644 index 0000000000..7147178849 --- /dev/null +++ b/actionpack/test/template/erb/helper.rb @@ -0,0 +1,30 @@ +module ERBTest + class ViewContext + mock_controller = Class.new do + include SharedTestRoutes.url_helpers + end + + include ActionView::Helpers::TagHelper + include ActionView::Helpers::JavaScriptHelper + include ActionView::Helpers::FormHelper + + attr_accessor :output_buffer + + def protect_against_forgery?() false end + + define_method(:controller) do + mock_controller.new + end + end + + class BlockTestCase < ActiveSupport::TestCase + def render_content(start, inside) + template = block_helper(start, inside) + ActionView::Template::Handlers::Erubis.new(template).evaluate(ViewContext.new) + end + + def block_helper(str, rest) + "<%= #{str} do %>#{rest}<% end %>" + end + end +end
\ No newline at end of file diff --git a/actionpack/test/template/erb/tag_helper_test.rb b/actionpack/test/template/erb/tag_helper_test.rb index b5b7ae87de..64a88bde1d 100644 --- a/actionpack/test/template/erb/tag_helper_test.rb +++ b/actionpack/test/template/erb/tag_helper_test.rb @@ -1,36 +1,10 @@ require "abstract_unit" +require "template/erb/helper" module ERBTest - class ViewContext - mock_controller = Class.new do - include SharedTestRoutes.url_helpers - end - - include ActionView::Helpers::TagHelper - include ActionView::Helpers::JavaScriptHelper - include ActionView::Helpers::FormHelper - - attr_accessor :output_buffer - - def protect_against_forgery?() false end - - define_method(:controller) do - mock_controller.new - end - end - - class DeprecatedViewContext < ViewContext - # include ActionView::Helpers::DeprecatedBlockHelpers - end - module SharedTagHelpers extend ActiveSupport::Testing::Declarative - def render_content(start, inside) - template = block_helper(start, inside) - ActionView::Template::Handlers::Erubis.new(template).evaluate(context.new) - end - def maybe_deprecated if @deprecated assert_deprecated { yield } @@ -64,11 +38,7 @@ module ERBTest end end - class TagHelperTest < ActiveSupport::TestCase - def context - ViewContext - end - + class TagHelperTest < BlockTestCase def block_helper(str, rest) "<%= #{str} do %>#{rest}<% end %>" end @@ -76,11 +46,7 @@ module ERBTest include SharedTagHelpers end - class DeprecatedTagHelperTest < ActiveSupport::TestCase - def context - DeprecatedViewContext - end - + class DeprecatedTagHelperTest < BlockTestCase def block_helper(str, rest) "<% __in_erb_template=true %><% #{str} do %>#{rest}<% end %>" end |