actionpack 3.0.20 → 3.1.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of actionpack might be problematic. Click here for more details.
- data/CHANGELOG +88 -142
- data/MIT-LICENSE +1 -1
- data/README.rdoc +5 -6
- data/lib/abstract_controller.rb +1 -0
- data/lib/abstract_controller/asset_paths.rb +2 -2
- data/lib/abstract_controller/base.rb +24 -19
- data/lib/abstract_controller/callbacks.rb +19 -19
- data/lib/abstract_controller/helpers.rb +11 -13
- data/lib/abstract_controller/layouts.rb +4 -5
- data/lib/abstract_controller/railties/routes_helpers.rb +18 -0
- data/lib/abstract_controller/rendering.rb +34 -31
- data/lib/abstract_controller/url_for.rb +27 -0
- data/lib/abstract_controller/view_paths.rb +31 -6
- data/lib/action_controller.rb +5 -3
- data/lib/action_controller/base.rb +15 -16
- data/lib/action_controller/caching.rb +2 -2
- data/lib/action_controller/caching/actions.rb +11 -12
- data/lib/action_controller/caching/fragments.rb +41 -19
- data/lib/action_controller/caching/pages.rb +3 -9
- data/lib/action_controller/caching/sweeping.rb +0 -1
- data/lib/action_controller/deprecated.rb +1 -1
- data/lib/action_controller/log_subscriber.rb +1 -1
- data/lib/action_controller/metal.rb +78 -20
- data/lib/action_controller/metal/compatibility.rb +0 -9
- data/lib/action_controller/metal/conditional_get.rb +9 -9
- data/lib/action_controller/metal/data_streaming.rb +145 -0
- data/lib/action_controller/metal/force_ssl.rb +35 -0
- data/lib/action_controller/metal/head.rb +1 -1
- data/lib/action_controller/metal/helpers.rb +37 -44
- data/lib/action_controller/metal/hide_actions.rb +2 -3
- data/lib/action_controller/metal/http_authentication.rb +41 -38
- data/lib/action_controller/metal/implicit_render.rb +13 -13
- data/lib/action_controller/metal/instrumentation.rb +2 -2
- data/lib/action_controller/metal/mime_responds.rb +25 -19
- data/lib/action_controller/metal/params_wrapper.rb +224 -0
- data/lib/action_controller/metal/redirecting.rb +6 -2
- data/lib/action_controller/metal/renderers.rb +50 -36
- data/lib/action_controller/metal/rendering.rb +34 -25
- data/lib/action_controller/metal/request_forgery_protection.rb +18 -36
- data/lib/action_controller/metal/responder.rb +47 -12
- data/lib/action_controller/metal/streaming.rb +244 -138
- data/lib/action_controller/metal/testing.rb +0 -9
- data/lib/action_controller/metal/url_for.rb +12 -14
- data/lib/action_controller/railtie.rb +19 -37
- data/lib/action_controller/railties/paths.rb +24 -0
- data/lib/action_controller/record_identifier.rb +4 -10
- data/lib/action_controller/test_case.rb +36 -19
- data/lib/action_controller/vendor/html-scanner/html/node.rb +5 -5
- data/lib/action_controller/vendor/html-scanner/html/sanitizer.rb +3 -3
- data/lib/action_controller/vendor/html-scanner/html/selector.rb +2 -0
- data/lib/action_dispatch.rb +4 -1
- data/lib/action_dispatch/http/cache.rb +5 -32
- data/lib/action_dispatch/http/filter_parameters.rb +3 -1
- data/lib/action_dispatch/http/mime_negotiation.rb +22 -3
- data/lib/action_dispatch/http/mime_type.rb +45 -5
- data/lib/action_dispatch/http/rack_cache.rb +58 -0
- data/lib/action_dispatch/http/request.rb +27 -41
- data/lib/action_dispatch/http/response.rb +56 -54
- data/lib/action_dispatch/http/upload.rb +1 -11
- data/lib/action_dispatch/http/url.rb +102 -42
- data/lib/action_dispatch/middleware/callbacks.rb +8 -25
- data/lib/action_dispatch/middleware/closed_error.rb +7 -0
- data/lib/action_dispatch/middleware/cookies.rb +37 -15
- data/lib/action_dispatch/middleware/flash.rb +80 -11
- data/lib/action_dispatch/middleware/params_parser.rb +2 -2
- data/lib/action_dispatch/middleware/reloader.rb +76 -0
- data/lib/action_dispatch/middleware/session/abstract_store.rb +56 -226
- data/lib/action_dispatch/middleware/session/cookie_store.rb +20 -44
- data/lib/action_dispatch/middleware/session/mem_cache_store.rb +7 -46
- data/lib/action_dispatch/middleware/show_exceptions.rb +15 -2
- data/lib/action_dispatch/middleware/stack.rb +50 -17
- data/lib/action_dispatch/middleware/static.rb +41 -29
- data/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb +3 -3
- data/lib/action_dispatch/middleware/templates/rescues/_trace.erb +3 -3
- data/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb +3 -3
- data/lib/action_dispatch/middleware/templates/rescues/layout.erb +4 -2
- data/lib/action_dispatch/middleware/templates/rescues/template_error.erb +2 -6
- data/lib/action_dispatch/railtie.rb +8 -0
- data/lib/action_dispatch/routing.rb +13 -1
- data/lib/action_dispatch/routing/mapper.rb +345 -227
- data/lib/action_dispatch/routing/polymorphic_routes.rb +33 -13
- data/lib/action_dispatch/routing/redirection.rb +110 -0
- data/lib/action_dispatch/routing/route.rb +15 -13
- data/lib/action_dispatch/routing/route_set.rb +116 -90
- data/lib/action_dispatch/routing/routes_proxy.rb +35 -0
- data/lib/action_dispatch/routing/url_for.rb +25 -1
- data/lib/action_dispatch/testing/assertions/response.rb +8 -10
- data/lib/action_dispatch/testing/assertions/routing.rb +15 -15
- data/lib/action_dispatch/testing/assertions/selector.rb +13 -220
- data/lib/action_dispatch/testing/integration.rb +37 -28
- data/lib/action_dispatch/testing/performance_test.rb +1 -3
- data/lib/action_dispatch/testing/test_process.rb +1 -1
- data/lib/action_dispatch/testing/test_request.rb +9 -3
- data/lib/action_dispatch/testing/test_response.rb +4 -111
- data/lib/action_pack.rb +1 -1
- data/lib/action_pack/version.rb +3 -3
- data/lib/action_view.rb +39 -24
- data/lib/action_view/base.rb +61 -86
- data/lib/action_view/buffers.rb +43 -0
- data/lib/action_view/context.rb +21 -24
- data/lib/action_view/flows.rb +79 -0
- data/lib/action_view/helpers.rb +8 -6
- data/lib/action_view/helpers/active_model_helper.rb +0 -23
- data/lib/action_view/helpers/asset_paths.rb +79 -0
- data/lib/action_view/helpers/asset_tag_helper.rb +30 -500
- data/lib/action_view/helpers/asset_tag_helpers/asset_include_tag.rb +147 -0
- data/lib/action_view/helpers/asset_tag_helpers/asset_paths.rb +101 -0
- data/lib/action_view/helpers/asset_tag_helpers/javascript_tag_helpers.rb +200 -0
- data/lib/action_view/helpers/asset_tag_helpers/stylesheet_tag_helpers.rb +152 -0
- data/lib/action_view/helpers/atom_feed_helper.rb +2 -2
- data/lib/action_view/helpers/cache_helper.rb +11 -19
- data/lib/action_view/helpers/capture_helper.rb +19 -8
- data/lib/action_view/helpers/controller_helper.rb +21 -0
- data/lib/action_view/helpers/csrf_helper.rb +22 -4
- data/lib/action_view/helpers/date_helper.rb +36 -22
- data/lib/action_view/helpers/form_helper.rb +199 -113
- data/lib/action_view/helpers/form_options_helper.rb +10 -11
- data/lib/action_view/helpers/form_tag_helper.rb +94 -22
- data/lib/action_view/helpers/javascript_helper.rb +24 -107
- data/lib/action_view/helpers/number_helper.rb +36 -33
- data/lib/action_view/helpers/output_safety_helper.rb +38 -0
- data/lib/action_view/helpers/record_tag_helper.rb +6 -6
- data/lib/action_view/helpers/rendering_helper.rb +90 -0
- data/lib/action_view/helpers/sanitize_helper.rb +2 -2
- data/lib/action_view/helpers/sprockets_helper.rb +69 -0
- data/lib/action_view/helpers/tag_helper.rb +34 -12
- data/lib/action_view/helpers/text_helper.rb +30 -145
- data/lib/action_view/helpers/translation_helper.rb +10 -17
- data/lib/action_view/helpers/url_helper.rb +70 -67
- data/lib/action_view/locale/en.yml +1 -1
- data/lib/action_view/lookup_context.rb +36 -14
- data/lib/action_view/{paths.rb → path_set.rb} +9 -8
- data/lib/action_view/railtie.rb +12 -4
- data/lib/action_view/renderer/abstract_renderer.rb +36 -0
- data/lib/action_view/{render/partials.rb → renderer/partial_renderer.rb} +147 -146
- data/lib/action_view/renderer/renderer.rb +54 -0
- data/lib/action_view/renderer/streaming_template_renderer.rb +106 -0
- data/lib/action_view/renderer/template_renderer.rb +74 -0
- data/lib/action_view/template.rb +91 -54
- data/lib/action_view/template/error.rb +11 -8
- data/lib/action_view/template/handler.rb +9 -1
- data/lib/action_view/template/handlers.rb +9 -9
- data/lib/action_view/template/handlers/builder.rb +4 -4
- data/lib/action_view/template/handlers/erb.rb +21 -41
- data/lib/action_view/template/resolver.rb +171 -57
- data/lib/action_view/template/text.rb +0 -4
- data/lib/action_view/test_case.rb +32 -16
- data/lib/action_view/testing/resolvers.rb +16 -10
- data/lib/sprockets/railtie.rb +100 -0
- metadata +162 -140
- checksums.yaml +0 -7
- data/lib/action_controller/deprecated/base.rb +0 -143
- data/lib/action_controller/deprecated/dispatcher.rb +0 -28
- data/lib/action_controller/deprecated/url_writer.rb +0 -14
- data/lib/action_dispatch/routing/deprecated_mapper.rb +0 -525
- data/lib/action_view/helpers/prototype_helper.rb +0 -851
- data/lib/action_view/helpers/raw_output_helper.rb +0 -18
- data/lib/action_view/helpers/scriptaculous_helper.rb +0 -263
- data/lib/action_view/render/layouts.rb +0 -83
- data/lib/action_view/render/rendering.rb +0 -67
- data/lib/action_view/template/handlers/rjs.rb +0 -17
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'stringio'
|
2
2
|
require 'uri'
|
3
3
|
require 'active_support/core_ext/kernel/singleton_class'
|
4
|
+
require 'active_support/core_ext/object/inclusion'
|
4
5
|
require 'active_support/core_ext/object/try'
|
5
6
|
require 'rack/test'
|
6
7
|
require 'test/unit/assertions'
|
@@ -26,31 +27,31 @@ module ActionDispatch
|
|
26
27
|
# object's <tt>@response</tt> instance variable will point to the same
|
27
28
|
# response object.
|
28
29
|
#
|
29
|
-
# You can also perform POST, PUT, DELETE, and HEAD requests with
|
30
|
-
#
|
30
|
+
# You can also perform POST, PUT, DELETE, and HEAD requests with +#post+,
|
31
|
+
# +#put+, +#delete+, and +#head+.
|
31
32
|
def get(path, parameters = nil, headers = nil)
|
32
33
|
process :get, path, parameters, headers
|
33
34
|
end
|
34
35
|
|
35
|
-
# Performs a POST request with the given parameters. See get
|
36
|
+
# Performs a POST request with the given parameters. See +#get+ for more
|
36
37
|
# details.
|
37
38
|
def post(path, parameters = nil, headers = nil)
|
38
39
|
process :post, path, parameters, headers
|
39
40
|
end
|
40
41
|
|
41
|
-
# Performs a PUT request with the given parameters. See get
|
42
|
+
# Performs a PUT request with the given parameters. See +#get+ for more
|
42
43
|
# details.
|
43
44
|
def put(path, parameters = nil, headers = nil)
|
44
45
|
process :put, path, parameters, headers
|
45
46
|
end
|
46
47
|
|
47
|
-
# Performs a DELETE request with the given parameters. See get
|
48
|
+
# Performs a DELETE request with the given parameters. See +#get+ for
|
48
49
|
# more details.
|
49
50
|
def delete(path, parameters = nil, headers = nil)
|
50
51
|
process :delete, path, parameters, headers
|
51
52
|
end
|
52
53
|
|
53
|
-
# Performs a HEAD request with the given parameters. See get
|
54
|
+
# Performs a HEAD request with the given parameters. See +#get+ for more
|
54
55
|
# details.
|
55
56
|
def head(path, parameters = nil, headers = nil)
|
56
57
|
process :head, path, parameters, headers
|
@@ -59,7 +60,7 @@ module ActionDispatch
|
|
59
60
|
# Performs an XMLHttpRequest request with the given parameters, mirroring
|
60
61
|
# a request from the Prototype library.
|
61
62
|
#
|
62
|
-
# The request_method is
|
63
|
+
# The request_method is +:get+, +:post+, +:put+, +:delete+ or +:head+; the
|
63
64
|
# parameters are +nil+, a hash, or a url-encoded or multipart string;
|
64
65
|
# the headers are a hash. Keys are automatically upcased and prefixed
|
65
66
|
# with 'HTTP_' if not already.
|
@@ -171,6 +172,7 @@ module ActionDispatch
|
|
171
172
|
|
172
173
|
# Create and initialize a new Session instance.
|
173
174
|
def initialize(app)
|
175
|
+
super()
|
174
176
|
@app = app
|
175
177
|
|
176
178
|
# If the app is a Rails app, make url_helpers available on the session
|
@@ -182,6 +184,7 @@ module ActionDispatch
|
|
182
184
|
reset!
|
183
185
|
end
|
184
186
|
|
187
|
+
remove_method :default_url_options
|
185
188
|
def default_url_options
|
186
189
|
{ :host => host, :protocol => https? ? "https" : "http" }
|
187
190
|
end
|
@@ -233,9 +236,7 @@ module ActionDispatch
|
|
233
236
|
# Set the host name to use in the next request.
|
234
237
|
#
|
235
238
|
# session.host! "www.example.com"
|
236
|
-
|
237
|
-
@host = name
|
238
|
-
end
|
239
|
+
alias :host! :host=
|
239
240
|
|
240
241
|
private
|
241
242
|
def _mock_session
|
@@ -243,7 +244,8 @@ module ActionDispatch
|
|
243
244
|
end
|
244
245
|
|
245
246
|
# Performs the actual request.
|
246
|
-
def process(method, path, parameters = nil,
|
247
|
+
def process(method, path, parameters = nil, env = nil)
|
248
|
+
env ||= {}
|
247
249
|
if path =~ %r{://}
|
248
250
|
location = URI.parse(path)
|
249
251
|
https! URI::HTTPS === location if location.scheme
|
@@ -259,7 +261,7 @@ module ActionDispatch
|
|
259
261
|
|
260
262
|
hostname, port = host.split(':')
|
261
263
|
|
262
|
-
|
264
|
+
default_env = {
|
263
265
|
:method => method,
|
264
266
|
:params => parameters,
|
265
267
|
|
@@ -277,9 +279,7 @@ module ActionDispatch
|
|
277
279
|
|
278
280
|
session = Rack::Test::Session.new(_mock_session)
|
279
281
|
|
280
|
-
(
|
281
|
-
env[key] = value
|
282
|
-
end
|
282
|
+
env.reverse_merge!(default_env)
|
283
283
|
|
284
284
|
# NOTE: rack-test v0.5 doesn't build a default uri correctly
|
285
285
|
# Make sure requested path is always a full uri
|
@@ -307,7 +307,7 @@ module ActionDispatch
|
|
307
307
|
include ActionDispatch::Assertions
|
308
308
|
|
309
309
|
def app
|
310
|
-
@app
|
310
|
+
@app ||= nil
|
311
311
|
end
|
312
312
|
|
313
313
|
# Reset the current session. This is useful for testing multiple sessions
|
@@ -319,10 +319,10 @@ module ActionDispatch
|
|
319
319
|
%w(get post put head delete cookies assigns
|
320
320
|
xml_http_request xhr get_via_redirect post_via_redirect).each do |method|
|
321
321
|
define_method(method) do |*args|
|
322
|
-
reset! unless
|
322
|
+
reset! unless integration_session
|
323
323
|
# reset the html_document variable, but only for new get/post calls
|
324
|
-
@html_document = nil unless
|
325
|
-
|
324
|
+
@html_document = nil unless method.in?(["cookies", "assigns"])
|
325
|
+
integration_session.__send__(method, *args).tap do
|
326
326
|
copy_session_variables!
|
327
327
|
end
|
328
328
|
end
|
@@ -347,7 +347,7 @@ module ActionDispatch
|
|
347
347
|
# Copy the instance variables from the current session instance into the
|
348
348
|
# test instance.
|
349
349
|
def copy_session_variables! #:nodoc:
|
350
|
-
return unless
|
350
|
+
return unless integration_session
|
351
351
|
%w(controller response request).each do |var|
|
352
352
|
instance_variable_set("@#{var}", @integration_session.__send__(var))
|
353
353
|
end
|
@@ -357,25 +357,34 @@ module ActionDispatch
|
|
357
357
|
include ActionDispatch::Routing::UrlFor
|
358
358
|
|
359
359
|
def url_options
|
360
|
-
reset! unless
|
361
|
-
|
360
|
+
reset! unless integration_session
|
361
|
+
integration_session.url_options
|
362
|
+
end
|
363
|
+
|
364
|
+
def respond_to?(method, include_private = false)
|
365
|
+
integration_session.respond_to?(method, include_private) || super
|
362
366
|
end
|
363
367
|
|
364
368
|
# Delegate unhandled messages to the current session instance.
|
365
369
|
def method_missing(sym, *args, &block)
|
366
|
-
reset! unless
|
367
|
-
if
|
368
|
-
|
370
|
+
reset! unless integration_session
|
371
|
+
if integration_session.respond_to?(sym)
|
372
|
+
integration_session.__send__(sym, *args, &block).tap do
|
369
373
|
copy_session_variables!
|
370
374
|
end
|
371
375
|
else
|
372
376
|
super
|
373
377
|
end
|
374
378
|
end
|
379
|
+
|
380
|
+
private
|
381
|
+
def integration_session
|
382
|
+
@integration_session ||= nil
|
383
|
+
end
|
375
384
|
end
|
376
385
|
end
|
377
386
|
|
378
|
-
# An test
|
387
|
+
# An integration test spans multiple controllers and actions,
|
379
388
|
# tying them all together to ensure they work together as expected. It tests
|
380
389
|
# more completely than either unit or functional tests do, exercising the
|
381
390
|
# entire stack, from the dispatcher to the database.
|
@@ -385,7 +394,7 @@ module ActionDispatch
|
|
385
394
|
#
|
386
395
|
# require "test_helper"
|
387
396
|
#
|
388
|
-
# class ExampleTest <
|
397
|
+
# class ExampleTest < ActionDispatch::IntegrationTest
|
389
398
|
# fixtures :people
|
390
399
|
#
|
391
400
|
# def test_login
|
@@ -409,7 +418,7 @@ module ActionDispatch
|
|
409
418
|
#
|
410
419
|
# require "test_helper"
|
411
420
|
#
|
412
|
-
# class AdvancedTest <
|
421
|
+
# class AdvancedTest < ActionDispatch::IntegrationTest
|
413
422
|
# fixtures :people, :rooms
|
414
423
|
#
|
415
424
|
# def test_login_and_speak
|
@@ -1,5 +1,4 @@
|
|
1
1
|
require 'active_support/testing/performance'
|
2
|
-
require 'active_support/testing/default'
|
3
2
|
|
4
3
|
begin
|
5
4
|
module ActionDispatch
|
@@ -11,9 +10,8 @@ begin
|
|
11
10
|
# formats are written, so you'll have two output files per test method.
|
12
11
|
class PerformanceTest < ActionDispatch::IntegrationTest
|
13
12
|
include ActiveSupport::Testing::Performance
|
14
|
-
include ActiveSupport::Testing::Default
|
15
13
|
end
|
16
14
|
end
|
17
15
|
rescue NameError
|
18
16
|
$stderr.puts "Specify ruby-prof as application's dependency in Gemfile to run benchmarks."
|
19
|
-
end
|
17
|
+
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'active_support/core_ext/object/blank'
|
2
2
|
require 'active_support/core_ext/hash/reverse_merge'
|
3
|
+
require 'rack/utils'
|
3
4
|
|
4
5
|
module ActionDispatch
|
5
6
|
class TestRequest < Request
|
@@ -10,9 +11,10 @@ module ActionDispatch
|
|
10
11
|
end
|
11
12
|
|
12
13
|
def initialize(env = {})
|
13
|
-
env = Rails.application.
|
14
|
+
env = Rails.application.env_config.merge(env) if defined?(Rails.application)
|
14
15
|
super(DEFAULT_ENV.merge(env))
|
15
16
|
|
17
|
+
@cookies = nil
|
16
18
|
self.host = 'test.host'
|
17
19
|
self.remote_addr = '0.0.0.0'
|
18
20
|
self.user_agent = 'Rails Testing'
|
@@ -66,7 +68,7 @@ module ActionDispatch
|
|
66
68
|
|
67
69
|
def accept=(mime_types)
|
68
70
|
@env.delete('action_dispatch.request.accepts')
|
69
|
-
@env['HTTP_ACCEPT'] = Array(mime_types).collect { |
|
71
|
+
@env['HTTP_ACCEPT'] = Array(mime_types).collect { |mime_type| mime_type.to_s }.join(",")
|
70
72
|
end
|
71
73
|
|
72
74
|
def cookies
|
@@ -76,10 +78,14 @@ module ActionDispatch
|
|
76
78
|
private
|
77
79
|
def write_cookies!
|
78
80
|
unless @cookies.blank?
|
79
|
-
@env['HTTP_COOKIE'] = @cookies.map { |name, value|
|
81
|
+
@env['HTTP_COOKIE'] = @cookies.map { |name, value| escape_cookie(name, value) }.join('; ')
|
80
82
|
end
|
81
83
|
end
|
82
84
|
|
85
|
+
def escape_cookie(name, value)
|
86
|
+
"#{Rack::Utils.escape(name)}=#{Rack::Utils.escape(value)}"
|
87
|
+
end
|
88
|
+
|
83
89
|
def delete_nil_values!
|
84
90
|
@env.delete_if { |k, v| v.nil? }
|
85
91
|
end
|
@@ -14,123 +14,16 @@ module ActionDispatch
|
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
|
-
module DeprecatedHelpers
|
18
|
-
def template
|
19
|
-
ActiveSupport::Deprecation.warn("response.template has been deprecated. Use controller.template instead", caller)
|
20
|
-
@template
|
21
|
-
end
|
22
|
-
attr_writer :template
|
23
|
-
|
24
|
-
def session
|
25
|
-
ActiveSupport::Deprecation.warn("response.session has been deprecated. Use request.session instead", caller)
|
26
|
-
@request.session
|
27
|
-
end
|
28
|
-
|
29
|
-
def assigns
|
30
|
-
ActiveSupport::Deprecation.warn("response.assigns has been deprecated. Use controller.assigns instead", caller)
|
31
|
-
@template.controller.assigns
|
32
|
-
end
|
33
|
-
|
34
|
-
def layout
|
35
|
-
ActiveSupport::Deprecation.warn("response.layout has been deprecated. Use template.layout instead", caller)
|
36
|
-
@template.layout
|
37
|
-
end
|
38
|
-
|
39
|
-
def redirected_to
|
40
|
-
::ActiveSupport::Deprecation.warn("response.redirected_to is deprecated. Use response.redirect_url instead", caller)
|
41
|
-
redirect_url
|
42
|
-
end
|
43
|
-
|
44
|
-
def redirect_url_match?(pattern)
|
45
|
-
::ActiveSupport::Deprecation.warn("response.redirect_url_match? is deprecated. Use assert_match(/foo/, response.redirect_url) instead", caller)
|
46
|
-
return false if redirect_url.nil?
|
47
|
-
p = Regexp.new(pattern) if pattern.class == String
|
48
|
-
p = pattern if pattern.class == Regexp
|
49
|
-
return false if p.nil?
|
50
|
-
p.match(redirect_url) != nil
|
51
|
-
end
|
52
|
-
|
53
|
-
# Returns the template of the file which was used to
|
54
|
-
# render this response (or nil)
|
55
|
-
def rendered
|
56
|
-
ActiveSupport::Deprecation.warn("response.rendered has been deprecated. Use template.rendered instead", caller)
|
57
|
-
@template.instance_variable_get(:@_rendered)
|
58
|
-
end
|
59
|
-
|
60
|
-
# A shortcut to the flash. Returns an empty hash if no session flash exists.
|
61
|
-
def flash
|
62
|
-
ActiveSupport::Deprecation.warn("response.flash has been deprecated. Use request.flash instead", caller)
|
63
|
-
request.session['flash'] || {}
|
64
|
-
end
|
65
|
-
|
66
|
-
# Do we have a flash?
|
67
|
-
def has_flash?
|
68
|
-
ActiveSupport::Deprecation.warn("response.has_flash? has been deprecated. Use flash.any? instead", caller)
|
69
|
-
!flash.empty?
|
70
|
-
end
|
71
|
-
|
72
|
-
# Do we have a flash that has contents?
|
73
|
-
def has_flash_with_contents?
|
74
|
-
ActiveSupport::Deprecation.warn("response.has_flash_with_contents? has been deprecated. Use flash.any? instead", caller)
|
75
|
-
!flash.empty?
|
76
|
-
end
|
77
|
-
|
78
|
-
# Does the specified flash object exist?
|
79
|
-
def has_flash_object?(name=nil)
|
80
|
-
ActiveSupport::Deprecation.warn("response.has_flash_object? has been deprecated. Use flash[name] instead", caller)
|
81
|
-
!flash[name].nil?
|
82
|
-
end
|
83
|
-
|
84
|
-
# Does the specified object exist in the session?
|
85
|
-
def has_session_object?(name=nil)
|
86
|
-
ActiveSupport::Deprecation.warn("response.has_session_object? has been deprecated. Use session[name] instead", caller)
|
87
|
-
!session[name].nil?
|
88
|
-
end
|
89
|
-
|
90
|
-
# A shortcut to the template.assigns
|
91
|
-
def template_objects
|
92
|
-
ActiveSupport::Deprecation.warn("response.template_objects has been deprecated. Use template.assigns instead", caller)
|
93
|
-
@template.assigns || {}
|
94
|
-
end
|
95
|
-
|
96
|
-
# Does the specified template object exist?
|
97
|
-
def has_template_object?(name=nil)
|
98
|
-
ActiveSupport::Deprecation.warn("response.has_template_object? has been deprecated. Use tempate.assigns[name].nil? instead", caller)
|
99
|
-
!template_objects[name].nil?
|
100
|
-
end
|
101
|
-
|
102
|
-
# Returns binary content (downloadable file), converted to a String
|
103
|
-
def binary_content
|
104
|
-
ActiveSupport::Deprecation.warn("response.binary_content has been deprecated. Use response.body instead", caller)
|
105
|
-
body
|
106
|
-
end
|
107
|
-
end
|
108
|
-
include DeprecatedHelpers
|
109
|
-
|
110
17
|
# Was the response successful?
|
111
|
-
|
112
|
-
(200..299).include?(response_code)
|
113
|
-
end
|
18
|
+
alias_method :success?, :successful?
|
114
19
|
|
115
20
|
# Was the URL not found?
|
116
|
-
|
117
|
-
response_code == 404
|
118
|
-
end
|
21
|
+
alias_method :missing?, :not_found?
|
119
22
|
|
120
23
|
# Were we redirected?
|
121
|
-
|
122
|
-
(300..399).include?(response_code)
|
123
|
-
end
|
24
|
+
alias_method :redirect?, :redirection?
|
124
25
|
|
125
26
|
# Was there a server-side error?
|
126
|
-
|
127
|
-
(500..599).include?(response_code)
|
128
|
-
end
|
129
|
-
alias_method :server_error?, :error?
|
130
|
-
|
131
|
-
# Was there a client client?
|
132
|
-
def client_error?
|
133
|
-
(400..499).include?(response_code)
|
134
|
-
end
|
27
|
+
alias_method :error?, :server_error?
|
135
28
|
end
|
136
29
|
end
|
data/lib/action_pack.rb
CHANGED
data/lib/action_pack/version.rb
CHANGED
data/lib/action_view.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
#--
|
2
|
-
# Copyright (c) 2004-
|
2
|
+
# Copyright (c) 2004-2011 David Heinemeier Hansson
|
3
3
|
#
|
4
4
|
# Permission is hereby granted, free of charge, to any person obtaining
|
5
5
|
# a copy of this software and associated documentation files (the
|
@@ -21,9 +21,6 @@
|
|
21
21
|
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
22
|
#++
|
23
23
|
|
24
|
-
activesupport_path = File.expand_path('../../../activesupport/lib', __FILE__)
|
25
|
-
$:.unshift(activesupport_path) if File.directory?(activesupport_path) && !$:.include?(activesupport_path)
|
26
|
-
|
27
24
|
require 'active_support/ruby/shim'
|
28
25
|
require 'active_support/core_ext/class/attribute_accessors'
|
29
26
|
|
@@ -33,34 +30,52 @@ module ActionView
|
|
33
30
|
extend ActiveSupport::Autoload
|
34
31
|
|
35
32
|
eager_autoload do
|
33
|
+
autoload :Base
|
36
34
|
autoload :Context
|
37
|
-
autoload :Template
|
38
35
|
autoload :Helpers
|
36
|
+
autoload :LookupContext
|
37
|
+
autoload :PathSet
|
38
|
+
autoload :Template
|
39
|
+
autoload :TestCase
|
39
40
|
|
40
|
-
autoload_under "
|
41
|
-
autoload :
|
42
|
-
autoload :
|
43
|
-
autoload :
|
41
|
+
autoload_under "renderer" do
|
42
|
+
autoload :Renderer
|
43
|
+
autoload :AbstractRenderer
|
44
|
+
autoload :PartialRenderer
|
45
|
+
autoload :TemplateRenderer
|
46
|
+
autoload :StreamingTemplateRenderer
|
44
47
|
end
|
45
48
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
49
|
+
autoload_at "action_view/template/resolver" do
|
50
|
+
autoload :Resolver
|
51
|
+
autoload :PathResolver
|
52
|
+
autoload :FileSystemResolver
|
53
|
+
autoload :FallbackFileSystemResolver
|
54
|
+
end
|
52
55
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
autoload :WrongEncodingError, 'action_view/template/error'
|
56
|
+
autoload_at "action_view/buffers" do
|
57
|
+
autoload :OutputBuffer
|
58
|
+
autoload :StreamingBuffer
|
59
|
+
end
|
58
60
|
|
59
|
-
|
60
|
-
|
61
|
-
|
61
|
+
autoload_at "action_view/flows" do
|
62
|
+
autoload :OutputFlow
|
63
|
+
autoload :StreamingFlow
|
64
|
+
end
|
62
65
|
|
63
|
-
|
66
|
+
autoload_at "action_view/template/error" do
|
67
|
+
autoload :MissingTemplate
|
68
|
+
autoload :ActionViewError
|
69
|
+
autoload :EncodingError
|
70
|
+
autoload :TemplateError
|
71
|
+
autoload :WrongEncodingError
|
72
|
+
end
|
73
|
+
|
74
|
+
autoload_at "action_view/template" do
|
75
|
+
autoload :TemplateHandler
|
76
|
+
autoload :TemplateHandlers
|
77
|
+
end
|
78
|
+
end
|
64
79
|
|
65
80
|
ENCODING_FLAG = '#.*coding[:=]\s*(\S+)[ \t]*'
|
66
81
|
end
|