aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/test')
-rw-r--r--actionpack/test/abstract_unit.rb4
-rw-r--r--actionpack/test/controller/base_test.rb5
-rw-r--r--actionpack/test/controller/http/action_methods_test.rb19
-rw-r--r--actionpack/test/controller/http/conditional_get_test.rb55
-rw-r--r--actionpack/test/controller/http/data_streaming_test.rb27
-rw-r--r--actionpack/test/controller/http/force_ssl_test.rb20
-rw-r--r--actionpack/test/controller/http/redirect_to_test.rb19
-rw-r--r--actionpack/test/controller/http/renderers_test.rb37
-rw-r--r--actionpack/test/controller/http/url_for_test.rb20
-rw-r--r--actionpack/test/controller/request_forgery_protection_test.rb24
-rw-r--r--actionpack/test/controller/sweeper_test.rb16
-rw-r--r--actionpack/test/dispatch/static_test.rb4
12 files changed, 44 insertions, 206 deletions
diff --git a/actionpack/test/abstract_unit.rb b/actionpack/test/abstract_unit.rb
index a05a816b71..b1a5356ddd 100644
--- a/actionpack/test/abstract_unit.rb
+++ b/actionpack/test/abstract_unit.rb
@@ -293,10 +293,6 @@ module ActionController
end
end
- class HTTP
- include SharedTestRoutes.url_helpers
- end
-
class TestCase
include ActionDispatch::TestProcess
diff --git a/actionpack/test/controller/base_test.rb b/actionpack/test/controller/base_test.rb
index 03d9873fc7..2d4083252e 100644
--- a/actionpack/test/controller/base_test.rb
+++ b/actionpack/test/controller/base_test.rb
@@ -130,8 +130,6 @@ class PerformActionTest < ActionController::TestCase
@request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new
@request.host = "www.nextangle.com"
-
- rescue_action_in_public!
end
def test_process_should_be_precise
@@ -155,7 +153,6 @@ class UrlOptionsTest < ActionController::TestCase
def setup
super
@request.host = 'www.example.com'
- rescue_action_in_public!
end
def test_url_for_query_params_included
@@ -206,7 +203,6 @@ class DefaultUrlOptionsTest < ActionController::TestCase
def setup
super
@request.host = 'www.example.com'
- rescue_action_in_public!
end
def test_default_url_options_override
@@ -257,7 +253,6 @@ class EmptyUrlOptionsTest < ActionController::TestCase
def setup
super
@request.host = 'www.example.com'
- rescue_action_in_public!
end
def test_ensure_url_for_works_as_expected_when_called_with_no_options_if_default_url_options_is_not_set
diff --git a/actionpack/test/controller/http/action_methods_test.rb b/actionpack/test/controller/http/action_methods_test.rb
deleted file mode 100644
index 20bb53aca2..0000000000
--- a/actionpack/test/controller/http/action_methods_test.rb
+++ /dev/null
@@ -1,19 +0,0 @@
-require 'abstract_unit'
-
-class ActionMethodsHTTPController < ActionController::HTTP
- def one; end
- def two; end
- hide_action :two
-end
-
-class ActionMethodsHTTPTest < ActiveSupport::TestCase
- def setup
- @controller = ActionMethodsHTTPController.new
- end
-
- def test_action_methods
- assert_equal Set.new(%w(one)),
- @controller.class.action_methods,
- "#{@controller.controller_path} should not be empty!"
- end
-end
diff --git a/actionpack/test/controller/http/conditional_get_test.rb b/actionpack/test/controller/http/conditional_get_test.rb
deleted file mode 100644
index 70d5ef296f..0000000000
--- a/actionpack/test/controller/http/conditional_get_test.rb
+++ /dev/null
@@ -1,55 +0,0 @@
-require 'abstract_unit'
-
-class ConditionalGetHTTPController < ActionController::HTTP
- before_filter :handle_last_modified_and_etags, :only => :two
-
- def one
- if stale?(:last_modified => Time.now.utc.beginning_of_day, :etag => [:foo, 123])
- render :text => "Hi!"
- end
- end
-
- def two
- render :text => "Hi!"
- end
-
- private
-
- def handle_last_modified_and_etags
- fresh_when(:last_modified => Time.now.utc.beginning_of_day, :etag => [ :foo, 123 ])
- end
-end
-
-class ConditionalGetHTTPTest < ActionController::TestCase
- tests ConditionalGetHTTPController
-
- def setup
- @last_modified = Time.now.utc.beginning_of_day.httpdate
- end
-
- def test_request_with_bang_gets_last_modified
- get :two
- assert_equal @last_modified, @response.headers['Last-Modified']
- assert_response :success
- end
-
- def test_request_with_bang_obeys_last_modified
- @request.if_modified_since = @last_modified
- get :two
- assert_response :not_modified
- end
-
- def test_last_modified_works_with_less_than_too
- @request.if_modified_since = 5.years.ago.httpdate
- get :two
- assert_response :success
- end
-
- def test_request_not_modified
- @request.if_modified_since = @last_modified
- get :one
- assert_equal 304, @response.status.to_i
- assert_blank @response.body
- assert_equal @last_modified, @response.headers['Last-Modified']
- end
-end
diff --git a/actionpack/test/controller/http/data_streaming_test.rb b/actionpack/test/controller/http/data_streaming_test.rb
deleted file mode 100644
index 67457b25b0..0000000000
--- a/actionpack/test/controller/http/data_streaming_test.rb
+++ /dev/null
@@ -1,27 +0,0 @@
-require 'abstract_unit'
-
-module TestHTTPFileUtils
- def file_name() File.basename(__FILE__) end
- def file_path() File.expand_path(__FILE__) end
- def file_data() @data ||= File.open(file_path, 'rb') { |f| f.read } end
-end
-
-class DataStreamingHTTPController < ActionController::HTTP
- include TestHTTPFileUtils
-
- def one; end
- def two
- send_data(file_data, {})
- end
-end
-
-class DataStreamingHTTPTest < ActionController::TestCase
- include TestHTTPFileUtils
- tests DataStreamingHTTPController
-
- def test_data
- response = process('two')
- assert_kind_of String, response.body
- assert_equal file_data, response.body
- end
-end
diff --git a/actionpack/test/controller/http/force_ssl_test.rb b/actionpack/test/controller/http/force_ssl_test.rb
deleted file mode 100644
index 479ede6b78..0000000000
--- a/actionpack/test/controller/http/force_ssl_test.rb
+++ /dev/null
@@ -1,20 +0,0 @@
-require 'abstract_unit'
-
-class ForceSSLHTTPController < ActionController::HTTP
- force_ssl
-
- def one; end
- def two
- head :ok
- end
-end
-
-class ForceSSLHTTPTest < ActionController::TestCase
- tests ForceSSLHTTPController
-
- def test_banana_redirects_to_https
- get :two
- assert_response 301
- assert_equal "https://test.host/force_sslhttp/two", redirect_to_url
- end
-end
diff --git a/actionpack/test/controller/http/redirect_to_test.rb b/actionpack/test/controller/http/redirect_to_test.rb
deleted file mode 100644
index c410910bae..0000000000
--- a/actionpack/test/controller/http/redirect_to_test.rb
+++ /dev/null
@@ -1,19 +0,0 @@
-require 'abstract_unit'
-
-class RedirectToHTTPController < ActionController::HTTP
- def one
- redirect_to :action => "two"
- end
-
- def two; end
-end
-
-class RedirectToHTTPTest < ActionController::TestCase
- tests RedirectToHTTPController
-
- def test_redirect_to
- get :one
- assert_response :redirect
- assert_equal "http://test.host/redirect_to_http/two", redirect_to_url
- end
-end
diff --git a/actionpack/test/controller/http/renderers_test.rb b/actionpack/test/controller/http/renderers_test.rb
deleted file mode 100644
index a28f226a94..0000000000
--- a/actionpack/test/controller/http/renderers_test.rb
+++ /dev/null
@@ -1,37 +0,0 @@
-require 'abstract_unit'
-
-class Model
- def to_json(options = {})
- { :a => 'b' }.to_json(options)
- end
-
- def to_xml(options = {})
- { :a => 'b' }.to_xml(options)
- end
-end
-
-class RenderersHTTPController < ActionController::HTTP
- def one
- render :json => Model.new
- end
-
- def two
- render :xml => Model.new
- end
-end
-
-class RenderersHTTPTest < ActionController::TestCase
- tests RenderersHTTPController
-
- def test_render_json
- get :one
- assert_response :success
- assert_equal({ :a => 'b' }.to_json, @response.body)
- end
-
- def test_render_xml
- get :two
- assert_response :success
- assert_equal({ :a => 'b' }.to_xml, @response.body)
- end
-end
diff --git a/actionpack/test/controller/http/url_for_test.rb b/actionpack/test/controller/http/url_for_test.rb
deleted file mode 100644
index fba24011a2..0000000000
--- a/actionpack/test/controller/http/url_for_test.rb
+++ /dev/null
@@ -1,20 +0,0 @@
-require 'abstract_unit'
-
-class UrlForHTTPController < ActionController::HTTP
- def one; end
- def two; end
-end
-
-class UrlForHTTPTest < ActionController::TestCase
- tests UrlForHTTPController
-
- def setup
- super
- @request.host = 'www.example.com'
- end
-
- def test_url_for
- get :one
- assert_equal "http://www.example.com/url_for_http/one", @controller.url_for
- end
-end
diff --git a/actionpack/test/controller/request_forgery_protection_test.rb b/actionpack/test/controller/request_forgery_protection_test.rb
index ef795dad89..8d4b76849f 100644
--- a/actionpack/test/controller/request_forgery_protection_test.rb
+++ b/actionpack/test/controller/request_forgery_protection_test.rb
@@ -35,6 +35,16 @@ module RequestForgeryProtectionActions
def form_for_without_protection
render :inline => "<%= form_for(:some_resource, :authenticity_token => false ) {} %>"
end
+
+ def form_for_remote
+ render :inline => "<%= form_for(:some_resource, :remote => true ) {} %>"
+ end
+
+ def form_for_remote_with_token
+ render :inline => "<%= form_for(:some_resource, :remote => true, :authenticity_token => true ) {} %>"
+ end
+
+ def rescue_action(e) raise e end
end
# sample controllers
@@ -98,6 +108,20 @@ module RequestForgeryProtectionTests
assert_select 'form>div>input[name=?][value=?]', 'custom_authenticity_token', @token
end
+ def test_should_render_form_without_token_tag_if_remote
+ assert_not_blocked do
+ get :form_for_remote
+ end
+ assert_no_match /authenticity_token/, response.body
+ end
+
+ def test_should_render_form_with_token_tag_if_remote_and_authenticity_token_requested
+ assert_not_blocked do
+ get :form_for_remote_with_token
+ end
+ assert_select 'form>div>input[name=?][value=?]', 'custom_authenticity_token', @token
+ end
+
def test_should_allow_get
assert_not_blocked { get :index }
end
diff --git a/actionpack/test/controller/sweeper_test.rb b/actionpack/test/controller/sweeper_test.rb
new file mode 100644
index 0000000000..0561efc62f
--- /dev/null
+++ b/actionpack/test/controller/sweeper_test.rb
@@ -0,0 +1,16 @@
+require 'abstract_unit'
+
+
+class SweeperTest < ActionController::TestCase
+
+ class ::AppSweeper < ActionController::Caching::Sweeper; end
+
+ def test_sweeper_should_not_ignore_unknown_method_calls
+ sweeper = ActionController::Caching::Sweeper.send(:new)
+ assert_raise NameError do
+ sweeper.instance_eval do
+ some_method_that_doesnt_exist
+ end
+ end
+ end
+end
diff --git a/actionpack/test/dispatch/static_test.rb b/actionpack/test/dispatch/static_test.rb
index 092ca3e20a..112f470786 100644
--- a/actionpack/test/dispatch/static_test.rb
+++ b/actionpack/test/dispatch/static_test.rb
@@ -7,6 +7,10 @@ module StaticTests
assert_equal "Hello, World!", get("/nofile").body
end
+ def test_handles_urls_with_bad_encoding
+ assert_equal "Hello, World!", get("/doorkeeper%E3E4").body
+ end
+
def test_sets_cache_control
response = get("/index.html")
assert_html "/index.html", response