aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/controller
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/test/controller')
-rw-r--r--actionpack/test/controller/assert_select_test.rb63
-rw-r--r--actionpack/test/controller/new_base/render_rjs_test.rb71
-rw-r--r--actionpack/test/controller/render_js_test.rb9
-rw-r--r--actionpack/test/controller/render_other_test.rb237
-rw-r--r--actionpack/test/controller/render_test.rb9
5 files changed, 0 insertions, 389 deletions
diff --git a/actionpack/test/controller/assert_select_test.rb b/actionpack/test/controller/assert_select_test.rb
index c72370e49d..878484eb57 100644
--- a/actionpack/test/controller/assert_select_test.rb
+++ b/actionpack/test/controller/assert_select_test.rb
@@ -34,13 +34,6 @@ class AssertSelectTest < ActionController::TestCase
@content = nil
end
- def rjs()
- render :update do |page|
- @update.call page
- end
- @update = nil
- end
-
def xml()
render :text=>@content, :layout=>false, :content_type=>Mime::XML
@content = nil
@@ -219,35 +212,6 @@ class AssertSelectTest < ActionController::TestCase
end
end
- # With single result.
- def test_assert_select_from_rjs_with_single_result
- render_rjs do |page|
- page.replace_html "test", "<div id=\"1\">foo</div>\n<div id=\"2\">foo</div>"
- end
- assert_select "div" do |elements|
- assert elements.size == 2
- assert_select "#1"
- assert_select "#2"
- end
- assert_select "div#?", /\d+/ do |elements|
- assert_select "#1"
- assert_select "#2"
- end
- end
-
- # With multiple results.
- def test_assert_select_from_rjs_with_multiple_results
- render_rjs do |page|
- page.replace_html "test", "<div id=\"1\">foo</div>"
- page.replace_html "test2", "<div id=\"2\">foo</div>"
- end
- assert_select "div" do |elements|
- assert elements.size == 2
- assert_select "#1"
- assert_select "#2"
- end
- end
-
def test_elect_with_xml_namespace_attributes
render_html %Q{<link xlink:href="http://nowhere.com"></link>}
assert_nothing_raised { assert_select "link[xlink:href=http://nowhere.com]" }
@@ -281,28 +245,6 @@ class AssertSelectTest < ActionController::TestCase
end
end
- # With one result.
- def test_css_select_from_rjs_with_single_result
- render_rjs do |page|
- page.replace_html "test", "<div id=\"1\">foo</div>\n<div id=\"2\">foo</div>"
- end
- assert_equal 2, css_select("div").size
- assert_equal 1, css_select("#1").size
- assert_equal 1, css_select("#2").size
- end
-
- # With multiple results.
- def test_css_select_from_rjs_with_multiple_results
- render_rjs do |page|
- page.replace_html "test", "<div id=\"1\">foo</div>"
- page.replace_html "test2", "<div id=\"2\">foo</div>"
- end
-
- assert_equal 2, css_select("div").size
- assert_equal 1, css_select("#1").size
- assert_equal 1, css_select("#2").size
- end
-
def test_feed_item_encoded
render_xml <<-EOF
<rss version="2.0">
@@ -377,11 +319,6 @@ EOF
get :html
end
- def render_rjs(&block)
- @controller.response_with(&block)
- get :rjs
- end
-
def render_xml(xml)
@controller.response_with = xml
get :xml
diff --git a/actionpack/test/controller/new_base/render_rjs_test.rb b/actionpack/test/controller/new_base/render_rjs_test.rb
deleted file mode 100644
index 74bf865b54..0000000000
--- a/actionpack/test/controller/new_base/render_rjs_test.rb
+++ /dev/null
@@ -1,71 +0,0 @@
-require 'abstract_unit'
-
-module RenderRjs
- class BasicController < ActionController::Base
- layout "application", :only => :index_respond_to
-
- self.view_paths = [ActionView::FixtureResolver.new(
- "layouts/application.html.erb" => "",
- "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"
- )]
-
- def index
- render
- end
-
- def index_respond_to
- respond_to do |format|
- format.js { render :action => "index_no_js" }
- end
- end
-
- def index_locale
- self.locale = :da
- end
- end
-
- class TestBasic < Rack::TestCase
- testing BasicController
-
- def setup
- @old_locale = I18n.locale
- end
-
- def teardown
- I18n.locale = @old_locale
- end
-
- test "rendering a partial in an RJS template should pick the JS template over the HTML one" do
- get :index, "format" => "js"
- 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\");")
- end
-
- test "replacing an element with a partial in an RJS template with a locale should pick the localed HTML template" do
- get :index_locale, "format" => "js"
- assert_response("$(\"customer\").update(\"Danish HTML Partial\");")
- end
- end
-end
diff --git a/actionpack/test/controller/render_js_test.rb b/actionpack/test/controller/render_js_test.rb
index 491c98a0fd..f070109b27 100644
--- a/actionpack/test/controller/render_js_test.rb
+++ b/actionpack/test/controller/render_js_test.rb
@@ -14,10 +14,6 @@ class RenderJSTest < ActionController::TestCase
render :js => "alert('hello')"
end
- def greeting
- # let's just rely on the template
- end
-
def show_partial
render :partial => 'partial'
end
@@ -31,11 +27,6 @@ class RenderJSTest < ActionController::TestCase
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, :show_partial, :format => 'js'
assert_equal 'partial js', @response.body
diff --git a/actionpack/test/controller/render_other_test.rb b/actionpack/test/controller/render_other_test.rb
index eda777e7a7..b5e74e373d 100644
--- a/actionpack/test/controller/render_other_test.rb
+++ b/actionpack/test/controller/render_other_test.rb
@@ -1,6 +1,4 @@
require 'abstract_unit'
-require 'controller/fake_models'
-require 'pathname'
ActionController.add_renderer :simon do |says, options|
self.content_type = Mime::TEXT
@@ -9,248 +7,13 @@ end
class RenderOtherTest < ActionController::TestCase
class TestController < ActionController::Base
- protect_from_forgery
-
- def self.controller_path
- 'test'
- end
-
- layout :determine_layout
-
- module RenderTestHelper
- def rjs_helper_method_from_module
- page.visual_effect :highlight
- end
- end
-
- helper RenderTestHelper
- helper do
- def rjs_helper_method(value)
- page.visual_effect :highlight, value
- end
- end
-
- def enum_rjs_test
- render :update do |page|
- page.select('.product').each do |value|
- page.rjs_helper_method_from_module
- page.rjs_helper_method(value)
- page.sortable(value, :url => { :action => "order" })
- page.draggable(value)
- end
- end
- end
-
- def render_explicit_html_template
- end
-
- def render_custom_code_rjs
- render :update, :status => 404 do |page|
- page.replace :foo, :partial => 'partial'
- end
- end
-
- def render_implicit_html_template
- end
-
- def render_js_with_explicit_template
- @project_id = 4
- render :template => 'test/delete_with_js'
- end
-
- def render_js_with_explicit_action_template
- @project_id = 4
- render :action => 'delete_with_js'
- end
-
- def delete_with_js
- @project_id = 4
- end
-
- def update_page
- render :update do |page|
- page.replace_html 'balance', '$37,000,000.00'
- page.visual_effect :highlight, 'balance'
- end
- end
-
- def update_page_with_instance_variables
- @money = '$37,000,000.00'
- @div_id = 'balance'
- render :update do |page|
- page.replace_html @div_id, @money
- page.visual_effect :highlight, @div_id
- end
- end
-
- def update_page_with_view_method
- render :update do |page|
- page.replace_html 'person', pluralize(2, 'person')
- end
- end
-
- def partial_as_rjs
- render :update do |page|
- page.replace :foo, :partial => 'partial'
- end
- end
-
- def respond_to_partial_as_rjs
- respond_to do |format|
- format.js do
- render :update do |page|
- page.replace :foo, :partial => 'partial'
- end
- end
- end
- end
-
- def render_alternate_default
- # For this test, the method "default_render" is overridden:
- @alternate_default_render = lambda do
- render :update do |page|
- page.replace :foo, :partial => 'partial'
- end
- end
- end
-
def render_simon_says
render :simon => "foo"
end
-
- private
- def default_render
- @alternate_default_render ||= nil
- if @alternate_default_render
- @alternate_default_render.call
- else
- super
- end
- end
-
- def determine_layout
- case action_name
- when "hello_world", "layout_test", "rendering_without_layout",
- "rendering_nothing_on_layout", "render_text_hello_world",
- "render_text_hello_world_with_layout",
- "hello_world_with_layout_false",
- "partial_only", "partial_only_with_layout",
- "accessing_params_in_template",
- "accessing_params_in_template_with_layout",
- "render_with_explicit_template",
- "render_with_explicit_string_template",
- "update_page", "update_page_with_instance_variables"
-
- "layouts/standard"
- when "action_talk_to_layout", "layout_overriding_layout"
- "layouts/talk_from_action"
- when "render_implicit_html_template_from_xhr_request"
- (request.xhr? ? 'layouts/xhr' : 'layouts/standard')
- end
- end
end
tests TestController
- def setup
- # enable a logger so that (e.g.) the benchmarking stuff runs, so we can get
- # a more accurate simulation of what happens in "real life".
- super
- @controller.logger = Logger.new(nil)
-
- @request.host = "www.nextangle.com"
- end
-
- def test_enum_rjs_test
- ActiveSupport::SecureRandom.stubs(:base64).returns("asdf")
- get :enum_rjs_test
- body = %{
- $$(".product").each(function(value, index) {
- new Effect.Highlight(element,{});
- new Effect.Highlight(value,{});
- Sortable.create(value, {onUpdate:function(){new Ajax.Request('/render_other_test/test/order', {asynchronous:true, evalScripts:true, parameters:Sortable.serialize(value) + '&authenticity_token=' + encodeURIComponent('asdf')})}});
- new Draggable(value, {});
- });
- }.gsub(/^ /, '').strip
- assert_equal body, @response.body
- end
-
- def test_explicitly_rendering_an_html_template_with_implicit_html_template_renders_should_be_possible_from_an_rjs_template
- [:js, "js"].each do |format|
- assert_nothing_raised do
- get :render_explicit_html_template, :format => format
- assert_equal %(document.write("Hello world\\n");), @response.body
- end
- end
- end
-
- def test_render_custom_code_rjs
- get :render_custom_code_rjs
- assert_response 404
- assert_equal %(Element.replace("foo", "partial html");), @response.body
- end
-
- def test_render_in_an_rjs_template_should_pick_html_templates_when_available
- [:js, "js"].each do |format|
- assert_nothing_raised do
- get :render_implicit_html_template, :format => format
- assert_equal %(document.write("Hello world\\n");), @response.body
- end
- end
- end
-
- def test_render_rjs_template_explicitly
- get :render_js_with_explicit_template
- assert_equal %!Element.remove("person");\nnew Effect.Highlight(\"project-4\",{});!, @response.body
- end
-
- def test_rendering_rjs_action_explicitly
- get :render_js_with_explicit_action_template
- assert_equal %!Element.remove("person");\nnew Effect.Highlight(\"project-4\",{});!, @response.body
- end
-
- def test_render_rjs_with_default
- get :delete_with_js
- assert_equal %!Element.remove("person");\nnew Effect.Highlight(\"project-4\",{});!, @response.body
- end
-
- def test_update_page
- get :update_page
- assert_template nil
- assert_equal 'text/javascript; charset=utf-8', @response.headers['Content-Type']
- assert_equal 2, @response.body.split($/).length
- end
-
- def test_update_page_with_instance_variables
- get :update_page_with_instance_variables
- assert_template nil
- assert_equal 'text/javascript; charset=utf-8', @response.headers["Content-Type"]
- assert_match(/balance/, @response.body)
- assert_match(/\$37/, @response.body)
- end
-
- def test_update_page_with_view_method
- get :update_page_with_view_method
- assert_template nil
- assert_equal 'text/javascript; charset=utf-8', @response.headers["Content-Type"]
- assert_match(/2 people/, @response.body)
- end
-
- def test_should_render_html_formatted_partial_with_rjs
- xhr :get, :partial_as_rjs
- assert_equal %(Element.replace("foo", "partial html");), @response.body
- end
-
- def test_should_render_html_formatted_partial_with_rjs_and_js_format
- xhr :get, :respond_to_partial_as_rjs
- assert_equal %(Element.replace("foo", "partial html");), @response.body
- end
-
- def test_should_render_with_alternate_default_render
- xhr :get, :render_alternate_default
- assert_equal %(Element.replace("foo", "partial html");), @response.body
- end
-
def test_using_custom_render_option
get :render_simon_says
assert_equal "Simon says: foo", @response.body
diff --git a/actionpack/test/controller/render_test.rb b/actionpack/test/controller/render_test.rb
index be492152f2..e62f3155c5 100644
--- a/actionpack/test/controller/render_test.rb
+++ b/actionpack/test/controller/render_test.rb
@@ -517,15 +517,6 @@ class TestController < ActionController::Base
render :partial => 'partial'
end
- def render_alternate_default
- # For this test, the method "default_render" is overridden:
- @alternate_default_render = lambda do
- render :update do |page|
- page.replace :foo, :partial => 'partial'
- end
- end
- end
-
def render_to_string_with_partial
@partial_only = render_to_string :partial => "partial_only"
@partial_with_locals = render_to_string :partial => "customer", :locals => { :customer => Customer.new("david") }