aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorXavier Noria <fxn@hashref.com>2011-03-25 23:12:09 +0100
committerXavier Noria <fxn@hashref.com>2011-04-13 13:23:18 +0200
commit5850f1693546f14420bf0bc630a48650f0d606d5 (patch)
tree0e7e1b631c5d4e0b85af3b448f39dbf4cb483cb8 /actionpack
parenteea66892c80d51c1b959171c2e3feac67124aaba (diff)
downloadrails-5850f1693546f14420bf0bc630a48650f0d606d5.tar.gz
rails-5850f1693546f14420bf0bc630a48650f0d606d5.tar.bz2
rails-5850f1693546f14420bf0bc630a48650f0d606d5.zip
removes the RJS template handler
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/lib/action_controller/metal/mime_responds.rb8
-rw-r--r--actionpack/lib/action_view/template/handlers.rb2
-rw-r--r--actionpack/lib/action_view/template/handlers/rjs.rb13
-rw-r--r--actionpack/test/controller/caching_test.rb14
-rw-r--r--actionpack/test/controller/content_type_test.rb9
-rw-r--r--actionpack/test/controller/mime_responds_test.rb29
-rw-r--r--actionpack/test/controller/new_base/content_type_test.rb9
-rw-r--r--actionpack/test/controller/new_base/render_layout_test.rb16
-rw-r--r--actionpack/test/fixtures/functional_caching/formatted_fragment_cached.js.rjs6
-rw-r--r--actionpack/test/fixtures/functional_caching/js_fragment_cached_with_partial.js.rjs1
-rw-r--r--actionpack/test/fixtures/old_content_type/render_default_for_rjs.rjs1
-rw-r--r--actionpack/test/fixtures/respond_to/all_types_with_layout.js.rjs1
-rw-r--r--actionpack/test/fixtures/respond_to/using_defaults.js.rjs1
-rw-r--r--actionpack/test/fixtures/respond_to/using_defaults_with_type_list.js.rjs1
-rw-r--r--actionpack/test/fixtures/respond_with/using_resource.js.rjs1
15 files changed, 15 insertions, 97 deletions
diff --git a/actionpack/lib/action_controller/metal/mime_responds.rb b/actionpack/lib/action_controller/metal/mime_responds.rb
index 618a6cdb7d..16d48e4677 100644
--- a/actionpack/lib/action_controller/metal/mime_responds.rb
+++ b/actionpack/lib/action_controller/metal/mime_responds.rb
@@ -33,10 +33,10 @@ module ActionController #:nodoc:
# and all actions except <tt>:edit</tt> respond to <tt>:xml</tt> and
# <tt>:json</tt>.
#
- # respond_to :rjs, :only => :create
+ # respond_to :json, :only => :create
#
# This specifies that the <tt>:create</tt> action and no other responds
- # to <tt>:rjs</tt>.
+ # to <tt>:json</tt>.
def respond_to(*mimes)
options = mimes.extract_options!
@@ -106,8 +106,8 @@ module ActionController #:nodoc:
# end
# end
#
- # If the client wants HTML, we just redirect them back to the person list. If they want Javascript
- # (format.js), then it is an RJS request and we render the RJS template associated with this action.
+ # If the client wants HTML, we just redirect them back to the person list. If they want JavaScript,
+ # then it is an Ajax request and we render the JavaScript template associated with this action.
# Lastly, if the client wants XML, we render the created person as XML, but with a twist: we also
# include the person's company in the rendered XML, so you get something like this:
#
diff --git a/actionpack/lib/action_view/template/handlers.rb b/actionpack/lib/action_view/template/handlers.rb
index 4438199497..959afa734e 100644
--- a/actionpack/lib/action_view/template/handlers.rb
+++ b/actionpack/lib/action_view/template/handlers.rb
@@ -3,12 +3,10 @@ module ActionView #:nodoc:
class Template
module Handlers #:nodoc:
autoload :ERB, 'action_view/template/handlers/erb'
- autoload :RJS, 'action_view/template/handlers/rjs'
autoload :Builder, 'action_view/template/handlers/builder'
def self.extended(base)
base.register_default_template_handler :erb, ERB.new
- base.register_template_handler :rjs, RJS.new
base.register_template_handler :builder, Builder.new
end
diff --git a/actionpack/lib/action_view/template/handlers/rjs.rb b/actionpack/lib/action_view/template/handlers/rjs.rb
deleted file mode 100644
index 9d71059134..0000000000
--- a/actionpack/lib/action_view/template/handlers/rjs.rb
+++ /dev/null
@@ -1,13 +0,0 @@
-module ActionView
- module Template::Handlers
- class RJS
- # Default format used by RJS.
- class_attribute :default_format
- self.default_format = Mime::JS
-
- def call(template)
- "update_page do |page|;#{template.source}\nend"
- end
- end
- end
-end
diff --git a/actionpack/test/controller/caching_test.rb b/actionpack/test/controller/caching_test.rb
index 01f3e8f2b6..fada0c7748 100644
--- a/actionpack/test/controller/caching_test.rb
+++ b/actionpack/test/controller/caching_test.rb
@@ -713,17 +713,10 @@ class FunctionalCachingController < CachingController
end
end
- def js_fragment_cached_with_partial
- respond_to do |format|
- format.js
- end
- end
-
def formatted_fragment_cached
respond_to do |format|
format.html
format.xml
- format.js
end
end
@@ -770,13 +763,6 @@ CACHED
assert_match("Some cached content", @store.read('views/test.host/functional_caching/inline_fragment_cached'))
end
- def test_fragment_caching_in_rjs_partials
- xhr :get, :js_fragment_cached_with_partial
- assert_response :success
- assert_match(/Old fragment caching in a partial/, @response.body)
- assert_match("Old fragment caching in a partial", @store.read('views/test.host/functional_caching/js_fragment_cached_with_partial'))
- end
-
def test_html_formatted_fragment_caching
get :formatted_fragment_cached, :format => "html"
assert_response :success
diff --git a/actionpack/test/controller/content_type_test.rb b/actionpack/test/controller/content_type_test.rb
index 9500c25a32..b12c798302 100644
--- a/actionpack/test/controller/content_type_test.rb
+++ b/actionpack/test/controller/content_type_test.rb
@@ -35,9 +35,6 @@ class OldContentTypeController < ActionController::Base
def render_default_for_builder
end
- def render_default_for_rjs
- end
-
def render_change_for_builder
response.content_type = Mime::HTML
render :action => "render_default_for_builder"
@@ -129,12 +126,6 @@ class ContentTypeTest < ActionController::TestCase
assert_equal "utf-8", @response.charset
end
- def test_default_for_rjs
- xhr :post, :render_default_for_rjs
- assert_equal Mime::JS, @response.content_type
- assert_equal "utf-8", @response.charset
- end
-
def test_change_for_builder
get :render_change_for_builder
assert_equal Mime::HTML, @response.content_type
diff --git a/actionpack/test/controller/mime_responds_test.rb b/actionpack/test/controller/mime_responds_test.rb
index be5866e5aa..9e09fc39ed 100644
--- a/actionpack/test/controller/mime_responds_test.rb
+++ b/actionpack/test/controller/mime_responds_test.rb
@@ -73,13 +73,12 @@ class RespondToController < ActionController::Base
def using_defaults
respond_to do |type|
type.html
- type.js
type.xml
end
end
def using_defaults_with_type_list
- respond_to(:html, :js, :xml)
+ respond_to(:html, :xml)
end
def made_for_content_type
@@ -130,7 +129,6 @@ class RespondToController < ActionController::Base
def all_types_with_layout
respond_to do |type|
type.html
- type.js
end
end
@@ -299,11 +297,6 @@ class RespondToControllerTest < ActionController::TestCase
assert_equal "text/html", @response.content_type
assert_equal 'Hello world!', @response.body
- @request.accept = "text/javascript"
- get :using_defaults
- assert_equal "text/javascript", @response.content_type
- assert_equal '$("body").visualEffect("highlight");', @response.body
-
@request.accept = "application/xml"
get :using_defaults
assert_equal "application/xml", @response.content_type
@@ -316,11 +309,6 @@ class RespondToControllerTest < ActionController::TestCase
assert_equal "text/html", @response.content_type
assert_equal 'Hello world!', @response.body
- @request.accept = "text/javascript"
- get :using_defaults_with_type_list
- assert_equal "text/javascript", @response.content_type
- assert_equal '$("body").visualEffect("highlight");', @response.body
-
@request.accept = "application/xml"
get :using_defaults_with_type_list
assert_equal "application/xml", @response.content_type
@@ -428,13 +416,6 @@ class RespondToControllerTest < ActionController::TestCase
assert_equal 'HTML', @response.body
end
-
- def test_rjs_type_skips_layout
- @request.accept = "text/javascript"
- get :all_types_with_layout
- assert_equal 'RJS for all_types_with_layout', @response.body
- end
-
def test_html_type_with_layout
@request.accept = "text/html"
get :all_types_with_layout
@@ -444,9 +425,6 @@ class RespondToControllerTest < ActionController::TestCase
def test_xhr
xhr :get, :js_or_html
assert_equal 'JS', @response.body
-
- xhr :get, :using_defaults
- assert_equal '$("body").visualEffect("highlight");', @response.body
end
def test_custom_constant
@@ -643,11 +621,6 @@ class RespondWithControllerTest < ActionController::TestCase
end
def test_using_resource
- @request.accept = "text/javascript"
- get :using_resource
- assert_equal "text/javascript", @response.content_type
- assert_equal '$("body").visualEffect("highlight");', @response.body
-
@request.accept = "application/xml"
get :using_resource
assert_equal "application/xml", @response.content_type
diff --git a/actionpack/test/controller/new_base/content_type_test.rb b/actionpack/test/controller/new_base/content_type_test.rb
index 8ba30944f5..4b70031c90 100644
--- a/actionpack/test/controller/new_base/content_type_test.rb
+++ b/actionpack/test/controller/new_base/content_type_test.rb
@@ -23,8 +23,7 @@ module ContentType
"content_type/implied/i_am_html_erb.html.erb" => "Hello world!",
"content_type/implied/i_am_xml_erb.xml.erb" => "<xml>Hello world!</xml>",
"content_type/implied/i_am_html_builder.html.builder" => "xml.p 'Hello'",
- "content_type/implied/i_am_xml_builder.xml.builder" => "xml.awesome 'Hello'",
- "content_type/implied/i_am_js_rjs.js.rjs" => "page.alert 'hello'"
+ "content_type/implied/i_am_xml_builder.xml.builder" => "xml.awesome 'Hello'"
)]
end
@@ -93,12 +92,6 @@ module ContentType
assert_header "Content-Type", "application/xml; charset=utf-8"
end
-
- test "sets Content-Type as text/javascript when rendering *.js" do
- get "/content_type/implied/i_am_js_rjs", "format" => "js"
-
- assert_header "Content-Type", "text/javascript; charset=utf-8"
- end
end
class ExplicitCharsetTest < Rack::TestCase
diff --git a/actionpack/test/controller/new_base/render_layout_test.rb b/actionpack/test/controller/new_base/render_layout_test.rb
index bb2a953536..d3dcb5cad6 100644
--- a/actionpack/test/controller/new_base/render_layout_test.rb
+++ b/actionpack/test/controller/new_base/render_layout_test.rb
@@ -70,8 +70,8 @@ module ControllerLayouts
class MismatchFormatController < ::ApplicationController
self.view_paths = [ActionView::FixtureResolver.new(
"layouts/application.html.erb" => "<html><%= yield %></html>",
- "controller_layouts/mismatch_format/index.js.rjs" => "page[:test].ext",
- "controller_layouts/mismatch_format/implicit.rjs" => "page[:test].ext"
+ "controller_layouts/mismatch_format/index.xml.builder" => "xml.instruct!",
+ "controller_layouts/mismatch_format/implicit.builder" => "xml.instruct!"
)]
def explicit
@@ -81,15 +81,17 @@ module ControllerLayouts
class MismatchFormatTest < Rack::TestCase
testing ControllerLayouts::MismatchFormatController
+
+ XML_INSTRUCT = %Q(<?xml version="1.0" encoding="UTF-8"?>\n)
- test "if JS is selected, an HTML template is not also selected" do
- get :index, "format" => "js"
- assert_response "$(\"test\").ext();"
+ test "if XML is selected, an HTML template is not also selected" do
+ get :index, :format => "xml"
+ assert_response XML_INSTRUCT
end
- test "if JS is implicitly selected, an HTML template is not also selected" do
+ test "if XML is implicitly selected, an HTML template is not also selected" do
get :implicit
- assert_response "$(\"test\").ext();"
+ assert_response XML_INSTRUCT
end
test "if an HTML template is explicitly provides for a JS template, an error is raised" do
diff --git a/actionpack/test/fixtures/functional_caching/formatted_fragment_cached.js.rjs b/actionpack/test/fixtures/functional_caching/formatted_fragment_cached.js.rjs
deleted file mode 100644
index 057f15e62f..0000000000
--- a/actionpack/test/fixtures/functional_caching/formatted_fragment_cached.js.rjs
+++ /dev/null
@@ -1,6 +0,0 @@
-page.assign 'title', 'Hey'
-cache do
- page['element_1'].visual_effect :highlight
- page['element_2'].visual_effect :highlight
-end
-page.assign 'footer', 'Bye'
diff --git a/actionpack/test/fixtures/functional_caching/js_fragment_cached_with_partial.js.rjs b/actionpack/test/fixtures/functional_caching/js_fragment_cached_with_partial.js.rjs
deleted file mode 100644
index 248842c9da..0000000000
--- a/actionpack/test/fixtures/functional_caching/js_fragment_cached_with_partial.js.rjs
+++ /dev/null
@@ -1 +0,0 @@
-page.replace_html 'notices', :partial => 'partial' \ No newline at end of file
diff --git a/actionpack/test/fixtures/old_content_type/render_default_for_rjs.rjs b/actionpack/test/fixtures/old_content_type/render_default_for_rjs.rjs
deleted file mode 100644
index 8d614d04ad..0000000000
--- a/actionpack/test/fixtures/old_content_type/render_default_for_rjs.rjs
+++ /dev/null
@@ -1 +0,0 @@
-page.alert 'hello world!' \ No newline at end of file
diff --git a/actionpack/test/fixtures/respond_to/all_types_with_layout.js.rjs b/actionpack/test/fixtures/respond_to/all_types_with_layout.js.rjs
deleted file mode 100644
index b7aec7c505..0000000000
--- a/actionpack/test/fixtures/respond_to/all_types_with_layout.js.rjs
+++ /dev/null
@@ -1 +0,0 @@
-page << "RJS for all_types_with_layout" \ No newline at end of file
diff --git a/actionpack/test/fixtures/respond_to/using_defaults.js.rjs b/actionpack/test/fixtures/respond_to/using_defaults.js.rjs
deleted file mode 100644
index 469fcd8e15..0000000000
--- a/actionpack/test/fixtures/respond_to/using_defaults.js.rjs
+++ /dev/null
@@ -1 +0,0 @@
-page[:body].visual_effect :highlight \ No newline at end of file
diff --git a/actionpack/test/fixtures/respond_to/using_defaults_with_type_list.js.rjs b/actionpack/test/fixtures/respond_to/using_defaults_with_type_list.js.rjs
deleted file mode 100644
index 469fcd8e15..0000000000
--- a/actionpack/test/fixtures/respond_to/using_defaults_with_type_list.js.rjs
+++ /dev/null
@@ -1 +0,0 @@
-page[:body].visual_effect :highlight \ No newline at end of file
diff --git a/actionpack/test/fixtures/respond_with/using_resource.js.rjs b/actionpack/test/fixtures/respond_with/using_resource.js.rjs
deleted file mode 100644
index 737c175a4e..0000000000
--- a/actionpack/test/fixtures/respond_with/using_resource.js.rjs
+++ /dev/null
@@ -1 +0,0 @@
-page[:body].visual_effect :highlight