aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/controller/new_base/render_rjs_test.rb
diff options
context:
space:
mode:
authorMikel Lindsaar <raasdnil@gmail.com>2010-03-28 14:44:34 +1100
committerMikel Lindsaar <raasdnil@gmail.com>2010-03-28 14:44:34 +1100
commit2bcc2ebf44b59e46c104c92d621e8051c97bfcf5 (patch)
treed2a3f04fd3020c1b5d88847af62d52f2d5e5bd61 /actionpack/test/controller/new_base/render_rjs_test.rb
parentf5774e3e3f70a3acfa559b9ff889e9417fb71d4b (diff)
parent8398f21880a952769ccd6437a4344922fe596dab (diff)
downloadrails-2bcc2ebf44b59e46c104c92d621e8051c97bfcf5.tar.gz
rails-2bcc2ebf44b59e46c104c92d621e8051c97bfcf5.tar.bz2
rails-2bcc2ebf44b59e46c104c92d621e8051c97bfcf5.zip
Merge branch 'master' of git://github.com/rails/rails
Diffstat (limited to 'actionpack/test/controller/new_base/render_rjs_test.rb')
-rw-r--r--actionpack/test/controller/new_base/render_rjs_test.rb20
1 files changed, 19 insertions, 1 deletions
diff --git a/actionpack/test/controller/new_base/render_rjs_test.rb b/actionpack/test/controller/new_base/render_rjs_test.rb
index 8c47b38ab6..b602b9f8e9 100644
--- a/actionpack/test/controller/new_base/render_rjs_test.rb
+++ b/actionpack/test/controller/new_base/render_rjs_test.rb
@@ -5,8 +5,10 @@ module RenderRjs
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/index_no_js.js.erb" => "<%= render(:partial => 'developer') %>",
"render_rjs/basic/_customer.js.erb" => "JS Partial",
"render_rjs/basic/_customer.html.erb" => "HTML Partial",
+ "render_rjs/basic/_developer.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"
@@ -16,8 +18,14 @@ module RenderRjs
render
end
+ def index_respond_to
+ respond_to do |format|
+ format.js { render :action => "index_no_js" }
+ end
+ end
+
def index_locale
- old_locale, I18n.locale = I18n.locale, :da
+ self.locale = :da
end
end
@@ -37,6 +45,16 @@ module RenderRjs
assert_response("$(\"customer\").update(\"JS Partial\");")
end
+ test "rendering a partial in an RJS template should pick the HTML one if no JS is available" do
+ get :index_no_js, "format" => "js"
+ assert_response("HTML Partial")
+ end
+
+ test "rendering a partial in an RJS template should pick the HTML one if no JS is available on respond_to" do
+ get :index_respond_to, "format" => "js"
+ assert_response("HTML 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\");")