diff options
author | Joshua Peek <josh@joshpeek.com> | 2009-10-03 21:05:51 -0500 |
---|---|---|
committer | Joshua Peek <josh@joshpeek.com> | 2009-10-03 21:05:51 -0500 |
commit | 018b79dd36d054d87fdc408d38dc9ac7f1b1500d (patch) | |
tree | a954ecef58682b2d259432a04ce503f8bb865840 /actionpack/test/controller/new_base/render_rjs_test.rb | |
parent | 84e94551f62d3bcbc71f1c6f3fda738342d984e2 (diff) | |
download | rails-018b79dd36d054d87fdc408d38dc9ac7f1b1500d.tar.gz rails-018b79dd36d054d87fdc408d38dc9ac7f1b1500d.tar.bz2 rails-018b79dd36d054d87fdc408d38dc9ac7f1b1500d.zip |
File extra test folders into controller, dispatch, or template
Diffstat (limited to 'actionpack/test/controller/new_base/render_rjs_test.rb')
-rw-r--r-- | actionpack/test/controller/new_base/render_rjs_test.rb | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/actionpack/test/controller/new_base/render_rjs_test.rb b/actionpack/test/controller/new_base/render_rjs_test.rb new file mode 100644 index 0000000000..7b76c54ab9 --- /dev/null +++ b/actionpack/test/controller/new_base/render_rjs_test.rb @@ -0,0 +1,50 @@ +require 'abstract_unit' + +module RenderRjs + class BasicController < ActionController::Base + self.view_paths = [ActionView::FixtureResolver.new( + "render_rjs/basic/index.js.rjs" => "page[:customer].replace_html render(:partial => 'customer')", + "render_rjs/basic/index_html.js.rjs" => "page[:customer].replace_html :partial => 'customer'", + "render_rjs/basic/_customer.js.erb" => "JS Partial", + "render_rjs/basic/_customer.html.erb" => "HTML Partial", + "render_rjs/basic/index_locale.js.rjs" => "page[:customer].replace_html :partial => 'customer'", + "render_rjs/basic/_customer.da.html.erb" => "Danish HTML Partial", + "render_rjs/basic/_customer.da.js.erb" => "Danish JS Partial" + )] + + def index + render + end + + def index_locale + old_locale, I18n.locale = I18n.locale, :da + end + end + + class TestBasic < SimpleRouteCase + testing BasicController + + def setup + @old_locale = I18n.locale + end + + def teardown + I18n.locale = @old_locale + end + + test "rendering a partial in an RJS template should pick the JS template over the HTML one" do + get :index, "format" => "js" + assert_response("$(\"customer\").update(\"JS Partial\");") + end + + test "replacing an element with a partial in an RJS template should pick the HTML template over the JS one" do + get :index_html, "format" => "js" + assert_response("$(\"customer\").update(\"HTML Partial\");") + end + + test "replacing an element with a partial in an RJS template with a locale should pick the localed HTML template" do + get :index_locale, "format" => "js" + assert_response("$(\"customer\").update(\"Danish HTML Partial\");") + end + end +end |