New Version

Sync with Latest Instiki Trunk.
Migrate to Rails 1.2.5.
Bump version number.
This commit is contained in:
Jacques Distler 2007-10-15 12:16:54 -05:00
parent de125367b0
commit 207fb1f7f2
120 changed files with 2592 additions and 662 deletions

View file

@ -165,7 +165,12 @@ class AssetTagHelperTest < Test::Unit::TestCase
def test_preset_empty_asset_id
Object.send(:const_set, :RAILS_ROOT, File.dirname(__FILE__) + "/../fixtures/")
# on windows, setting ENV["XXX"] to "" makes ENV["XXX"] return nil
if RUBY_PLATFORM =~ /win32/
ENV["RAILS_ASSET_ID"] = " "
else
ENV["RAILS_ASSET_ID"] = ""
end
assert_equal %(<img alt="Rails" src="/images/rails.png" />), image_tag("rails.png")
end

View file

@ -71,7 +71,12 @@ class CompiledTemplateTests < Test::Unit::TestCase
end
def test_compile_time
`echo '#{@a}' > #{@a}; echo '#{@b}' > #{@b}; ln -s #{@a} #{@s}`
File.open(@a, "w"){|f| f.puts @a}
File.open(@b, "w"){|f| f.puts @b}
# windows doesn't support symlinks (even under cygwin)
windows = (RUBY_PLATFORM =~ /win32/)
`ln -s #{@a} #{@s}` unless windows
v = ActionView::Base.new
v.base_path = '.'
@ -79,47 +84,54 @@ class CompiledTemplateTests < Test::Unit::TestCase
sleep 1
t = Time.now
sleep 1
v.compile_and_render_template(:rhtml, '', @a)
v.compile_and_render_template(:rhtml, '', @b)
v.compile_and_render_template(:rhtml, '', @s)
v.compile_and_render_template(:rhtml, '', @s) unless windows
a_n = v.method_names[@a]
b_n = v.method_names[@b]
s_n = v.method_names[@s]
s_n = v.method_names[@s] unless windows
ct_a = v.compile_time[a_n]
ct_b = v.compile_time[b_n]
ct_s = v.compile_time[s_n] unless windows
# all of the files have changed since last compile
assert v.compile_time[a_n] > t
assert v.compile_time[b_n] > t
assert v.compile_time[s_n] > t
assert v.compile_time[s_n] > t unless windows
sleep 1
t = Time.now
v.compile_and_render_template(:rhtml, '', @a)
v.compile_and_render_template(:rhtml, '', @b)
v.compile_and_render_template(:rhtml, '', @s)
v.compile_and_render_template(:rhtml, '', @s) unless windows
# none of the files have changed since last compile
assert v.compile_time[a_n] < t
assert v.compile_time[b_n] < t
assert v.compile_time[s_n] < t
# so they should not have been recmpiled
assert_equal ct_a, v.compile_time[a_n]
assert_equal ct_b, v.compile_time[b_n]
assert_equal ct_s, v.compile_time[s_n] unless windows
`rm #{@s}; ln -s #{@b} #{@s}`
`rm #{@s}; ln -s #{@b} #{@s}` unless windows
v.compile_and_render_template(:rhtml, '', @a)
v.compile_and_render_template(:rhtml, '', @b)
v.compile_and_render_template(:rhtml, '', @s)
v.compile_and_render_template(:rhtml, '', @s) unless windows
# the symlink has changed since last compile
assert v.compile_time[a_n] < t
assert v.compile_time[b_n] < t
assert v.compile_time[s_n] > t
assert_equal ct_a, v.compile_time[a_n]
assert_equal ct_b, v.compile_time[b_n]
assert v.compile_time[s_n] > t unless windows
sleep 1
`touch #{@b}`
FileUtils.touch @b
t = Time.now
sleep 1
v.compile_and_render_template(:rhtml, '', @a)
v.compile_and_render_template(:rhtml, '', @b)
v.compile_and_render_template(:rhtml, '', @s)
v.compile_and_render_template(:rhtml, '', @s) unless windows
# the file at the end of the symlink has changed since last compile
# both the symlink and the file at the end of it should be recompiled
assert v.compile_time[a_n] < t
assert v.compile_time[b_n] > t
assert v.compile_time[s_n] > t
assert v.compile_time[s_n] > t unless windows
end
end

View file

@ -36,14 +36,14 @@ class JavaScriptHelperTest < Test::Unit::TestCase
html = link_to_function( "Greet me!" ) do |page|
page.replace_html 'header', "<h1>Greetings</h1>"
end
assert_dom_equal %(<a href="#" onclick="Element.update(&quot;header&quot;, &quot;&lt;h1&gt;Greetings&lt;/h1&gt;&quot;);; return false;">Greet me!</a>), html
assert_dom_equal %q(<a href="#" onclick="Element.update(&quot;header&quot;, &quot;\074h1\076Greetings\074/h1\076&quot;);; return false;">Greet me!</a>), html
end
def test_link_to_function_with_rjs_block_and_options
html = link_to_function( "Greet me!", :class => "updater" ) do |page|
page.replace_html 'header', "<h1>Greetings</h1>"
end
assert_dom_equal %(<a href="#" class="updater" onclick="Element.update(&quot;header&quot;, &quot;&lt;h1&gt;Greetings&lt;/h1&gt;&quot;);; return false;">Greet me!</a>), html
assert_dom_equal %q(<a href="#" class="updater" onclick="Element.update(&quot;header&quot;, &quot;\074h1\076Greetings\074/h1\076&quot;);; return false;">Greet me!</a>), html
end
def test_button_to_function
@ -55,13 +55,13 @@ class JavaScriptHelperTest < Test::Unit::TestCase
html = button_to_function( "Greet me!" ) do |page|
page.replace_html 'header', "<h1>Greetings</h1>"
end
assert_dom_equal %(<input type="button" onclick="Element.update(&quot;header&quot;, &quot;&lt;h1&gt;Greetings&lt;/h1&gt;&quot;);;" value="Greet me!" />), html
assert_dom_equal %q(<input type="button" onclick="Element.update(&quot;header&quot;, &quot;\074h1\076Greetings\074/h1\076&quot;);;" value="Greet me!" />), html
end
def test_button_to_function_with_rjs_block_and_options
html = button_to_function( "Greet me!", :class => "greeter" ) do |page|
page.replace_html 'header', "<h1>Greetings</h1>"
end
assert_dom_equal %(<input type="button" class="greeter" onclick="Element.update(&quot;header&quot;, &quot;&lt;h1&gt;Greetings&lt;/h1&gt;&quot;);;" value="Greet me!" />), html
assert_dom_equal %q(<input type="button" class="greeter" onclick="Element.update(&quot;header&quot;, &quot;\074h1\076Greetings\074/h1\076&quot;);;" value="Greet me!" />), html
end
end

View file

@ -22,7 +22,7 @@ class NumberHelperTest < Test::Unit::TestCase
def test_number_to_currency
assert_equal("$1,234,567,890.50", number_to_currency(1234567890.50))
assert_equal("$1,234,567,890.51", number_to_currency(1234567890.506))
assert_equal("$1,234,567,890", number_to_currency(1234567890.50, {:precision => 0}))
assert_equal("$1,234,567,891", number_to_currency(1234567890.51, {:precision => 0}))
assert_equal("$1,234,567,890.5", number_to_currency(1234567890.50, {:precision => 1}))
assert_equal("&pound;1234567890,50", number_to_currency(1234567890.50, {:unit => "&pound;", :separator => ",", :delimiter => ""}))
assert_equal("$1,234,567,890.50", number_to_currency("1234567890.50"))

View file

@ -125,7 +125,7 @@ class PrototypeHelperTest < Test::Unit::TestCase
end
def test_observe_field
assert_dom_equal %(<script type=\"text/javascript\">\n//<![CDATA[\nnew Form.Element.Observer('glass', 300, function(element, value) {new Ajax.Request('http://www.example.com/reorder_if_empty', {asynchronous:true, evalScripts:true})})\n//]]>\n</script>),
assert_dom_equal %(<script type=\"text/javascript\">\n//<![CDATA[\nnew Form.Element.Observer('glass', 300, function(element, value) {new Ajax.Request('http://www.example.com/reorder_if_empty', {asynchronous:true, evalScripts:true, parameters:value})})\n//]]>\n</script>),
observe_field("glass", :frequency => 5.minutes, :url => { :action => "reorder_if_empty" })
end
@ -135,7 +135,7 @@ class PrototypeHelperTest < Test::Unit::TestCase
end
def test_observe_form
assert_dom_equal %(<script type=\"text/javascript\">\n//<![CDATA[\nnew Form.Observer('cart', 2, function(element, value) {new Ajax.Request('http://www.example.com/cart_changed', {asynchronous:true, evalScripts:true})})\n//]]>\n</script>),
assert_dom_equal %(<script type=\"text/javascript\">\n//<![CDATA[\nnew Form.Observer('cart', 2, function(element, value) {new Ajax.Request('http://www.example.com/cart_changed', {asynchronous:true, evalScripts:true, parameters:value})})\n//]]>\n</script>),
observe_form("cart", :frequency => 2, :url => { :action => "cart_changed" })
end
@ -170,23 +170,23 @@ class JavaScriptGeneratorTest < Test::Unit::TestCase
end
def test_insert_html_with_string
assert_equal 'new Insertion.Top("element", "<p>This is a test</p>");',
assert_equal 'new Insertion.Top("element", "\074p\076This is a test\074/p\076");',
@generator.insert_html(:top, 'element', '<p>This is a test</p>')
assert_equal 'new Insertion.Bottom("element", "<p>This is a test</p>");',
assert_equal 'new Insertion.Bottom("element", "\074p\076This is a test\074/p\076");',
@generator.insert_html(:bottom, 'element', '<p>This is a test</p>')
assert_equal 'new Insertion.Before("element", "<p>This is a test</p>");',
assert_equal 'new Insertion.Before("element", "\074p\076This is a test\074/p\076");',
@generator.insert_html(:before, 'element', '<p>This is a test</p>')
assert_equal 'new Insertion.After("element", "<p>This is a test</p>");',
assert_equal 'new Insertion.After("element", "\074p\076This is a test\074/p\076");',
@generator.insert_html(:after, 'element', '<p>This is a test</p>')
end
def test_replace_html_with_string
assert_equal 'Element.update("element", "<p>This is a test</p>");',
assert_equal 'Element.update("element", "\074p\076This is a test\074/p\076");',
@generator.replace_html('element', '<p>This is a test</p>')
end
def test_replace_element_with_string
assert_equal 'Element.replace("element", "<div id=\"element\"><p>This is a test</p></div>");',
assert_equal 'Element.replace("element", "\074div id=\"element\"\076\074p\076This is a test\074/p\076\074/div\076");',
@generator.replace('element', '<div id="element"><p>This is a test</p></div>')
end
@ -241,12 +241,12 @@ class JavaScriptGeneratorTest < Test::Unit::TestCase
@generator.remove('foo', 'bar')
@generator.replace_html('baz', '<p>This is a test</p>')
assert_equal <<-EOS.chomp, @generator.to_s
new Insertion.Top("element", "<p>This is a test</p>");
new Insertion.Bottom("element", "<p>This is a test</p>");
expected = %q(new Insertion.Top("element", "\074p\076This is a test\074/p\076");
new Insertion.Bottom("element", "\074p\076This is a test\074/p\076");
["foo", "bar"].each(Element.remove);
Element.update("baz", "<p>This is a test</p>");
EOS
Element.update("baz", "\074p\076This is a test\074/p\076");)
assert_equal expected, @generator.to_s
end
def test_element_access