halorgium-actionpack 3.0.pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (154) hide show
  1. data/CHANGELOG +5179 -0
  2. data/MIT-LICENSE +21 -0
  3. data/README +409 -0
  4. data/lib/abstract_controller.rb +16 -0
  5. data/lib/abstract_controller/base.rb +158 -0
  6. data/lib/abstract_controller/callbacks.rb +113 -0
  7. data/lib/abstract_controller/exceptions.rb +12 -0
  8. data/lib/abstract_controller/helpers.rb +151 -0
  9. data/lib/abstract_controller/layouts.rb +250 -0
  10. data/lib/abstract_controller/localized_cache.rb +49 -0
  11. data/lib/abstract_controller/logger.rb +61 -0
  12. data/lib/abstract_controller/rendering_controller.rb +188 -0
  13. data/lib/action_controller.rb +72 -0
  14. data/lib/action_controller/base.rb +168 -0
  15. data/lib/action_controller/caching.rb +80 -0
  16. data/lib/action_controller/caching/actions.rb +163 -0
  17. data/lib/action_controller/caching/fragments.rb +116 -0
  18. data/lib/action_controller/caching/pages.rb +154 -0
  19. data/lib/action_controller/caching/sweeping.rb +97 -0
  20. data/lib/action_controller/deprecated.rb +4 -0
  21. data/lib/action_controller/deprecated/integration_test.rb +2 -0
  22. data/lib/action_controller/deprecated/performance_test.rb +1 -0
  23. data/lib/action_controller/dispatch/dispatcher.rb +57 -0
  24. data/lib/action_controller/metal.rb +129 -0
  25. data/lib/action_controller/metal/benchmarking.rb +73 -0
  26. data/lib/action_controller/metal/compatibility.rb +145 -0
  27. data/lib/action_controller/metal/conditional_get.rb +86 -0
  28. data/lib/action_controller/metal/configuration.rb +28 -0
  29. data/lib/action_controller/metal/cookies.rb +105 -0
  30. data/lib/action_controller/metal/exceptions.rb +55 -0
  31. data/lib/action_controller/metal/filter_parameter_logging.rb +77 -0
  32. data/lib/action_controller/metal/flash.rb +162 -0
  33. data/lib/action_controller/metal/head.rb +27 -0
  34. data/lib/action_controller/metal/helpers.rb +115 -0
  35. data/lib/action_controller/metal/hide_actions.rb +47 -0
  36. data/lib/action_controller/metal/http_authentication.rb +312 -0
  37. data/lib/action_controller/metal/layouts.rb +171 -0
  38. data/lib/action_controller/metal/mime_responds.rb +317 -0
  39. data/lib/action_controller/metal/rack_convenience.rb +27 -0
  40. data/lib/action_controller/metal/redirector.rb +22 -0
  41. data/lib/action_controller/metal/render_options.rb +103 -0
  42. data/lib/action_controller/metal/rendering_controller.rb +57 -0
  43. data/lib/action_controller/metal/request_forgery_protection.rb +108 -0
  44. data/lib/action_controller/metal/rescuable.rb +13 -0
  45. data/lib/action_controller/metal/responder.rb +200 -0
  46. data/lib/action_controller/metal/session.rb +15 -0
  47. data/lib/action_controller/metal/session_management.rb +45 -0
  48. data/lib/action_controller/metal/streaming.rb +188 -0
  49. data/lib/action_controller/metal/testing.rb +39 -0
  50. data/lib/action_controller/metal/url_for.rb +41 -0
  51. data/lib/action_controller/metal/verification.rb +130 -0
  52. data/lib/action_controller/middleware.rb +38 -0
  53. data/lib/action_controller/notifications.rb +10 -0
  54. data/lib/action_controller/polymorphic_routes.rb +183 -0
  55. data/lib/action_controller/record_identifier.rb +91 -0
  56. data/lib/action_controller/testing/process.rb +111 -0
  57. data/lib/action_controller/testing/test_case.rb +345 -0
  58. data/lib/action_controller/translation.rb +13 -0
  59. data/lib/action_controller/url_rewriter.rb +204 -0
  60. data/lib/action_controller/vendor/html-scanner.rb +16 -0
  61. data/lib/action_controller/vendor/html-scanner/html/document.rb +68 -0
  62. data/lib/action_controller/vendor/html-scanner/html/node.rb +537 -0
  63. data/lib/action_controller/vendor/html-scanner/html/sanitizer.rb +176 -0
  64. data/lib/action_controller/vendor/html-scanner/html/selector.rb +828 -0
  65. data/lib/action_controller/vendor/html-scanner/html/tokenizer.rb +105 -0
  66. data/lib/action_controller/vendor/html-scanner/html/version.rb +11 -0
  67. data/lib/action_dispatch.rb +70 -0
  68. data/lib/action_dispatch/http/headers.rb +33 -0
  69. data/lib/action_dispatch/http/mime_type.rb +231 -0
  70. data/lib/action_dispatch/http/mime_types.rb +23 -0
  71. data/lib/action_dispatch/http/request.rb +539 -0
  72. data/lib/action_dispatch/http/response.rb +290 -0
  73. data/lib/action_dispatch/http/status_codes.rb +42 -0
  74. data/lib/action_dispatch/http/utils.rb +20 -0
  75. data/lib/action_dispatch/middleware/callbacks.rb +50 -0
  76. data/lib/action_dispatch/middleware/params_parser.rb +79 -0
  77. data/lib/action_dispatch/middleware/rescue.rb +26 -0
  78. data/lib/action_dispatch/middleware/session/abstract_store.rb +208 -0
  79. data/lib/action_dispatch/middleware/session/cookie_store.rb +235 -0
  80. data/lib/action_dispatch/middleware/session/mem_cache_store.rb +47 -0
  81. data/lib/action_dispatch/middleware/show_exceptions.rb +143 -0
  82. data/lib/action_dispatch/middleware/stack.rb +116 -0
  83. data/lib/action_dispatch/middleware/static.rb +44 -0
  84. data/lib/action_dispatch/middleware/string_coercion.rb +29 -0
  85. data/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb +24 -0
  86. data/lib/action_dispatch/middleware/templates/rescues/_trace.erb +26 -0
  87. data/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb +10 -0
  88. data/lib/action_dispatch/middleware/templates/rescues/layout.erb +29 -0
  89. data/lib/action_dispatch/middleware/templates/rescues/missing_template.erb +2 -0
  90. data/lib/action_dispatch/middleware/templates/rescues/routing_error.erb +10 -0
  91. data/lib/action_dispatch/middleware/templates/rescues/template_error.erb +21 -0
  92. data/lib/action_dispatch/middleware/templates/rescues/unknown_action.erb +2 -0
  93. data/lib/action_dispatch/routing.rb +381 -0
  94. data/lib/action_dispatch/routing/deprecated_mapper.rb +878 -0
  95. data/lib/action_dispatch/routing/mapper.rb +327 -0
  96. data/lib/action_dispatch/routing/route.rb +49 -0
  97. data/lib/action_dispatch/routing/route_set.rb +497 -0
  98. data/lib/action_dispatch/testing/assertions.rb +8 -0
  99. data/lib/action_dispatch/testing/assertions/dom.rb +35 -0
  100. data/lib/action_dispatch/testing/assertions/model.rb +19 -0
  101. data/lib/action_dispatch/testing/assertions/response.rb +145 -0
  102. data/lib/action_dispatch/testing/assertions/routing.rb +144 -0
  103. data/lib/action_dispatch/testing/assertions/selector.rb +639 -0
  104. data/lib/action_dispatch/testing/assertions/tag.rb +123 -0
  105. data/lib/action_dispatch/testing/integration.rb +504 -0
  106. data/lib/action_dispatch/testing/performance_test.rb +15 -0
  107. data/lib/action_dispatch/testing/test_request.rb +83 -0
  108. data/lib/action_dispatch/testing/test_response.rb +131 -0
  109. data/lib/action_pack.rb +24 -0
  110. data/lib/action_pack/version.rb +9 -0
  111. data/lib/action_view.rb +58 -0
  112. data/lib/action_view/base.rb +308 -0
  113. data/lib/action_view/context.rb +44 -0
  114. data/lib/action_view/erb/util.rb +48 -0
  115. data/lib/action_view/helpers.rb +62 -0
  116. data/lib/action_view/helpers/active_model_helper.rb +306 -0
  117. data/lib/action_view/helpers/ajax_helper.rb +68 -0
  118. data/lib/action_view/helpers/asset_tag_helper.rb +830 -0
  119. data/lib/action_view/helpers/atom_feed_helper.rb +198 -0
  120. data/lib/action_view/helpers/cache_helper.rb +39 -0
  121. data/lib/action_view/helpers/capture_helper.rb +168 -0
  122. data/lib/action_view/helpers/date_helper.rb +988 -0
  123. data/lib/action_view/helpers/debug_helper.rb +38 -0
  124. data/lib/action_view/helpers/form_helper.rb +1102 -0
  125. data/lib/action_view/helpers/form_options_helper.rb +600 -0
  126. data/lib/action_view/helpers/form_tag_helper.rb +495 -0
  127. data/lib/action_view/helpers/javascript_helper.rb +208 -0
  128. data/lib/action_view/helpers/number_helper.rb +311 -0
  129. data/lib/action_view/helpers/prototype_helper.rb +1309 -0
  130. data/lib/action_view/helpers/raw_output_helper.rb +9 -0
  131. data/lib/action_view/helpers/record_identification_helper.rb +20 -0
  132. data/lib/action_view/helpers/record_tag_helper.rb +58 -0
  133. data/lib/action_view/helpers/sanitize_helper.rb +259 -0
  134. data/lib/action_view/helpers/scriptaculous_helper.rb +226 -0
  135. data/lib/action_view/helpers/tag_helper.rb +151 -0
  136. data/lib/action_view/helpers/text_helper.rb +594 -0
  137. data/lib/action_view/helpers/translation_helper.rb +39 -0
  138. data/lib/action_view/helpers/url_helper.rb +639 -0
  139. data/lib/action_view/locale/en.yml +117 -0
  140. data/lib/action_view/paths.rb +80 -0
  141. data/lib/action_view/render/partials.rb +342 -0
  142. data/lib/action_view/render/rendering.rb +134 -0
  143. data/lib/action_view/safe_buffer.rb +28 -0
  144. data/lib/action_view/template/error.rb +101 -0
  145. data/lib/action_view/template/handler.rb +36 -0
  146. data/lib/action_view/template/handlers.rb +52 -0
  147. data/lib/action_view/template/handlers/builder.rb +17 -0
  148. data/lib/action_view/template/handlers/erb.rb +53 -0
  149. data/lib/action_view/template/handlers/rjs.rb +18 -0
  150. data/lib/action_view/template/resolver.rb +165 -0
  151. data/lib/action_view/template/template.rb +131 -0
  152. data/lib/action_view/template/text.rb +38 -0
  153. data/lib/action_view/test_case.rb +163 -0
  154. metadata +236 -0
@@ -0,0 +1,97 @@
1
+ module ActionController #:nodoc:
2
+ module Caching
3
+ # Sweepers are the terminators of the caching world and responsible for expiring caches when model objects change.
4
+ # They do this by being half-observers, half-filters and implementing callbacks for both roles. A Sweeper example:
5
+ #
6
+ # class ListSweeper < ActionController::Caching::Sweeper
7
+ # observe List, Item
8
+ #
9
+ # def after_save(record)
10
+ # list = record.is_a?(List) ? record : record.list
11
+ # expire_page(:controller => "lists", :action => %w( show public feed ), :id => list.id)
12
+ # expire_action(:controller => "lists", :action => "all")
13
+ # list.shares.each { |share| expire_page(:controller => "lists", :action => "show", :id => share.url_key) }
14
+ # end
15
+ # end
16
+ #
17
+ # The sweeper is assigned in the controllers that wish to have its job performed using the <tt>cache_sweeper</tt> class method:
18
+ #
19
+ # class ListsController < ApplicationController
20
+ # caches_action :index, :show, :public, :feed
21
+ # cache_sweeper :list_sweeper, :only => [ :edit, :destroy, :share ]
22
+ # end
23
+ #
24
+ # In the example above, four actions are cached and three actions are responsible for expiring those caches.
25
+ #
26
+ # You can also name an explicit class in the declaration of a sweeper, which is needed if the sweeper is in a module:
27
+ #
28
+ # class ListsController < ApplicationController
29
+ # caches_action :index, :show, :public, :feed
30
+ # cache_sweeper OpenBar::Sweeper, :only => [ :edit, :destroy, :share ]
31
+ # end
32
+ module Sweeping
33
+ def self.included(base) #:nodoc:
34
+ base.extend(ClassMethods)
35
+ end
36
+
37
+ module ClassMethods #:nodoc:
38
+ def cache_sweeper(*sweepers)
39
+ configuration = sweepers.extract_options!
40
+
41
+ sweepers.each do |sweeper|
42
+ ActiveRecord::Base.observers << sweeper if defined?(ActiveRecord) and defined?(ActiveRecord::Base)
43
+ sweeper_instance = (sweeper.is_a?(Symbol) ? Object.const_get(sweeper.to_s.classify) : sweeper).instance
44
+
45
+ if sweeper_instance.is_a?(Sweeper)
46
+ around_filter(sweeper_instance, :only => configuration[:only])
47
+ else
48
+ after_filter(sweeper_instance, :only => configuration[:only])
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end
54
+
55
+ if defined?(ActiveRecord) and defined?(ActiveRecord::Observer)
56
+ class Sweeper < ActiveRecord::Observer #:nodoc:
57
+ attr_accessor :controller
58
+
59
+ def before(controller)
60
+ self.controller = controller
61
+ callback(:before) if controller.perform_caching
62
+ end
63
+
64
+ def after(controller)
65
+ callback(:after) if controller.perform_caching
66
+ # Clean up, so that the controller can be collected after this request
67
+ self.controller = nil
68
+ end
69
+
70
+ protected
71
+ # gets the action cache path for the given options.
72
+ def action_path_for(options)
73
+ Actions::ActionCachePath.new(controller, options).path
74
+ end
75
+
76
+ # Retrieve instance variables set in the controller.
77
+ def assigns(key)
78
+ controller.instance_variable_get("@#{key}")
79
+ end
80
+
81
+ private
82
+ def callback(timing)
83
+ controller_callback_method_name = "#{timing}_#{controller.controller_name.underscore}"
84
+ action_callback_method_name = "#{controller_callback_method_name}_#{controller.action_name}"
85
+
86
+ __send__(controller_callback_method_name) if respond_to?(controller_callback_method_name, true)
87
+ __send__(action_callback_method_name) if respond_to?(action_callback_method_name, true)
88
+ end
89
+
90
+ def method_missing(method, *arguments, &block)
91
+ return if @controller.nil?
92
+ @controller.__send__(method, *arguments, &block)
93
+ end
94
+ end
95
+ end
96
+ end
97
+ end
@@ -0,0 +1,4 @@
1
+ ActionController::AbstractRequest = ActionController::Request = ActionDispatch::Request
2
+ ActionController::AbstractResponse = ActionController::Response = ActionDispatch::Response
3
+ ActionController::Routing = ActionDispatch::Routing
4
+ ActionController::Routing::Routes = ActionDispatch::Routing::RouteSet.new
@@ -0,0 +1,2 @@
1
+ ActionController::Integration = ActionDispatch::Integration
2
+ ActionController::IntegrationTest = ActionDispatch::IntegrationTest
@@ -0,0 +1 @@
1
+ ActionController::PerformanceTest = ActionDispatch::PerformanceTest
@@ -0,0 +1,57 @@
1
+ require 'active_support/core_ext/module/delegation'
2
+
3
+ module ActionController
4
+ # Dispatches requests to the appropriate controller and takes care of
5
+ # reloading the app after each request when Dependencies.load? is true.
6
+ class Dispatcher
7
+ cattr_accessor :prepare_each_request
8
+ self.prepare_each_request = false
9
+
10
+ class << self
11
+ def define_dispatcher_callbacks(cache_classes)
12
+ unless cache_classes
13
+ # Run prepare callbacks before every request in development mode
14
+ self.prepare_each_request = true
15
+
16
+ # Development mode callbacks
17
+ ActionDispatch::Callbacks.before_dispatch do |app|
18
+ ActionController::Routing::Routes.reload
19
+ end
20
+
21
+ ActionDispatch::Callbacks.after_dispatch do
22
+ # Cleanup the application before processing the current request.
23
+ ActiveRecord::Base.reset_subclasses if defined?(ActiveRecord)
24
+ ActiveSupport::Dependencies.clear
25
+ ActiveRecord::Base.clear_reloadable_connections! if defined?(ActiveRecord)
26
+ end
27
+
28
+ ActionView::Helpers::AssetTagHelper.cache_asset_timestamps = false
29
+ end
30
+
31
+ if defined?(ActiveRecord)
32
+ to_prepare(:activerecord_instantiate_observers) do
33
+ ActiveRecord::Base.instantiate_observers
34
+ end
35
+ end
36
+
37
+ if Base.logger && Base.logger.respond_to?(:flush)
38
+ after_dispatch do
39
+ Base.logger.flush
40
+ end
41
+ end
42
+
43
+ to_prepare do
44
+ I18n.reload!
45
+ end
46
+ end
47
+
48
+ delegate :to_prepare, :before_dispatch, :around_dispatch, :after_dispatch,
49
+ :to => ActionDispatch::Callbacks
50
+
51
+ def new
52
+ # DEPRECATE Rails application fallback
53
+ Rails.application
54
+ end
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,129 @@
1
+ require 'active_support/core_ext/class/inheritable_attributes'
2
+
3
+ module ActionController
4
+ # ActionController::Metal provides a way to get a valid Rack application from a controller.
5
+ #
6
+ # In AbstractController, dispatching is triggered directly by calling #process on a new controller.
7
+ # ActionController::Metal provides an #action method that returns a valid Rack application for a
8
+ # given action. Other rack builders, such as Rack::Builder, Rack::URLMap, and the Rails router,
9
+ # can dispatch directly to the action returned by FooController.action(:index).
10
+ class Metal < AbstractController::Base
11
+ abstract!
12
+
13
+ # :api: public
14
+ attr_internal :params, :env
15
+
16
+ # Returns the last part of the controller's name, underscored, without the ending
17
+ # "Controller". For instance, MyApp::MyPostsController would return "my_posts" for
18
+ # controller_name
19
+ #
20
+ # ==== Returns
21
+ # String
22
+ def self.controller_name
23
+ @controller_name ||= controller_path.split("/").last
24
+ end
25
+
26
+ # Delegates to the class' #controller_name
27
+ def controller_name
28
+ self.class.controller_name
29
+ end
30
+
31
+ # Returns the full controller name, underscored, without the ending Controller.
32
+ # For instance, MyApp::MyPostsController would return "my_app/my_posts" for
33
+ # controller_name.
34
+ #
35
+ # ==== Returns
36
+ # String
37
+ def self.controller_path
38
+ @controller_path ||= name && name.sub(/Controller$/, '').underscore
39
+ end
40
+
41
+ # Delegates to the class' #controller_path
42
+ def controller_path
43
+ self.class.controller_path
44
+ end
45
+
46
+ # The details below can be overridden to support a specific
47
+ # Request and Response object. The default ActionController::Base
48
+ # implementation includes RackConvenience, which makes a request
49
+ # and response object available. You might wish to control the
50
+ # environment and response manually for performance reasons.
51
+
52
+ attr_internal :status, :headers, :content_type, :response
53
+
54
+ def initialize(*)
55
+ @_headers = {}
56
+ super
57
+ end
58
+
59
+ # Basic implementations for content_type=, location=, and headers are
60
+ # provided to reduce the dependency on the RackConvenience module
61
+ # in Renderer and Redirector.
62
+
63
+ def content_type=(type)
64
+ headers["Content-Type"] = type.to_s
65
+ end
66
+
67
+ def location=(url)
68
+ headers["Location"] = url
69
+ end
70
+
71
+ # :api: private
72
+ def dispatch(name, env)
73
+ @_env = env
74
+ process(name)
75
+ to_a
76
+ end
77
+
78
+ # :api: private
79
+ def to_a
80
+ response ? response.to_a : [status, headers, response_body]
81
+ end
82
+
83
+ class ActionEndpoint
84
+ @@endpoints = Hash.new {|h,k| h[k] = Hash.new {|h,k| h[k] = {} } }
85
+
86
+ def self.for(controller, action, stack)
87
+ @@endpoints[controller][action][stack] ||= begin
88
+ endpoint = new(controller, action)
89
+ stack.build(endpoint)
90
+ end
91
+ end
92
+
93
+ def initialize(controller, action)
94
+ @controller, @action = controller, action
95
+ end
96
+
97
+ def call(env)
98
+ @controller.new.dispatch(@action, env)
99
+ end
100
+ end
101
+
102
+ extlib_inheritable_accessor(:middleware_stack) { ActionDispatch::MiddlewareStack.new }
103
+
104
+ def self.use(*args)
105
+ middleware_stack.use(*args)
106
+ end
107
+
108
+ def self.middleware
109
+ middleware_stack
110
+ end
111
+
112
+ def self.call(env)
113
+ action(env['action_dispatch.request.path_parameters'][:action]).call(env)
114
+ end
115
+
116
+ # Return a rack endpoint for the given action. Memoize the endpoint, so
117
+ # multiple calls into MyController.action will return the same object
118
+ # for the same action.
119
+ #
120
+ # ==== Parameters
121
+ # action<#to_s>:: An action name
122
+ #
123
+ # ==== Returns
124
+ # Proc:: A rack application
125
+ def self.action(name)
126
+ ActionEndpoint.for(self, name, middleware_stack)
127
+ end
128
+ end
129
+ end
@@ -0,0 +1,73 @@
1
+ require 'active_support/core_ext/benchmark'
2
+
3
+ module ActionController #:nodoc:
4
+ # The benchmarking module times the performance of actions and reports to the logger. If the Active Record
5
+ # package has been included, a separate timing section for database calls will be added as well.
6
+ module Benchmarking #:nodoc:
7
+ extend ActiveSupport::Concern
8
+
9
+ protected
10
+ def render(*args, &block)
11
+ if logger
12
+ if Object.const_defined?("ActiveRecord") && ActiveRecord::Base.connected?
13
+ db_runtime = ActiveRecord::Base.connection.reset_runtime
14
+ end
15
+
16
+ render_output = nil
17
+ @view_runtime = Benchmark.ms { render_output = super }
18
+
19
+ if Object.const_defined?("ActiveRecord") && ActiveRecord::Base.connected?
20
+ @db_rt_before_render = db_runtime
21
+ @db_rt_after_render = ActiveRecord::Base.connection.reset_runtime
22
+ @view_runtime -= @db_rt_after_render
23
+ end
24
+
25
+ render_output
26
+ else
27
+ super
28
+ end
29
+ end
30
+
31
+ private
32
+ def process_action(*args)
33
+ if logger
34
+ ms = [Benchmark.ms { super }, 0.01].max
35
+ logging_view = defined?(@view_runtime)
36
+ logging_active_record = Object.const_defined?("ActiveRecord") && ActiveRecord::Base.connected?
37
+
38
+ log_message = 'Completed in %.0fms' % ms
39
+
40
+ if logging_view || logging_active_record
41
+ log_message << " ("
42
+ log_message << view_runtime if logging_view
43
+
44
+ if logging_active_record
45
+ log_message << ", " if logging_view
46
+ log_message << active_record_runtime + ")"
47
+ else
48
+ ")"
49
+ end
50
+ end
51
+
52
+ log_message << " | #{response.status}"
53
+ log_message << " [#{complete_request_uri rescue "unknown"}]"
54
+
55
+ logger.info(log_message)
56
+ response.headers["X-Runtime"] = "%.0f" % ms
57
+ else
58
+ super
59
+ end
60
+ end
61
+
62
+ def view_runtime
63
+ "View: %.0f" % @view_runtime
64
+ end
65
+
66
+ def active_record_runtime
67
+ db_runtime = ActiveRecord::Base.connection.reset_runtime
68
+ db_runtime += @db_rt_before_render if @db_rt_before_render
69
+ db_runtime += @db_rt_after_render if @db_rt_after_render
70
+ "DB: %.0f" % db_runtime
71
+ end
72
+ end
73
+ end
@@ -0,0 +1,145 @@
1
+ module ActionController
2
+ module Rails2Compatibility
3
+ extend ActiveSupport::Concern
4
+
5
+ class ::ActionController::ActionControllerError < StandardError #:nodoc:
6
+ end
7
+
8
+ # Temporary hax
9
+ included do
10
+ ::ActionController::UnknownAction = ::AbstractController::ActionNotFound
11
+ ::ActionController::DoubleRenderError = ::AbstractController::DoubleRenderError
12
+
13
+ cattr_accessor :session_options
14
+ self.session_options = {}
15
+
16
+ cattr_accessor :allow_concurrency
17
+ self.allow_concurrency = false
18
+
19
+ cattr_accessor :relative_url_root
20
+ self.relative_url_root = ENV['RAILS_RELATIVE_URL_ROOT']
21
+
22
+ class << self
23
+ delegate :default_charset=, :to => "ActionDispatch::Response"
24
+ end
25
+
26
+ # cattr_reader :protected_instance_variables
27
+ cattr_accessor :protected_instance_variables
28
+ self.protected_instance_variables = %w(@assigns @performed_redirect @performed_render
29
+ @variables_added @request_origin @url
30
+ @parent_controller @action_name
31
+ @before_filter_chain_aborted @_headers @_params
32
+ @_flash @_response)
33
+
34
+ # Indicates whether or not optimise the generated named
35
+ # route helper methods
36
+ cattr_accessor :optimise_named_routes
37
+ self.optimise_named_routes = true
38
+
39
+ cattr_accessor :resources_path_names
40
+ self.resources_path_names = { :new => 'new', :edit => 'edit' }
41
+
42
+ # Controls the resource action separator
43
+ cattr_accessor :resource_action_separator
44
+ self.resource_action_separator = "/"
45
+
46
+ cattr_accessor :use_accept_header
47
+ self.use_accept_header = true
48
+
49
+ cattr_accessor :page_cache_directory
50
+ self.page_cache_directory = defined?(Rails.public_path) ? Rails.public_path : ""
51
+
52
+ cattr_reader :cache_store
53
+
54
+ cattr_accessor :consider_all_requests_local
55
+ self.consider_all_requests_local = true
56
+
57
+ # Prepends all the URL-generating helpers from AssetHelper. This makes it possible to easily move javascripts, stylesheets,
58
+ # and images to a dedicated asset server away from the main web server. Example:
59
+ # ActionController::Base.asset_host = "http://assets.example.com"
60
+ cattr_accessor :asset_host
61
+
62
+ cattr_accessor :ip_spoofing_check
63
+ self.ip_spoofing_check = true
64
+
65
+ cattr_accessor :trusted_proxies
66
+ end
67
+
68
+ # For old tests
69
+ def initialize_template_class(*) end
70
+ def assign_shortcuts(*) end
71
+
72
+ # TODO: Remove this after we flip
73
+ def template
74
+ @template ||= view_context
75
+ end
76
+
77
+ def process_action(*)
78
+ template
79
+ super
80
+ end
81
+
82
+ module ClassMethods
83
+ def consider_all_requests_local
84
+ end
85
+
86
+ def rescue_action(env)
87
+ raise env["action_dispatch.rescue.exception"]
88
+ end
89
+
90
+ # Defines the storage option for cached fragments
91
+ def cache_store=(store_option)
92
+ @@cache_store = ActiveSupport::Cache.lookup_store(store_option)
93
+ end
94
+ end
95
+
96
+ def render_to_body(options)
97
+ if options.is_a?(Hash) && options.key?(:template)
98
+ options[:template].sub!(/^\//, '')
99
+ end
100
+
101
+ options[:text] = nil if options.delete(:nothing) == true
102
+ options[:text] = " " if options.key?(:text) && options[:text].nil?
103
+
104
+ super || " "
105
+ end
106
+
107
+ def _handle_method_missing
108
+ method_missing(@_action_name.to_sym)
109
+ end
110
+
111
+ def method_for_action(action_name)
112
+ super || (respond_to?(:method_missing) && "_handle_method_missing")
113
+ end
114
+
115
+ def _find_layout(name, details)
116
+ details[:prefix] = nil if name =~ /\blayouts/
117
+ super
118
+ end
119
+
120
+ # Move this into a "don't run in production" module
121
+ def _default_layout(details, require_layout = false)
122
+ super
123
+ rescue ActionView::MissingTemplate
124
+ _find_layout(_layout({}), {})
125
+ nil
126
+ end
127
+
128
+ def performed?
129
+ response_body
130
+ end
131
+
132
+ # ==== Request only view path switching ====
133
+ def append_view_path(path)
134
+ view_paths.push(*path)
135
+ end
136
+
137
+ def prepend_view_path(path)
138
+ view_paths.unshift(*path)
139
+ end
140
+
141
+ def view_paths
142
+ view_context.view_paths
143
+ end
144
+ end
145
+ end