diff options
author | Yehuda Katz <wycats@gmail.com> | 2009-03-20 14:05:10 -0700 |
---|---|---|
committer | Yehuda Katz <wycats@gmail.com> | 2009-03-20 14:05:10 -0700 |
commit | d1256f71d64b207497b5e8ae220ae1a48ae15a8b (patch) | |
tree | a5e07424c09b543a4826547c10982a4f58093352 | |
parent | 7a86f8ea90f88a388b3093471d60b3019ea8ebac (diff) | |
download | rails-d1256f71d64b207497b5e8ae220ae1a48ae15a8b.tar.gz rails-d1256f71d64b207497b5e8ae220ae1a48ae15a8b.tar.bz2 rails-d1256f71d64b207497b5e8ae220ae1a48ae15a8b.zip |
Hacked up fixture view paths to simplify tests for a bit
-rw-r--r-- | actionpack/test/new_base/fixture_view_path_test.rb | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/actionpack/test/new_base/fixture_view_path_test.rb b/actionpack/test/new_base/fixture_view_path_test.rb new file mode 100644 index 0000000000..482607474f --- /dev/null +++ b/actionpack/test/new_base/fixture_view_path_test.rb @@ -0,0 +1,69 @@ +require File.join(File.expand_path(File.dirname(__FILE__)), "test_helper") + +module ActionView #:nodoc: + class FixtureTemplate < Template + class FixturePath < Template::Path + def initialize(hash) + @hash = {} + + hash.each do |k, v| + @hash[k.sub(/\.\w+$/, '')] = FixtureTemplate.new(v, k.split("/").last, self) + end + + super("") + end + + def find_template(path) + @hash[path] + end + end + + def initialize(body, template_path, load_paths = []) + @body = body + end + + def relative_path + "fail" + end + + def filename + "fail" + end + + def method_name_without_locals + "abc" + end + + def source + @body + end + end +end + +OMG = { + "happy_path/render_action/hello_world.html.erb" => "Hello world!" +} + +module HappyPath + + # This has no layout and it works + class RenderActionController < ActionController::Base2 + + self.view_paths = [ActionView::FixtureTemplate::FixturePath.new(OMG)] + + def render_action_hello_world + render :action => "hello_world" + end + + end + + class TestRenderAction < SimpleRouteCase + + describe "Rendering an action using :action => <String>" + + get "/happy_path/render_action/render_action_hello_world" + assert_body "Hello world!" + assert_status 200 + + end +end
\ No newline at end of file |