1
0
Fork 0
mirror of https://github.com/haml/haml.git synced 2022-11-09 12:33:31 -05:00

Fix tests for old versions of Rails.

This commit is contained in:
Nathan Weizenbaum 2008-11-25 01:22:18 -08:00
parent 56578c5d9f
commit a0f832ab51
3 changed files with 44 additions and 17 deletions

View file

@ -103,7 +103,7 @@ if defined?(ActionView) and not defined?(Merb::Plugins)
preserve = haml_buffer.options[:preserve].include?(name.to_s)
if block_given? && block_called_from_erb?(block) && preserve
if block_given? && block_is_haml?(block) && preserve
return content_tag_without_haml(name, *args) {preserve(&block)}
end

View file

@ -4,6 +4,8 @@ require 'haml/template'
require 'sass/plugin'
require File.dirname(__FILE__) + '/mocks/article'
require 'action_pack/version'
module Haml::Filters::Test
include Haml::Filters::Base
@ -28,8 +30,10 @@ class TemplateTest < Test::Unit::TestCase
TEMPLATE_PATH = File.join(File.dirname(__FILE__), "templates")
TEMPLATES = %w{ very_basic standard helpers
whitespace_handling original_engine list helpful
silent_script tag_parsing just_stuff partials partial_layout
silent_script tag_parsing just_stuff partials
filters nuke_outer_whitespace nuke_inner_whitespace }
# partial layouts were introduced in 2.0.0
TEMPLATES << 'partial_layout' unless ActionPack::VERSION::MAJOR < 2
def setup
vars = { 'article' => Article.new, 'foo' => 'value one' }
@ -70,7 +74,7 @@ class TemplateTest < Test::Unit::TestCase
end
def assert_renders_correctly(name, &render_method)
render_method ||= proc { |name| @base.render(name) }
render_method ||= proc { |name| @base.render(:file => name) }
load_result(name).split("\n").zip(render_method[name].split("\n")).each_with_index do |pair, line|
message = "template: #{name}\nline: #{line}"

View file

@ -35,20 +35,43 @@ click
%p boom
- concat "foo\n"
- haml_buffer.tabulation = 0
- def url_for(*stuff); stuff.join(' '); end
-# The form URLs must be empty
-# because of a weird bug that causes url_for to misbehave.
%p
= form_tag ''
- form_tag '' do
%div= submit_tag 'save'
- @foo = 'value one'
= test_partial 'partial'
- form_for :article, @article, :url => '' do |f|
Title:
= f.text_field :title
Body:
= f.text_field :body
-#
-# ActionPack pre-2.0 has weird url_for issues here.
- if ActionPack::VERSION::MAJOR < 2
:plain
<p>
<form action="" method="post">
</p>
<form action="" method="post">
<div><input name="commit" type="submit" value="save" /></div>
<p>
@foo =
value one
</p>
Toplevel? false
<p>
@foo =
value three
</p>
</form>
<form action="" method="post">
Title:
<input id="article_title" name="article[title]" size="30" type="text" value="Hello" />
Body:
<input id="article_body" name="article[body]" size="30" type="text" value="World" />
</form>
- else
%p
= form_tag ''
- form_tag '' do
%div= submit_tag 'save'
- @foo = 'value one'
= test_partial 'partial'
- form_for :article, @article, :url => '' do |f|
Title:
= f.text_field :title
Body:
= f.text_field :body
= list_of({:google => 'http://www.google.com'}) do |name, link|
%a{ :href => link }= name
%p