actionpack 4.1.7 → 4.2.1

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.

Files changed (106) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +311 -527
  3. data/README.rdoc +7 -2
  4. data/lib/abstract_controller/base.rb +16 -6
  5. data/lib/abstract_controller/callbacks.rb +28 -51
  6. data/lib/abstract_controller/helpers.rb +11 -4
  7. data/lib/abstract_controller/railties/routes_helpers.rb +3 -3
  8. data/lib/abstract_controller/url_for.rb +1 -1
  9. data/lib/action_controller/base.rb +2 -1
  10. data/lib/action_controller/caching/fragments.rb +7 -1
  11. data/lib/action_controller/caching.rb +1 -1
  12. data/lib/action_controller/log_subscriber.rb +26 -26
  13. data/lib/action_controller/metal/conditional_get.rb +37 -12
  14. data/lib/action_controller/metal/etag_with_template_digest.rb +50 -0
  15. data/lib/action_controller/metal/exceptions.rb +1 -1
  16. data/lib/action_controller/metal/force_ssl.rb +1 -1
  17. data/lib/action_controller/metal/head.rb +7 -3
  18. data/lib/action_controller/metal/http_authentication.rb +14 -9
  19. data/lib/action_controller/metal/instrumentation.rb +8 -5
  20. data/lib/action_controller/metal/live.rb +57 -6
  21. data/lib/action_controller/metal/mime_responds.rb +23 -246
  22. data/lib/action_controller/metal/params_wrapper.rb +2 -2
  23. data/lib/action_controller/metal/rack_delegation.rb +1 -1
  24. data/lib/action_controller/metal/redirecting.rb +14 -8
  25. data/lib/action_controller/metal/renderers.rb +30 -10
  26. data/lib/action_controller/metal/rendering.rb +2 -6
  27. data/lib/action_controller/metal/request_forgery_protection.rb +78 -7
  28. data/lib/action_controller/metal/streaming.rb +1 -1
  29. data/lib/action_controller/metal/strong_parameters.rb +125 -12
  30. data/lib/action_controller/metal/url_for.rb +11 -12
  31. data/lib/action_controller/metal.rb +12 -11
  32. data/lib/action_controller/model_naming.rb +1 -1
  33. data/lib/action_controller/railtie.rb +4 -0
  34. data/lib/action_controller/test_case.rb +112 -75
  35. data/lib/action_controller.rb +1 -1
  36. data/lib/action_dispatch/http/cache.rb +5 -4
  37. data/lib/action_dispatch/http/filter_parameters.rb +2 -2
  38. data/lib/action_dispatch/http/headers.rb +43 -9
  39. data/lib/action_dispatch/http/mime_negotiation.rb +10 -3
  40. data/lib/action_dispatch/http/mime_type.rb +2 -2
  41. data/lib/action_dispatch/http/parameter_filter.rb +1 -1
  42. data/lib/action_dispatch/http/parameters.rb +11 -26
  43. data/lib/action_dispatch/http/request.rb +37 -11
  44. data/lib/action_dispatch/http/response.rb +70 -18
  45. data/lib/action_dispatch/http/upload.rb +3 -8
  46. data/lib/action_dispatch/http/url.rb +88 -69
  47. data/lib/action_dispatch/journey/formatter.rb +33 -17
  48. data/lib/action_dispatch/journey/gtg/builder.rb +3 -3
  49. data/lib/action_dispatch/journey/gtg/simulator.rb +10 -7
  50. data/lib/action_dispatch/journey/gtg/transition_table.rb +20 -28
  51. data/lib/action_dispatch/journey/nfa/dot.rb +2 -2
  52. data/lib/action_dispatch/journey/nfa/simulator.rb +1 -1
  53. data/lib/action_dispatch/journey/nfa/transition_table.rb +5 -5
  54. data/lib/action_dispatch/journey/nodes/node.rb +4 -0
  55. data/lib/action_dispatch/journey/parser.rb +52 -60
  56. data/lib/action_dispatch/journey/parser.y +11 -10
  57. data/lib/action_dispatch/journey/path/pattern.rb +16 -19
  58. data/lib/action_dispatch/journey/route.rb +3 -18
  59. data/lib/action_dispatch/journey/router/strexp.rb +9 -6
  60. data/lib/action_dispatch/journey/router.rb +53 -77
  61. data/lib/action_dispatch/journey/scanner.rb +5 -5
  62. data/lib/action_dispatch/journey/visitors.rb +81 -92
  63. data/lib/action_dispatch/journey/visualizer/fsm.css +0 -4
  64. data/lib/action_dispatch/journey/visualizer/index.html.erb +2 -2
  65. data/lib/action_dispatch/middleware/callbacks.rb +1 -1
  66. data/lib/action_dispatch/middleware/cookies.rb +29 -29
  67. data/lib/action_dispatch/middleware/debug_exceptions.rb +15 -4
  68. data/lib/action_dispatch/middleware/exception_wrapper.rb +50 -18
  69. data/lib/action_dispatch/middleware/flash.rb +13 -7
  70. data/lib/action_dispatch/middleware/params_parser.rb +1 -1
  71. data/lib/action_dispatch/middleware/public_exceptions.rb +12 -3
  72. data/lib/action_dispatch/middleware/remote_ip.rb +40 -54
  73. data/lib/action_dispatch/middleware/request_id.rb +1 -1
  74. data/lib/action_dispatch/middleware/session/cookie_store.rb +1 -1
  75. data/lib/action_dispatch/middleware/show_exceptions.rb +1 -0
  76. data/lib/action_dispatch/middleware/static.rb +66 -37
  77. data/lib/action_dispatch/middleware/templates/rescues/_source.erb +21 -19
  78. data/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb +37 -9
  79. data/lib/action_dispatch/middleware/templates/rescues/_trace.text.erb +2 -8
  80. data/lib/action_dispatch/middleware/templates/rescues/{diagnostics.erb → diagnostics.html.erb} +0 -0
  81. data/lib/action_dispatch/middleware/templates/rescues/diagnostics.text.erb +9 -0
  82. data/lib/action_dispatch/middleware/templates/rescues/layout.erb +6 -0
  83. data/lib/action_dispatch/middleware/templates/rescues/missing_template.html.erb +4 -0
  84. data/lib/action_dispatch/middleware/templates/rescues/routing_error.html.erb +2 -0
  85. data/lib/action_dispatch/middleware/templates/rescues/template_error.html.erb +1 -24
  86. data/lib/action_dispatch/middleware/templates/rescues/template_error.text.erb +0 -1
  87. data/lib/action_dispatch/middleware/templates/routes/_table.html.erb +120 -64
  88. data/lib/action_dispatch/routing/endpoint.rb +10 -0
  89. data/lib/action_dispatch/routing/inspector.rb +5 -12
  90. data/lib/action_dispatch/routing/mapper.rb +410 -281
  91. data/lib/action_dispatch/routing/polymorphic_routes.rb +191 -79
  92. data/lib/action_dispatch/routing/redirection.rb +10 -12
  93. data/lib/action_dispatch/routing/route_set.rb +297 -168
  94. data/lib/action_dispatch/routing/url_for.rb +15 -4
  95. data/lib/action_dispatch/testing/assertions/dom.rb +2 -26
  96. data/lib/action_dispatch/testing/assertions/response.rb +2 -7
  97. data/lib/action_dispatch/testing/assertions/routing.rb +22 -22
  98. data/lib/action_dispatch/testing/assertions/selector.rb +2 -429
  99. data/lib/action_dispatch/testing/assertions/tag.rb +2 -134
  100. data/lib/action_dispatch/testing/assertions.rb +11 -7
  101. data/lib/action_dispatch/testing/integration.rb +24 -19
  102. data/lib/action_dispatch/testing/test_request.rb +1 -1
  103. data/lib/action_dispatch/testing/test_response.rb +7 -0
  104. data/lib/action_pack/gem_version.rb +3 -3
  105. metadata +55 -13
  106. data/lib/action_controller/metal/responder.rb +0 -297
@@ -23,25 +23,24 @@ module ActionController
23
23
  include AbstractController::UrlFor
24
24
 
25
25
  def url_options
26
- @_url_options ||= super.reverse_merge(
26
+ @_url_options ||= {
27
27
  :host => request.host,
28
28
  :port => request.optional_port,
29
29
  :protocol => request.protocol,
30
- :_recall => request.symbolized_path_parameters
31
- ).freeze
30
+ :_recall => request.path_parameters
31
+ }.merge!(super).freeze
32
32
 
33
- if (same_origin = _routes.equal?(env["action_dispatch.routes"])) ||
33
+ if (same_origin = _routes.equal?(env["action_dispatch.routes".freeze])) ||
34
34
  (script_name = env["ROUTES_#{_routes.object_id}_SCRIPT_NAME"]) ||
35
- (original_script_name = env['ORIGINAL_SCRIPT_NAME'])
35
+ (original_script_name = env['ORIGINAL_SCRIPT_NAME'.freeze])
36
36
 
37
- @_url_options.dup.tap do |options|
38
- if original_script_name
39
- options[:original_script_name] = original_script_name
40
- else
41
- options[:script_name] = same_origin ? request.script_name.dup : script_name
42
- end
43
- options.freeze
37
+ options = @_url_options.dup
38
+ if original_script_name
39
+ options[:original_script_name] = original_script_name
40
+ else
41
+ options[:script_name] = same_origin ? request.script_name.dup : script_name
44
42
  end
43
+ options.freeze
45
44
  else
46
45
  @_url_options
47
46
  end
@@ -30,10 +30,8 @@ module ActionController
30
30
  end
31
31
  end
32
32
 
33
- def build(action, app=nil, &block)
34
- app ||= block
33
+ def build(action, app = Proc.new)
35
34
  action = action.to_s
36
- raise "MiddlewareStack#build requires an app" unless app
37
35
 
38
36
  middlewares.reverse.inject(app) do |a, middleware|
39
37
  middleware.valid?(action) ? middleware.build(a) : a
@@ -167,7 +165,7 @@ module ActionController
167
165
  headers["Location"] = url
168
166
  end
169
167
 
170
- # basic url_for that can be overridden for more robust functionality
168
+ # Basic url_for that can be overridden for more robust functionality
171
169
  def url_for(string)
172
170
  string
173
171
  end
@@ -175,6 +173,7 @@ module ActionController
175
173
  def status
176
174
  @_status
177
175
  end
176
+ alias :response_code :status # :nodoc:
178
177
 
179
178
  def status=(status)
180
179
  @_status = Rack::Utils.status_code(status)
@@ -185,6 +184,7 @@ module ActionController
185
184
  super
186
185
  end
187
186
 
187
+ # Tests if render or redirect has already happened.
188
188
  def performed?
189
189
  response_body || (response && response.committed?)
190
190
  end
@@ -223,18 +223,19 @@ module ActionController
223
223
  # Makes the controller a Rack endpoint that runs the action in the given
224
224
  # +env+'s +action_dispatch.request.path_parameters+ key.
225
225
  def self.call(env)
226
- action(env['action_dispatch.request.path_parameters'][:action]).call(env)
226
+ req = ActionDispatch::Request.new env
227
+ action(req.path_parameters[:action]).call(env)
227
228
  end
228
229
 
229
230
  # Returns a Rack endpoint for the given action name.
230
231
  def self.action(name, klass = ActionDispatch::Request)
231
- middleware_stack.build(name.to_s) do |env|
232
- new.dispatch(name, klass.new(env))
232
+ if middleware_stack.any?
233
+ middleware_stack.build(name) do |env|
234
+ new.dispatch(name, klass.new(env))
235
+ end
236
+ else
237
+ lambda { |env| new.dispatch(name, klass.new(env)) }
233
238
  end
234
239
  end
235
-
236
- def _status_code
237
- @_status
238
- end
239
240
  end
240
241
  end
@@ -6,7 +6,7 @@ module ActionController
6
6
  end
7
7
 
8
8
  def model_name_from_record_or_class(record_or_class)
9
- (record_or_class.is_a?(Class) ? record_or_class : convert_to_model(record_or_class).class).model_name
9
+ convert_to_model(record_or_class).model_name
10
10
  end
11
11
  end
12
12
  end
@@ -23,6 +23,10 @@ module ActionController
23
23
  options = app.config.action_controller
24
24
 
25
25
  ActionController::Parameters.permit_all_parameters = options.delete(:permit_all_parameters) { false }
26
+ if app.config.action_controller[:always_permitted_parameters]
27
+ ActionController::Parameters.always_permitted_parameters =
28
+ app.config.action_controller.delete(:always_permitted_parameters)
29
+ end
26
30
  ActionController::Parameters.action_on_unpermitted_parameters = options.delete(:action_on_unpermitted_parameters) do
27
31
  (Rails.env.test? || Rails.env.development?) ? :log : false
28
32
  end
@@ -2,6 +2,9 @@ require 'rack/session/abstract/id'
2
2
  require 'active_support/core_ext/object/to_query'
3
3
  require 'active_support/core_ext/module/anonymous'
4
4
  require 'active_support/core_ext/hash/keys'
5
+ require 'active_support/deprecation'
6
+
7
+ require 'rails-dom-testing'
5
8
 
6
9
  module ActionController
7
10
  module TemplateAssertions
@@ -12,13 +15,16 @@ module ActionController
12
15
  teardown :teardown_subscriptions
13
16
  end
14
17
 
18
+ RENDER_TEMPLATE_INSTANCE_VARIABLES = %w{partials templates layouts files}.freeze
19
+
15
20
  def setup_subscriptions
16
- @_partials = Hash.new(0)
17
- @_templates = Hash.new(0)
18
- @_layouts = Hash.new(0)
19
- @_files = Hash.new(0)
21
+ RENDER_TEMPLATE_INSTANCE_VARIABLES.each do |instance_variable|
22
+ instance_variable_set("@_#{instance_variable}", Hash.new(0))
23
+ end
24
+
25
+ @_subscribers = []
20
26
 
21
- ActiveSupport::Notifications.subscribe("render_template.action_view") do |_name, _start, _finish, _id, payload|
27
+ @_subscribers << ActiveSupport::Notifications.subscribe("render_template.action_view") do |_name, _start, _finish, _id, payload|
22
28
  path = payload[:layout]
23
29
  if path
24
30
  @_layouts[path] += 1
@@ -28,42 +34,46 @@ module ActionController
28
34
  end
29
35
  end
30
36
 
31
- ActiveSupport::Notifications.subscribe("!render_template.action_view") do |_name, _start, _finish, _id, payload|
32
- path = payload[:virtual_path]
33
- next unless path
34
- partial = path =~ /^.*\/_[^\/]*$/
37
+ @_subscribers << ActiveSupport::Notifications.subscribe("!render_template.action_view") do |_name, _start, _finish, _id, payload|
38
+ if virtual_path = payload[:virtual_path]
39
+ partial = virtual_path =~ /^.*\/_[^\/]*$/
35
40
 
36
- if partial
37
- @_partials[path] += 1
38
- @_partials[path.split("/").last] += 1
39
- end
40
-
41
- @_templates[path] += 1
42
- end
43
-
44
- ActiveSupport::Notifications.subscribe("!render_template.action_view") do |_name, _start, _finish, _id, payload|
45
- next if payload[:virtual_path] # files don't have virtual path
41
+ if partial
42
+ @_partials[virtual_path] += 1
43
+ @_partials[virtual_path.split("/").last] += 1
44
+ end
46
45
 
47
- path = payload[:identifier]
48
- if path
49
- @_files[path] += 1
50
- @_files[path.split("/").last] += 1
46
+ @_templates[virtual_path] += 1
47
+ else
48
+ path = payload[:identifier]
49
+ if path
50
+ @_files[path] += 1
51
+ @_files[path.split("/").last] += 1
52
+ end
51
53
  end
52
54
  end
53
55
  end
54
56
 
55
57
  def teardown_subscriptions
56
- ActiveSupport::Notifications.unsubscribe("render_template.action_view")
57
- ActiveSupport::Notifications.unsubscribe("!render_template.action_view")
58
+ @_subscribers.each do |subscriber|
59
+ ActiveSupport::Notifications.unsubscribe(subscriber)
60
+ end
58
61
  end
59
62
 
60
63
  def process(*args)
61
- @_partials = Hash.new(0)
62
- @_templates = Hash.new(0)
63
- @_layouts = Hash.new(0)
64
+ reset_template_assertion
64
65
  super
65
66
  end
66
67
 
68
+ def reset_template_assertion
69
+ RENDER_TEMPLATE_INSTANCE_VARIABLES.each do |instance_variable|
70
+ ivar_name = "@_#{instance_variable}"
71
+ if instance_variable_defined?(ivar_name)
72
+ instance_variable_get(ivar_name).clear
73
+ end
74
+ end
75
+ end
76
+
67
77
  # Asserts that the request was rendered with the appropriate template file or partials.
68
78
  #
69
79
  # # assert that the "new" view template was rendered
@@ -87,6 +97,13 @@ module ActionController
87
97
  # # assert that no partials were rendered
88
98
  # assert_template partial: false
89
99
  #
100
+ # # assert that a file was rendered
101
+ # assert_template file: "README.rdoc"
102
+ #
103
+ # # assert that no file was rendered
104
+ # assert_template file: nil
105
+ # assert_template file: false
106
+ #
90
107
  # In a view test case, you can also assert that specific locals are passed
91
108
  # to partials:
92
109
  #
@@ -136,6 +153,8 @@ module ActionController
136
153
 
137
154
  if options[:file]
138
155
  assert_includes @_files.keys, options[:file]
156
+ elsif options.key?(:file)
157
+ assert @_files.blank?, "expected no files but #{@_files.keys} was rendered"
139
158
  end
140
159
 
141
160
  if expected_partial = options[:partial]
@@ -197,7 +216,7 @@ module ActionController
197
216
  value = value.dup
198
217
  end
199
218
 
200
- if extra_keys.include?(key.to_sym)
219
+ if extra_keys.include?(key)
201
220
  non_path_parameters[key] = value
202
221
  else
203
222
  if value.is_a?(Array)
@@ -206,7 +225,7 @@ module ActionController
206
225
  value = value.to_param
207
226
  end
208
227
 
209
- path_parameters[key.to_s] = value
228
+ path_parameters[key] = value
210
229
  end
211
230
  end
212
231
 
@@ -231,7 +250,6 @@ module ActionController
231
250
  @formats = nil
232
251
  @env.delete_if { |k, v| k =~ /^(action_dispatch|rack)\.request/ }
233
252
  @env.delete_if { |k, v| k =~ /^action_dispatch\.rescue/ }
234
- @symbolized_path_params = nil
235
253
  @method = @request_method = nil
236
254
  @fullpath = @ip = @remote_ip = @protocol = nil
237
255
  @env['action_dispatch.request.query_parameters'] = {}
@@ -430,6 +448,7 @@ module ActionController
430
448
  extend ActiveSupport::Concern
431
449
  include ActionDispatch::TestProcess
432
450
  include ActiveSupport::Testing::ConstantLookup
451
+ include Rails::Dom::Testing::Assertions
433
452
 
434
453
  attr_reader :response, :request
435
454
 
@@ -453,7 +472,6 @@ module ActionController
453
472
  end
454
473
 
455
474
  def controller_class=(new_class)
456
- prepare_controller_class(new_class) if new_class
457
475
  self._controller_class = new_class
458
476
  end
459
477
 
@@ -470,11 +488,6 @@ module ActionController
470
488
  Class === constant && constant < ActionController::Metal
471
489
  end
472
490
  end
473
-
474
- def prepare_controller_class(new_class)
475
- new_class.send :include, ActionController::TestCase::RaiseActionExceptions
476
- end
477
-
478
491
  end
479
492
 
480
493
  # Simulate a GET request with the given parameters.
@@ -486,8 +499,8 @@ module ActionController
486
499
  # - +session+: A hash of parameters to store in the session. This may be +nil+.
487
500
  # - +flash+: A hash of parameters to store in the flash. This may be +nil+.
488
501
  #
489
- # You can also simulate POST, PATCH, PUT, DELETE, HEAD, and OPTIONS requests with
490
- # +post+, +patch+, +put+, +delete+, +head+, and +options+.
502
+ # You can also simulate POST, PATCH, PUT, DELETE, and HEAD requests with
503
+ # +post+, +patch+, +put+, +delete+, and +head+.
491
504
  #
492
505
  # Note that the request method is not verified. The different methods are
493
506
  # available to make the tests more expressive.
@@ -548,6 +561,31 @@ module ActionController
548
561
  end
549
562
  end
550
563
 
564
+ # Simulate a HTTP request to +action+ by specifying request method,
565
+ # parameters and set/volley the response.
566
+ #
567
+ # - +action+: The controller action to call.
568
+ # - +http_method+: Request method used to send the http request. Possible values
569
+ # are +GET+, +POST+, +PATCH+, +PUT+, +DELETE+, +HEAD+. Defaults to +GET+.
570
+ # - +parameters+: The HTTP parameters. This may be +nil+, a hash, or a
571
+ # string that is appropriately encoded (+application/x-www-form-urlencoded+
572
+ # or +multipart/form-data+).
573
+ # - +session+: A hash of parameters to store in the session. This may be +nil+.
574
+ # - +flash+: A hash of parameters to store in the flash. This may be +nil+.
575
+ #
576
+ # Example calling +create+ action and sending two params:
577
+ #
578
+ # process :create, 'POST', user: { name: 'Gaurish Sharma', email: 'user@example.com' }
579
+ #
580
+ # Example sending parameters, +nil+ session and setting a flash message:
581
+ #
582
+ # process :view, 'GET', { id: 7 }, nil, { notice: 'This is flash message' }
583
+ #
584
+ # To simulate +GET+, +POST+, +PATCH+, +PUT+, +DELETE+ and +HEAD+ requests
585
+ # prefer using #get, #post, #patch, #put, #delete and #head methods
586
+ # respectively which will make tests more expressive.
587
+ #
588
+ # Note that the request method is not verified.
551
589
  def process(action, http_method = 'GET', *args)
552
590
  check_required_ivars
553
591
 
@@ -556,6 +594,7 @@ module ActionController
556
594
  end
557
595
 
558
596
  parameters, session, flash = args
597
+ parameters ||= {}
559
598
 
560
599
  # Ensure that numbers and symbols passed as params are converted to
561
600
  # proper params, as is the case when engaging rack.
@@ -565,7 +604,6 @@ module ActionController
565
604
 
566
605
  unless @controller.respond_to?(:recycle!)
567
606
  @controller.extend(Testing::Functional)
568
- @controller.class.class_eval { include Testing }
569
607
  end
570
608
 
571
609
  @request.recycle!
@@ -574,7 +612,6 @@ module ActionController
574
612
 
575
613
  @request.env['REQUEST_METHOD'] = http_method
576
614
 
577
- parameters ||= {}
578
615
  controller_class_name = @controller.class.anonymous? ?
579
616
  "anonymous" :
580
617
  @controller.class.controller_path
@@ -602,8 +639,11 @@ module ActionController
602
639
  @response.prepare!
603
640
 
604
641
  @assigns = @controller.respond_to?(:view_assigns) ? @controller.view_assigns : {}
605
- @request.session['flash'] = @request.flash.to_session_value
606
- @request.session.delete('flash') if @request.session['flash'].blank?
642
+
643
+ if flash_value = @request.flash.to_session_value
644
+ @request.session['flash'] = flash_value
645
+ end
646
+
607
647
  @response
608
648
  end
609
649
 
@@ -651,6 +691,11 @@ module ActionController
651
691
  end
652
692
 
653
693
  private
694
+
695
+ def document_root_element
696
+ html_document.root
697
+ end
698
+
654
699
  def check_required_ivars
655
700
  # Sanity check for required instance variables so we can give an
656
701
  # understandable error message.
@@ -665,12 +710,32 @@ module ActionController
665
710
  unless @request.env["PATH_INFO"]
666
711
  options = @controller.respond_to?(:url_options) ? @controller.__send__(:url_options).merge(parameters) : parameters
667
712
  options.update(
668
- :only_path => true,
669
713
  :action => action,
670
714
  :relative_url_root => nil,
671
- :_recall => @request.symbolized_path_parameters)
715
+ :_recall => @request.path_parameters)
716
+
717
+ if route_name = options.delete(:use_route)
718
+ ActiveSupport::Deprecation.warn <<-MSG.squish
719
+ Passing the `use_route` option in functional tests are deprecated.
720
+ Support for this option in the `process` method (and the related
721
+ `get`, `head`, `post`, `patch`, `put` and `delete` helpers) will
722
+ be removed in the next version without replacement.
723
+
724
+ Functional tests are essentially unit tests for controllers and
725
+ they should not require knowledge to how the application's routes
726
+ are configured. Instead, you should explicitly pass the appropiate
727
+ params to the `process` method.
728
+
729
+ Previously the engines guide also contained an incorrect example
730
+ that recommended using this option to test an engine's controllers
731
+ within the dummy application. That recommendation was incorrect
732
+ and has since been corrected. Instead, you should override the
733
+ `@routes` variable in the test case with `Foo::Engine.routes`. See
734
+ the updated engines guide for details.
735
+ MSG
736
+ end
672
737
 
673
- url, query_string = @routes.url_for(options).split("?", 2)
738
+ url, query_string = @routes.path_for(options, route_name).split("?", 2)
674
739
 
675
740
  @request.env["SCRIPT_NAME"] = @controller.config.relative_url_root
676
741
  @request.env["PATH_INFO"] = url
@@ -679,39 +744,11 @@ module ActionController
679
744
  end
680
745
 
681
746
  def html_format?(parameters)
682
- return true unless parameters.is_a?(Hash)
747
+ return true unless parameters.key?(:format)
683
748
  Mime.fetch(parameters[:format]) { Mime['html'] }.html?
684
749
  end
685
750
  end
686
751
 
687
- # When the request.remote_addr remains the default for testing, which is 0.0.0.0, the exception is simply raised inline
688
- # (skipping the regular exception handling from rescue_action). If the request.remote_addr is anything else, the regular
689
- # rescue_action process takes place. This means you can test your rescue_action code by setting remote_addr to something else
690
- # than 0.0.0.0.
691
- #
692
- # The exception is stored in the exception accessor for further inspection.
693
- module RaiseActionExceptions
694
- def self.included(base) #:nodoc:
695
- unless base.method_defined?(:exception) && base.method_defined?(:exception=)
696
- base.class_eval do
697
- attr_accessor :exception
698
- protected :exception, :exception=
699
- end
700
- end
701
- end
702
-
703
- protected
704
- def rescue_action_without_handler(e)
705
- self.exception = e
706
-
707
- if request.remote_addr == "0.0.0.0"
708
- raise(e)
709
- else
710
- super(e)
711
- end
712
- end
713
- end
714
-
715
752
  include Behavior
716
753
  end
717
754
  end