actionpack 3.0.0.beta → 3.0.0.beta2

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 (118) hide show
  1. data/CHANGELOG +291 -260
  2. data/lib/abstract_controller.rb +5 -2
  3. data/lib/abstract_controller/assigns.rb +21 -0
  4. data/lib/abstract_controller/base.rb +13 -5
  5. data/lib/abstract_controller/collector.rb +2 -0
  6. data/lib/abstract_controller/helpers.rb +4 -14
  7. data/lib/abstract_controller/layouts.rb +50 -99
  8. data/lib/abstract_controller/logger.rb +2 -2
  9. data/lib/abstract_controller/rendering.rb +105 -173
  10. data/lib/abstract_controller/view_paths.rb +69 -0
  11. data/lib/action_controller.rb +1 -2
  12. data/lib/action_controller/base.rb +10 -32
  13. data/lib/action_controller/caching.rb +19 -18
  14. data/lib/action_controller/caching/actions.rb +17 -11
  15. data/lib/action_controller/caching/fragments.rb +5 -17
  16. data/lib/action_controller/caching/pages.rb +24 -24
  17. data/lib/action_controller/caching/sweeping.rb +1 -3
  18. data/lib/action_controller/deprecated.rb +0 -2
  19. data/lib/action_controller/deprecated/base.rb +143 -0
  20. data/lib/action_controller/metal.rb +29 -26
  21. data/lib/action_controller/metal/compatibility.rb +18 -87
  22. data/lib/action_controller/metal/cookies.rb +0 -1
  23. data/lib/action_controller/metal/head.rb +1 -0
  24. data/lib/action_controller/metal/helpers.rb +2 -2
  25. data/lib/action_controller/metal/hide_actions.rb +4 -6
  26. data/lib/action_controller/metal/http_authentication.rb +18 -33
  27. data/lib/action_controller/metal/implicit_render.rb +21 -0
  28. data/lib/action_controller/metal/instrumentation.rb +1 -1
  29. data/lib/action_controller/metal/mime_responds.rb +2 -1
  30. data/lib/action_controller/metal/rack_delegation.rb +3 -8
  31. data/lib/action_controller/metal/redirecting.rb +2 -1
  32. data/lib/action_controller/metal/renderers.rb +4 -2
  33. data/lib/action_controller/metal/rendering.rb +31 -44
  34. data/lib/action_controller/metal/request_forgery_protection.rb +41 -4
  35. data/lib/action_controller/metal/responder.rb +2 -0
  36. data/lib/action_controller/metal/session_management.rb +0 -36
  37. data/lib/action_controller/metal/streaming.rb +20 -47
  38. data/lib/action_controller/metal/testing.rb +0 -1
  39. data/lib/action_controller/metal/url_for.rb +11 -148
  40. data/lib/action_controller/middleware.rb +2 -1
  41. data/lib/action_controller/polymorphic_routes.rb +1 -2
  42. data/lib/action_controller/railtie.rb +63 -10
  43. data/lib/action_controller/railties/{subscriber.rb → log_subscriber.rb} +5 -12
  44. data/lib/action_controller/railties/url_helpers.rb +14 -0
  45. data/lib/action_controller/record_identifier.rb +20 -1
  46. data/lib/action_controller/test_case.rb +123 -12
  47. data/lib/action_dispatch.rb +1 -0
  48. data/lib/action_dispatch/http/cache.rb +20 -3
  49. data/lib/action_dispatch/http/filter_parameters.rb +40 -25
  50. data/lib/action_dispatch/http/mime_negotiation.rb +6 -17
  51. data/lib/action_dispatch/http/mime_type.rb +2 -7
  52. data/lib/action_dispatch/http/request.rb +12 -33
  53. data/lib/action_dispatch/http/response.rb +35 -15
  54. data/lib/action_dispatch/http/upload.rb +2 -0
  55. data/lib/action_dispatch/http/url.rb +5 -32
  56. data/lib/action_dispatch/middleware/callbacks.rb +1 -1
  57. data/lib/action_dispatch/middleware/cookies.rb +4 -3
  58. data/lib/action_dispatch/middleware/params_parser.rb +4 -3
  59. data/lib/action_dispatch/middleware/remote_ip.rb +51 -0
  60. data/lib/action_dispatch/middleware/session/abstract_store.rb +1 -0
  61. data/lib/action_dispatch/middleware/session/cookie_store.rb +6 -8
  62. data/lib/action_dispatch/middleware/show_exceptions.rb +0 -14
  63. data/lib/action_dispatch/middleware/stack.rb +6 -2
  64. data/lib/action_dispatch/railtie.rb +3 -1
  65. data/lib/action_dispatch/routing.rb +2 -0
  66. data/lib/action_dispatch/routing/deprecated_mapper.rb +35 -7
  67. data/lib/action_dispatch/routing/mapper.rb +134 -48
  68. data/lib/action_dispatch/routing/route.rb +2 -2
  69. data/lib/action_dispatch/routing/route_set.rb +217 -158
  70. data/lib/action_dispatch/routing/url_for.rb +139 -0
  71. data/lib/action_dispatch/testing/assertions/response.rb +14 -61
  72. data/lib/action_dispatch/testing/assertions/routing.rb +25 -14
  73. data/lib/action_dispatch/testing/integration.rb +32 -50
  74. data/lib/action_dispatch/testing/performance_test.rb +3 -1
  75. data/lib/action_dispatch/testing/test_process.rb +2 -0
  76. data/lib/action_dispatch/testing/test_request.rb +2 -0
  77. data/lib/action_pack/version.rb +4 -3
  78. data/lib/action_view.rb +11 -6
  79. data/lib/action_view/base.rb +33 -121
  80. data/lib/action_view/context.rb +0 -2
  81. data/lib/action_view/helpers.rb +26 -23
  82. data/lib/action_view/helpers/active_model_helper.rb +28 -18
  83. data/lib/action_view/helpers/asset_tag_helper.rb +109 -54
  84. data/lib/action_view/helpers/atom_feed_helper.rb +2 -2
  85. data/lib/action_view/helpers/cache_helper.rb +22 -1
  86. data/lib/action_view/helpers/capture_helper.rb +22 -22
  87. data/lib/action_view/helpers/date_helper.rb +6 -5
  88. data/lib/action_view/helpers/form_helper.rb +78 -63
  89. data/lib/action_view/helpers/form_options_helper.rb +6 -4
  90. data/lib/action_view/helpers/form_tag_helper.rb +26 -15
  91. data/lib/action_view/helpers/javascript_helper.rb +90 -10
  92. data/lib/action_view/helpers/number_helper.rb +315 -118
  93. data/lib/action_view/helpers/prototype_helper.rb +19 -46
  94. data/lib/action_view/helpers/record_tag_helper.rb +4 -4
  95. data/lib/action_view/helpers/tag_helper.rb +7 -24
  96. data/lib/action_view/helpers/text_helper.rb +8 -7
  97. data/lib/action_view/helpers/translation_helper.rb +7 -5
  98. data/lib/action_view/helpers/url_helper.rb +19 -16
  99. data/lib/action_view/locale/en.yml +45 -6
  100. data/lib/action_view/lookup_context.rb +190 -0
  101. data/lib/action_view/paths.rb +22 -63
  102. data/lib/action_view/railtie.rb +14 -4
  103. data/lib/action_view/railties/{subscriber.rb → log_subscriber.rb} +1 -1
  104. data/lib/action_view/render/layouts.rb +73 -0
  105. data/lib/action_view/render/partials.rb +15 -41
  106. data/lib/action_view/render/rendering.rb +27 -78
  107. data/lib/action_view/template.rb +20 -24
  108. data/lib/action_view/template/error.rb +22 -2
  109. data/lib/action_view/template/handlers/erb.rb +33 -9
  110. data/lib/action_view/template/handlers/rjs.rb +1 -2
  111. data/lib/action_view/template/resolver.rb +46 -104
  112. data/lib/action_view/template/text.rb +5 -12
  113. data/lib/action_view/test_case.rb +14 -23
  114. metadata +83 -40
  115. data/lib/abstract_controller/compatibility.rb +0 -18
  116. data/lib/abstract_controller/localized_cache.rb +0 -49
  117. data/lib/action_controller/metal/configuration.rb +0 -28
  118. data/lib/action_controller/url_rewriter.rb +0 -76
@@ -0,0 +1,139 @@
1
+ module ActionDispatch
2
+ module Routing
3
+ # In <b>routes.rb</b> one defines URL-to-controller mappings, but the reverse
4
+ # is also possible: an URL can be generated from one of your routing definitions.
5
+ # URL generation functionality is centralized in this module.
6
+ #
7
+ # See ActionDispatch::Routing and ActionController::Resources for general
8
+ # information about routing and routes.rb.
9
+ #
10
+ # <b>Tip:</b> If you need to generate URLs from your models or some other place,
11
+ # then ActionController::UrlFor is what you're looking for. Read on for
12
+ # an introduction.
13
+ #
14
+ # == URL generation from parameters
15
+ #
16
+ # As you may know, some functions - such as ActionController::Base#url_for
17
+ # and ActionView::Helpers::UrlHelper#link_to, can generate URLs given a set
18
+ # of parameters. For example, you've probably had the chance to write code
19
+ # like this in one of your views:
20
+ #
21
+ # <%= link_to('Click here', :controller => 'users',
22
+ # :action => 'new', :message => 'Welcome!') %>
23
+ #
24
+ # #=> Generates a link to: /users/new?message=Welcome%21
25
+ #
26
+ # link_to, and all other functions that require URL generation functionality,
27
+ # actually use ActionController::UrlFor under the hood. And in particular,
28
+ # they use the ActionController::UrlFor#url_for method. One can generate
29
+ # the same path as the above example by using the following code:
30
+ #
31
+ # include UrlFor
32
+ # url_for(:controller => 'users',
33
+ # :action => 'new',
34
+ # :message => 'Welcome!',
35
+ # :only_path => true)
36
+ # # => "/users/new?message=Welcome%21"
37
+ #
38
+ # Notice the <tt>:only_path => true</tt> part. This is because UrlFor has no
39
+ # information about the website hostname that your Rails app is serving. So if you
40
+ # want to include the hostname as well, then you must also pass the <tt>:host</tt>
41
+ # argument:
42
+ #
43
+ # include UrlFor
44
+ # url_for(:controller => 'users',
45
+ # :action => 'new',
46
+ # :message => 'Welcome!',
47
+ # :host => 'www.example.com') # Changed this.
48
+ # # => "http://www.example.com/users/new?message=Welcome%21"
49
+ #
50
+ # By default, all controllers and views have access to a special version of url_for,
51
+ # that already knows what the current hostname is. So if you use url_for in your
52
+ # controllers or your views, then you don't need to explicitly pass the <tt>:host</tt>
53
+ # argument.
54
+ #
55
+ # For convenience reasons, mailers provide a shortcut for ActionController::UrlFor#url_for.
56
+ # So within mailers, you only have to type 'url_for' instead of 'ActionController::UrlFor#url_for'
57
+ # in full. However, mailers don't have hostname information, and what's why you'll still
58
+ # have to specify the <tt>:host</tt> argument when generating URLs in mailers.
59
+ #
60
+ #
61
+ # == URL generation for named routes
62
+ #
63
+ # UrlFor also allows one to access methods that have been auto-generated from
64
+ # named routes. For example, suppose that you have a 'users' resource in your
65
+ # <b>routes.rb</b>:
66
+ #
67
+ # map.resources :users
68
+ #
69
+ # This generates, among other things, the method <tt>users_path</tt>. By default,
70
+ # this method is accessible from your controllers, views and mailers. If you need
71
+ # to access this auto-generated method from other places (such as a model), then
72
+ # you can do that by including ActionController::UrlFor in your class:
73
+ #
74
+ # class User < ActiveRecord::Base
75
+ # include Rails.application.routes.url_helpers
76
+ #
77
+ # def base_uri
78
+ # user_path(self)
79
+ # end
80
+ # end
81
+ #
82
+ # User.find(1).base_uri # => "/users/1"
83
+ #
84
+ module UrlFor
85
+ extend ActiveSupport::Concern
86
+
87
+ included do
88
+ # TODO: with_routing extends @controller with url_helpers, trickling down to including this module which overrides its default_url_options
89
+ unless method_defined?(:default_url_options)
90
+ # Including in a class uses an inheritable hash. Modules get a plain hash.
91
+ if respond_to?(:class_attribute)
92
+ class_attribute :default_url_options
93
+ else
94
+ mattr_accessor :default_url_options
95
+ remove_method :default_url_options
96
+ end
97
+
98
+ self.default_url_options = {}
99
+ end
100
+ end
101
+
102
+ def url_options
103
+ default_url_options
104
+ end
105
+
106
+ # Generate a url based on the options provided, default_url_options and the
107
+ # routes defined in routes.rb. The following options are supported:
108
+ #
109
+ # * <tt>:only_path</tt> - If true, the relative url is returned. Defaults to +false+.
110
+ # * <tt>:protocol</tt> - The protocol to connect to. Defaults to 'http'.
111
+ # * <tt>:host</tt> - Specifies the host the link should be targeted at.
112
+ # If <tt>:only_path</tt> is false, this option must be
113
+ # provided either explicitly, or via +default_url_options+.
114
+ # * <tt>:port</tt> - Optionally specify the port to connect to.
115
+ # * <tt>:anchor</tt> - An anchor name to be appended to the path.
116
+ # * <tt>:trailing_slash</tt> - If true, adds a trailing slash, as in "/archive/2009/"
117
+ #
118
+ # Any other key (<tt>:controller</tt>, <tt>:action</tt>, etc.) given to
119
+ # +url_for+ is forwarded to the Routes module.
120
+ #
121
+ # Examples:
122
+ #
123
+ # url_for :controller => 'tasks', :action => 'testing', :host=>'somehost.org', :port=>'8080' # => 'http://somehost.org:8080/tasks/testing'
124
+ # url_for :controller => 'tasks', :action => 'testing', :host=>'somehost.org', :anchor => 'ok', :only_path => true # => '/tasks/testing#ok'
125
+ # url_for :controller => 'tasks', :action => 'testing', :trailing_slash=>true # => 'http://somehost.org/tasks/testing/'
126
+ # url_for :controller => 'tasks', :action => 'testing', :host=>'somehost.org', :number => '33' # => 'http://somehost.org/tasks/testing?number=33'
127
+ def url_for(options = nil)
128
+ case options
129
+ when String
130
+ options
131
+ when nil, Hash
132
+ _router.url_for(url_options.merge(options || {}))
133
+ else
134
+ polymorphic_url(options)
135
+ end
136
+ end
137
+ end
138
+ end
139
+ end
@@ -73,58 +73,6 @@ module ActionDispatch
73
73
  end
74
74
  end
75
75
 
76
- # Asserts that the request was rendered with the appropriate template file or partials
77
- #
78
- # ==== Examples
79
- #
80
- # # assert that the "new" view template was rendered
81
- # assert_template "new"
82
- #
83
- # # assert that the "_customer" partial was rendered twice
84
- # assert_template :partial => '_customer', :count => 2
85
- #
86
- # # assert that no partials were rendered
87
- # assert_template :partial => false
88
- #
89
- def assert_template(options = {}, message = nil)
90
- validate_request!
91
-
92
- case options
93
- when NilClass, String
94
- rendered = (@controller.template.rendered[:template] || []).map { |t| t.identifier }
95
- msg = build_message(message,
96
- "expecting <?> but rendering with <?>",
97
- options, rendered.join(', '))
98
- assert_block(msg) do
99
- if options.nil?
100
- @controller.template.rendered[:template].blank?
101
- else
102
- rendered.any? { |t| t.match(options) }
103
- end
104
- end
105
- when Hash
106
- if expected_partial = options[:partial]
107
- partials = @controller.template.rendered[:partials]
108
- if expected_count = options[:count]
109
- found = partials.detect { |p, _| p.identifier.match(expected_partial) }
110
- actual_count = found.nil? ? 0 : found.second
111
- msg = build_message(message,
112
- "expecting ? to be rendered ? time(s) but rendered ? time(s)",
113
- expected_partial, expected_count, actual_count)
114
- assert(actual_count == expected_count.to_i, msg)
115
- else
116
- msg = build_message(message,
117
- "expecting partial <?> but action rendered <?>",
118
- options[:partial], partials.keys)
119
- assert(partials.keys.any? { |p| p.identifier.match(expected_partial) }, msg)
120
- end
121
- else
122
- assert @controller.template.rendered[:partials].empty?,
123
- "Expected no partials to be rendered"
124
- end
125
- end
126
- end
127
-
128
76
  private
129
77
  # Proxy to to_param if the object will respond to it.
130
78
  def parameterize(value)
@@ -132,16 +80,21 @@ module ActionDispatch
132
80
  end
133
81
 
134
82
  def normalize_argument_to_redirection(fragment)
135
- after_routing = @controller.url_for(fragment)
136
- if after_routing =~ %r{^\w+://.*}
137
- after_routing
138
- else
139
- # FIXME - this should probably get removed.
140
- if after_routing.first != '/'
141
- after_routing = '/' + after_routing
83
+ case fragment
84
+ when %r{^\w[\w\d+.-]*:.*}
85
+ fragment
86
+ when String
87
+ if fragment =~ %r{^\w[\w\d+.-]*:.*}
88
+ fragment
89
+ else
90
+ @request.protocol + @request.host_with_port + fragment
142
91
  end
143
- @request.protocol + @request.host_with_port + after_routing
144
- end
92
+ when :back
93
+ raise RedirectBackError unless refer = @request.headers["Referer"]
94
+ refer
95
+ else
96
+ @controller.url_for(fragment)
97
+ end.gsub(/[\r\n]/, '')
145
98
  end
146
99
 
147
100
  def validate_request!
@@ -80,7 +80,7 @@ module ActionDispatch
80
80
  expected_path = "/#{expected_path}" unless expected_path[0] == ?/
81
81
  # Load routes.rb if it hasn't been loaded.
82
82
 
83
- generated_path, extra_keys = ActionController::Routing::Routes.generate_extras(options, defaults)
83
+ generated_path, extra_keys = @routes.generate_extras(options, defaults)
84
84
  found_extras = options.reject {|k, v| ! extra_keys.include? k}
85
85
 
86
86
  msg = build_message(message, "found extras <?>, not <?>", found_extras, extras)
@@ -125,7 +125,7 @@ module ActionDispatch
125
125
  end
126
126
 
127
127
  # A helper to make it easier to test different route configurations.
128
- # This method temporarily replaces ActionController::Routing::Routes
128
+ # This method temporarily replaces @routes
129
129
  # with a new RouteSet instance.
130
130
  #
131
131
  # The new instance is yielded to the passed block. Typically the block
@@ -142,22 +142,33 @@ module ActionDispatch
142
142
  # end
143
143
  #
144
144
  def with_routing
145
- real_routes = ActionController::Routing::Routes
146
- ActionController::Routing.module_eval { remove_const :Routes }
147
-
148
- temporary_routes = ActionController::Routing::RouteSet.new
149
- ActionController::Routing.module_eval { const_set :Routes, temporary_routes }
150
-
151
- yield temporary_routes
145
+ old_routes, @routes = @routes, ActionDispatch::Routing::RouteSet.new
146
+ old_controller, @controller = @controller, @controller.clone if @controller
147
+ _routes = @routes
148
+
149
+ # Unfortunately, there is currently an abstraction leak between AC::Base
150
+ # and AV::Base which requires having the URL helpers in both AC and AV.
151
+ # To do this safely at runtime for tests, we need to bump up the helper serial
152
+ # to that the old AV subclass isn't cached.
153
+ #
154
+ # TODO: Make this unnecessary
155
+ if @controller
156
+ @controller.singleton_class.send(:include, _routes.url_helpers)
157
+ @controller.view_context_class = Class.new(@controller.view_context_class) do
158
+ include _routes.url_helpers
159
+ end
160
+ end
161
+ yield @routes
152
162
  ensure
153
- if ActionController::Routing.const_defined? :Routes
154
- ActionController::Routing.module_eval { remove_const :Routes }
163
+ @routes = old_routes
164
+ if @controller
165
+ @controller = old_controller
155
166
  end
156
- ActionController::Routing.const_set(:Routes, real_routes) if real_routes
157
167
  end
158
168
 
169
+ # ROUTES TODO: These assertions should really work in an integration context
159
170
  def method_missing(selector, *args, &block)
160
- if @controller && ActionController::Routing::Routes.named_routes.helpers.include?(selector)
171
+ if @controller && @routes && @routes.named_routes.helpers.include?(selector)
161
172
  @controller.send(selector, *args, &block)
162
173
  else
163
174
  super
@@ -174,7 +185,7 @@ module ActionDispatch
174
185
  request.env["REQUEST_METHOD"] = request_method.to_s.upcase if request_method
175
186
  request.path = path
176
187
 
177
- params = ActionController::Routing::Routes.recognize_path(path, { :method => request.method })
188
+ params = @routes.recognize_path(path, { :method => request.method })
178
189
  request.path_parameters = params.with_indifferent_access
179
190
 
180
191
  request
@@ -1,7 +1,8 @@
1
1
  require 'stringio'
2
2
  require 'uri'
3
- require 'active_support/core_ext/object/metaclass'
3
+ require 'active_support/core_ext/object/singleton_class'
4
4
  require 'rack/test'
5
+ require 'test/unit/assertions'
5
6
 
6
7
  module ActionDispatch
7
8
  module Integration #:nodoc:
@@ -162,12 +163,25 @@ module ActionDispatch
162
163
  # A running counter of the number of requests processed.
163
164
  attr_accessor :request_count
164
165
 
166
+ include ActionDispatch::Routing::UrlFor
167
+
165
168
  # Create and initialize a new Session instance.
166
169
  def initialize(app)
167
170
  @app = app
171
+
172
+ # If the app is a Rails app, make url_helpers available on the session
173
+ # This makes app.url_for and app.foo_path available in the console
174
+ if app.respond_to?(:routes) && app.routes.respond_to?(:url_helpers)
175
+ singleton_class.class_eval { include app.routes.url_helpers }
176
+ end
177
+
168
178
  reset!
169
179
  end
170
180
 
181
+ def default_url_options
182
+ { :host => host, :protocol => https? ? "https" : "http" }
183
+ end
184
+
171
185
  # Resets the instance. This can be used to reset the state information
172
186
  # in an existing session instance, so it can be used from a clean-slate
173
187
  # condition.
@@ -187,12 +201,10 @@ module ActionDispatch
187
201
 
188
202
  unless defined? @named_routes_configured
189
203
  # install the named routes in this session instance.
190
- klass = metaclass
191
- ActionController::Routing::Routes.install_helpers(klass)
204
+ klass = singleton_class
192
205
 
193
206
  # the helpers are made protected by default--we make them public for
194
207
  # easier access during testing and troubleshooting.
195
- klass.module_eval { public *ActionController::Routing::Routes.named_routes.helpers }
196
208
  @named_routes_configured = true
197
209
  end
198
210
  end
@@ -221,14 +233,6 @@ module ActionDispatch
221
233
  @host = name
222
234
  end
223
235
 
224
- # Returns the URL for the given options, according to the rules specified
225
- # in the application's routes.
226
- def url_for(options)
227
- controller ?
228
- controller.url_for(options) :
229
- generic_url_rewriter.rewrite(options)
230
- end
231
-
232
236
  private
233
237
 
234
238
  # Performs the actual request.
@@ -273,29 +277,19 @@ module ActionDispatch
273
277
 
274
278
  @request_count += 1
275
279
  @request = ActionDispatch::Request.new(session.last_request.env)
276
- @response = ActionDispatch::TestResponse.from_response(@mock_session.last_response)
280
+ response = @mock_session.last_response
281
+ @response = ActionDispatch::TestResponse.new(response.status, response.headers, response.body)
277
282
  @html_document = nil
278
283
 
279
284
  @controller = session.last_request.env['action_controller.instance']
280
285
 
281
286
  return response.status
282
287
  end
283
-
284
- # Get a temporary URL writer object
285
- def generic_url_rewriter
286
- env = {
287
- 'REQUEST_METHOD' => "GET",
288
- 'QUERY_STRING' => "",
289
- "REQUEST_URI" => "/",
290
- "HTTP_HOST" => host,
291
- "SERVER_PORT" => https? ? "443" : "80",
292
- "HTTPS" => https? ? "on" : "off"
293
- }
294
- ActionController::UrlRewriter.new(ActionDispatch::Request.new(env), {})
295
- end
296
288
  end
297
289
 
298
290
  module Runner
291
+ include ActionDispatch::Assertions
292
+
299
293
  def app
300
294
  @app
301
295
  end
@@ -303,7 +297,7 @@ module ActionDispatch
303
297
  # Reset the current session. This is useful for testing multiple sessions
304
298
  # in a single test case.
305
299
  def reset!
306
- @integration_session = open_session
300
+ @integration_session = Integration::Session.new(app)
307
301
  end
308
302
 
309
303
  %w(get post put head delete cookies assigns
@@ -329,30 +323,9 @@ module ActionDispatch
329
323
  # can use this method to open multiple sessions that ought to be tested
330
324
  # simultaneously.
331
325
  def open_session(app = nil)
332
- session = Integration::Session.new(app || self.app)
333
-
334
- # delegate the fixture accessors back to the test instance
335
- extras = Module.new { attr_accessor :delegate, :test_result }
336
- if self.class.respond_to?(:fixture_table_names)
337
- self.class.fixture_table_names.each do |table_name|
338
- name = table_name.tr(".", "_")
339
- next unless respond_to?(name)
340
- extras.__send__(:define_method, name) { |*args|
341
- delegate.send(name, *args)
342
- }
343
- end
326
+ dup.tap do |session|
327
+ yield session if block_given?
344
328
  end
345
-
346
- # delegate add_assertion to the test case
347
- extras.__send__(:define_method, :add_assertion) {
348
- test_result.add_assertion
349
- }
350
- session.extend(extras)
351
- session.delegate = self
352
- session.test_result = @_result
353
-
354
- yield session if block_given?
355
- session
356
329
  end
357
330
 
358
331
  # Copy the instance variables from the current session instance into the
@@ -364,6 +337,14 @@ module ActionDispatch
364
337
  end
365
338
  end
366
339
 
340
+ extend ActiveSupport::Concern
341
+ include ActionDispatch::Routing::UrlFor
342
+
343
+ def url_options
344
+ reset! unless @integration_session
345
+ @integration_session.url_options
346
+ end
347
+
367
348
  # Delegate unhandled messages to the current session instance.
368
349
  def method_missing(sym, *args, &block)
369
350
  reset! unless @integration_session
@@ -455,6 +436,7 @@ module ActionDispatch
455
436
  # end
456
437
  class IntegrationTest < ActiveSupport::TestCase
457
438
  include Integration::Runner
439
+ include ActionController::TemplateAssertions
458
440
 
459
441
  @@app = nil
460
442