actionpack 3.1.4 → 3.1.5.rc1
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.md +5 -0
- data/lib/action_controller/metal/redirecting.rb +1 -1
- data/lib/action_controller/test_case.rb +18 -8
- data/lib/action_dispatch/http/parameters.rb +4 -0
- data/lib/action_dispatch/http/url.rb +6 -4
- data/lib/action_dispatch/middleware/flash.rb +3 -6
- data/lib/action_dispatch/middleware/session/cookie_store.rb +1 -1
- data/lib/action_dispatch/routing/mapper.rb +4 -2
- data/lib/action_dispatch/routing/redirection.rb +12 -2
- data/lib/action_dispatch/routing/route_set.rb +7 -1
- data/lib/action_dispatch/routing/url_for.rb +3 -2
- data/lib/action_dispatch/testing/assertions/response.rb +1 -1
- data/lib/action_dispatch/testing/integration.rb +24 -7
- data/lib/action_pack/version.rb +2 -2
- data/lib/action_view/asset_paths.rb +1 -1
- data/lib/action_view/helpers/asset_tag_helper.rb +1 -1
- data/lib/sprockets/static_compiler.rb +3 -0
- metadata +30 -22
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
## Rails 3.1.4 (unreleased) ##
|
2
2
|
|
3
|
+
* :subdomain can now be specified with a value of false in url_for,
|
4
|
+
allowing for subdomain(s) removal from the host during link generation. GH #4083
|
5
|
+
|
6
|
+
*Arun Agrawal*
|
7
|
+
|
3
8
|
* Skip assets group in Gemfile and all assets configurations options
|
4
9
|
when the application is generated with --skip-sprockets option.
|
5
10
|
|
@@ -145,17 +145,23 @@ module ActionController
|
|
145
145
|
extra_keys = routes.extra_keys(parameters)
|
146
146
|
non_path_parameters = get? ? query_parameters : request_parameters
|
147
147
|
parameters.each do |key, value|
|
148
|
-
if value.is_a?
|
149
|
-
value = value.
|
150
|
-
elsif value.is_a?
|
151
|
-
value =
|
152
|
-
elsif value.
|
148
|
+
if value.is_a?(Array) && (value.frozen? || value.any?(&:frozen?))
|
149
|
+
value = value.map{ |v| v.duplicable? ? v.dup : v }
|
150
|
+
elsif value.is_a?(Hash) && (value.frozen? || value.any?{ |k,v| v.frozen? })
|
151
|
+
value = Hash[value.map{ |k,v| [k, v.duplicable? ? v.dup : v] }]
|
152
|
+
elsif value.frozen? && value.duplicable?
|
153
153
|
value = value.dup
|
154
154
|
end
|
155
155
|
|
156
156
|
if extra_keys.include?(key.to_sym)
|
157
157
|
non_path_parameters[key] = value
|
158
158
|
else
|
159
|
+
if value.is_a?(Array)
|
160
|
+
value = Result.new(value.map(&:to_param))
|
161
|
+
else
|
162
|
+
value = value.to_param
|
163
|
+
end
|
164
|
+
|
159
165
|
path_parameters[key.to_s] = value
|
160
166
|
end
|
161
167
|
end
|
@@ -411,7 +417,7 @@ module ActionController
|
|
411
417
|
def process(action, parameters = nil, session = nil, flash = nil, http_method = 'GET')
|
412
418
|
# Ensure that numbers and symbols passed as params are converted to
|
413
419
|
# proper params, as is the case when engaging rack.
|
414
|
-
parameters = paramify_values(parameters)
|
420
|
+
parameters = paramify_values(parameters) if html_format?(parameters)
|
415
421
|
|
416
422
|
# Sanity check for required instance variables so we can give an
|
417
423
|
# understandable error message.
|
@@ -439,10 +445,8 @@ module ActionController
|
|
439
445
|
|
440
446
|
@request.session = ActionController::TestSession.new(session) if session
|
441
447
|
@request.session["flash"] = @request.flash.update(flash || {})
|
442
|
-
@request.session["flash"].sweep
|
443
448
|
|
444
449
|
@controller.request = @request
|
445
|
-
@controller.params.merge!(parameters)
|
446
450
|
build_request_uri(action, parameters)
|
447
451
|
@controller.class.class_eval { include Testing }
|
448
452
|
@controller.recycle!
|
@@ -499,6 +503,12 @@ module ActionController
|
|
499
503
|
@request.env["QUERY_STRING"] = query_string || ""
|
500
504
|
end
|
501
505
|
end
|
506
|
+
|
507
|
+
def html_format?(parameters)
|
508
|
+
return true unless parameters.is_a?(Hash)
|
509
|
+
format = Mime[parameters[:format]]
|
510
|
+
format.nil? || format.html?
|
511
|
+
end
|
502
512
|
end
|
503
513
|
|
504
514
|
# When the request.remote_addr remains the default for testing, which is 0.0.0.0, the exception is simply raised inline
|
@@ -35,6 +35,10 @@ module ActionDispatch
|
|
35
35
|
@env["action_dispatch.request.path_parameters"] ||= {}
|
36
36
|
end
|
37
37
|
|
38
|
+
def reset_parameters #:nodoc:
|
39
|
+
@env.delete("action_dispatch.request.parameters")
|
40
|
+
end
|
41
|
+
|
38
42
|
private
|
39
43
|
|
40
44
|
# TODO: Validate that the characters are UTF-8. If they aren't,
|
@@ -64,14 +64,16 @@ module ActionDispatch
|
|
64
64
|
end
|
65
65
|
|
66
66
|
def host_or_subdomain_and_domain(options)
|
67
|
-
return options[:host]
|
67
|
+
return options[:host] if !named_host?(options[:host]) || (options[:subdomain].nil? && options[:domain].nil?)
|
68
68
|
|
69
69
|
tld_length = options[:tld_length] || @@tld_length
|
70
70
|
|
71
71
|
host = ""
|
72
|
-
|
73
|
-
|
74
|
-
|
72
|
+
unless options[:subdomain] == false
|
73
|
+
host << (options[:subdomain] || extract_subdomain(options[:host], tld_length)).to_param
|
74
|
+
host << "."
|
75
|
+
end
|
76
|
+
host << (options[:domain] || extract_domain(options[:host], tld_length))
|
75
77
|
host
|
76
78
|
end
|
77
79
|
end
|
@@ -4,7 +4,7 @@ module ActionDispatch
|
|
4
4
|
# read a notice you put there or <tt>flash["notice"] = "hello"</tt>
|
5
5
|
# to put a new one.
|
6
6
|
def flash
|
7
|
-
@env[Flash::KEY] ||= (session["flash"] || Flash::FlashHash.new)
|
7
|
+
@env[Flash::KEY] ||= (session["flash"] || Flash::FlashHash.new).tap(&:sweep)
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
@@ -240,10 +240,6 @@ module ActionDispatch
|
|
240
240
|
end
|
241
241
|
|
242
242
|
def call(env)
|
243
|
-
if (session = env['rack.session']) && (flash = session['flash'])
|
244
|
-
flash.sweep
|
245
|
-
end
|
246
|
-
|
247
243
|
@app.call(env)
|
248
244
|
ensure
|
249
245
|
session = env['rack.session'] || {}
|
@@ -261,7 +257,8 @@ module ActionDispatch
|
|
261
257
|
new_hash.close!
|
262
258
|
end
|
263
259
|
|
264
|
-
if session.
|
260
|
+
if (!session.respond_to?(:loaded?) || session.loaded?) && # (reset_session uses {}, which doesn't implement #loaded?)
|
261
|
+
session.key?('flash') && session['flash'].empty?
|
265
262
|
session.delete('flash')
|
266
263
|
end
|
267
264
|
end
|
@@ -35,6 +35,8 @@ module ActionDispatch
|
|
35
35
|
}
|
36
36
|
|
37
37
|
return true
|
38
|
+
ensure
|
39
|
+
req.reset_parameters
|
38
40
|
end
|
39
41
|
|
40
42
|
def call(env)
|
@@ -107,7 +109,7 @@ module ActionDispatch
|
|
107
109
|
|
108
110
|
# Add a constraint for wildcard route to make it non-greedy and match the
|
109
111
|
# optional format part of the route by default
|
110
|
-
if path.match(
|
112
|
+
if path.match(%r{\*([^/\)]+)\)?$}) && @options[:format] != false
|
111
113
|
@options.reverse_merge!(:"#{$1}" => /.+?/)
|
112
114
|
end
|
113
115
|
|
@@ -331,7 +333,7 @@ module ActionDispatch
|
|
331
333
|
# +call+ or a string representing a controller's action.
|
332
334
|
#
|
333
335
|
# match 'path', :to => 'controller#action'
|
334
|
-
# match 'path', :to => lambda { [200, {}, "Success!"] }
|
336
|
+
# match 'path', :to => lambda { |env| [200, {}, "Success!"] }
|
335
337
|
# match 'path', :to => RackApp
|
336
338
|
#
|
337
339
|
# [:on]
|
@@ -1,4 +1,6 @@
|
|
1
1
|
require 'action_dispatch/http/request'
|
2
|
+
require 'active_support/core_ext/uri'
|
3
|
+
require 'rack/utils'
|
2
4
|
|
3
5
|
module ActionDispatch
|
4
6
|
module Routing
|
@@ -43,7 +45,7 @@ module ActionDispatch
|
|
43
45
|
path = args.shift
|
44
46
|
|
45
47
|
path_proc = if path.is_a?(String)
|
46
|
-
proc { |params| (params.empty? || !path.match(/%\{\w*\}/)) ? path : (path % params) }
|
48
|
+
proc { |params| (params.empty? || !path.match(/%\{\w*\}/)) ? path : (path % escape(params)) }
|
47
49
|
elsif options.any?
|
48
50
|
options_proc(options)
|
49
51
|
elsif path.respond_to?(:call)
|
@@ -66,7 +68,7 @@ module ActionDispatch
|
|
66
68
|
elsif params.empty? || !options[:path].match(/%\{\w*\}/)
|
67
69
|
options.delete(:path)
|
68
70
|
else
|
69
|
-
(options.delete(:path) % params)
|
71
|
+
(options.delete(:path) % escape_path(params))
|
70
72
|
end
|
71
73
|
|
72
74
|
default_options = {
|
@@ -105,6 +107,14 @@ module ActionDispatch
|
|
105
107
|
end
|
106
108
|
end
|
107
109
|
|
110
|
+
def escape(params)
|
111
|
+
Hash[params.map{ |k,v| [k, Rack::Utils.escape(v)] }]
|
112
|
+
end
|
113
|
+
|
114
|
+
def escape_path(params)
|
115
|
+
Hash[params.map{ |k,v| [k, URI.parser.escape(v)] }]
|
116
|
+
end
|
117
|
+
|
108
118
|
end
|
109
119
|
end
|
110
120
|
end
|
@@ -8,6 +8,12 @@ require 'active_support/core_ext/module/remove_method'
|
|
8
8
|
module ActionDispatch
|
9
9
|
module Routing
|
10
10
|
class RouteSet #:nodoc:
|
11
|
+
# Since the router holds references to many parts of the system
|
12
|
+
# like engines, controllers and the application itself, inspecting
|
13
|
+
# the route set can actually be really slow, therefore we default
|
14
|
+
# alias inspect to to_s.
|
15
|
+
alias inspect to_s
|
16
|
+
|
11
17
|
PARAMETERS_KEY = 'action_dispatch.request.path_parameters'
|
12
18
|
|
13
19
|
class Dispatcher #:nodoc:
|
@@ -166,7 +172,7 @@ module ActionDispatch
|
|
166
172
|
options = args.extract_options!
|
167
173
|
result = #{options.inspect}
|
168
174
|
|
169
|
-
if args.
|
175
|
+
if args.size > 0
|
170
176
|
result[:_positional_args] = args
|
171
177
|
result[:_positional_keys] = #{route.segment_keys.inspect}
|
172
178
|
end
|
@@ -116,9 +116,10 @@ module ActionDispatch
|
|
116
116
|
# If <tt>:only_path</tt> is false, this option must be
|
117
117
|
# provided either explicitly, or via +default_url_options+.
|
118
118
|
# * <tt>:subdomain</tt> - Specifies the subdomain of the link, using the +tld_length+
|
119
|
-
# to split the domain from the host.
|
120
|
-
# * <tt>:domain</tt> - Specifies the domain of the link, using the +tld_length+
|
121
119
|
# to split the subdomain from the host.
|
120
|
+
# If false, removes all subdomains from the host part of the link.
|
121
|
+
# * <tt>:domain</tt> - Specifies the domain of the link, using the +tld_length+
|
122
|
+
# to split the domain from the host.
|
122
123
|
# * <tt>:tld_length</tt> - Number of labels the TLD id composed of, only used if
|
123
124
|
# <tt>:subdomain</tt> or <tt>:domain</tt> are supplied. Defaults to
|
124
125
|
# <tt>ActionDispatch::Http::URL.tld_length</tt>, which in turn defaults to 1.
|
@@ -184,9 +184,16 @@ module ActionDispatch
|
|
184
184
|
reset!
|
185
185
|
end
|
186
186
|
|
187
|
-
|
188
|
-
|
189
|
-
|
187
|
+
def url_options
|
188
|
+
@url_options ||= default_url_options.dup.tap do |url_options|
|
189
|
+
url_options.reverse_merge!(controller.url_options) if controller
|
190
|
+
|
191
|
+
if @app.respond_to?(:routes) && @app.routes.respond_to?(:default_url_options)
|
192
|
+
url_options.reverse_merge!(@app.routes.default_url_options)
|
193
|
+
end
|
194
|
+
|
195
|
+
url_options.reverse_merge!(:host => host, :protocol => https? ? "https" : "http")
|
196
|
+
end
|
190
197
|
end
|
191
198
|
|
192
199
|
# Resets the instance. This can be used to reset the state information
|
@@ -199,6 +206,7 @@ module ActionDispatch
|
|
199
206
|
@controller = @request = @response = nil
|
200
207
|
@_mock_session = nil
|
201
208
|
@request_count = 0
|
209
|
+
@url_options = nil
|
202
210
|
|
203
211
|
self.host = DEFAULT_HOST
|
204
212
|
self.remote_addr = "127.0.0.1"
|
@@ -296,6 +304,7 @@ module ActionDispatch
|
|
296
304
|
response = _mock_session.last_response
|
297
305
|
@response = ActionDispatch::TestResponse.new(response.status, response.headers, response.body)
|
298
306
|
@html_document = nil
|
307
|
+
@url_options = nil
|
299
308
|
|
300
309
|
@controller = session.last_request.env['action_controller.instance']
|
301
310
|
|
@@ -353,12 +362,14 @@ module ActionDispatch
|
|
353
362
|
end
|
354
363
|
end
|
355
364
|
|
356
|
-
|
357
|
-
|
365
|
+
def default_url_options
|
366
|
+
reset! unless integration_session
|
367
|
+
integration_session.default_url_options
|
368
|
+
end
|
358
369
|
|
359
|
-
def
|
370
|
+
def default_url_options=(options)
|
360
371
|
reset! unless integration_session
|
361
|
-
integration_session.
|
372
|
+
integration_session.default_url_options = options
|
362
373
|
end
|
363
374
|
|
364
375
|
def respond_to?(method, include_private = false)
|
@@ -462,6 +473,7 @@ module ActionDispatch
|
|
462
473
|
class IntegrationTest < ActiveSupport::TestCase
|
463
474
|
include Integration::Runner
|
464
475
|
include ActionController::TemplateAssertions
|
476
|
+
include ActionDispatch::Routing::UrlFor
|
465
477
|
|
466
478
|
@@app = nil
|
467
479
|
|
@@ -478,5 +490,10 @@ module ActionDispatch
|
|
478
490
|
def app
|
479
491
|
super || self.class.app
|
480
492
|
end
|
493
|
+
|
494
|
+
def url_options
|
495
|
+
reset! unless integration_session
|
496
|
+
integration_session.url_options
|
497
|
+
end
|
481
498
|
end
|
482
499
|
end
|
data/lib/action_pack/version.rb
CHANGED
@@ -16,6 +16,9 @@ module Sprockets
|
|
16
16
|
def compile
|
17
17
|
manifest = {}
|
18
18
|
env.each_logical_path do |logical_path|
|
19
|
+
if File.basename(logical_path)[/[^\.]+/, 0] == 'index'
|
20
|
+
logical_path.sub!(/\/index\./, '.')
|
21
|
+
end
|
19
22
|
next unless compile_path?(logical_path)
|
20
23
|
if asset = env.find_asset(logical_path)
|
21
24
|
manifest[logical_path] = write_asset(asset)
|
metadata
CHANGED
@@ -1,13 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: actionpack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 4225350523
|
5
|
+
prerelease: 6
|
6
6
|
segments:
|
7
7
|
- 3
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
|
9
|
+
- 5
|
10
|
+
- rc
|
11
|
+
- 1
|
12
|
+
version: 3.1.5.rc1
|
11
13
|
platform: ruby
|
12
14
|
authors:
|
13
15
|
- David Heinemeier Hansson
|
@@ -15,7 +17,7 @@ autorequire:
|
|
15
17
|
bindir: bin
|
16
18
|
cert_chain: []
|
17
19
|
|
18
|
-
date: 2012-
|
20
|
+
date: 2012-05-28 00:00:00 Z
|
19
21
|
dependencies:
|
20
22
|
- !ruby/object:Gem::Dependency
|
21
23
|
name: activesupport
|
@@ -25,12 +27,14 @@ dependencies:
|
|
25
27
|
requirements:
|
26
28
|
- - "="
|
27
29
|
- !ruby/object:Gem::Version
|
28
|
-
hash:
|
30
|
+
hash: 4225350523
|
29
31
|
segments:
|
30
32
|
- 3
|
31
33
|
- 1
|
32
|
-
-
|
33
|
-
|
34
|
+
- 5
|
35
|
+
- rc
|
36
|
+
- 1
|
37
|
+
version: 3.1.5.rc1
|
34
38
|
type: :runtime
|
35
39
|
version_requirements: *id001
|
36
40
|
- !ruby/object:Gem::Dependency
|
@@ -41,12 +45,14 @@ dependencies:
|
|
41
45
|
requirements:
|
42
46
|
- - "="
|
43
47
|
- !ruby/object:Gem::Version
|
44
|
-
hash:
|
48
|
+
hash: 4225350523
|
45
49
|
segments:
|
46
50
|
- 3
|
47
51
|
- 1
|
48
|
-
-
|
49
|
-
|
52
|
+
- 5
|
53
|
+
- rc
|
54
|
+
- 1
|
55
|
+
version: 3.1.5.rc1
|
50
56
|
type: :runtime
|
51
57
|
version_requirements: *id002
|
52
58
|
- !ruby/object:Gem::Dependency
|
@@ -57,11 +63,11 @@ dependencies:
|
|
57
63
|
requirements:
|
58
64
|
- - ~>
|
59
65
|
- !ruby/object:Gem::Version
|
60
|
-
hash:
|
66
|
+
hash: 11
|
61
67
|
segments:
|
62
68
|
- 1
|
63
|
-
-
|
64
|
-
version: "1.
|
69
|
+
- 2
|
70
|
+
version: "1.2"
|
65
71
|
type: :runtime
|
66
72
|
version_requirements: *id003
|
67
73
|
- !ruby/object:Gem::Dependency
|
@@ -151,12 +157,12 @@ dependencies:
|
|
151
157
|
requirements:
|
152
158
|
- - ~>
|
153
159
|
- !ruby/object:Gem::Version
|
154
|
-
hash:
|
160
|
+
hash: 7
|
155
161
|
segments:
|
156
162
|
- 2
|
157
163
|
- 0
|
158
|
-
-
|
159
|
-
version: 2.0.
|
164
|
+
- 4
|
165
|
+
version: 2.0.4
|
160
166
|
type: :runtime
|
161
167
|
version_requirements: *id009
|
162
168
|
- !ruby/object:Gem::Dependency
|
@@ -410,16 +416,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
410
416
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
411
417
|
none: false
|
412
418
|
requirements:
|
413
|
-
- - "
|
419
|
+
- - ">"
|
414
420
|
- !ruby/object:Gem::Version
|
415
|
-
hash:
|
421
|
+
hash: 25
|
416
422
|
segments:
|
417
|
-
-
|
418
|
-
|
423
|
+
- 1
|
424
|
+
- 3
|
425
|
+
- 1
|
426
|
+
version: 1.3.1
|
419
427
|
requirements:
|
420
428
|
- none
|
421
429
|
rubyforge_project:
|
422
|
-
rubygems_version: 1.8.
|
430
|
+
rubygems_version: 1.8.22
|
423
431
|
signing_key:
|
424
432
|
specification_version: 3
|
425
433
|
summary: Web-flow and rendering framework putting the VC in MVC (part of Rails).
|