diff options
Diffstat (limited to 'actionpack/test/controller')
9 files changed, 70 insertions, 58 deletions
diff --git a/actionpack/test/controller/caching_test.rb b/actionpack/test/controller/caching_test.rb index 8a13d1e5f1..de92fc56fd 100644 --- a/actionpack/test/controller/caching_test.rb +++ b/actionpack/test/controller/caching_test.rb @@ -611,7 +611,7 @@ class FragmentCachingTest < ActionController::TestCase @store.write('views/expensive', 'fragment content') fragment_computed = false - buffer = 'generated till now -> ' + buffer = 'generated till now -> '.html_safe @controller.fragment_for(buffer, 'expensive') { fragment_computed = true } assert fragment_computed @@ -622,7 +622,7 @@ class FragmentCachingTest < ActionController::TestCase @store.write('views/expensive', 'fragment content') fragment_computed = false - buffer = 'generated till now -> ' + buffer = 'generated till now -> '.html_safe @controller.fragment_for(buffer, 'expensive') { fragment_computed = true } assert !fragment_computed diff --git a/actionpack/test/controller/filters_test.rb b/actionpack/test/controller/filters_test.rb index 8445428e8f..004e1369d3 100644 --- a/actionpack/test/controller/filters_test.rb +++ b/actionpack/test/controller/filters_test.rb @@ -435,7 +435,7 @@ class FilterTest < ActionController::TestCase end def non_yielding_filter - @filters << "zomg it didn't yield" + @filters << "it didn't yield" @filter_return_value end @@ -465,14 +465,14 @@ class FilterTest < ActionController::TestCase controller = NonYieldingAroundFilterController.new controller.instance_variable_set "@filter_return_value", false test_process(controller, "index") - assert_equal ["filter_one", "zomg it didn't yield"], controller.assigns['filters'] + assert_equal ["filter_one", "it didn't yield"], controller.assigns['filters'] end def test_after_filters_are_not_run_if_around_filter_does_not_yield controller = NonYieldingAroundFilterController.new controller.instance_variable_set "@filter_return_value", true test_process(controller, "index") - assert_equal ["filter_one", "zomg it didn't yield"], controller.assigns['filters'] + assert_equal ["filter_one", "it didn't yield"], controller.assigns['filters'] end def test_added_filter_to_inheritance_graph diff --git a/actionpack/test/controller/new_base/render_action_test.rb b/actionpack/test/controller/new_base/render_action_test.rb index 239f68659c..0804d7b09d 100644 --- a/actionpack/test/controller/new_base/render_action_test.rb +++ b/actionpack/test/controller/new_base/render_action_test.rb @@ -119,9 +119,9 @@ module RenderActionWithApplicationLayout # Set the view path to an application view structure with layouts self.view_paths = self.view_paths = [ActionView::FixtureResolver.new( "render_action_with_application_layout/basic/hello_world.html.erb" => "Hello World!", - "render_action_with_application_layout/basic/hello.html.builder" => "xml.p 'Omg'", - "layouts/application.html.erb" => "OHAI <%= yield %> KTHXBAI", - "layouts/greetings.html.erb" => "Greetings <%= yield %> Bai", + "render_action_with_application_layout/basic/hello.html.builder" => "xml.p 'Hello'", + "layouts/application.html.erb" => "Hi <%= yield %> OK, Bye", + "layouts/greetings.html.erb" => "Greetings <%= yield %> Bye", "layouts/builder.html.builder" => "xml.html do\n xml << yield\nend" )] @@ -156,14 +156,14 @@ module RenderActionWithApplicationLayout test "rendering implicit application.html.erb as layout" do get "/render_action_with_application_layout/basic/hello_world" - assert_body "OHAI Hello World! KTHXBAI" + assert_body "Hi Hello World! OK, Bye" assert_status 200 end test "rendering with layout => true" do get "/render_action_with_application_layout/basic/hello_world_with_layout" - assert_body "OHAI Hello World! KTHXBAI" + assert_body "Hi Hello World! OK, Bye" assert_status 200 end @@ -184,7 +184,7 @@ module RenderActionWithApplicationLayout test "rendering with layout => 'greetings'" do get "/render_action_with_application_layout/basic/hello_world_with_custom_layout" - assert_body "Greetings Hello World! Bai" + assert_body "Greetings Hello World! Bye" assert_status 200 end end @@ -194,7 +194,7 @@ module RenderActionWithApplicationLayout test "builder works with layouts" do get :with_builder_and_layout - assert_response "<html>\n<p>Omg</p>\n</html>\n" + assert_response "<html>\n<p>Hello</p>\n</html>\n" end end @@ -204,7 +204,7 @@ module RenderActionWithControllerLayout class BasicController < ActionController::Base self.view_paths = self.view_paths = [ActionView::FixtureResolver.new( "render_action_with_controller_layout/basic/hello_world.html.erb" => "Hello World!", - "layouts/render_action_with_controller_layout/basic.html.erb" => "With Controller Layout! <%= yield %> KTHXBAI" + "layouts/render_action_with_controller_layout/basic.html.erb" => "With Controller Layout! <%= yield %> Bye" )] def hello_world @@ -234,14 +234,14 @@ module RenderActionWithControllerLayout test "render hello_world and implicitly use <controller_path>.html.erb as a layout." do get "/render_action_with_controller_layout/basic/hello_world" - assert_body "With Controller Layout! Hello World! KTHXBAI" + assert_body "With Controller Layout! Hello World! Bye" assert_status 200 end test "rendering with layout => true" do get "/render_action_with_controller_layout/basic/hello_world_with_layout" - assert_body "With Controller Layout! Hello World! KTHXBAI" + assert_body "With Controller Layout! Hello World! Bye" assert_status 200 end @@ -265,8 +265,8 @@ module RenderActionWithBothLayouts class BasicController < ActionController::Base self.view_paths = [ActionView::FixtureResolver.new({ "render_action_with_both_layouts/basic/hello_world.html.erb" => "Hello World!", - "layouts/application.html.erb" => "OHAI <%= yield %> KTHXBAI", - "layouts/render_action_with_both_layouts/basic.html.erb" => "With Controller Layout! <%= yield %> KTHXBAI" + "layouts/application.html.erb" => "Oh Hi <%= yield %> Bye", + "layouts/render_action_with_both_layouts/basic.html.erb" => "With Controller Layout! <%= yield %> Bye" })] def hello_world @@ -292,14 +292,14 @@ module RenderActionWithBothLayouts test "rendering implicitly use <controller_path>.html.erb over application.html.erb as a layout" do get "/render_action_with_both_layouts/basic/hello_world" - assert_body "With Controller Layout! Hello World! KTHXBAI" + assert_body "With Controller Layout! Hello World! Bye" assert_status 200 end test "rendering with layout => true" do get "/render_action_with_both_layouts/basic/hello_world_with_layout" - assert_body "With Controller Layout! Hello World! KTHXBAI" + assert_body "With Controller Layout! Hello World! Bye" assert_status 200 end diff --git a/actionpack/test/controller/new_base/render_layout_test.rb b/actionpack/test/controller/new_base/render_layout_test.rb index 6a9668b81a..372fb66b88 100644 --- a/actionpack/test/controller/new_base/render_layout_test.rb +++ b/actionpack/test/controller/new_base/render_layout_test.rb @@ -3,10 +3,10 @@ require 'abstract_unit' module ControllerLayouts class ImplicitController < ::ApplicationController self.view_paths = [ActionView::FixtureResolver.new( - "layouts/application.html.erb" => "OMG <%= yield %> KTHXBAI", + "layouts/application.html.erb" => "Main <%= yield %> Layout", "layouts/override.html.erb" => "Override! <%= yield %>", "basic.html.erb" => "Hello world!", - "controller_layouts/implicit/layout_false.html.erb" => "hai(layout_false.html.erb)" + "controller_layouts/implicit/layout_false.html.erb" => "hi(layout_false.html.erb)" )] def index @@ -27,7 +27,7 @@ module ControllerLayouts class ImplicitNameController < ::ApplicationController self.view_paths = [ActionView::FixtureResolver.new( - "layouts/controller_layouts/implicit_name.html.erb" => "OMGIMPLICIT <%= yield %> KTHXBAI", + "layouts/controller_layouts/implicit_name.html.erb" => "Implicit <%= yield %> Layout", "basic.html.erb" => "Hello world!" )] @@ -40,14 +40,14 @@ module ControllerLayouts test "rendering a normal template, but using the implicit layout" do get "/controller_layouts/implicit/index" - assert_body "OMG Hello world! KTHXBAI" + assert_body "Main Hello world! Layout" assert_status 200 end test "rendering a normal template, but using an implicit NAMED layout" do get "/controller_layouts/implicit_name/index" - assert_body "OMGIMPLICIT Hello world! KTHXBAI" + assert_body "Implicit Hello world! Layout" assert_status 200 end @@ -63,15 +63,15 @@ module ControllerLayouts test "rendering with :layout => false leaves out the implicit layout" do get :layout_false - assert_response "hai(layout_false.html.erb)" + assert_response "hi(layout_false.html.erb)" end end 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].omg", - "controller_layouts/mismatch_format/implicit.rjs" => "page[:test].omg" + "controller_layouts/mismatch_format/index.js.rjs" => "page[:test].ext", + "controller_layouts/mismatch_format/implicit.rjs" => "page[:test].ext" )] def explicit @@ -84,12 +84,12 @@ module ControllerLayouts test "if JS is selected, an HTML template is not also selected" do get :index, "format" => "js" - assert_response "$(\"test\").omg();" + assert_response "$(\"test\").ext();" end test "if JS is implicitly selected, an HTML template is not also selected" do get :implicit - assert_response "$(\"test\").omg();" + assert_response "$(\"test\").ext();" end test "if an HTML template is explicitly provides for a JS template, an error is raised" do diff --git a/actionpack/test/controller/new_base/render_partial_test.rb b/actionpack/test/controller/new_base/render_partial_test.rb index 8fddcbcd57..1a1b36a65e 100644 --- a/actionpack/test/controller/new_base/render_partial_test.rb +++ b/actionpack/test/controller/new_base/render_partial_test.rb @@ -5,7 +5,7 @@ module RenderPartial class BasicController < ActionController::Base self.view_paths = [ActionView::FixtureResolver.new( - "render_partial/basic/_basic.html.erb" => "OMG!", + "render_partial/basic/_basic.html.erb" => "BasicPartial!", "render_partial/basic/basic.html.erb" => "<%= @test_unchanged = 'goodbye' %><%= render :partial => 'basic' %><%= @test_unchanged %>" )] @@ -20,7 +20,7 @@ module RenderPartial test "rendering a partial in ActionView doesn't pull the ivars again from the controller" do get :changing - assert_response("goodbyeOMG!goodbye") + assert_response("goodbyeBasicPartial!goodbye") end end diff --git a/actionpack/test/controller/new_base/render_template_test.rb b/actionpack/test/controller/new_base/render_template_test.rb index c81b951c0d..70cebbfd89 100644 --- a/actionpack/test/controller/new_base/render_template_test.rb +++ b/actionpack/test/controller/new_base/render_template_test.rb @@ -2,18 +2,19 @@ require 'abstract_unit' module RenderTemplate class WithoutLayoutController < ActionController::Base - + self.view_paths = [ActionView::FixtureResolver.new( "test/basic.html.erb" => "Hello from basic.html.erb", "shared.html.erb" => "Elastica", "locals.html.erb" => "The secret is <%= secret %>", - "xml_template.xml.builder" => "xml.html do\n xml.p 'Hello'\nend" + "xml_template.xml.builder" => "xml.html do\n xml.p 'Hello'\nend", + "with_raw.html.erb" => "Hello <%=raw '<strong>this is raw</strong>' %>" )] - + def index render :template => "test/basic" end - + def index_without_key render "test/basic" end @@ -25,59 +26,70 @@ module RenderTemplate def in_top_directory_with_slash render :template => '/shared' end - + def in_top_directory_with_slash_without_key render '/shared' end - + def with_locals render :template => "locals", :locals => { :secret => 'area51' } end - + def builder_template render :template => "xml_template" end + + def with_raw + render :template => "with_raw" + end end - + class TestWithoutLayout < Rack::TestCase testing RenderTemplate::WithoutLayoutController - + test "rendering a normal template with full path without layout" do get :index assert_response "Hello from basic.html.erb" end - + test "rendering a normal template with full path without layout without key" do get :index_without_key assert_response "Hello from basic.html.erb" end - + test "rendering a template not in a subdirectory" do get :in_top_directory assert_response "Elastica" end - + test "rendering a template not in a subdirectory with a leading slash" do get :in_top_directory_with_slash assert_response "Elastica" end - + test "rendering a template not in a subdirectory with a leading slash without key" do get :in_top_directory_with_slash_without_key assert_response "Elastica" end - + test "rendering a template with local variables" do get :with_locals assert_response "The secret is area51" end - + test "rendering a builder template" do get :builder_template, "format" => "xml" assert_response "<html>\n <p>Hello</p>\n</html>\n" end + + test "rendering a template with <%=raw stuff %>" do + get :with_raw + + assert_body "Hello <strong>this is raw</strong>" + assert_status 200 + end end - + class WithLayoutController < ::ApplicationController self.view_paths = [ActionView::FixtureResolver.new( "test/basic.html.erb" => "Hello from basic.html.erb", @@ -85,28 +97,28 @@ module RenderTemplate "layouts/application.html.erb" => "<%= yield %>, I'm here!", "layouts/greetings.html.erb" => "<%= yield %>, I wish thee well." )] - + def index render :template => "test/basic" end - + def with_layout render :template => "test/basic", :layout => true end - + def with_layout_false render :template => "test/basic", :layout => false end - + def with_layout_nil render :template => "test/basic", :layout => nil end - + def with_custom_layout render :template => "test/basic", :layout => "greetings" end end - + class TestWithLayout < Rack::TestCase describe "Rendering with :template using implicit or explicit layout" diff --git a/actionpack/test/controller/output_escaping_test.rb b/actionpack/test/controller/output_escaping_test.rb index 7332f3f1e3..43a8c05cda 100644 --- a/actionpack/test/controller/output_escaping_test.rb +++ b/actionpack/test/controller/output_escaping_test.rb @@ -13,7 +13,7 @@ class OutputEscapingTest < ActiveSupport::TestCase test "escapeHTML shouldn't touch explicitly safe strings" do # TODO this seems easier to compose and reason about, but # this should be verified - assert_equal "<", ERB::Util.h("<".html_safe!) + assert_equal "<", ERB::Util.h("<".html_safe) end end diff --git a/actionpack/test/controller/subscriber_test.rb b/actionpack/test/controller/subscriber_test.rb index 152a0d0c04..119a18ebc5 100644 --- a/actionpack/test/controller/subscriber_test.rb +++ b/actionpack/test/controller/subscriber_test.rb @@ -13,7 +13,7 @@ module Another end def data_sender - send_data "cool data", :filename => "omg.txt" + send_data "cool data", :filename => "file.txt" end def xfile_sender @@ -121,7 +121,7 @@ class ACSubscriberTest < ActionController::TestCase wait assert_equal 3, logs.size - assert_match /Sent data omg\.txt/, logs[1] + assert_match /Sent data file\.txt/, logs[1] end def test_send_file diff --git a/actionpack/test/controller/view_paths_test.rb b/actionpack/test/controller/view_paths_test.rb index 05d2c8407c..56821332c5 100644 --- a/actionpack/test/controller/view_paths_test.rb +++ b/actionpack/test/controller/view_paths_test.rb @@ -142,9 +142,9 @@ class ViewLoadPathsTest < ActionController::TestCase assert_paths A, "a/path" assert_paths A, *B.view_paths assert_paths C, *original_load_paths - + C.view_paths = [] - assert_nothing_raised { C.view_paths << 'c/path' } + assert_nothing_raised { C.append_view_path 'c/path' } assert_paths C, "c/path" end end |