aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorJoshua Peek <josh@joshpeek.com>2009-01-27 14:09:11 -0600
committerJoshua Peek <josh@joshpeek.com>2009-01-27 14:09:11 -0600
commit093f758bd05d5b6144fd06aa0606c2f987c4ee09 (patch)
treede5412e2a38f2529f42c091bceb6e43e5ef8a34b /actionpack
parentf17c87665e36206bcae9c260cb25cd67bf9695e6 (diff)
downloadrails-093f758bd05d5b6144fd06aa0606c2f987c4ee09.tar.gz
rails-093f758bd05d5b6144fd06aa0606c2f987c4ee09.tar.bz2
rails-093f758bd05d5b6144fd06aa0606c2f987c4ee09.zip
Restore implicit rendering for XHR requests that want a HTML template [#1590 state:resolved]
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/lib/action_view/paths.rb3
-rw-r--r--actionpack/test/controller/render_test.rb8
-rw-r--r--actionpack/test/fixtures/test/render_implicit_html_template_from_xhr_request.html.erb1
3 files changed, 12 insertions, 0 deletions
diff --git a/actionpack/lib/action_view/paths.rb b/actionpack/lib/action_view/paths.rb
index cb351620d2..ee26542a07 100644
--- a/actionpack/lib/action_view/paths.rb
+++ b/actionpack/lib/action_view/paths.rb
@@ -45,6 +45,9 @@ module ActionView #:nodoc:
return template
elsif template = load_path[template_path]
return template
+ # Try to find html version if the format is javascript
+ elsif format == :js && template = load_path["#{template_path}.html"]
+ return template
end
end
diff --git a/actionpack/test/controller/render_test.rb b/actionpack/test/controller/render_test.rb
index 8809aa7c34..584b9277c4 100644
--- a/actionpack/test/controller/render_test.rb
+++ b/actionpack/test/controller/render_test.rb
@@ -274,6 +274,9 @@ class TestController < ActionController::Base
def render_explicit_html_template
end
+ def render_implicit_html_template_from_xhr_request
+ end
+
def formatted_html_erb
end
@@ -1010,6 +1013,11 @@ class RenderTest < ActionController::TestCase
end
end
+ def test_should_implicitly_render_html_template_from_xhr_request
+ get :render_implicit_html_template_from_xhr_request, :format => :js
+ assert_equal "Hello HTML!", @response.body
+ end
+
def test_should_render_formatted_template
get :formatted_html_erb
assert_equal 'formatted html erb', @response.body
diff --git a/actionpack/test/fixtures/test/render_implicit_html_template_from_xhr_request.html.erb b/actionpack/test/fixtures/test/render_implicit_html_template_from_xhr_request.html.erb
new file mode 100644
index 0000000000..4a11845cfe
--- /dev/null
+++ b/actionpack/test/fixtures/test/render_implicit_html_template_from_xhr_request.html.erb
@@ -0,0 +1 @@
+Hello HTML! \ No newline at end of file