diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2006-11-20 09:04:26 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2006-11-20 09:04:26 +0000 |
commit | d41f380a2c7c7926ce89ee2bcef8093d1fd59036 (patch) | |
tree | c5fdfc4ef646b81e7b9a840edf9b11451b4e425f /actionpack/test | |
parent | 19c99acfbc26c5fad02d968f37a958b1cbfa617b (diff) | |
download | rails-d41f380a2c7c7926ce89ee2bcef8093d1fd59036.tar.gz rails-d41f380a2c7c7926ce89ee2bcef8093d1fd59036.tar.bz2 rails-d41f380a2c7c7926ce89ee2bcef8093d1fd59036.zip |
Extract template_changed_since? from compile_template? so plugins may override its behavior for non-file-based templates. Closes #6651.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5587 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/test')
-rw-r--r-- | actionpack/test/template/compiled_templates_test.rb | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/actionpack/test/template/compiled_templates_test.rb b/actionpack/test/template/compiled_templates_test.rb index e46543d645..a64ae95743 100644 --- a/actionpack/test/template/compiled_templates_test.rb +++ b/actionpack/test/template/compiled_templates_test.rb @@ -71,14 +71,24 @@ class CompiledTemplateTests < Test::Unit::TestCase end def test_compile_time + t = Time.now + sleep 1 `echo '#{@a}' > #{@a}; echo '#{@b}' > #{@b}; ln -s #{@a} #{@s}` v = ActionView::Base.new v.base_path = '.' v.cache_template_loading = false; + # private methods template_changed_since? and compile_template? + # should report true for all since they have not been compiled + assert v.send(:template_changed_since?, @a, t) + assert v.send(:template_changed_since?, @b, t) + assert v.send(:template_changed_since?, @s, t) + assert v.send(:compile_template?, nil, @a, {}) + assert v.send(:compile_template?, nil, @b, {}) + assert v.send(:compile_template?, nil, @s, {}) + 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) @@ -92,6 +102,14 @@ class CompiledTemplateTests < Test::Unit::TestCase sleep 1 t = Time.now + # private methods template_changed_since? and compile_template? + # should report false for all since none have changed since compile + assert !v.send(:template_changed_since?, @a, v.compile_time[a_n]) + assert !v.send(:template_changed_since?, @b, v.compile_time[b_n]) + assert !v.send(:template_changed_since?, @s, v.compile_time[s_n]) + assert !v.send(:compile_template?, nil, @a, {}) + assert !v.send(:compile_template?, nil, @b, {}) + assert !v.send(:compile_template?, nil, @s, {}) v.compile_and_render_template(:rhtml, '', @a) v.compile_and_render_template(:rhtml, '', @b) v.compile_and_render_template(:rhtml, '', @s) @@ -101,6 +119,14 @@ class CompiledTemplateTests < Test::Unit::TestCase assert v.compile_time[s_n] < t `rm #{@s}; ln -s #{@b} #{@s}` + # private methods template_changed_since? and compile_template? + # should report true for symlink since it has changed since compile + assert !v.send(:template_changed_since?, @a, v.compile_time[a_n]) + assert !v.send(:template_changed_since?, @b, v.compile_time[b_n]) + assert v.send(:template_changed_since?, @s, v.compile_time[s_n]) + assert !v.send(:compile_template?, nil, @a, {}) + assert !v.send(:compile_template?, nil, @b, {}) + assert v.send(:compile_template?, nil, @s, {}) v.compile_and_render_template(:rhtml, '', @a) v.compile_and_render_template(:rhtml, '', @b) v.compile_and_render_template(:rhtml, '', @s) @@ -111,6 +137,15 @@ class CompiledTemplateTests < Test::Unit::TestCase sleep 1 `touch #{@b}` + # private methods template_changed_since? and compile_template? + # should report true for symlink and file at end of symlink + # since it has changed since last compile + assert !v.send(:template_changed_since?, @a, v.compile_time[a_n]) + assert v.send(:template_changed_since?, @b, v.compile_time[b_n]) + assert v.send(:template_changed_since?, @s, v.compile_time[s_n]) + assert !v.send(:compile_template?, nil, @a, {}) + assert v.send(:compile_template?, nil, @b, {}) + assert v.send(:compile_template?, nil, @s, {}) t = Time.now v.compile_and_render_template(:rhtml, '', @a) v.compile_and_render_template(:rhtml, '', @b) |