Changesets can be listed by changeset number.
The Git repository is here.
- Revision:
- 193
- Log:
First stage commit of Typo 4.1, modified for the ROOL site.
Includes all local modifications but a final pass needs to be
made to delete any files left over from earlier Typo versions
that shouldn't be here anymore. See the 'tags' section of the
repository for a clean Typo 4.1 tree.Note that symlinks to shared files in the RISC OS Open theme
directory have been deliberately included this time around; I
decided that on balance it was better to leave them in as
placeholders, since unlike symlinks in app/views/shared, the
Typo theme structure is not a standard Rails concept.
- Author:
- rool
- Date:
- Wed Apr 04 18:51:02 +0100 2007
- Size:
- 3196 Bytes
1 | #!/usr/bin/env ruby |
2 | |
3 | require 'test/unit' |
4 | require File.dirname(__FILE__) + '/../lib/haml/template' |
5 | |
6 | class HelperTest < Test::Unit::TestCase |
7 | include Haml::Helpers |
8 | |
9 | def setup |
10 | ActionView::Base.register_template_handler("haml", Haml::Template) |
11 | @base = ActionView::Base.new |
12 | @base.controller = ActionController::Base.new |
13 | end |
14 | |
15 | def render(text, options = {}) |
16 | if options == :action_view |
17 | @base.render :inline => text, :type => :haml |
18 | else |
19 | Haml::Engine.new(text, options).to_html |
20 | end |
21 | end |
22 | |
23 | def test_flatten |
24 | assert_equal(flatten("FooBar"), "FooBar") |
25 | |
26 | assert_equal(flatten("Foo\rBar"), "FooBar") |
27 | |
28 | assert_equal(flatten("Foo\nBar"), "Foo
Bar") |
29 | |
30 | assert_equal(flatten("Hello\nWorld!\nYOU ARE \rFLAT?\n\rOMGZ!"), |
31 | "Hello
World!
YOU ARE FLAT?
OMGZ!") |
32 | end |
33 | |
34 | def test_list_of_should_render_correctly |
35 | assert_equal("<li>1</li>\n<li>2</li>\n", render("= list_of([1, 2]) do |i|\n = i")) |
36 | assert_equal("<li>1</li>\n", render("= list_of([[1]]) do |i|\n = i.first")) |
37 | assert_equal("<li>\n <h1>Fee</h1>\n <p>A word!</p>\n</li>\n<li>\n <h1>Fi</h1>\n <p>A word!</p>\n</li>\n<li>\n <h1>Fo</h1>\n <p>A word!</p>\n</li>\n<li>\n <h1>Fum</h1>\n <p>A word!</p>\n</li>\n", |
38 | render("= list_of(['Fee', 'Fi', 'Fo', 'Fum']) do |title|\n %h1= title\n %p A word!")) |
39 | end |
40 | |
41 | def test_buffer_access |
42 | assert(render("= buffer") =~ /#<Haml::Buffer:0x[a-z0-9]+>/) |
43 | assert_equal(render("= (buffer == _hamlout)"), "true\n") |
44 | end |
45 | |
46 | def test_tabs |
47 | assert_equal(render("foo\n- tab_up\nbar\n- tab_down\nbaz"), "foo\n bar\nbaz\n") |
48 | end |
49 | |
50 | def test_helpers_dont_leak |
51 | # Haml helpers shouldn't be accessible from ERB |
52 | render("foo") |
53 | proper_behavior = false |
54 | |
55 | begin |
56 | ActionView::Base.new.render(:inline => "<%= flatten('Foo\\nBar') %>") |
57 | rescue NoMethodError |
58 | proper_behavior = true |
59 | end |
60 | assert(proper_behavior) |
61 | |
62 | begin |
63 | ActionView::Base.new.render(:inline => "<%= concat('foo') %>") |
64 | rescue ArgumentError |
65 | proper_behavior = true |
66 | end |
67 | assert(proper_behavior) |
68 | end |
69 | |
70 | def test_action_view_included |
71 | assert(Haml::Helpers.action_view?) |
72 | end |
73 | |
74 | def test_action_view_not_included |
75 | #This is for 100% rcov, rather than any real testing purposes. |
76 | Kernel.module_eval do |
77 | alias_method :old_require, :require |
78 | def require(string) |
79 | raise LoadError if string == "action_view" |
80 | old_require string |
81 | end |
82 | end |
83 | |
84 | load File.dirname(__FILE__) + '/../lib/haml/helpers/action_view_mods.rb' |
85 | |
86 | Kernel.module_eval do |
87 | alias_method :require, :old_require |
88 | end |
89 | end |
90 | |
91 | def test_form_tag |
92 | # Until the next Rails is released, form_tag with a block can have one of |
93 | # two behaviors. |
94 | |
95 | result = render("- form_tag 'foo' do\n %p bar\n %strong baz", :action_view) |
96 | new_rails = "<form action=\"foo\" method=\"post\">\n <p>bar</p>\n <strong>baz</strong>\n</form>" |
97 | old_rails = "" |
98 | assert(result == new_rails || result == old_rails) |
99 | end |
100 | |
101 | def test_capture_haml |
102 | assert_equal("\"<p>13</p>\\n\"\n", render("- foo = capture_haml(13) do |a|\n %p= a\n= foo.dump")) |
103 | end |
104 | end |
105 |