aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/controller/render_js_test.rb
diff options
context:
space:
mode:
authorYehuda Katz + Carl Lerche <ykatz+clerche@engineyard.com>2009-05-13 17:00:36 -0700
committerYehuda Katz + Carl Lerche <ykatz+clerche@engineyard.com>2009-05-13 17:00:59 -0700
commit49a84ff69ca4fc4db821ca3b5a5926d07832c845 (patch)
tree9161f1f963afaacd7cae93e8226dfc7644ce2721 /actionpack/test/controller/render_js_test.rb
parent4f291fa528e5faad03def69ae7ac98224ab859db (diff)
downloadrails-49a84ff69ca4fc4db821ca3b5a5926d07832c845.tar.gz
rails-49a84ff69ca4fc4db821ca3b5a5926d07832c845.tar.bz2
rails-49a84ff69ca4fc4db821ca3b5a5926d07832c845.zip
Ported over render :file tests.
Diffstat (limited to 'actionpack/test/controller/render_js_test.rb')
-rw-r--r--actionpack/test/controller/render_js_test.rb37
1 files changed, 37 insertions, 0 deletions
diff --git a/actionpack/test/controller/render_js_test.rb b/actionpack/test/controller/render_js_test.rb
new file mode 100644
index 0000000000..7b50242910
--- /dev/null
+++ b/actionpack/test/controller/render_js_test.rb
@@ -0,0 +1,37 @@
+require 'abstract_unit'
+require 'controller/fake_models'
+require 'pathname'
+
+class TestController < ActionController::Base
+ protect_from_forgery
+
+ def render_vanilla_js_hello
+ render :js => "alert('hello')"
+ end
+
+ def greeting
+ # let's just rely on the template
+ end
+
+ def partial
+ render :partial => 'partial'
+ end
+end
+
+class RenderTest < ActionController::TestCase
+ def test_render_vanilla_js
+ get :render_vanilla_js_hello
+ assert_equal "alert('hello')", @response.body
+ assert_equal "text/javascript", @response.content_type
+ end
+
+ def test_render_with_default_from_accept_header
+ xhr :get, :greeting
+ assert_equal "$(\"body\").visualEffect(\"highlight\");", @response.body
+ end
+
+ def test_should_render_js_partial
+ xhr :get, :partial, :format => 'js'
+ assert_equal 'partial js', @response.body
+ end
+end \ No newline at end of file