aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRick Olson <technoweenie@gmail.com>2007-04-08 17:16:36 +0000
committerRick Olson <technoweenie@gmail.com>2007-04-08 17:16:36 +0000
commite0f834267642c526299189916ad9c97318c1b121 (patch)
treeb549b24beb52937931246fa22fd421aaec30e420
parentbdb1fcc3b8e0293f8b099111da2302fedf4fd513 (diff)
downloadrails-e0f834267642c526299189916ad9c97318c1b121.tar.gz
rails-e0f834267642c526299189916ad9c97318c1b121.tar.bz2
rails-e0f834267642c526299189916ad9c97318c1b121.zip
Change default respond_to templates for xml and rjs formats. [Rick]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6507 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
-rw-r--r--actionpack/CHANGELOG5
-rw-r--r--actionpack/lib/action_controller/mime_responds.rb9
-rw-r--r--actionpack/test/controller/mime_responds_test.rb2
-rw-r--r--actionpack/test/fixtures/respond_to/all_types_with_layout.html.erb (renamed from actionpack/test/fixtures/respond_to/all_types_with_layout.rhtml)0
-rw-r--r--actionpack/test/fixtures/respond_to/all_types_with_layout.js.rjs (renamed from actionpack/test/fixtures/respond_to/all_types_with_layout.rjs)0
-rw-r--r--actionpack/test/fixtures/respond_to/using_defaults.html.erb (renamed from actionpack/test/fixtures/respond_to/using_defaults.rhtml)0
-rw-r--r--actionpack/test/fixtures/respond_to/using_defaults.js.rjs (renamed from actionpack/test/fixtures/respond_to/using_defaults.rjs)0
-rw-r--r--actionpack/test/fixtures/respond_to/using_defaults.xml.builder (renamed from actionpack/test/fixtures/respond_to/using_defaults.rxml)0
-rw-r--r--actionpack/test/fixtures/respond_to/using_defaults_with_type_list.html.erb (renamed from actionpack/test/fixtures/respond_to/using_defaults_with_type_list.rhtml)0
-rw-r--r--actionpack/test/fixtures/respond_to/using_defaults_with_type_list.js.rjs (renamed from actionpack/test/fixtures/respond_to/using_defaults_with_type_list.rjs)0
-rw-r--r--actionpack/test/fixtures/respond_to/using_defaults_with_type_list.xml.builder (renamed from actionpack/test/fixtures/respond_to/using_defaults_with_type_list.rxml)0
11 files changed, 11 insertions, 5 deletions
diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG
index 57fdda48a5..018a720c94 100644
--- a/actionpack/CHANGELOG
+++ b/actionpack/CHANGELOG
@@ -1,5 +1,10 @@
*SVN*
+* Change default respond_to templates for xml and rjs formats. [Rick]
+
+ * Default xml template goes from #{action_name}.rxml => #{action_name}.xml.builder.
+ * Default rjs template goes from #{action_name}.rjs => #{action_name}.js.rjs.
+
* Fix WSOD due to modification of a formatted template extension so that requests to templates like 'foo.html.erb' fail on the second hit. [Rick]
* Fix WSOD when template compilation fails [Rick]
diff --git a/actionpack/lib/action_controller/mime_responds.rb b/actionpack/lib/action_controller/mime_responds.rb
index ff07c3c12e..e4d1dbbccc 100644
--- a/actionpack/lib/action_controller/mime_responds.rb
+++ b/actionpack/lib/action_controller/mime_responds.rb
@@ -107,10 +107,11 @@ module ActionController #:nodoc:
end
class Responder #:nodoc:
- DEFAULT_BLOCKS = [:html, :js, :xml].inject({}) do |blocks, ext|
- template_extension = (ext == :html ? '' : ".r#{ext}")
- blocks.update ext => %(Proc.new { render :action => "\#{action_name}#{template_extension}", :content_type => Mime::#{ext.to_s.upcase} })
- end
+ default_block_format = %(Proc.new { render :action => "\#{action_name}%s", :content_type => Mime::%s })
+ DEFAULT_BLOCKS = {}
+ DEFAULT_BLOCKS[:html] = default_block_format % ['', 'HTML']
+ DEFAULT_BLOCKS[:js] = default_block_format % ['.js.rjs', 'JS']
+ DEFAULT_BLOCKS[:xml] = default_block_format % ['.xml.builder', 'XML']
def initialize(block_binding)
@block_binding = block_binding
diff --git a/actionpack/test/controller/mime_responds_test.rb b/actionpack/test/controller/mime_responds_test.rb
index 3a1df02a7f..aa31d5b649 100644
--- a/actionpack/test/controller/mime_responds_test.rb
+++ b/actionpack/test/controller/mime_responds_test.rb
@@ -351,6 +351,6 @@ class MimeControllerTest < Test::Unit::TestCase
assert_equal "using_defaults", @response.body
get :using_defaults, :format => "xml"
- assert_equal "using_defaults.rxml", @response.body
+ assert_equal "using_defaults.xml.builder", @response.body
end
end
diff --git a/actionpack/test/fixtures/respond_to/all_types_with_layout.rhtml b/actionpack/test/fixtures/respond_to/all_types_with_layout.html.erb
index 84a84049f8..84a84049f8 100644
--- a/actionpack/test/fixtures/respond_to/all_types_with_layout.rhtml
+++ b/actionpack/test/fixtures/respond_to/all_types_with_layout.html.erb
diff --git a/actionpack/test/fixtures/respond_to/all_types_with_layout.rjs b/actionpack/test/fixtures/respond_to/all_types_with_layout.js.rjs
index b7aec7c505..b7aec7c505 100644
--- a/actionpack/test/fixtures/respond_to/all_types_with_layout.rjs
+++ b/actionpack/test/fixtures/respond_to/all_types_with_layout.js.rjs
diff --git a/actionpack/test/fixtures/respond_to/using_defaults.rhtml b/actionpack/test/fixtures/respond_to/using_defaults.html.erb
index 6769dd60bd..6769dd60bd 100644
--- a/actionpack/test/fixtures/respond_to/using_defaults.rhtml
+++ b/actionpack/test/fixtures/respond_to/using_defaults.html.erb
diff --git a/actionpack/test/fixtures/respond_to/using_defaults.rjs b/actionpack/test/fixtures/respond_to/using_defaults.js.rjs
index 469fcd8e15..469fcd8e15 100644
--- a/actionpack/test/fixtures/respond_to/using_defaults.rjs
+++ b/actionpack/test/fixtures/respond_to/using_defaults.js.rjs
diff --git a/actionpack/test/fixtures/respond_to/using_defaults.rxml b/actionpack/test/fixtures/respond_to/using_defaults.xml.builder
index 598d62e2fc..598d62e2fc 100644
--- a/actionpack/test/fixtures/respond_to/using_defaults.rxml
+++ b/actionpack/test/fixtures/respond_to/using_defaults.xml.builder
diff --git a/actionpack/test/fixtures/respond_to/using_defaults_with_type_list.rhtml b/actionpack/test/fixtures/respond_to/using_defaults_with_type_list.html.erb
index 6769dd60bd..6769dd60bd 100644
--- a/actionpack/test/fixtures/respond_to/using_defaults_with_type_list.rhtml
+++ b/actionpack/test/fixtures/respond_to/using_defaults_with_type_list.html.erb
diff --git a/actionpack/test/fixtures/respond_to/using_defaults_with_type_list.rjs b/actionpack/test/fixtures/respond_to/using_defaults_with_type_list.js.rjs
index 469fcd8e15..469fcd8e15 100644
--- a/actionpack/test/fixtures/respond_to/using_defaults_with_type_list.rjs
+++ b/actionpack/test/fixtures/respond_to/using_defaults_with_type_list.js.rjs
diff --git a/actionpack/test/fixtures/respond_to/using_defaults_with_type_list.rxml b/actionpack/test/fixtures/respond_to/using_defaults_with_type_list.xml.builder
index 598d62e2fc..598d62e2fc 100644
--- a/actionpack/test/fixtures/respond_to/using_defaults_with_type_list.rxml
+++ b/actionpack/test/fixtures/respond_to/using_defaults_with_type_list.xml.builder