aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/new_base
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/test/new_base')
-rw-r--r--actionpack/test/new_base/base_test.rb4
-rw-r--r--actionpack/test/new_base/content_negotiation_test.rb18
-rw-r--r--actionpack/test/new_base/content_type_test.rb2
-rw-r--r--actionpack/test/new_base/etag_test.rb4
-rw-r--r--actionpack/test/new_base/metal_test.rb3
-rw-r--r--actionpack/test/new_base/middleware_test.rb77
-rw-r--r--actionpack/test/new_base/redirect_test.rb1
-rw-r--r--actionpack/test/new_base/render_action_test.rb4
-rw-r--r--actionpack/test/new_base/render_file_test.rb6
-rw-r--r--actionpack/test/new_base/render_implicit_action_test.rb4
-rw-r--r--actionpack/test/new_base/render_layout_test.rb4
-rw-r--r--actionpack/test/new_base/render_partial_test.rb4
-rw-r--r--actionpack/test/new_base/render_rjs_test.rb15
-rw-r--r--actionpack/test/new_base/render_template_test.rb4
-rw-r--r--actionpack/test/new_base/render_test.rb4
-rw-r--r--actionpack/test/new_base/render_text_test.rb4
-rw-r--r--actionpack/test/new_base/render_xml_test.rb4
-rw-r--r--actionpack/test/new_base/test_helper.rb110
18 files changed, 130 insertions, 142 deletions
diff --git a/actionpack/test/new_base/base_test.rb b/actionpack/test/new_base/base_test.rb
index 1b2e917ced..effde324bc 100644
--- a/actionpack/test/new_base/base_test.rb
+++ b/actionpack/test/new_base/base_test.rb
@@ -1,4 +1,4 @@
-require File.join(File.expand_path(File.dirname(__FILE__)), "test_helper")
+require 'abstract_unit'
# Tests the controller dispatching happy path
module Dispatching
@@ -65,4 +65,4 @@ module Dispatching
assert_equal 'contained_empty', Submodule::ContainedEmptyController.controller_name
end
end
-end \ No newline at end of file
+end
diff --git a/actionpack/test/new_base/content_negotiation_test.rb b/actionpack/test/new_base/content_negotiation_test.rb
new file mode 100644
index 0000000000..c43cb677f8
--- /dev/null
+++ b/actionpack/test/new_base/content_negotiation_test.rb
@@ -0,0 +1,18 @@
+require 'abstract_unit'
+
+module ContentNegotiation
+
+ # This has no layout and it works
+ class BasicController < ActionController::Base
+ self.view_paths = [ActionView::FixtureResolver.new(
+ "content_negotiation/basic/hello.html.erb" => "Hello world <%= request.formats %>!"
+ )]
+ end
+
+ class TestContentNegotiation < SimpleRouteCase
+ test "A */* Accept header will return HTML" do
+ get "/content_negotiation/basic/hello", {}, "HTTP_ACCEPT" => "*/*"
+ assert_body "Hello world */*!"
+ end
+ end
+end
diff --git a/actionpack/test/new_base/content_type_test.rb b/actionpack/test/new_base/content_type_test.rb
index ceee508224..898d0bb9f3 100644
--- a/actionpack/test/new_base/content_type_test.rb
+++ b/actionpack/test/new_base/content_type_test.rb
@@ -1,4 +1,4 @@
-require File.join(File.expand_path(File.dirname(__FILE__)), "test_helper")
+require 'abstract_unit'
module ContentType
class BaseController < ActionController::Base
diff --git a/actionpack/test/new_base/etag_test.rb b/actionpack/test/new_base/etag_test.rb
index 3a69e7dac4..d5b7942ab6 100644
--- a/actionpack/test/new_base/etag_test.rb
+++ b/actionpack/test/new_base/etag_test.rb
@@ -1,4 +1,4 @@
-require File.join(File.expand_path(File.dirname(__FILE__)), "test_helper")
+require 'abstract_unit'
module Etags
class BasicController < ActionController::Base
@@ -43,4 +43,4 @@ module Etags
%("#{Digest::MD5.hexdigest(text)}")
end
end
-end \ No newline at end of file
+end
diff --git a/actionpack/test/new_base/metal_test.rb b/actionpack/test/new_base/metal_test.rb
index 2b7720863a..e1d46b906e 100644
--- a/actionpack/test/new_base/metal_test.rb
+++ b/actionpack/test/new_base/metal_test.rb
@@ -1,4 +1,4 @@
-require File.join(File.expand_path(File.dirname(__FILE__)), "test_helper")
+require 'abstract_unit'
module MetalTest
class MetalMiddleware < ActionController::Middleware
@@ -41,4 +41,3 @@ module MetalTest
end
end
end
-
diff --git a/actionpack/test/new_base/middleware_test.rb b/actionpack/test/new_base/middleware_test.rb
new file mode 100644
index 0000000000..ada0215b1a
--- /dev/null
+++ b/actionpack/test/new_base/middleware_test.rb
@@ -0,0 +1,77 @@
+require 'abstract_unit'
+
+module MiddlewareTest
+ class MyMiddleware
+ def initialize(app)
+ @app = app
+ end
+
+ def call(env)
+ result = @app.call(env)
+ result[1]["Middleware-Test"] = "Success"
+ result[1]["Middleware-Order"] = "First"
+ result
+ end
+ end
+
+ class ExclaimerMiddleware
+ def initialize(app)
+ @app = app
+ end
+
+ def call(env)
+ result = @app.call(env)
+ result[1]["Middleware-Order"] << "!"
+ result
+ end
+ end
+
+ class MyController < ActionController::Metal
+ use MyMiddleware
+
+ middleware.insert_before MyMiddleware, ExclaimerMiddleware
+
+ def index
+ self.response_body = "Hello World"
+ end
+ end
+
+ class InheritedController < MyController
+ end
+
+ module MiddlewareTests
+ extend ActiveSupport::Testing::Declarative
+
+ test "middleware that is 'use'd is called as part of the Rack application" do
+ result = @app.call(env_for("/"))
+ assert_equal "Hello World", result[2]
+ assert_equal "Success", result[1]["Middleware-Test"]
+ end
+
+ test "the middleware stack is exposed as 'middleware' in the controller" do
+ result = @app.call(env_for("/"))
+ assert_equal "First!", result[1]["Middleware-Order"]
+ end
+ end
+
+ class TestMiddleware < ActiveSupport::TestCase
+ include MiddlewareTests
+
+ def setup
+ @app = MyController.action(:index)
+ end
+
+ def env_for(url)
+ Rack::MockRequest.env_for(url)
+ end
+ end
+
+ class TestInheritedMiddleware < TestMiddleware
+ def setup
+ @app = InheritedController.action(:index)
+ end
+
+ test "middleware inherits" do
+ end
+ end
+end
diff --git a/actionpack/test/new_base/redirect_test.rb b/actionpack/test/new_base/redirect_test.rb
deleted file mode 100644
index e591ebd05f..0000000000
--- a/actionpack/test/new_base/redirect_test.rb
+++ /dev/null
@@ -1 +0,0 @@
-require File.join(File.expand_path(File.dirname(__FILE__)), "test_helper") \ No newline at end of file
diff --git a/actionpack/test/new_base/render_action_test.rb b/actionpack/test/new_base/render_action_test.rb
index dfa7cc2141..d5896c1ebd 100644
--- a/actionpack/test/new_base/render_action_test.rb
+++ b/actionpack/test/new_base/render_action_test.rb
@@ -1,4 +1,4 @@
-require File.join(File.expand_path(File.dirname(__FILE__)), "test_helper")
+require 'abstract_unit'
module RenderAction
# This has no layout and it works
@@ -317,4 +317,4 @@ module RenderActionWithBothLayouts
assert_status 200
end
end
-end \ No newline at end of file
+end
diff --git a/actionpack/test/new_base/render_file_test.rb b/actionpack/test/new_base/render_file_test.rb
index 769949be0c..c4098855e6 100644
--- a/actionpack/test/new_base/render_file_test.rb
+++ b/actionpack/test/new_base/render_file_test.rb
@@ -1,9 +1,9 @@
-require File.join(File.expand_path(File.dirname(__FILE__)), "test_helper")
+require 'abstract_unit'
module RenderFile
class BasicController < ActionController::Base
- self.view_paths = "."
+ self.view_paths = File.dirname(__FILE__)
def index
render :file => File.join(File.dirname(__FILE__), *%w[.. fixtures test hello_world])
@@ -107,4 +107,4 @@ module RenderFile
end
end
-end \ No newline at end of file
+end
diff --git a/actionpack/test/new_base/render_implicit_action_test.rb b/actionpack/test/new_base/render_implicit_action_test.rb
index fd96e1955f..2b78fa7d4f 100644
--- a/actionpack/test/new_base/render_implicit_action_test.rb
+++ b/actionpack/test/new_base/render_implicit_action_test.rb
@@ -1,4 +1,4 @@
-require File.join(File.expand_path(File.dirname(__FILE__)), "test_helper")
+require 'abstract_unit'
module RenderImplicitAction
class SimpleController < ::ApplicationController
@@ -25,4 +25,4 @@ module RenderImplicitAction
assert_status 200
end
end
-end \ No newline at end of file
+end
diff --git a/actionpack/test/new_base/render_layout_test.rb b/actionpack/test/new_base/render_layout_test.rb
index 933eef58e7..f840a47ecf 100644
--- a/actionpack/test/new_base/render_layout_test.rb
+++ b/actionpack/test/new_base/render_layout_test.rb
@@ -1,4 +1,4 @@
-require File.join(File.expand_path(File.dirname(__FILE__)), "test_helper")
+require 'abstract_unit'
module ControllerLayouts
class ImplicitController < ::ApplicationController
@@ -98,4 +98,4 @@ module ControllerLayouts
end
end
end
-end \ No newline at end of file
+end
diff --git a/actionpack/test/new_base/render_partial_test.rb b/actionpack/test/new_base/render_partial_test.rb
index bbb98a0c01..7c2c20e1c7 100644
--- a/actionpack/test/new_base/render_partial_test.rb
+++ b/actionpack/test/new_base/render_partial_test.rb
@@ -1,4 +1,4 @@
-require File.join(File.expand_path(File.dirname(__FILE__)), "test_helper")
+require 'abstract_unit'
module RenderPartial
@@ -24,4 +24,4 @@ module RenderPartial
end
end
-end \ No newline at end of file
+end
diff --git a/actionpack/test/new_base/render_rjs_test.rb b/actionpack/test/new_base/render_rjs_test.rb
index 3d3e516905..7b76c54ab9 100644
--- a/actionpack/test/new_base/render_rjs_test.rb
+++ b/actionpack/test/new_base/render_rjs_test.rb
@@ -1,9 +1,7 @@
-require File.join(File.expand_path(File.dirname(__FILE__)), "test_helper")
+require 'abstract_unit'
module RenderRjs
-
class BasicController < ActionController::Base
-
self.view_paths = [ActionView::FixtureResolver.new(
"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'",
@@ -26,6 +24,14 @@ module RenderRjs
class TestBasic < SimpleRouteCase
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\");")
@@ -40,6 +46,5 @@ module RenderRjs
get :index_locale, "format" => "js"
assert_response("$(\"customer\").update(\"Danish HTML Partial\");")
end
-
end
-end \ No newline at end of file
+end
diff --git a/actionpack/test/new_base/render_template_test.rb b/actionpack/test/new_base/render_template_test.rb
index 967cbd07b0..3b24c2d75a 100644
--- a/actionpack/test/new_base/render_template_test.rb
+++ b/actionpack/test/new_base/render_template_test.rb
@@ -1,4 +1,4 @@
-require File.join(File.expand_path(File.dirname(__FILE__)), "test_helper")
+require 'abstract_unit'
module RenderTemplate
class WithoutLayoutController < ActionController::Base
@@ -167,4 +167,4 @@ module RenderTemplate
end
end
end
-end \ No newline at end of file
+end
diff --git a/actionpack/test/new_base/render_test.rb b/actionpack/test/new_base/render_test.rb
index 5783b4766a..804be79d17 100644
--- a/actionpack/test/new_base/render_test.rb
+++ b/actionpack/test/new_base/render_test.rb
@@ -1,4 +1,4 @@
-require File.join(File.expand_path(File.dirname(__FILE__)), "test_helper")
+require 'abstract_unit'
module Render
class BlankRenderController < ActionController::Base
@@ -82,4 +82,4 @@ module Render
assert_body "Controller Name: blank_render"
end
end
-end \ No newline at end of file
+end
diff --git a/actionpack/test/new_base/render_text_test.rb b/actionpack/test/new_base/render_text_test.rb
index 84f77432c9..f5839ee16f 100644
--- a/actionpack/test/new_base/render_text_test.rb
+++ b/actionpack/test/new_base/render_text_test.rb
@@ -1,4 +1,4 @@
-require File.join(File.expand_path(File.dirname(__FILE__)), "test_helper")
+require 'abstract_unit'
module RenderText
class SimpleController < ActionController::Base
@@ -134,4 +134,4 @@ module RenderText
assert_status 200
end
end
-end \ No newline at end of file
+end
diff --git a/actionpack/test/new_base/render_xml_test.rb b/actionpack/test/new_base/render_xml_test.rb
index a3890ddfb2..d044738a78 100644
--- a/actionpack/test/new_base/render_xml_test.rb
+++ b/actionpack/test/new_base/render_xml_test.rb
@@ -1,4 +1,4 @@
-require File.join(File.expand_path(File.dirname(__FILE__)), "test_helper")
+require 'abstract_unit'
module RenderXml
@@ -8,4 +8,4 @@ module RenderXml
"render_xml/basic/with_render_erb" => "Hello world!"
)]
end
-end \ No newline at end of file
+end
diff --git a/actionpack/test/new_base/test_helper.rb b/actionpack/test/new_base/test_helper.rb
deleted file mode 100644
index b7ccd3db8d..0000000000
--- a/actionpack/test/new_base/test_helper.rb
+++ /dev/null
@@ -1,110 +0,0 @@
-$:.unshift(File.dirname(__FILE__) + '/../../lib')
-$:.unshift(File.dirname(__FILE__) + '/../../../activesupport/lib')
-$:.unshift(File.dirname(__FILE__) + '/../lib')
-
-require 'test/unit'
-require 'active_support'
-require 'active_support/test_case'
-require 'action_view'
-require 'fixture_template'
-
-begin
- require 'ruby-debug'
- Debugger.settings[:autoeval] = true
- Debugger.start
-rescue LoadError
- # Debugging disabled. `gem install ruby-debug` to enable.
-end
-
-require 'action_controller'
-require 'pp' # require 'pp' early to prevent hidden_methods from not picking up the pretty-print methods until too late
-
-require 'action_controller/testing/process'
-require 'action_controller/testing/integration'
-
-module Rails
- def self.env
- x = Object.new
- def x.test?() true end
- x
- end
-end
-
-# Temporary base class
-class Rack::TestCase < ActionController::IntegrationTest
- setup do
- ActionController::Base.session_options[:key] = "abc"
- ActionController::Base.session_options[:secret] = ("*" * 30)
- end
-
- def app
- @app ||= ActionController::Dispatcher.new
- end
-
- def self.testing(klass = nil)
- if klass
- @testing = "/#{klass.name.underscore}".sub!(/_controller$/, '')
- else
- @testing
- end
- end
-
- def get(thing, *args)
- if thing.is_a?(Symbol)
- super("#{self.class.testing}/#{thing}", *args)
- else
- super
- end
- end
-
- def assert_body(body)
- assert_equal body, Array.wrap(response.body).join
- end
-
- def assert_status(code)
- assert_equal code, response.status
- end
-
- def assert_response(body, status = 200, headers = {})
- assert_body body
- assert_status status
- headers.each do |header, value|
- assert_header header, value
- end
- end
-
- def assert_content_type(type)
- assert_equal type, response.headers["Content-Type"]
- end
-
- def assert_header(name, value)
- assert_equal value, response.headers[name]
- end
-end
-
-class ::ApplicationController < ActionController::Base
-end
-
-module ActionController
- class << Routing
- def possible_controllers
- @@possible_controllers ||= []
- end
- end
-
- class Base
- def self.inherited(klass)
- name = klass.name.underscore.sub(/_controller$/, '')
- ActionController::Routing.possible_controllers << name unless name.blank?
- super
- end
- end
-end
-
-class SimpleRouteCase < Rack::TestCase
- setup do
- ActionController::Routing::Routes.draw do |map|
- map.connect ':controller/:action/:id'
- end
- end
-end