aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/CHANGELOG2
-rw-r--r--actionpack/README.rdoc2
-rwxr-xr-xactionpack/Rakefile4
-rw-r--r--actionpack/actionpack.gemspec6
-rw-r--r--actionpack/lib/abstract_controller/base.rb2
-rw-r--r--actionpack/lib/abstract_controller/helpers.rb2
-rw-r--r--actionpack/lib/action_controller.rb13
-rw-r--r--actionpack/lib/action_controller/caching/actions.rb4
-rw-r--r--actionpack/lib/action_controller/metal/data_streaming.rb6
-rw-r--r--actionpack/lib/action_controller/metal/force_ssl.rb6
-rw-r--r--actionpack/lib/action_controller/metal/http_authentication.rb4
-rw-r--r--actionpack/lib/action_controller/metal/instrumentation.rb2
-rw-r--r--actionpack/lib/action_controller/metal/request_forgery_protection.rb8
-rw-r--r--actionpack/lib/action_controller/test_case.rb2
-rw-r--r--actionpack/lib/action_controller/vendor/html-scanner/html/sanitizer.rb2
-rw-r--r--actionpack/lib/action_dispatch/http/mime_type.rb4
-rw-r--r--actionpack/lib/action_dispatch/http/request.rb14
-rw-r--r--actionpack/lib/action_dispatch/http/response.rb26
-rw-r--r--actionpack/lib/action_dispatch/middleware/callbacks.rb3
-rw-r--r--actionpack/lib/action_dispatch/middleware/cookies.rb4
-rw-r--r--actionpack/lib/action_dispatch/middleware/session/abstract_store.rb10
-rw-r--r--actionpack/lib/action_dispatch/routing/mapper.rb14
-rw-r--r--actionpack/lib/action_dispatch/routing/route.rb7
-rw-r--r--actionpack/lib/action_dispatch/routing/url_for.rb2
-rw-r--r--actionpack/lib/action_dispatch/testing/assertions.rb13
-rw-r--r--actionpack/lib/action_dispatch/testing/assertions/response.rb7
-rw-r--r--actionpack/lib/action_dispatch/testing/assertions/routing.rb18
-rw-r--r--actionpack/lib/action_dispatch/testing/integration.rb2
-rw-r--r--actionpack/lib/action_view/helpers.rb2
-rw-r--r--actionpack/lib/action_view/helpers/asset_paths.rb13
-rw-r--r--actionpack/lib/action_view/helpers/asset_tag_helper.rb18
-rw-r--r--actionpack/lib/action_view/helpers/asset_tag_helpers/asset_paths.rb11
-rw-r--r--actionpack/lib/action_view/helpers/asset_tag_helpers/javascript_tag_helpers.rb8
-rw-r--r--actionpack/lib/action_view/helpers/asset_tag_helpers/stylesheet_tag_helpers.rb8
-rw-r--r--actionpack/lib/action_view/helpers/capture_helper.rb4
-rw-r--r--actionpack/lib/action_view/helpers/date_helper.rb2
-rw-r--r--actionpack/lib/action_view/helpers/form_helper.rb20
-rw-r--r--actionpack/lib/action_view/helpers/form_options_helper.rb8
-rw-r--r--actionpack/lib/action_view/helpers/form_tag_helper.rb2
-rw-r--r--actionpack/lib/action_view/helpers/sanitize_helper.rb10
-rw-r--r--actionpack/lib/action_view/helpers/sprockets_helper.rb69
-rw-r--r--actionpack/lib/action_view/helpers/tag_helper.rb2
-rw-r--r--actionpack/lib/action_view/helpers/text_helper.rb4
-rw-r--r--actionpack/lib/action_view/helpers/url_helper.rb12
-rw-r--r--actionpack/lib/action_view/template.rb1
-rw-r--r--actionpack/lib/action_view/template/handler.rb49
-rw-r--r--actionpack/lib/action_view/template/handlers.rb6
-rw-r--r--actionpack/lib/action_view/template/handlers/erb.rb2
-rw-r--r--actionpack/lib/action_view/test_case.rb6
-rw-r--r--actionpack/lib/sprockets/helpers.rb5
-rw-r--r--actionpack/lib/sprockets/helpers/rails_helper.rb107
-rw-r--r--actionpack/lib/sprockets/railtie.rb32
-rw-r--r--actionpack/test/activerecord/controller_runtime_test.rb26
-rw-r--r--actionpack/test/controller/caching_test.rb3
-rw-r--r--actionpack/test/controller/deprecation/deprecated_base_methods_test.rb26
-rw-r--r--actionpack/test/controller/helper_test.rb2
-rw-r--r--actionpack/test/controller/mime_responds_test.rb6
-rw-r--r--actionpack/test/controller/render_test.rb7
-rw-r--r--actionpack/test/controller/request_forgery_protection_test.rb6
-rw-r--r--actionpack/test/controller/view_paths_test.rb8
-rw-r--r--actionpack/test/dispatch/response_body_is_proc_test.rb37
-rw-r--r--actionpack/test/dispatch/session/cookie_store_test.rb2
-rw-r--r--actionpack/test/fixtures/sprockets/app/javascripts/application.js1
-rw-r--r--actionpack/test/fixtures/sprockets/app/stylesheets/application.css1
-rw-r--r--actionpack/test/fixtures/test/deprecated_nested_layout.erb3
-rw-r--r--actionpack/test/template/form_helper_test.rb125
-rw-r--r--actionpack/test/template/number_helper_test.rb9
-rw-r--r--actionpack/test/template/sprockets_helper_test.rb42
-rw-r--r--actionpack/test/template/streaming_render_test.rb4
-rw-r--r--actionpack/test/template/test_case_test.rb16
-rw-r--r--actionpack/test/template/url_helper_test.rb2
71 files changed, 453 insertions, 463 deletions
diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG
index 15abfb8369..48b3e5bfff 100644
--- a/actionpack/CHANGELOG
+++ b/actionpack/CHANGELOG
@@ -1,5 +1,7 @@
*Rails 3.1.0 (unreleased)*
+* Added 'ActionView::Helpers::FormHelper.fields_for_with_index', similar to fields_for but allows to have access to the current iteration index [Jorge Bejar]
+
* Warn if we cannot verify CSRF token authenticity [José Valim]
* Allow AM/PM format in datetime selectors [Aditya Sanghi]
diff --git a/actionpack/README.rdoc b/actionpack/README.rdoc
index 5919b5c6d4..c494d78415 100644
--- a/actionpack/README.rdoc
+++ b/actionpack/README.rdoc
@@ -334,7 +334,7 @@ Action Pack is released under the MIT license.
API documentation is at
-* http://api.rubyonrails.com
+* http://api.rubyonrails.org
Bug reports and feature requests can be filed with the rest for the Ruby on Rails project here:
diff --git a/actionpack/Rakefile b/actionpack/Rakefile
index 9030db9f7a..66dd88f0c6 100755
--- a/actionpack/Rakefile
+++ b/actionpack/Rakefile
@@ -1,7 +1,7 @@
#!/usr/bin/env rake
require 'rake/testtask'
require 'rake/packagetask'
-require 'rake/gempackagetask'
+require 'rubygems/package_task'
desc "Default Task"
task :default => :test
@@ -36,7 +36,7 @@ end
spec = eval(File.read('actionpack.gemspec'))
-Rake::GemPackageTask.new(spec) do |p|
+Gem::PackageTask.new(spec) do |p|
p.gem_spec = spec
end
diff --git a/actionpack/actionpack.gemspec b/actionpack/actionpack.gemspec
index 02a65bf468..d7c8aeadd3 100644
--- a/actionpack/actionpack.gemspec
+++ b/actionpack/actionpack.gemspec
@@ -20,11 +20,11 @@ Gem::Specification.new do |s|
s.add_dependency('activemodel', version)
s.add_dependency('rack-cache', '~> 1.0.1')
s.add_dependency('builder', '~> 3.0.0')
- s.add_dependency('i18n', '~> 0.6.0beta1')
- s.add_dependency('rack', '~> 1.3.0.beta2')
+ s.add_dependency('i18n', '~> 0.6')
+ s.add_dependency('rack', '~> 1.3.0')
s.add_dependency('rack-test', '~> 0.6.0')
s.add_dependency('rack-mount', '~> 0.8.1')
- s.add_dependency('sprockets', '~> 2.0.0.beta.5')
+ s.add_dependency('sprockets', '~> 2.0.0.beta.8')
s.add_dependency('tzinfo', '~> 0.3.27')
s.add_dependency('erubis', '~> 2.7.0')
end
diff --git a/actionpack/lib/abstract_controller/base.rb b/actionpack/lib/abstract_controller/base.rb
index f67d0e558e..fd6a46fbec 100644
--- a/actionpack/lib/abstract_controller/base.rb
+++ b/actionpack/lib/abstract_controller/base.rb
@@ -10,7 +10,7 @@ module AbstractController
# <tt>AbstractController::Base</tt> is a low-level API. Nobody should be
# using it directly, and subclasses (like ActionController::Base) are
# expected to provide their own +render+ method, since rendering means
- # different things depending on the context.
+ # different things depending on the context.
class Base
attr_internal :response_body
attr_internal :action_name
diff --git a/actionpack/lib/abstract_controller/helpers.rb b/actionpack/lib/abstract_controller/helpers.rb
index dc9778a416..77cc4c07d9 100644
--- a/actionpack/lib/abstract_controller/helpers.rb
+++ b/actionpack/lib/abstract_controller/helpers.rb
@@ -67,7 +67,7 @@ module AbstractController
# helper FooHelper # => includes FooHelper
#
# When the argument is a string or symbol, the method will provide the "_helper" suffix, require the file
- # and include the module in the template class. The second form illustrates how to include custom helpers
+ # and include the module in the template class. The second form illustrates how to include custom helpers
# when working with namespaced controllers, or other cases where the file containing the helper definition is not
# in one of Rails' standard load paths:
# helper :foo # => requires 'foo_helper' and includes FooHelper
diff --git a/actionpack/lib/action_controller.rb b/actionpack/lib/action_controller.rb
index eba5e9377b..f13fd71050 100644
--- a/actionpack/lib/action_controller.rb
+++ b/actionpack/lib/action_controller.rb
@@ -37,12 +37,13 @@ module ActionController
autoload :UrlFor
end
- autoload :Integration, 'action_controller/deprecated/integration_test'
- autoload :IntegrationTest, 'action_controller/deprecated/integration_test'
- autoload :PerformanceTest, 'action_controller/deprecated/performance_test'
- autoload :UrlWriter, 'action_controller/deprecated'
- autoload :Routing, 'action_controller/deprecated'
- autoload :TestCase, 'action_controller/test_case'
+ autoload :Integration, 'action_controller/deprecated/integration_test'
+ autoload :IntegrationTest, 'action_controller/deprecated/integration_test'
+ autoload :PerformanceTest, 'action_controller/deprecated/performance_test'
+ autoload :UrlWriter, 'action_controller/deprecated'
+ autoload :Routing, 'action_controller/deprecated'
+ autoload :TestCase, 'action_controller/test_case'
+ autoload :TemplateAssertions, 'action_controller/test_case'
eager_autoload do
autoload :RecordIdentifier
diff --git a/actionpack/lib/action_controller/caching/actions.rb b/actionpack/lib/action_controller/caching/actions.rb
index 5fc6956266..667ba15cc9 100644
--- a/actionpack/lib/action_controller/caching/actions.rb
+++ b/actionpack/lib/action_controller/caching/actions.rb
@@ -39,8 +39,8 @@ module ActionController #:nodoc:
# <tt>:action => 'list', :format => :xml</tt>.
#
# You can set modify the default action cache path by passing a
- # <tt>:cache_path</tt> option. This will be passed directly to
- # <tt>ActionCachePath.path_for</tt>. This is handy for actions with
+ # <tt>:cache_path</tt> option. This will be passed directly to
+ # <tt>ActionCachePath.path_for</tt>. This is handy for actions with
# multiple possible routes that should be cached differently. If a
# block is given, it is called with the current controller instance.
#
diff --git a/actionpack/lib/action_controller/metal/data_streaming.rb b/actionpack/lib/action_controller/metal/data_streaming.rb
index 997bc6e958..623a9873fc 100644
--- a/actionpack/lib/action_controller/metal/data_streaming.rb
+++ b/actionpack/lib/action_controller/metal/data_streaming.rb
@@ -37,7 +37,7 @@ module ActionController #:nodoc:
#
# The default Content-Type and Content-Disposition headers are
# set to download arbitrary binary files in as many browsers as
- # possible. IE versions 4, 5, 5.5, and 6 are all known to have
+ # possible. IE versions 4, 5, 5.5, and 6 are all known to have
# a variety of quirks (especially when downloading over SSL).
#
# Simple download:
@@ -58,8 +58,8 @@ module ActionController #:nodoc:
#
# Also be aware that the document may be cached by proxies and browsers.
# The Pragma and Cache-Control headers declare how the file may be cached
- # by intermediaries. They default to require clients to validate with
- # the server before releasing cached responses. See
+ # by intermediaries. They default to require clients to validate with
+ # the server before releasing cached responses. See
# http://www.mnot.net/cache_docs/ for an overview of web caching and
# http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9
# for the Cache-Control header spec.
diff --git a/actionpack/lib/action_controller/metal/force_ssl.rb b/actionpack/lib/action_controller/metal/force_ssl.rb
index eb8ed7dfbd..ed693c5967 100644
--- a/actionpack/lib/action_controller/metal/force_ssl.rb
+++ b/actionpack/lib/action_controller/metal/force_ssl.rb
@@ -1,12 +1,12 @@
module ActionController
- # This module provides a method which will redirects browser to use HTTPS
+ # This module provides a method which will redirect browser to use HTTPS
# protocol. This will ensure that user's sensitive information will be
# transferred safely over the internet. You _should_ always force browser
# to use HTTPS when you're transferring sensitive information such as
# user authentication, account information, or credit card information.
#
- # Note that if you really concern about your application safety, you might
- # consider using +config.force_ssl+ in your configuration config file instead.
+ # Note that if you are really concerned about your application security,
+ # you might consider using +config.force_ssl+ in your config file instead.
# That will ensure all the data transferred via HTTPS protocol and prevent
# user from getting session hijacked when accessing the site under unsecured
# HTTP protocol.
diff --git a/actionpack/lib/action_controller/metal/http_authentication.rb b/actionpack/lib/action_controller/metal/http_authentication.rb
index 1d6df89007..2ad571b2b5 100644
--- a/actionpack/lib/action_controller/metal/http_authentication.rb
+++ b/actionpack/lib/action_controller/metal/http_authentication.rb
@@ -400,7 +400,7 @@ module ActionController
# the present token and options.
#
# controller - ActionController::Base instance for the current request.
- # login_procedure - Proc to call if a token is present. The Proc should
+ # login_procedure - Proc to call if a token is present. The Proc should
# take 2 arguments:
# authenticate(controller) { |token, options| ... }
#
@@ -413,7 +413,7 @@ module ActionController
end
end
- # Parses the token and options out of the token authorization header. If
+ # Parses the token and options out of the token authorization header. If
# the header looks like this:
# Authorization: Token token="abc", nonce="def"
# Then the returned token is "abc", and the options is {:nonce => "def"}
diff --git a/actionpack/lib/action_controller/metal/instrumentation.rb b/actionpack/lib/action_controller/metal/instrumentation.rb
index 16cbbce2fb..85d0f5f699 100644
--- a/actionpack/lib/action_controller/metal/instrumentation.rb
+++ b/actionpack/lib/action_controller/metal/instrumentation.rb
@@ -19,7 +19,7 @@ module ActionController
:controller => self.class.name,
:action => self.action_name,
:params => request.filtered_parameters,
- :format => request.format.ref,
+ :format => request.format.try(:ref),
:method => request.method,
:path => (request.fullpath rescue "unknown")
}
diff --git a/actionpack/lib/action_controller/metal/request_forgery_protection.rb b/actionpack/lib/action_controller/metal/request_forgery_protection.rb
index 13044a7450..2080e9b5b9 100644
--- a/actionpack/lib/action_controller/metal/request_forgery_protection.rb
+++ b/actionpack/lib/action_controller/metal/request_forgery_protection.rb
@@ -63,7 +63,7 @@ module ActionController #:nodoc:
#
# Valid Options:
#
- # * <tt>:only/:except</tt> - Passed to the <tt>before_filter</tt> call. Set which actions are verified.
+ # * <tt>:only/:except</tt> - Passed to the <tt>before_filter</tt> call. Set which actions are verified.
def protect_from_forgery(options = {})
self.request_forgery_protection_token ||= :authenticity_token
prepend_before_filter :verify_authenticity_token, options
@@ -71,7 +71,7 @@ module ActionController #:nodoc:
end
protected
- # The actual before_filter that is used. Modify this to change how you handle unverified requests.
+ # The actual before_filter that is used. Modify this to change how you handle unverified requests.
def verify_authenticity_token
unless verified_request?
logger.debug "WARNING: Can't verify CSRF token authenticity" if logger
@@ -83,7 +83,7 @@ module ActionController #:nodoc:
reset_session
end
- # Returns true or false if a request is verified. Checks:
+ # Returns true or false if a request is verified. Checks:
#
# * is it a GET request? Gets should be safe and idempotent
# * Does the form_authenticity_token match the given token value from the params?
@@ -96,7 +96,7 @@ module ActionController #:nodoc:
# Sets the token value for the current session.
def form_authenticity_token
- session[:_csrf_token] ||= ActiveSupport::SecureRandom.base64(32)
+ session[:_csrf_token] ||= SecureRandom.base64(32)
end
# The form's authenticity parameter. Override to provide your own.
diff --git a/actionpack/lib/action_controller/test_case.rb b/actionpack/lib/action_controller/test_case.rb
index 639e24c995..bfb820fcdf 100644
--- a/actionpack/lib/action_controller/test_case.rb
+++ b/actionpack/lib/action_controller/test_case.rb
@@ -130,7 +130,7 @@ module ActionController
super
self.session = TestSession.new
- self.session_options = TestSession::DEFAULT_OPTIONS.merge(:id => ActiveSupport::SecureRandom.hex(16))
+ self.session_options = TestSession::DEFAULT_OPTIONS.merge(:id => SecureRandom.hex(16))
end
class Result < ::Array #:nodoc:
diff --git a/actionpack/lib/action_controller/vendor/html-scanner/html/sanitizer.rb b/actionpack/lib/action_controller/vendor/html-scanner/html/sanitizer.rb
index 91a97c02ff..eaefdc0f15 100644
--- a/actionpack/lib/action_controller/vendor/html-scanner/html/sanitizer.rb
+++ b/actionpack/lib/action_controller/vendor/html-scanner/html/sanitizer.rb
@@ -103,7 +103,7 @@ module HTML
# Specifies the default Set of allowed shorthand css properties for the #sanitize and #sanitize_css helpers.
self.shorthand_css_properties = Set.new(%w(background border margin padding))
- # Sanitizes a block of css code. Used by #sanitize when it comes across a style attribute
+ # Sanitizes a block of css code. Used by #sanitize when it comes across a style attribute
def sanitize_css(style)
# disallow urls
style = style.to_s.gsub(/url\s*\(\s*[^\s)]+?\s*\)\s*/, ' ')
diff --git a/actionpack/lib/action_dispatch/http/mime_type.rb b/actionpack/lib/action_dispatch/http/mime_type.rb
index 7c9ebe7c7b..fa2948c8db 100644
--- a/actionpack/lib/action_dispatch/http/mime_type.rb
+++ b/actionpack/lib/action_dispatch/http/mime_type.rb
@@ -47,7 +47,7 @@ module Mime
cattr_reader :html_types
# These are the content types which browsers can generate without using ajax, flash, etc
- # i.e. following a link, getting an image or posting a form. CSRF protection
+ # i.e. following a link, getting an image or posting a form. CSRF protection
# only needs to protect against these types.
@@browser_generated_types = Set.new [:html, :url_encoded_form, :multipart_form, :text]
cattr_reader :browser_generated_types
@@ -246,7 +246,7 @@ module Mime
end
end
- # Returns true if Action Pack should check requests using this Mime Type for possible request forgery. See
+ # Returns true if Action Pack should check requests using this Mime Type for possible request forgery. See
# ActionController::RequestForgeryProtection.
def verify_request?
@@browser_generated_types.include?(to_sym)
diff --git a/actionpack/lib/action_dispatch/http/request.rb b/actionpack/lib/action_dispatch/http/request.rb
index ccb866f4f7..b22d426c1f 100644
--- a/actionpack/lib/action_dispatch/http/request.rb
+++ b/actionpack/lib/action_dispatch/http/request.rb
@@ -2,7 +2,6 @@ require 'tempfile'
require 'stringio'
require 'strscan'
-require 'active_support/core_ext/module/deprecation'
require 'active_support/core_ext/hash/indifferent_access'
require 'active_support/core_ext/string/access'
require 'active_support/inflector'
@@ -26,7 +25,7 @@ module ActionDispatch
HTTP_ACCEPT HTTP_ACCEPT_CHARSET HTTP_ACCEPT_ENCODING
HTTP_ACCEPT_LANGUAGE HTTP_CACHE_CONTROL HTTP_FROM
HTTP_NEGOTIATE HTTP_PRAGMA ].freeze
-
+
ENV_METHODS.each do |env|
class_eval <<-METHOD, __FILE__, __LINE__ + 1
def #{env.sub(/^HTTP_/n, '').downcase}
@@ -134,11 +133,6 @@ module ActionDispatch
@fullpath ||= super
end
- def forgery_whitelisted?
- get?
- end
- deprecate :forgery_whitelisted? => "it is just an alias for 'get?' now, update your code"
-
def media_type
content_mime_type.to_s
end
@@ -172,10 +166,10 @@ module ActionDispatch
)\.
}x
- # Determines originating IP address. REMOTE_ADDR is the standard
- # but will fail if the user is behind a proxy. HTTP_CLIENT_IP and/or
+ # Determines originating IP address. REMOTE_ADDR is the standard
+ # but will fail if the user is behind a proxy. HTTP_CLIENT_IP and/or
# HTTP_X_FORWARDED_FOR are set by proxies so check for these if
- # REMOTE_ADDR is a proxy. HTTP_X_FORWARDED_FOR may be a comma-
+ # REMOTE_ADDR is a proxy. HTTP_X_FORWARDED_FOR may be a comma-
# delimited list in the case of multiple chained proxies; the last
# address which is not trusted is the originating IP.
def remote_ip
diff --git a/actionpack/lib/action_dispatch/http/response.rb b/actionpack/lib/action_dispatch/http/response.rb
index 3a6b1da4fd..f1e85559a3 100644
--- a/actionpack/lib/action_dispatch/http/response.rb
+++ b/actionpack/lib/action_dispatch/http/response.rb
@@ -33,7 +33,8 @@ module ActionDispatch # :nodoc:
# end
# end
class Response
- attr_accessor :request, :header, :status
+ attr_accessor :request, :header
+ attr_reader :status
attr_writer :sending_file
alias_method :headers=, :header=
@@ -115,32 +116,9 @@ module ActionDispatch # :nodoc:
EMPTY = " "
- class BodyBuster #:nodoc:
- def initialize(response)
- @response = response
- @body = ""
- end
-
- def bust(body)
- body.call(@response, self)
- body.close if body.respond_to?(:close)
- @body
- end
-
- def write(string)
- @body << string.to_s
- end
- end
-
def body=(body)
@blank = true if body == EMPTY
- if body.respond_to?(:call)
- ActiveSupport::Deprecation.warn "Setting a Proc or an object that responds to call " \
- "in response_body is no longer supported", caller
- body = BodyBuster.new(self).bust(body)
- end
-
# Explicitly check for strings. This is *wrong* theoretically
# but if we don't check this, the performance on string bodies
# is bad on Ruby 1.8 (because strings responds to each then).
diff --git a/actionpack/lib/action_dispatch/middleware/callbacks.rb b/actionpack/lib/action_dispatch/middleware/callbacks.rb
index 1bb2ad7f67..8c0f4052ec 100644
--- a/actionpack/lib/action_dispatch/middleware/callbacks.rb
+++ b/actionpack/lib/action_dispatch/middleware/callbacks.rb
@@ -19,8 +19,7 @@ module ActionDispatch
set_callback(:call, :after, *args, &block)
end
- def initialize(app, unused = nil)
- ActiveSupport::Deprecation.warn "Passing a second argument to ActionDispatch::Callbacks.new is deprecated." unless unused.nil?
+ def initialize(app)
@app = app
end
diff --git a/actionpack/lib/action_dispatch/middleware/cookies.rb b/actionpack/lib/action_dispatch/middleware/cookies.rb
index 0057f64dd3..47c4bad489 100644
--- a/actionpack/lib/action_dispatch/middleware/cookies.rb
+++ b/actionpack/lib/action_dispatch/middleware/cookies.rb
@@ -59,7 +59,7 @@ module ActionDispatch
# The option symbols for setting cookies are:
#
# * <tt>:value</tt> - The cookie's value or list of values (as an array).
- # * <tt>:path</tt> - The path for which this cookie applies. Defaults to the root
+ # * <tt>:path</tt> - The path for which this cookie applies. Defaults to the root
# of the application.
# * <tt>:domain</tt> - The domain for which this cookie applies so you can
# restrict to the domain level. If you use a schema like www.example.com
@@ -305,7 +305,7 @@ module ActionDispatch
if secret.length < SECRET_MIN_LENGTH
raise ArgumentError, "Secret should be something secure, " +
- "like \"#{ActiveSupport::SecureRandom.hex(16)}\". The value you " +
+ "like \"#{SecureRandom.hex(16)}\". The value you " +
"provided, \"#{secret}\", is shorter than the minimum length " +
"of #{SECRET_MIN_LENGTH} characters"
end
diff --git a/actionpack/lib/action_dispatch/middleware/session/abstract_store.rb b/actionpack/lib/action_dispatch/middleware/session/abstract_store.rb
index 1a811ce1b1..a70d814749 100644
--- a/actionpack/lib/action_dispatch/middleware/session/abstract_store.rb
+++ b/actionpack/lib/action_dispatch/middleware/session/abstract_store.rb
@@ -29,7 +29,7 @@ module ActionDispatch
end
def generate_sid
- sid = ActiveSupport::SecureRandom.hex(16)
+ sid = SecureRandom.hex(16)
sid.encode!('UTF-8') if sid.respond_to?(:encode!)
sid
end
@@ -73,13 +73,7 @@ module ActionDispatch
include StaleSessionCheck
def destroy_session(env, sid, options)
- ActiveSupport::Deprecation.warn "Implementing #destroy in session stores is deprecated. " <<
- "Please implement destroy_session(env, session_id, options) instead."
- destroy(env)
- end
-
- def destroy(env)
- raise '#destroy needs to be implemented.'
+ raise '#destroy_session needs to be implemented.'
end
end
end
diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb
index c25f8c90bc..3999bd0a5e 100644
--- a/actionpack/lib/action_dispatch/routing/mapper.rb
+++ b/actionpack/lib/action_dispatch/routing/mapper.rb
@@ -335,7 +335,7 @@ module ActionDispatch
#
# [:on]
# Shorthand for wrapping routes in a specific RESTful context. Valid
- # values are +:member+, +:collection+, and +:new+. Only use within
+ # values are +:member+, +:collection+, and +:new+. Only use within
# <tt>resource(s)</tt> block. For example:
#
# resource :bar do
@@ -578,8 +578,8 @@ module ActionDispatch
# end
#
# This generates helpers such as +account_projects_path+, just like +resources+ does.
- # The difference here being that the routes generated are like /rails/projects/2,
- # rather than /accounts/rails/projects/2.
+ # The difference here being that the routes generated are like /:account_id/projects,
+ # rather than /accounts/:account_id/projects.
#
# === Options
#
@@ -1094,11 +1094,11 @@ module ActionDispatch
# [:shallow_path]
# Prefixes nested shallow routes with the specified path.
#
- # scope :shallow_path => "sekret" do
- # resources :posts do
- # resources :comments, :shallow => true
+ # scope :shallow_path => "sekret" do
+ # resources :posts do
+ # resources :comments, :shallow => true
+ # end
# end
- # end
#
# The +comments+ resource here will have the following routes generated for it:
#
diff --git a/actionpack/lib/action_dispatch/routing/route.rb b/actionpack/lib/action_dispatch/routing/route.rb
index a049510182..10b3d38346 100644
--- a/actionpack/lib/action_dispatch/routing/route.rb
+++ b/actionpack/lib/action_dispatch/routing/route.rb
@@ -1,5 +1,3 @@
-require 'active_support/core_ext/module/deprecation'
-
module ActionDispatch
module Routing
class Route #:nodoc:
@@ -47,11 +45,6 @@ module ActionDispatch
@segment_keys ||= conditions[:path_info].names.compact.map { |key| key.to_sym }
end
- def to_a
- [@app, @conditions, @defaults, @name]
- end
- deprecate :to_a
-
def to_s
@to_s ||= begin
"%-6s %-40s %s" % [(verb || :any).to_s.upcase, path, requirements.inspect]
diff --git a/actionpack/lib/action_dispatch/routing/url_for.rb b/actionpack/lib/action_dispatch/routing/url_for.rb
index 5893f86798..480144fe9d 100644
--- a/actionpack/lib/action_dispatch/routing/url_for.rb
+++ b/actionpack/lib/action_dispatch/routing/url_for.rb
@@ -108,7 +108,7 @@ module ActionDispatch
end
# Generate a url based on the options provided, default_url_options and the
- # routes defined in routes.rb. The following options are supported:
+ # routes defined in routes.rb. The following options are supported:
#
# * <tt>:only_path</tt> - If true, the relative url is returned. Defaults to +false+.
# * <tt>:protocol</tt> - The protocol to connect to. Defaults to 'http'.
diff --git a/actionpack/lib/action_dispatch/testing/assertions.rb b/actionpack/lib/action_dispatch/testing/assertions.rb
index 822150b768..226baf9ad0 100644
--- a/actionpack/lib/action_dispatch/testing/assertions.rb
+++ b/actionpack/lib/action_dispatch/testing/assertions.rb
@@ -8,12 +8,11 @@ module ActionDispatch
extend ActiveSupport::Concern
- included do
- include DomAssertions
- include ResponseAssertions
- include RoutingAssertions
- include SelectorAssertions
- include TagAssertions
- end
+ include DomAssertions
+ include ResponseAssertions
+ include RoutingAssertions
+ include SelectorAssertions
+ include TagAssertions
end
end
+
diff --git a/actionpack/lib/action_dispatch/testing/assertions/response.rb b/actionpack/lib/action_dispatch/testing/assertions/response.rb
index 3335742d47..606b01893e 100644
--- a/actionpack/lib/action_dispatch/testing/assertions/response.rb
+++ b/actionpack/lib/action_dispatch/testing/assertions/response.rb
@@ -6,13 +6,6 @@ module ActionDispatch
module ResponseAssertions
extend ActiveSupport::Concern
- included do
- # TODO: Need to pull in AV::Template monkey patches that track which
- # templates are rendered. assert_template should probably be part
- # of AV instead of AD.
- require 'action_view/test_case'
- end
-
# Asserts that the response is one of the following types:
#
# * <tt>:success</tt> - Status code was 200
diff --git a/actionpack/lib/action_dispatch/testing/assertions/routing.rb b/actionpack/lib/action_dispatch/testing/assertions/routing.rb
index b760db42e2..57a24a1bd9 100644
--- a/actionpack/lib/action_dispatch/testing/assertions/routing.rb
+++ b/actionpack/lib/action_dispatch/testing/assertions/routing.rb
@@ -7,18 +7,18 @@ module ActionDispatch
# Suite of assertions to test routes generated by \Rails and the handling of requests made to them.
module RoutingAssertions
# Asserts that the routing of the given +path+ was handled correctly and that the parsed options (given in the +expected_options+ hash)
- # match +path+. Basically, it asserts that \Rails recognizes the route given by +expected_options+.
+ # match +path+. Basically, it asserts that \Rails recognizes the route given by +expected_options+.
#
- # Pass a hash in the second argument (+path+) to specify the request method. This is useful for routes
- # requiring a specific HTTP method. The hash should contain a :path with the incoming request path
+ # Pass a hash in the second argument (+path+) to specify the request method. This is useful for routes
+ # requiring a specific HTTP method. The hash should contain a :path with the incoming request path
# and a :method containing the required HTTP verb.
#
# # assert that POSTing to /items will call the create action on ItemsController
# assert_recognizes({:controller => 'items', :action => 'create'}, {:path => 'items', :method => :post})
#
- # You can also pass in +extras+ with a hash containing URL parameters that would normally be in the query string. This can be used
- # to assert that values in the query string string will end up in the params hash correctly. To test query strings you must use the
- # extras argument, appending the query string on the path directly will not work. For example:
+ # You can also pass in +extras+ with a hash containing URL parameters that would normally be in the query string. This can be used
+ # to assert that values in the query string string will end up in the params hash correctly. To test query strings you must use the
+ # extras argument, appending the query string on the path directly will not work. For example:
#
# # assert that a path of '/items/list/1?view=print' returns the correct options
# assert_recognizes({:controller => 'items', :action => 'list', :id => '1', :view => 'print'}, 'items/list/1', { :view => "print" })
@@ -49,7 +49,7 @@ module ActionDispatch
assert_equal(expected_options, request.path_parameters, msg)
end
- # Asserts that the provided options can be used to generate the provided path. This is the inverse of +assert_recognizes+.
+ # Asserts that the provided options can be used to generate the provided path. This is the inverse of +assert_recognizes+.
# The +extras+ parameter is used to tell the request the names and values of additional request parameters that would be in
# a query string. The +message+ parameter allows you to specify a custom error message for assertion failures.
#
@@ -92,10 +92,10 @@ module ActionDispatch
end
# Asserts that path and options match both ways; in other words, it verifies that <tt>path</tt> generates
- # <tt>options</tt> and then that <tt>options</tt> generates <tt>path</tt>. This essentially combines +assert_recognizes+
+ # <tt>options</tt> and then that <tt>options</tt> generates <tt>path</tt>. This essentially combines +assert_recognizes+
# and +assert_generates+ into one step.
#
- # The +extras+ hash allows you to specify options that would normally be provided as a query string to the action. The
+ # The +extras+ hash allows you to specify options that would normally be provided as a query string to the action. The
# +message+ parameter allows you to specify a custom error message to display upon failure.
#
# ==== Examples
diff --git a/actionpack/lib/action_dispatch/testing/integration.rb b/actionpack/lib/action_dispatch/testing/integration.rb
index 7d707d03a9..9791ba58e2 100644
--- a/actionpack/lib/action_dispatch/testing/integration.rb
+++ b/actionpack/lib/action_dispatch/testing/integration.rb
@@ -62,7 +62,7 @@ module ActionDispatch
#
# The request_method is +:get+, +:post+, +:put+, +:delete+ or +:head+; the
# parameters are +nil+, a hash, or a url-encoded or multipart string;
- # the headers are a hash. Keys are automatically upcased and prefixed
+ # the headers are a hash. Keys are automatically upcased and prefixed
# with 'HTTP_' if not already.
def xml_http_request(request_method, path, parameters = nil, headers = nil)
headers ||= {}
diff --git a/actionpack/lib/action_view/helpers.rb b/actionpack/lib/action_view/helpers.rb
index 78a68db282..262e0f1010 100644
--- a/actionpack/lib/action_view/helpers.rb
+++ b/actionpack/lib/action_view/helpers.rb
@@ -22,7 +22,6 @@ module ActionView #:nodoc:
autoload :RecordTagHelper
autoload :RenderingHelper
autoload :SanitizeHelper
- autoload :SprocketsHelper
autoload :TagHelper
autoload :TextHelper
autoload :TranslationHelper
@@ -53,7 +52,6 @@ module ActionView #:nodoc:
include RecordTagHelper
include RenderingHelper
include SanitizeHelper
- include SprocketsHelper
include TagHelper
include TextHelper
include TranslationHelper
diff --git a/actionpack/lib/action_view/helpers/asset_paths.rb b/actionpack/lib/action_view/helpers/asset_paths.rb
index 38810eea2e..9a99c3cf52 100644
--- a/actionpack/lib/action_view/helpers/asset_paths.rb
+++ b/actionpack/lib/action_view/helpers/asset_paths.rb
@@ -44,7 +44,12 @@ module ActionView
raise NotImplementedError
end
+ def rewrite_relative_url_root(source, relative_url_root)
+ relative_url_root && !source.starts_with?("#{relative_url_root}/") ? "#{relative_url_root}#{source}" : source
+ end
+
def rewrite_host_and_protocol(source, has_request)
+ source = rewrite_relative_url_root(source, controller.config.relative_url_root) if has_request
host = compute_asset_host(source)
if has_request && host && !is_uri?(host)
host = "#{controller.request.protocol}#{host}"
@@ -55,11 +60,11 @@ module ActionView
# Pick an asset host for this source. Returns +nil+ if no host is set,
# the host if no wildcard is set, the host interpolated with the
# numbers 0-3 if it contains <tt>%d</tt> (the number is the source hash mod 4),
- # or the value returned from invoking the proc if it's a proc or the value from
- # invoking call if it's an object responding to call.
+ # or the value returned from invoking call on an object responding to call
+ # (proc or otherwise).
def compute_asset_host(source)
if host = config.asset_host
- if host.is_a?(Proc) || host.respond_to?(:call)
+ if host.respond_to?(:call)
case host.is_a?(Proc) ? host.arity : host.method(:call).arity
when 2
request = controller.respond_to?(:request) && controller.request
@@ -75,4 +80,4 @@ module ActionView
end
end
-end \ No newline at end of file
+end
diff --git a/actionpack/lib/action_view/helpers/asset_tag_helper.rb b/actionpack/lib/action_view/helpers/asset_tag_helper.rb
index 9bc847a1ab..7970176d37 100644
--- a/actionpack/lib/action_view/helpers/asset_tag_helper.rb
+++ b/actionpack/lib/action_view/helpers/asset_tag_helper.rb
@@ -274,11 +274,7 @@ module ActionView
# The alias +path_to_image+ is provided to avoid that. Rails uses the alias internally, and
# plugin authors are encouraged to do so.
def image_path(source)
- if config.use_sprockets
- asset_path(source)
- else
- asset_paths.compute_public_path(source, 'images')
- end
+ asset_paths.compute_public_path(source, 'images')
end
alias_method :path_to_image, :image_path # aliased to avoid conflicts with an image_path named route
@@ -293,11 +289,7 @@ module ActionView
# video_path("/trailers/hd.avi") # => /trailers/hd.avi
# video_path("http://www.example.com/vid/hd.avi") # => http://www.example.com/vid/hd.avi
def video_path(source)
- if config.use_sprockets
- asset_path(source)
- else
- asset_paths.compute_public_path(source, 'videos')
- end
+ asset_paths.compute_public_path(source, 'videos')
end
alias_method :path_to_video, :video_path # aliased to avoid conflicts with a video_path named route
@@ -312,11 +304,7 @@ module ActionView
# audio_path("/sounds/horse.wav") # => /sounds/horse.wav
# audio_path("http://www.example.com/sounds/horse.wav") # => http://www.example.com/sounds/horse.wav
def audio_path(source)
- if config.use_sprockets
- asset_path(source)
- else
- asset_paths.compute_public_path(source, 'audios')
- end
+ asset_paths.compute_public_path(source, 'audios')
end
alias_method :path_to_audio, :audio_path # aliased to avoid conflicts with an audio_path named route
diff --git a/actionpack/lib/action_view/helpers/asset_tag_helpers/asset_paths.rb b/actionpack/lib/action_view/helpers/asset_tag_helpers/asset_paths.rb
index cd0f8c8878..2d49823412 100644
--- a/actionpack/lib/action_view/helpers/asset_tag_helpers/asset_paths.rb
+++ b/actionpack/lib/action_view/helpers/asset_tag_helpers/asset_paths.rb
@@ -85,17 +85,8 @@ module ActionView
end
end
end
-
- def rewrite_relative_url_root(source, relative_url_root)
- relative_url_root && !source.starts_with?("#{relative_url_root}/") ? "#{relative_url_root}#{source}" : source
- end
-
- def rewrite_host_and_protocol(source, has_request)
- source = rewrite_relative_url_root(source, controller.config.relative_url_root) if has_request
- super(source, has_request)
- end
end
end
end
-end \ No newline at end of file
+end
diff --git a/actionpack/lib/action_view/helpers/asset_tag_helpers/javascript_tag_helpers.rb b/actionpack/lib/action_view/helpers/asset_tag_helpers/javascript_tag_helpers.rb
index e1ee0d0e1a..0f8a63901e 100644
--- a/actionpack/lib/action_view/helpers/asset_tag_helpers/javascript_tag_helpers.rb
+++ b/actionpack/lib/action_view/helpers/asset_tag_helpers/javascript_tag_helpers.rb
@@ -187,12 +187,8 @@ module ActionView
#
# javascript_include_tag :all, :cache => true, :recursive => true
def javascript_include_tag(*sources)
- if config.use_sprockets
- sprockets_javascript_include_tag(*sources)
- else
- @javascript_include ||= JavascriptIncludeTag.new(config, asset_paths)
- @javascript_include.include_tag(*sources)
- end
+ @javascript_include ||= JavascriptIncludeTag.new(config, asset_paths)
+ @javascript_include.include_tag(*sources)
end
end
end
diff --git a/actionpack/lib/action_view/helpers/asset_tag_helpers/stylesheet_tag_helpers.rb b/actionpack/lib/action_view/helpers/asset_tag_helpers/stylesheet_tag_helpers.rb
index a95eb221be..e4f11c9bc7 100644
--- a/actionpack/lib/action_view/helpers/asset_tag_helpers/stylesheet_tag_helpers.rb
+++ b/actionpack/lib/action_view/helpers/asset_tag_helpers/stylesheet_tag_helpers.rb
@@ -137,12 +137,8 @@ module ActionView
# stylesheet_link_tag :all, :concat => true
#
def stylesheet_link_tag(*sources)
- if config.use_sprockets
- sprockets_stylesheet_link_tag(*sources)
- else
- @stylesheet_include ||= StylesheetIncludeTag.new(config, asset_paths)
- @stylesheet_include.include_tag(*sources)
- end
+ @stylesheet_include ||= StylesheetIncludeTag.new(config, asset_paths)
+ @stylesheet_include.include_tag(*sources)
end
end
diff --git a/actionpack/lib/action_view/helpers/capture_helper.rb b/actionpack/lib/action_view/helpers/capture_helper.rb
index 3b5f4e694f..62f95379cd 100644
--- a/actionpack/lib/action_view/helpers/capture_helper.rb
+++ b/actionpack/lib/action_view/helpers/capture_helper.rb
@@ -27,7 +27,7 @@ module ActionView
# "The current timestamp is #{Time.now}."
# end
#
- # You can then use that variable anywhere else. For example:
+ # You can then use that variable anywhere else. For example:
#
# <html>
# <head><title><%= @greeting %></title></head>
@@ -76,7 +76,7 @@ module ActionView
#
# <%= stored_content %>
#
- # You can use the <tt>yield</tt> syntax alongside an existing call to <tt>yield</tt> in a layout. For example:
+ # You can use the <tt>yield</tt> syntax alongside an existing call to <tt>yield</tt> in a layout. For example:
#
# <%# This is the layout %>
# <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
diff --git a/actionpack/lib/action_view/helpers/date_helper.rb b/actionpack/lib/action_view/helpers/date_helper.rb
index c78c03a5eb..56e3af683b 100644
--- a/actionpack/lib/action_view/helpers/date_helper.rb
+++ b/actionpack/lib/action_view/helpers/date_helper.rb
@@ -517,7 +517,7 @@ module ActionView
# # that is named 'due' rather than 'day'.
# select_day(my_time, :field_name => 'due')
#
- # # Generates a select field for days with a custom prompt. Use <tt>:prompt => true</tt> for a
+ # # Generates a select field for days with a custom prompt. Use <tt>:prompt => true</tt> for a
# # generic prompt.
# select_day(5, :prompt => 'Choose day')
#
diff --git a/actionpack/lib/action_view/helpers/form_helper.rb b/actionpack/lib/action_view/helpers/form_helper.rb
index 07e2c8d341..cb1c13912a 100644
--- a/actionpack/lib/action_view/helpers/form_helper.rb
+++ b/actionpack/lib/action_view/helpers/form_helper.rb
@@ -555,6 +555,19 @@ module ActionView
# ...
# <% end %>
#
+ # In addition, you may want to have access to the current iteration index.
+ # In that case, you can use a similar method called fields_for_with_index
+ # which receives a block with an extra parameter:
+ #
+ # <%= form_for @person do |person_form| %>
+ # ...
+ # <%= person_form.fields_for_with_index :projects do |project_fields, index| %>
+ # Position: <%= index %>
+ # Name: <%= project_fields.text_field :name %>
+ # <% end %>
+ # ...
+ # <% end %>
+ #
# When projects is already an association on Person you can use
# +accepts_nested_attributes_for+ to define the writer method for you:
#
@@ -1216,6 +1229,13 @@ module ActionView
RUBY_EVAL
end
+ # Check +fields_for+ for docs and examples.
+ def fields_for_with_index(record_name, record_object = nil, fields_options = {}, &block)
+ index = fields_options[:index] || options[:child_index] || nested_child_index(@object_name)
+ block_with_index = Proc.new{ |obj| block.call(obj, index) }
+ fields_for(record_name, record_object, fields_options, &block_with_index)
+ end
+
def fields_for(record_name, record_object = nil, fields_options = {}, &block)
fields_options, record_object = record_object, nil if record_object.is_a?(Hash)
fields_options[:builder] ||= options[:builder]
diff --git a/actionpack/lib/action_view/helpers/form_options_helper.rb b/actionpack/lib/action_view/helpers/form_options_helper.rb
index 0aaa690129..794132637c 100644
--- a/actionpack/lib/action_view/helpers/form_options_helper.rb
+++ b/actionpack/lib/action_view/helpers/form_options_helper.rb
@@ -125,7 +125,7 @@ module ActionView
# This allows the user to submit a form page more than once with the expected results of creating multiple records.
# In addition, this allows a single partial to be used to generate form inputs for both edit and create forms.
#
- # By default, <tt>post.person_id</tt> is the selected option. Specify <tt>:selected => value</tt> to use a different selection
+ # By default, <tt>post.person_id</tt> is the selected option. Specify <tt>:selected => value</tt> to use a different selection
# or <tt>:selected => nil</tt> to leave all options unselected. Similarly, you can specify values to be disabled in the option
# tags by specifying the <tt>:disabled</tt> option. This can either be a single value or an array of values to be disabled.
def select(object, method, choices, options = {}, html_options = {})
@@ -255,7 +255,7 @@ module ActionView
# Accepts a container (hash, array, enumerable, your type) and returns a string of option tags. Given a container
# where the elements respond to first and last (such as a two-element array), the "lasts" serve as option values and
# the "firsts" as option text. Hashes are turned into this form automatically, so the keys become "firsts" and values
- # become lasts. If +selected+ is specified, the matching "last" or element will get the selected option-tag. +selected+
+ # become lasts. If +selected+ is specified, the matching "last" or element will get the selected option-tag. +selected+
# may also be an array of values to be selected when using a multiple select.
#
# Examples (call, result):
@@ -406,13 +406,13 @@ module ActionView
# wraps them with <tt><optgroup></tt> tags.
#
# Parameters:
- # * +grouped_options+ - Accepts a nested array or hash of strings. The first value serves as the
+ # * +grouped_options+ - Accepts a nested array or hash of strings. The first value serves as the
# <tt><optgroup></tt> label while the second value must be an array of options. The second value can be a
# nested array of text-value pairs. See <tt>options_for_select</tt> for more info.
# Ex. ["North America",[["United States","US"],["Canada","CA"]]]
# * +selected_key+ - A value equal to the +value+ attribute for one of the <tt><option></tt> tags,
# which will have the +selected+ attribute set. Note: It is possible for this value to match multiple options
- # as you might have the same option in multiple groups. Each will then get <tt>selected="selected"</tt>.
+ # as you might have the same option in multiple groups. Each will then get <tt>selected="selected"</tt>.
# * +prompt+ - set to true or a prompt string. When the select element doesn't have a value yet, this
# prepends an option with a generic prompt - "Please select" - or the given prompt string.
#
diff --git a/actionpack/lib/action_view/helpers/form_tag_helper.rb b/actionpack/lib/action_view/helpers/form_tag_helper.rb
index 65a98fb27a..a91e86f4db 100644
--- a/actionpack/lib/action_view/helpers/form_tag_helper.rb
+++ b/actionpack/lib/action_view/helpers/form_tag_helper.rb
@@ -204,7 +204,7 @@ module ActionView
text_field_tag(name, value, options.stringify_keys.update("type" => "hidden"))
end
- # Creates a file upload field. If you are using file uploads then you will also need
+ # Creates a file upload field. If you are using file uploads then you will also need
# to set the multipart option for the form tag:
#
# <%= form_tag '/upload', :multipart => true do %>
diff --git a/actionpack/lib/action_view/helpers/sanitize_helper.rb b/actionpack/lib/action_view/helpers/sanitize_helper.rb
index 841be0a567..bcc8f6fbcb 100644
--- a/actionpack/lib/action_view/helpers/sanitize_helper.rb
+++ b/actionpack/lib/action_view/helpers/sanitize_helper.rb
@@ -14,13 +14,13 @@ module ActionView
#
# It also strips href/src tags with invalid protocols, like javascript: especially.
# It does its best to counter any tricks that hackers may use, like throwing in
- # unicode/ascii/hex values to get past the javascript: filters. Check out
+ # unicode/ascii/hex values to get past the javascript: filters. Check out
# the extensive test suite.
#
# <%= sanitize @article.body %>
#
# You can add or remove tags/attributes if you want to customize it a bit.
- # See ActionView::Base for full docs on the available options. You can add
+ # See ActionView::Base for full docs on the available options. You can add
# tags/attributes for single uses of +sanitize+ by passing either the
# <tt>:attributes</tt> or <tt>:tags</tt> options:
#
@@ -66,7 +66,7 @@ module ActionView
self.class.white_list_sanitizer.sanitize_css(style)
end
- # Strips all HTML tags from the +html+, including comments. This uses the
+ # Strips all HTML tags from the +html+, including comments. This uses the
# html-scanner tokenizer and so its HTML parsing ability is limited by
# that of html-scanner.
#
@@ -142,7 +142,7 @@ module ActionView
white_list_sanitizer.protocol_separator = value
end
- # Gets the HTML::FullSanitizer instance used by +strip_tags+. Replace with
+ # Gets the HTML::FullSanitizer instance used by +strip_tags+. Replace with
# any object that responds to +sanitize+.
#
# class Application < Rails::Application
@@ -153,7 +153,7 @@ module ActionView
@full_sanitizer ||= HTML::FullSanitizer.new
end
- # Gets the HTML::LinkSanitizer instance used by +strip_links+. Replace with
+ # Gets the HTML::LinkSanitizer instance used by +strip_links+. Replace with
# any object that responds to +sanitize+.
#
# class Application < Rails::Application
diff --git a/actionpack/lib/action_view/helpers/sprockets_helper.rb b/actionpack/lib/action_view/helpers/sprockets_helper.rb
deleted file mode 100644
index ab98da9624..0000000000
--- a/actionpack/lib/action_view/helpers/sprockets_helper.rb
+++ /dev/null
@@ -1,69 +0,0 @@
-require 'uri'
-require 'action_view/helpers/asset_paths'
-
-module ActionView
- module Helpers
- module SprocketsHelper
- def asset_path(source, default_ext = nil)
- sprockets_asset_paths.compute_public_path(source, 'assets', default_ext, true)
- end
-
- def sprockets_javascript_include_tag(source, options = {})
- options = {
- 'type' => "text/javascript",
- 'src' => asset_path(source, 'js')
- }.merge(options.stringify_keys)
-
- content_tag 'script', "", options
- end
-
- def sprockets_stylesheet_link_tag(source, options = {})
- options = {
- 'rel' => "stylesheet",
- 'type' => "text/css",
- 'media' => "screen",
- 'href' => asset_path(source, 'css')
- }.merge(options.stringify_keys)
-
- tag 'link', options
- end
-
- private
-
- def sprockets_asset_paths
- @sprockets_asset_paths ||= begin
- config = self.config if respond_to?(:config)
- controller = self.controller if respond_to?(:controller)
- SprocketsHelper::AssetPaths.new(config, controller)
- end
- end
-
- class AssetPaths < ActionView::Helpers::AssetPaths #:nodoc:
- def rewrite_asset_path(source, dir)
- if source[0] == ?/
- source
- else
- assets.path(source, performing_caching?, dir)
- end
- end
-
- def rewrite_extension(source, dir, ext)
- if ext && File.extname(source).empty?
- "#{source}.#{ext}"
- else
- source
- end
- end
-
- def assets
- Rails.application.assets
- end
-
- # When included in Sprockets::Context, we need to ask the top-level config as the controller is not available
- def performing_caching?
- @config ? @config.perform_caching : Rails.application.config.action_controller.perform_caching
- end
- end
- end
- end
-end \ No newline at end of file
diff --git a/actionpack/lib/action_view/helpers/tag_helper.rb b/actionpack/lib/action_view/helpers/tag_helper.rb
index 786af5ca58..8c33ef09fa 100644
--- a/actionpack/lib/action_view/helpers/tag_helper.rb
+++ b/actionpack/lib/action_view/helpers/tag_helper.rb
@@ -94,7 +94,7 @@ module ActionView
end
end
- # Returns a CDATA section with the given +content+. CDATA sections
+ # Returns a CDATA section with the given +content+. CDATA sections
# are used to escape blocks of text containing characters which would
# otherwise be recognized as markup. CDATA sections begin with the string
# <tt><![CDATA[</tt> and end with (and may not contain) the string <tt>]]></tt>.
diff --git a/actionpack/lib/action_view/helpers/text_helper.rb b/actionpack/lib/action_view/helpers/text_helper.rb
index ca09c77b5c..75422a343d 100644
--- a/actionpack/lib/action_view/helpers/text_helper.rb
+++ b/actionpack/lib/action_view/helpers/text_helper.rb
@@ -232,7 +232,7 @@ module ActionView
# considered as a linebreak and a <tt><br /></tt> tag is appended. This
# method does not remove the newlines from the +text+.
#
- # You can pass any HTML attributes into <tt>html_options</tt>. These
+ # You can pass any HTML attributes into <tt>html_options</tt>. These
# will be added to all created paragraphs.
#
# ==== Options
@@ -267,7 +267,7 @@ module ActionView
# Creates a Cycle object whose _to_s_ method cycles through elements of an
# array every time it is called. This can be used for example, to alternate
- # classes for table rows. You can use named cycles to allow nesting in loops.
+ # classes for table rows. You can use named cycles to allow nesting in loops.
# Passing a Hash as the last parameter with a <tt>:name</tt> key will create a
# named cycle. The default name for a cycle without a +:name+ key is
# <tt>"default"</tt>. You can manually reset a cycle by calling reset_cycle
diff --git a/actionpack/lib/action_view/helpers/url_helper.rb b/actionpack/lib/action_view/helpers/url_helper.rb
index 5488c752cc..25411856cb 100644
--- a/actionpack/lib/action_view/helpers/url_helper.rb
+++ b/actionpack/lib/action_view/helpers/url_helper.rb
@@ -160,7 +160,7 @@ module ActionView
#
# ==== Examples
# Because it relies on +url_for+, +link_to+ supports both older-style controller/action/id arguments
- # and newer RESTful routes. Current Rails style favors RESTful routes whenever possible, so base
+ # and newer RESTful routes. Current Rails style favors RESTful routes whenever possible, so base
# your application on resources and use
#
# link_to "Profile", profile_path(@profile)
@@ -348,7 +348,7 @@ module ActionView
# Creates a link tag of the given +name+ using a URL created by the set of
# +options+ unless the current request URI is the same as the links, in
# which case only the name is returned (or the given block is yielded, if
- # one exists). You can give +link_to_unless_current+ a block which will
+ # one exists). You can give +link_to_unless_current+ a block which will
# specialize the default behavior (e.g., show a "Start Here" link rather
# than the link's text).
#
@@ -375,7 +375,7 @@ module ActionView
# </ul>
#
# The implicit block given to +link_to_unless_current+ is evaluated if the current
- # action is the action given. So, if we had a comments page and wanted to render a
+ # action is the action given. So, if we had a comments page and wanted to render a
# "Go Back" link instead of a link to the comments page, we could do something like this...
#
# <%=
@@ -579,7 +579,7 @@ module ActionView
url_string = url_for(options)
# We ignore any extra parameters in the request_uri if the
- # submitted url doesn't have any either. This lets the function
+ # submitted url doesn't have any either. This lets the function
# work with things like ?order=asc
if url_string.index("?")
request_uri = request.fullpath
@@ -641,7 +641,7 @@ module ActionView
# Processes the +html_options+ hash, converting the boolean
# attributes from true/false form into the form required by
- # HTML/XHTML. (An attribute is considered to be boolean if
+ # HTML/XHTML. (An attribute is considered to be boolean if
# its name is listed in the given +bool_attrs+ array.)
#
# More specifically, for each boolean attribute in +html_options+
@@ -651,7 +651,7 @@ module ActionView
#
# if the associated +bool_value+ evaluates to true, it is
# replaced with the attribute's name; otherwise the attribute is
- # removed from the +html_options+ hash. (See the XHTML 1.0 spec,
+ # removed from the +html_options+ hash. (See the XHTML 1.0 spec,
# section 4.5 "Attribute Minimization" for more:
# http://www.w3.org/TR/xhtml1/#h-4.5)
#
diff --git a/actionpack/lib/action_view/template.rb b/actionpack/lib/action_view/template.rb
index b99d24d281..10797c010f 100644
--- a/actionpack/lib/action_view/template.rb
+++ b/actionpack/lib/action_view/template.rb
@@ -91,7 +91,6 @@ module ActionView
eager_autoload do
autoload :Error
- autoload :Handler
autoload :Handlers
autoload :Text
end
diff --git a/actionpack/lib/action_view/template/handler.rb b/actionpack/lib/action_view/template/handler.rb
deleted file mode 100644
index 636f3ebbad..0000000000
--- a/actionpack/lib/action_view/template/handler.rb
+++ /dev/null
@@ -1,49 +0,0 @@
-require 'action_dispatch/http/mime_type'
-require 'active_support/core_ext/class/attribute'
-
-# Legacy TemplateHandler stub
-module ActionView
- class Template
- module Handlers #:nodoc:
- module Compilable
- def self.included(base)
- ActiveSupport::Deprecation.warn "Including Compilable in your template handler is deprecated. " <<
- "Since Rails 3, all the API your template handler needs to implement is to respond to #call."
- base.extend(ClassMethods)
- end
-
- module ClassMethods
- def call(template)
- new.compile(template)
- end
- end
-
- def compile(template)
- raise "Need to implement #{self.class.name}#compile(template)"
- end
- end
- end
-
- class Template::Handler
- class_attribute :default_format
- self.default_format = Mime::HTML
-
- def self.inherited(base)
- ActiveSupport::Deprecation.warn "Inheriting from ActionView::Template::Handler is deprecated. " <<
- "Since Rails 3, all the API your template handler needs to implement is to respond to #call."
- super
- end
-
- def self.call(template)
- raise "Need to implement #{self.class.name}#call(template)"
- end
-
- def render(template, local_assigns)
- raise "Need to implement #{self.class.name}#render(template, local_assigns)"
- end
- end
- end
-
- TemplateHandlers = Template::Handlers
- TemplateHandler = Template::Handler
-end
diff --git a/actionpack/lib/action_view/template/handlers.rb b/actionpack/lib/action_view/template/handlers.rb
index 959afa734e..aa693335e3 100644
--- a/actionpack/lib/action_view/template/handlers.rb
+++ b/actionpack/lib/action_view/template/handlers.rb
@@ -41,12 +41,6 @@ module ActionView #:nodoc:
@@default_template_handlers = klass
end
- def handler_class_for_extension(extension)
- ActiveSupport::Deprecation.warn "handler_class_for_extension is deprecated. " <<
- "Please use handler_for_extension instead", caller
- handler_for_extension(extension)
- end
-
def handler_for_extension(extension)
registered_template_handler(extension) || @@default_template_handlers
end
diff --git a/actionpack/lib/action_view/template/handlers/erb.rb b/actionpack/lib/action_view/template/handlers/erb.rb
index a1e3fd7768..77720e2bc8 100644
--- a/actionpack/lib/action_view/template/handlers/erb.rb
+++ b/actionpack/lib/action_view/template/handlers/erb.rb
@@ -1,5 +1,5 @@
+require 'action_dispatch/http/mime_type'
require 'active_support/core_ext/class/attribute_accessors'
-require 'action_view/template/handler'
require 'erubis'
module ActionView
diff --git a/actionpack/lib/action_view/test_case.rb b/actionpack/lib/action_view/test_case.rb
index d0317a148b..2cc85a9f69 100644
--- a/actionpack/lib/action_view/test_case.rb
+++ b/actionpack/lib/action_view/test_case.rb
@@ -218,12 +218,6 @@ module ActionView
end]
end
- def _assigns
- ActiveSupport::Deprecation.warn "ActionView::TestCase#_assigns is deprecated and will be removed in future versions. " <<
- "Please use view_assigns instead."
- view_assigns
- end
-
def _routes
@controller._routes if @controller.respond_to?(:_routes)
end
diff --git a/actionpack/lib/sprockets/helpers.rb b/actionpack/lib/sprockets/helpers.rb
new file mode 100644
index 0000000000..a952a55c5e
--- /dev/null
+++ b/actionpack/lib/sprockets/helpers.rb
@@ -0,0 +1,5 @@
+module Sprockets
+ module Helpers
+ autoload :RailsHelper, "sprockets/helpers/rails_helper"
+ end
+end
diff --git a/actionpack/lib/sprockets/helpers/rails_helper.rb b/actionpack/lib/sprockets/helpers/rails_helper.rb
new file mode 100644
index 0000000000..a99dcad81d
--- /dev/null
+++ b/actionpack/lib/sprockets/helpers/rails_helper.rb
@@ -0,0 +1,107 @@
+require "action_view/helpers/asset_paths"
+require "action_view/helpers/asset_tag_helper"
+
+module Sprockets
+ module Helpers
+ module RailsHelper
+ extend ActiveSupport::Concern
+ include ActionView::Helpers::AssetTagHelper
+
+ def asset_paths
+ @asset_paths ||= begin
+ config = self.config if respond_to?(:config)
+ controller = self.controller if respond_to?(:controller)
+ RailsHelper::AssetPaths.new(config, controller)
+ end
+ end
+
+ def javascript_include_tag(source, options = {})
+ debug = options.key?(:debug) ? options.delete(:debug) : debug_assets?
+ body = options.key?(:body) ? options.delete(:body) : false
+
+ if debug && asset = asset_paths.asset_for(source, 'js')
+ asset.to_a.map { |dep|
+ javascript_include_tag(dep, :debug => false, :body => true)
+ }.join("\n").html_safe
+ else
+ options = {
+ 'type' => "text/javascript",
+ 'src' => asset_path(source, 'js', body)
+ }.merge(options.stringify_keys)
+
+ content_tag 'script', "", options
+ end
+ end
+
+ def stylesheet_link_tag(source, options = {})
+ debug = options.key?(:debug) ? options.delete(:debug) : debug_assets?
+ body = options.key?(:body) ? options.delete(:body) : false
+
+ if debug && asset = asset_paths.asset_for(source, 'css')
+ asset.to_a.map { |dep|
+ stylesheet_link_tag(dep, :debug => false, :body => true)
+ }.join("\n").html_safe
+ else
+ options = {
+ 'rel' => "stylesheet",
+ 'type' => "text/css",
+ 'media' => "screen",
+ 'href' => asset_path(source, 'css', body)
+ }.merge(options.stringify_keys)
+
+ tag 'link', options
+ end
+ end
+
+ private
+ def debug_assets?
+ params[:debug_assets] == '1' ||
+ params[:debug_assets] == 'true'
+ end
+
+ def asset_path(source, default_ext = nil, body = false)
+ source = source.logical_path if source.respond_to?(:logical_path)
+ path = asset_paths.compute_public_path(source, 'assets', default_ext, true)
+ body ? "#{path}?body=1" : path
+ end
+
+ class AssetPaths < ActionView::Helpers::AssetPaths #:nodoc:
+ def compute_public_path(source, dir, ext=nil, include_host=true)
+ super(source, 'assets', ext, include_host)
+ end
+
+ def asset_for(source, ext)
+ source = source.to_s
+ return nil if is_uri?(source)
+ source = rewrite_extension(source, nil, ext)
+ assets[source]
+ end
+
+ def rewrite_asset_path(source, dir)
+ if source[0] == ?/
+ source
+ else
+ assets.path(source, performing_caching?, dir)
+ end
+ end
+
+ def rewrite_extension(source, dir, ext)
+ if ext && File.extname(source).empty?
+ "#{source}.#{ext}"
+ else
+ source
+ end
+ end
+
+ def assets
+ Rails.application.assets
+ end
+
+ # When included in Sprockets::Context, we need to ask the top-level config as the controller is not available
+ def performing_caching?
+ @config ? @config.perform_caching : Rails.application.config.action_controller.perform_caching
+ end
+ end
+ end
+ end
+end
diff --git a/actionpack/lib/sprockets/railtie.rb b/actionpack/lib/sprockets/railtie.rb
index 8cee3babe2..7b8a7ad3bb 100644
--- a/actionpack/lib/sprockets/railtie.rb
+++ b/actionpack/lib/sprockets/railtie.rb
@@ -1,5 +1,7 @@
module Sprockets
- class Railtie < Rails::Railtie
+ autoload :Helpers, "sprockets/helpers"
+
+ class Railtie < ::Rails::Railtie
def self.using_coffee?
require 'coffee-script'
defined?(CoffeeScript)
@@ -7,15 +9,7 @@ module Sprockets
false
end
- def self.using_scss?
- require 'sass'
- defined?(Sass)
- rescue LoadError
- false
- end
-
config.app_generators.javascript_engine :coffee if using_coffee?
- config.app_generators.stylesheet_engine :scss if using_scss?
# Configure ActionController to use sprockets.
initializer "sprockets.set_configs", :after => "action_controller.set_configs" do |app|
@@ -26,7 +20,8 @@ module Sprockets
# We need to configure this after initialization to ensure we collect
# paths from all engines. This hook is invoked exactly before routes
- # are compiled.
+ # are compiled, and so that other Railties have an opportunity to
+ # register compressors.
config.after_initialize do |app|
assets = app.config.assets
next unless assets.enabled
@@ -34,8 +29,10 @@ module Sprockets
app.assets = asset_environment(app)
ActiveSupport.on_load(:action_view) do
+ include ::Sprockets::Helpers::RailsHelper
+
app.assets.context_class.instance_eval do
- include ::ActionView::Helpers::SprocketsHelper
+ include ::Sprockets::Helpers::RailsHelper
end
end
@@ -57,8 +54,8 @@ module Sprockets
env.static_root = File.join(app.root.join("public"), assets.prefix)
env.paths.concat assets.paths
env.logger = Rails.logger
- env.js_compressor = expand_js_compressor(assets.js_compressor)
- env.css_compressor = expand_css_compressor(assets.css_compressor)
+ env.js_compressor = expand_js_compressor(assets.js_compressor) if assets.compress
+ env.css_compressor = expand_css_compressor(assets.css_compressor) if assets.compress
env
end
@@ -80,15 +77,6 @@ module Sprockets
def expand_css_compressor(sym)
case sym
- when :scss
- require 'sass'
- compressor = Object.new
- def compressor.compress(source)
- Sass::Engine.new(source,
- :syntax => :scss, :style => :compressed
- ).render
- end
- compressor
when :yui
require 'yui/compressor'
YUI::CssCompressor.new
diff --git a/actionpack/test/activerecord/controller_runtime_test.rb b/actionpack/test/activerecord/controller_runtime_test.rb
index b87b9f9c47..2d789395ce 100644
--- a/actionpack/test/activerecord/controller_runtime_test.rb
+++ b/actionpack/test/activerecord/controller_runtime_test.rb
@@ -15,6 +15,17 @@ class ControllerRuntimeLogSubscriberTest < ActionController::TestCase
def zero
render :inline => "Zero DB runtime"
end
+
+ def redirect
+ Project.all
+ redirect_to :action => 'show'
+ end
+
+ def db_after_render
+ render :inline => "Hello world"
+ Project.all
+ ActiveRecord::LogSubscriber.runtime += 100
+ end
end
include ActiveSupport::LogSubscriber::TestHelper
@@ -52,4 +63,19 @@ class ControllerRuntimeLogSubscriberTest < ActionController::TestCase
assert_equal 2, @logger.logged(:info).size
assert_match(/\(Views: [\d.]+ms \| ActiveRecord: 0.0ms\)/, @logger.logged(:info)[1])
end
+
+ def test_log_with_active_record_when_redirecting
+ get :redirect
+ wait
+ assert_equal 3, @logger.logged(:info).size
+ assert_match(/\(ActiveRecord: [\d.]+ms\)/, @logger.logged(:info)[2])
+ end
+
+ def test_include_time_query_time_after_rendering
+ get :db_after_render
+ wait
+
+ assert_equal 2, @logger.logged(:info).size
+ assert_match(/\(Views: [\d.]+ms \| ActiveRecord: ([1-9][\d.]+)ms\)/, @logger.logged(:info)[1])
+ end
end
diff --git a/actionpack/test/controller/caching_test.rb b/actionpack/test/controller/caching_test.rb
index fada0c7748..82c2c23607 100644
--- a/actionpack/test/controller/caching_test.rb
+++ b/actionpack/test/controller/caching_test.rb
@@ -187,6 +187,9 @@ class ActionCachingTestController < CachingController
rescue_from(ActiveRecord::RecordNotFound) { head :not_found }
end
+ # Eliminate uninitialized ivar warning
+ before_filter { @title = nil }
+
caches_action :index, :redirected, :forbidden, :if => Proc.new { |c| !c.request.format.json? }, :expires_in => 1.hour
caches_action :show, :cache_path => 'http://test.host/custom/show'
caches_action :edit, :cache_path => Proc.new { |c| c.params[:id] ? "http://test.host/#{c.params[:id]};edit" : "http://test.host/edit" }
diff --git a/actionpack/test/controller/deprecation/deprecated_base_methods_test.rb b/actionpack/test/controller/deprecation/deprecated_base_methods_test.rb
deleted file mode 100644
index 0c02afea36..0000000000
--- a/actionpack/test/controller/deprecation/deprecated_base_methods_test.rb
+++ /dev/null
@@ -1,26 +0,0 @@
-require 'abstract_unit'
-
-class DeprecatedBaseMethodsTest < ActionController::TestCase
- class Target < ActionController::Base
- def home_url(greeting)
- "http://example.com/#{greeting}"
- end
-
- def raises_name_error
- this_method_doesnt_exist
- end
-
- def rescue_action(e) raise e end
- end
-
- tests Target
-
- if defined? Test::Unit::Error
- def test_assertion_failed_error_silences_deprecation_warnings
- get :raises_name_error
- rescue => e
- error = Test::Unit::Error.new('testing ur doodz', e)
- assert_not_deprecated { error.message }
- end
- end
-end
diff --git a/actionpack/test/controller/helper_test.rb b/actionpack/test/controller/helper_test.rb
index 9f0670ffdf..584d73668a 100644
--- a/actionpack/test/controller/helper_test.rb
+++ b/actionpack/test/controller/helper_test.rb
@@ -77,7 +77,7 @@ class HelperTest < ActiveSupport::TestCase
self.test_helper = LocalAbcHelper
end
- def test_deprecated_helper
+ def test_helper
assert_equal expected_helper_methods, missing_methods
assert_nothing_raised { @controller_class.helper TestHelper }
assert_equal [], missing_methods
diff --git a/actionpack/test/controller/mime_responds_test.rb b/actionpack/test/controller/mime_responds_test.rb
index 4a5e597500..26270571cf 100644
--- a/actionpack/test/controller/mime_responds_test.rb
+++ b/actionpack/test/controller/mime_responds_test.rb
@@ -498,6 +498,12 @@ class RespondToControllerTest < ActionController::TestCase
assert_equal '<html><div id="iphone">Hello iPhone future from iPhone!</div></html>', @response.body
assert_equal "text/html", @response.content_type
end
+
+ def test_invalid_format
+ get :using_defaults, :format => "invalidformat"
+ assert_equal " ", @response.body
+ assert_equal "text/html", @response.content_type
+ end
end
class RespondWithController < ActionController::Base
diff --git a/actionpack/test/controller/render_test.rb b/actionpack/test/controller/render_test.rb
index e62f3155c5..be59da9105 100644
--- a/actionpack/test/controller/render_test.rb
+++ b/actionpack/test/controller/render_test.rb
@@ -1023,11 +1023,6 @@ class RenderTest < ActionController::TestCase
assert_equal " ", @response.body
end
- def test_render_to_string_not_deprecated
- assert_not_deprecated { get :hello_in_a_string }
- assert_equal "How's there? goodbyeHello: davidHello: marygoodbye\n", @response.body
- end
-
def test_render_to_string_doesnt_break_assigns
get :render_to_string_with_assigns
assert_equal "i'm before the render", assigns(:before)
@@ -1106,7 +1101,7 @@ class RenderTest < ActionController::TestCase
end
def test_yield_content_for
- assert_not_deprecated { get :yield_content_for }
+ get :yield_content_for
assert_equal "<title>Putting stuff in the title!</title>\nGreat stuff!\n", @response.body
end
diff --git a/actionpack/test/controller/request_forgery_protection_test.rb b/actionpack/test/controller/request_forgery_protection_test.rb
index dea80ed887..d94db7f5fb 100644
--- a/actionpack/test/controller/request_forgery_protection_test.rb
+++ b/actionpack/test/controller/request_forgery_protection_test.rb
@@ -80,7 +80,7 @@ module RequestForgeryProtectionTests
def setup
@token = "cf50faa3fe97702ca1ae"
- ActiveSupport::SecureRandom.stubs(:base64).returns(@token)
+ SecureRandom.stubs(:base64).returns(@token)
ActionController::Base.request_forgery_protection_token = :custom_authenticity_token
end
@@ -184,7 +184,7 @@ class RequestForgeryProtectionControllerTest < ActionController::TestCase
end
test 'should emit a csrf-param meta tag and a csrf-token meta tag' do
- ActiveSupport::SecureRandom.stubs(:base64).returns(@token + '<=?')
+ SecureRandom.stubs(:base64).returns(@token + '<=?')
get :meta
assert_select 'meta[name=?][content=?]', 'csrf-param', 'custom_authenticity_token'
assert_select 'meta[name=?][content=?]', 'csrf-token', 'cf50faa3fe97702ca1ae&lt;=?'
@@ -207,7 +207,7 @@ class FreeCookieControllerTest < ActionController::TestCase
@response = ActionController::TestResponse.new
@token = "cf50faa3fe97702ca1ae"
- ActiveSupport::SecureRandom.stubs(:base64).returns(@token)
+ SecureRandom.stubs(:base64).returns(@token)
end
def test_should_not_render_form_with_token_tag
diff --git a/actionpack/test/controller/view_paths_test.rb b/actionpack/test/controller/view_paths_test.rb
index 3de1849db8..f5ac886c20 100644
--- a/actionpack/test/controller/view_paths_test.rb
+++ b/actionpack/test/controller/view_paths_test.rb
@@ -32,17 +32,11 @@ class ViewLoadPathsTest < ActionController::TestCase
@controller.send :assign_shortcuts, @request, @response
@controller.send :initialize_template_class, @response
- # Track the last warning.
- @old_behavior = ActiveSupport::Deprecation.behavior
- @last_message = nil
- ActiveSupport::Deprecation.behavior = Proc.new { |message, callback| @last_message = message }
-
@paths = TestController.view_paths
end
def teardown
TestController.view_paths = @paths
- ActiveSupport::Deprecation.behavior = @old_behavior
end
def expand(array)
@@ -179,7 +173,7 @@ class ViewLoadPathsTest < ActionController::TestCase
assert_nothing_raised { C.append_view_path 'c/path' }
assert_paths C, "c/path"
end
-
+
def test_lookup_context_accessor
assert_equal ["test"], TestController.new.lookup_context.prefixes
end
diff --git a/actionpack/test/dispatch/response_body_is_proc_test.rb b/actionpack/test/dispatch/response_body_is_proc_test.rb
deleted file mode 100644
index fd94832624..0000000000
--- a/actionpack/test/dispatch/response_body_is_proc_test.rb
+++ /dev/null
@@ -1,37 +0,0 @@
-require 'abstract_unit'
-
-class ResponseBodyIsProcTest < ActionDispatch::IntegrationTest
- class TestController < ActionController::Base
- def test
- self.response_body = proc { |response, output|
- output.write 'Hello'
- }
- end
- end
-
- def test_simple_get
- with_test_route_set do
- assert_deprecated do
- get '/test'
- end
- assert_response :success
- assert_equal 'Hello', response.body
- end
- end
-
- private
-
- def with_test_route_set(options = {})
- with_routing do |set|
- set.draw do
- match ':action', :to => ::ResponseBodyIsProcTest::TestController
- end
-
- @app = self.class.build_app(set) do |middleware|
- middleware.delete "ActionDispatch::ShowExceptions"
- end
-
- yield
- end
- end
-end
diff --git a/actionpack/test/dispatch/session/cookie_store_test.rb b/actionpack/test/dispatch/session/cookie_store_test.rb
index b0efbcef4a..301bf9c6d2 100644
--- a/actionpack/test/dispatch/session/cookie_store_test.rb
+++ b/actionpack/test/dispatch/session/cookie_store_test.rb
@@ -6,7 +6,7 @@ class CookieStoreTest < ActionDispatch::IntegrationTest
SessionSecret = 'b3c631c314c0bbca50c1b2843150fe33'
Verifier = ActiveSupport::MessageVerifier.new(SessionSecret, 'SHA1')
- SignedBar = Verifier.generate(:foo => "bar", :session_id => ActiveSupport::SecureRandom.hex(16))
+ SignedBar = Verifier.generate(:foo => "bar", :session_id => SecureRandom.hex(16))
class TestController < ActionController::Base
def no_session_access
diff --git a/actionpack/test/fixtures/sprockets/app/javascripts/application.js b/actionpack/test/fixtures/sprockets/app/javascripts/application.js
index e69de29bb2..e611d2b129 100644
--- a/actionpack/test/fixtures/sprockets/app/javascripts/application.js
+++ b/actionpack/test/fixtures/sprockets/app/javascripts/application.js
@@ -0,0 +1 @@
+//= require xmlhr
diff --git a/actionpack/test/fixtures/sprockets/app/stylesheets/application.css b/actionpack/test/fixtures/sprockets/app/stylesheets/application.css
index e69de29bb2..2365eaa4cd 100644
--- a/actionpack/test/fixtures/sprockets/app/stylesheets/application.css
+++ b/actionpack/test/fixtures/sprockets/app/stylesheets/application.css
@@ -0,0 +1 @@
+/*= require style */
diff --git a/actionpack/test/fixtures/test/deprecated_nested_layout.erb b/actionpack/test/fixtures/test/deprecated_nested_layout.erb
deleted file mode 100644
index 7b6dcbb6c7..0000000000
--- a/actionpack/test/fixtures/test/deprecated_nested_layout.erb
+++ /dev/null
@@ -1,3 +0,0 @@
-<% content_for :title, "title" -%>
-<% content_for :column do -%>column<% end -%>
-<% render :layout => 'layouts/column' do -%>content<% end -%> \ No newline at end of file
diff --git a/actionpack/test/template/form_helper_test.rb b/actionpack/test/template/form_helper_test.rb
index 286bfb4d04..f2a49f7a68 100644
--- a/actionpack/test/template/form_helper_test.rb
+++ b/actionpack/test/template/form_helper_test.rb
@@ -974,6 +974,22 @@ class FormHelperTest < ActionView::TestCase
assert_dom_equal expected, output_buffer
end
+ def test_nested_fields_for_with_index_with_index_and_parent_fields
+ form_for(@post, :index => 1) do |c|
+ concat c.text_field(:title)
+ concat c.fields_for_with_index('comment', @comment, :index => 1) { |r, comment_index|
+ concat r.text_field(:name, "data-index" => comment_index)
+ }
+ end
+
+ expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', 'put') do
+ "<input name='post[1][title]' size='30' type='text' id='post_1_title' value='Hello World' />" +
+ "<input name='post[1][comment][1][name]' size='30' type='text' id='post_1_comment_1_name' value='new comment' data-index='1' />"
+ end
+
+ assert_dom_equal expected, output_buffer
+ end
+
def test_form_for_with_index_and_nested_fields_for
output_buffer = form_for(@post, :index => 1) do |f|
concat f.fields_for(:comment, @post) { |c|
@@ -1030,6 +1046,20 @@ class FormHelperTest < ActionView::TestCase
assert_dom_equal expected, output_buffer
end
+ def test_nested_fields_for_with_index_with_index_radio_button
+ form_for(@post) do |f|
+ concat f.fields_for_with_index(:comment, @post, :index => 5) { |c, index|
+ concat c.radio_button(:title, "hello", "data-index" => index)
+ }
+ end
+
+ expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', 'put') do
+ "<input name='post[comment][5][title]' type='radio' id='post_comment_5_title_hello' value='hello' data-index='5' />"
+ end
+
+ assert_dom_equal expected, output_buffer
+ end
+
def test_nested_fields_for_with_auto_index_on_both
form_for(@post, :as => "post[]") do |f|
concat f.fields_for("comment[]", @post) { |c|
@@ -1229,6 +1259,29 @@ class FormHelperTest < ActionView::TestCase
assert_dom_equal expected, output_buffer
end
+ def test_nested_fields_for_with_index_with_existing_records_on_a_nested_attributes_collection_association
+ @post.comments = Array.new(2) { |id| Comment.new(id + 1) }
+
+ form_for(@post) do |f|
+ concat f.text_field(:title)
+ @post.comments.each do |comment|
+ concat f.fields_for_with_index(:comments, comment) { |cf, index|
+ concat cf.text_field(:name, "data-index" => index)
+ }
+ end
+ end
+
+ expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', :method => 'put') do
+ '<input name="post[title]" size="30" type="text" id="post_title" value="Hello World" />' +
+ '<input id="post_comments_attributes_0_name" name="post[comments_attributes][0][name]" size="30" type="text" value="comment #1" data-index="0" />' +
+ '<input id="post_comments_attributes_0_id" name="post[comments_attributes][0][id]" type="hidden" value="1" />' +
+ '<input id="post_comments_attributes_1_name" name="post[comments_attributes][1][name]" size="30" type="text" value="comment #2" data-index="1" />' +
+ '<input id="post_comments_attributes_1_id" name="post[comments_attributes][1][id]" type="hidden" value="2" />'
+ end
+
+ assert_dom_equal expected, output_buffer
+ end
+
def test_nested_fields_for_with_existing_records_on_a_nested_attributes_collection_association_with_disabled_hidden_id
@post.comments = Array.new(2) { |id| Comment.new(id + 1) }
@post.author = Author.new(321)
@@ -1256,6 +1309,33 @@ class FormHelperTest < ActionView::TestCase
assert_dom_equal expected, output_buffer
end
+ def test_nested_fields_for_with_index_with_existing_records_on_a_nested_attributes_collection_association_with_disabled_hidden_id
+ @post.comments = Array.new(2) { |id| Comment.new(id + 1) }
+ @post.author = Author.new(321)
+
+ form_for(@post) do |f|
+ concat f.text_field(:title)
+ concat f.fields_for(:author) { |af|
+ concat af.text_field(:name)
+ }
+ @post.comments.each do |comment|
+ concat f.fields_for_with_index(:comments, comment, :include_id => false) { |cf, index|
+ concat cf.text_field(:name, 'data-index' => index)
+ }
+ end
+ end
+
+ expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', :method => 'put') do
+ '<input name="post[title]" size="30" type="text" id="post_title" value="Hello World" />' +
+ '<input id="post_author_attributes_name" name="post[author_attributes][name]" size="30" type="text" value="author #321" />' +
+ '<input id="post_author_attributes_id" name="post[author_attributes][id]" type="hidden" value="321" />' +
+ '<input id="post_comments_attributes_0_name" name="post[comments_attributes][0][name]" size="30" type="text" value="comment #1" data-index="0" />' +
+ '<input id="post_comments_attributes_1_name" name="post[comments_attributes][1][name]" size="30" type="text" value="comment #2" data-index="1" />'
+ end
+
+ assert_dom_equal expected, output_buffer
+ end
+
def test_nested_fields_for_with_existing_records_on_a_nested_attributes_collection_association_with_disabled_hidden_id_inherited
@post.comments = Array.new(2) { |id| Comment.new(id + 1) }
@post.author = Author.new(321)
@@ -1377,6 +1457,28 @@ class FormHelperTest < ActionView::TestCase
assert_dom_equal expected, output_buffer
end
+ def test_nested_fields_for_with_index_with_new_records_on_a_nested_attributes_collection_association
+ @post.comments = [Comment.new, Comment.new]
+
+ form_for(@post) do |f|
+ concat f.text_field(:title)
+ @post.comments.each do |comment|
+ concat f.fields_for_with_index(:comments, comment) { |cf, index|
+ concat cf.text_field(:name, "data-index" => index)
+ }
+ end
+ end
+
+ expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', :method => 'put') do
+ '<input name="post[title]" size="30" type="text" id="post_title" value="Hello World" />' +
+ '<input id="post_comments_attributes_0_name" name="post[comments_attributes][0][name]" size="30" type="text" value="new comment" data-index="0" />' +
+ '<input id="post_comments_attributes_1_name" name="post[comments_attributes][1][name]" size="30" type="text" value="new comment" data-index="1" />'
+ end
+
+ assert_dom_equal expected, output_buffer
+ end
+
+
def test_nested_fields_for_with_existing_and_new_records_on_a_nested_attributes_collection_association
@post.comments = [Comment.new(321), Comment.new]
@@ -1399,6 +1501,29 @@ class FormHelperTest < ActionView::TestCase
assert_dom_equal expected, output_buffer
end
+ def test_nested_fields_for_with_index_with_existing_and_new_records_on_a_nested_attributes_collection_association
+ @post.comments = [Comment.new(321), Comment.new]
+
+ form_for(@post) do |f|
+ concat f.text_field(:title)
+ @post.comments.each do |comment|
+ concat f.fields_for_with_index(:comments, comment) { |cf, index|
+ concat cf.text_field(:name, "data-index" => index)
+ }
+ end
+ end
+
+ expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', :method => 'put') do
+ '<input name="post[title]" size="30" type="text" id="post_title" value="Hello World" />' +
+ '<input id="post_comments_attributes_0_name" name="post[comments_attributes][0][name]" size="30" type="text" value="comment #321" data-index="0" />' +
+ '<input id="post_comments_attributes_0_id" name="post[comments_attributes][0][id]" type="hidden" value="321" />' +
+ '<input id="post_comments_attributes_1_name" name="post[comments_attributes][1][name]" size="30" type="text" value="new comment" data-index="1" />'
+ end
+
+ assert_dom_equal expected, output_buffer
+ end
+
+
def test_nested_fields_for_with_an_empty_supplied_attributes_collection
form_for(@post) do |f|
concat f.text_field(:title)
diff --git a/actionpack/test/template/number_helper_test.rb b/actionpack/test/template/number_helper_test.rb
index 63b92aadf4..0104c20bc7 100644
--- a/actionpack/test/template/number_helper_test.rb
+++ b/actionpack/test/template/number_helper_test.rb
@@ -19,15 +19,6 @@ class NumberHelperTest < ActionView::TestCase
gigabytes(number) * 1024
end
- def silence_deprecation_warnings
- @old_deprecatios_silenced = ActiveSupport::Deprecation.silenced
- ActiveSupport::Deprecation.silenced = true
- end
-
- def restore_deprecation_warnings
- ActiveSupport::Deprecation.silenced = @old_deprecatios_silenced
- end
-
def test_number_to_phone
assert_equal("555-1234", number_to_phone(5551234))
assert_equal("800-555-1212", number_to_phone(8005551212))
diff --git a/actionpack/test/template/sprockets_helper_test.rb b/actionpack/test/template/sprockets_helper_test.rb
index 8d3be09a4f..ebb7e48d70 100644
--- a/actionpack/test/template/sprockets_helper_test.rb
+++ b/actionpack/test/template/sprockets_helper_test.rb
@@ -1,11 +1,10 @@
require 'abstract_unit'
require 'sprockets'
+require 'sprockets/helpers/rails_helper'
require 'mocha'
-module Rails; end
-
class SprocketsHelperTest < ActionView::TestCase
- tests ActionView::Helpers::SprocketsHelper
+ tests Sprockets::Helpers::RailsHelper
attr_accessor :assets
@@ -13,6 +12,7 @@ class SprocketsHelperTest < ActionView::TestCase
super
@controller = BasicController.new
+ @controller.stubs(:params).returns({})
@request = Class.new do
def protocol() 'http://' end
@@ -57,6 +57,12 @@ class SprocketsHelperTest < ActionView::TestCase
asset_path("http://www.example.com/video/play.mp4")
end
+ test "asset path with relative url root" do
+ @controller.config.relative_url_root = "/collaboration/hieraki"
+ assert_equal "/collaboration/hieraki/images/logo.gif",
+ asset_path("/images/logo.gif")
+ end
+
test "javascript path" do
assert_equal "/assets/application-d41d8cd98f00b204e9800998ecf8427e.js",
asset_path(:application, "js")
@@ -77,18 +83,21 @@ class SprocketsHelperTest < ActionView::TestCase
test "javascript include tag" do
assert_equal '<script src="/assets/application-d41d8cd98f00b204e9800998ecf8427e.js" type="text/javascript"></script>',
- sprockets_javascript_include_tag(:application)
+ javascript_include_tag(:application)
assert_equal '<script src="/assets/xmlhr-d41d8cd98f00b204e9800998ecf8427e.js" type="text/javascript"></script>',
- sprockets_javascript_include_tag("xmlhr")
+ javascript_include_tag("xmlhr")
assert_equal '<script src="/assets/xmlhr-d41d8cd98f00b204e9800998ecf8427e.js" type="text/javascript"></script>',
- sprockets_javascript_include_tag("xmlhr.js")
+ javascript_include_tag("xmlhr.js")
assert_equal '<script src="http://www.example.com/xmlhr" type="text/javascript"></script>',
- sprockets_javascript_include_tag("http://www.example.com/xmlhr")
+ javascript_include_tag("http://www.example.com/xmlhr")
+
+ assert_equal "<script src=\"/assets/xmlhr-d41d8cd98f00b204e9800998ecf8427e.js?body=1\" type=\"text/javascript\"></script>\n<script src=\"/assets/application-d41d8cd98f00b204e9800998ecf8427e.js?body=1\" type=\"text/javascript\"></script>",
+ javascript_include_tag(:application, :debug => true)
end
test "stylesheet path" do
- assert_equal "/assets/application-d41d8cd98f00b204e9800998ecf8427e.css", asset_path(:application, "css")
+ assert_equal "/assets/application-68b329da9893e34099c7d8ad5cb9c940.css", asset_path(:application, "css")
assert_equal "/assets/style-d41d8cd98f00b204e9800998ecf8427e.css", asset_path("style", "css")
assert_equal "/assets/dir/style-d41d8cd98f00b204e9800998ecf8427e.css", asset_path("dir/style.css", "css")
@@ -101,19 +110,22 @@ class SprocketsHelperTest < ActionView::TestCase
end
test "stylesheet link tag" do
- assert_equal '<link href="/assets/application-d41d8cd98f00b204e9800998ecf8427e.css" media="screen" rel="stylesheet" type="text/css" />',
- sprockets_stylesheet_link_tag(:application)
+ assert_equal '<link href="/assets/application-68b329da9893e34099c7d8ad5cb9c940.css" media="screen" rel="stylesheet" type="text/css" />',
+ stylesheet_link_tag(:application)
assert_equal '<link href="/assets/style-d41d8cd98f00b204e9800998ecf8427e.css" media="screen" rel="stylesheet" type="text/css" />',
- sprockets_stylesheet_link_tag("style")
+ stylesheet_link_tag("style")
assert_equal '<link href="/assets/style-d41d8cd98f00b204e9800998ecf8427e.css" media="screen" rel="stylesheet" type="text/css" />',
- sprockets_stylesheet_link_tag("style.css")
+ stylesheet_link_tag("style.css")
assert_equal '<link href="http://www.example.com/style.css" media="screen" rel="stylesheet" type="text/css" />',
- sprockets_stylesheet_link_tag("http://www.example.com/style.css")
+ stylesheet_link_tag("http://www.example.com/style.css")
assert_equal '<link href="/assets/style-d41d8cd98f00b204e9800998ecf8427e.css" media="all" rel="stylesheet" type="text/css" />',
- sprockets_stylesheet_link_tag("style", :media => "all")
+ stylesheet_link_tag("style", :media => "all")
assert_equal '<link href="/assets/style-d41d8cd98f00b204e9800998ecf8427e.css" media="print" rel="stylesheet" type="text/css" />',
- sprockets_stylesheet_link_tag("style", :media => "print")
+ stylesheet_link_tag("style", :media => "print")
+
+ assert_equal "<link href=\"/assets/style-d41d8cd98f00b204e9800998ecf8427e.css?body=1\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />\n<link href=\"/assets/application-68b329da9893e34099c7d8ad5cb9c940.css?body=1\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />",
+ stylesheet_link_tag(:application, :debug => true)
end
end
diff --git a/actionpack/test/template/streaming_render_test.rb b/actionpack/test/template/streaming_render_test.rb
index b2df8efee3..023ce723ed 100644
--- a/actionpack/test/template/streaming_render_test.rb
+++ b/actionpack/test/template/streaming_render_test.rb
@@ -8,7 +8,7 @@ end
class FiberedTest < ActiveSupport::TestCase
def setup
view_paths = ActionController::Base.view_paths
- @assigns = { :secret => 'in the sauce' }
+ @assigns = { :secret => 'in the sauce', :name => nil }
@view = ActionView::Base.new(view_paths, @assigns)
@controller_view = TestController.new.view_context
end
@@ -106,4 +106,4 @@ class FiberedTest < ActiveSupport::TestCase
buffered_render(:template => "test/nested_streaming", :layout => "layouts/streaming")
end
-end if defined?(Fiber) \ No newline at end of file
+end if defined?(Fiber)
diff --git a/actionpack/test/template/test_case_test.rb b/actionpack/test/template/test_case_test.rb
index cd4618a505..f463675a2e 100644
--- a/actionpack/test/template/test_case_test.rb
+++ b/actionpack/test/template/test_case_test.rb
@@ -141,22 +141,6 @@ module ActionView
end
end
- class AssignsTest < ActionView::TestCase
- setup do
- ActiveSupport::Deprecation.stubs(:warn)
- end
-
- test "_assigns delegates to user_defined_ivars" do
- self.expects(:view_assigns)
- _assigns
- end
-
- test "_assigns is deprecated" do
- ActiveSupport::Deprecation.expects(:warn)
- _assigns
- end
- end
-
class ViewAssignsTest < ActionView::TestCase
test "view_assigns returns a Hash of user defined ivars" do
@a = 'b'
diff --git a/actionpack/test/template/url_helper_test.rb b/actionpack/test/template/url_helper_test.rb
index 8d0f0124c2..4aa45c8bf0 100644
--- a/actionpack/test/template/url_helper_test.rb
+++ b/actionpack/test/template/url_helper_test.rb
@@ -25,6 +25,8 @@ class UrlHelperTest < ActiveSupport::TestCase
include ActionView::Context
include RenderERBUtils
+ setup :_prepare_context
+
def hash_for(opts = [])
ActiveSupport::OrderedHash[*([:controller, "foo", :action, "bar"].concat(opts))]
end