aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorMikel Lindsaar <raasdnil@gmail.com>2010-02-02 10:51:19 +1100
committerMikel Lindsaar <raasdnil@gmail.com>2010-02-02 10:51:19 +1100
commitd1eed079e1338249aa3b2881d07029ac4e71f4ed (patch)
tree18088ca9388e1b7bd27fffea8cb41fa52b618c34 /actionpack
parentddf2b4add33d5e54c5f5e7adacadbb50d3fa7b52 (diff)
parentb9edb0c60c11025311fb06f2e60b3354f1b6cb09 (diff)
downloadrails-d1eed079e1338249aa3b2881d07029ac4e71f4ed.tar.gz
rails-d1eed079e1338249aa3b2881d07029ac4e71f4ed.tar.bz2
rails-d1eed079e1338249aa3b2881d07029ac4e71f4ed.zip
Merge branch 'master' of git://github.com/rails/rails
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/lib/abstract_controller/helpers.rb10
-rw-r--r--actionpack/lib/abstract_controller/layouts.rb8
-rw-r--r--actionpack/lib/abstract_controller/rendering.rb18
-rw-r--r--actionpack/lib/action_controller/metal.rb9
-rw-r--r--actionpack/lib/action_controller/metal/compatibility.rb28
-rw-r--r--actionpack/lib/action_controller/metal/helpers.rb4
-rw-r--r--actionpack/lib/action_controller/metal/hide_actions.rb9
-rw-r--r--actionpack/lib/action_controller/metal/mime_responds.rb21
-rw-r--r--actionpack/lib/action_controller/metal/renderers.rb10
-rw-r--r--actionpack/lib/action_controller/metal/request_forgery_protection.rb6
-rw-r--r--actionpack/lib/action_controller/metal/url_for.rb7
-rw-r--r--actionpack/lib/action_view.rb3
-rw-r--r--actionpack/lib/action_view/base.rb5
-rw-r--r--actionpack/lib/action_view/erb/util.rb49
-rw-r--r--actionpack/lib/action_view/helpers/active_model_helper.rb11
-rw-r--r--actionpack/lib/action_view/helpers/asset_tag_helper.rb6
-rw-r--r--actionpack/lib/action_view/helpers/capture_helper.rb2
-rw-r--r--actionpack/lib/action_view/helpers/date_helper.rb14
-rw-r--r--actionpack/lib/action_view/helpers/debug_helper.rb4
-rw-r--r--actionpack/lib/action_view/helpers/form_helper.rb4
-rw-r--r--actionpack/lib/action_view/helpers/form_options_helper.rb2
-rw-r--r--actionpack/lib/action_view/helpers/form_tag_helper.rb6
-rw-r--r--actionpack/lib/action_view/helpers/number_helper.rb2
-rw-r--r--actionpack/lib/action_view/helpers/prototype_helper.rb2
-rw-r--r--actionpack/lib/action_view/helpers/raw_output_helper.rb2
-rw-r--r--actionpack/lib/action_view/helpers/sanitize_helper.rb12
-rw-r--r--actionpack/lib/action_view/helpers/tag_helper.rb9
-rw-r--r--actionpack/lib/action_view/helpers/text_helper.rb10
-rw-r--r--actionpack/lib/action_view/helpers/translation_helper.rb2
-rw-r--r--actionpack/lib/action_view/helpers/url_helper.rb8
-rw-r--r--actionpack/lib/action_view/render/partials.rb2
-rw-r--r--actionpack/lib/action_view/safe_buffer.rb27
-rw-r--r--actionpack/lib/action_view/template/handler.rb4
-rw-r--r--actionpack/lib/action_view/template/handlers/erb.rb8
-rw-r--r--actionpack/lib/action_view/template/resolver.rb3
-rw-r--r--actionpack/lib/action_view/test_case.rb2
-rw-r--r--actionpack/test/abstract_unit.rb11
-rw-r--r--actionpack/test/controller/caching_test.rb4
-rw-r--r--actionpack/test/controller/new_base/render_template_test.rb56
-rw-r--r--actionpack/test/controller/output_escaping_test.rb2
-rw-r--r--actionpack/test/controller/view_paths_test.rb4
-rw-r--r--actionpack/test/template/erb_util_test.rb2
-rw-r--r--actionpack/test/template/form_helper_test.rb2
-rw-r--r--actionpack/test/template/form_tag_helper_test.rb6
-rw-r--r--actionpack/test/template/safe_buffer_test.rb41
-rw-r--r--actionpack/test/template/test_case_test.rb2
46 files changed, 193 insertions, 266 deletions
diff --git a/actionpack/lib/abstract_controller/helpers.rb b/actionpack/lib/abstract_controller/helpers.rb
index eb621c0865..578b884a4d 100644
--- a/actionpack/lib/abstract_controller/helpers.rb
+++ b/actionpack/lib/abstract_controller/helpers.rb
@@ -1,4 +1,6 @@
require 'active_support/dependencies'
+require 'active_support/core_ext/class/attribute'
+require 'active_support/core_ext/module/delegation'
module AbstractController
module Helpers
@@ -12,10 +14,10 @@ module AbstractController
end
included do
- extlib_inheritable_accessor(:_helpers) { Module.new }
- extlib_inheritable_accessor(:_helper_serial) do
- AbstractController::Helpers.next_serial
- end
+ class_attribute :_helpers, :_helper_serial
+ delegate :_helpers, :to => :'self.class'
+ self._helpers = Module.new
+ self._helper_serial = ::AbstractController::Helpers.next_serial
end
module ClassMethods
diff --git a/actionpack/lib/abstract_controller/layouts.rb b/actionpack/lib/abstract_controller/layouts.rb
index 56ddf9bf01..0d214396aa 100644
--- a/actionpack/lib/abstract_controller/layouts.rb
+++ b/actionpack/lib/abstract_controller/layouts.rb
@@ -1,3 +1,6 @@
+require 'active_support/core_ext/class/attribute'
+require 'active_support/core_ext/module/delegation'
+
module AbstractController
# Layouts reverse the common pattern of including shared headers and footers in many templates to isolate changes in
# repeated setups. The inclusion pattern has pages that look like this:
@@ -161,8 +164,9 @@ module AbstractController
include Rendering
included do
- extlib_inheritable_accessor(:_layout_conditions) { Hash.new }
- extlib_inheritable_accessor(:_action_has_layout) { Hash.new }
+ class_attribute :_layout_conditions
+ delegate :_layout_conditions, :to => :'self.class'
+ self._layout_conditions = {}
_write_layout_method
end
diff --git a/actionpack/lib/abstract_controller/rendering.rb b/actionpack/lib/abstract_controller/rendering.rb
index ac407bda5e..619a49571b 100644
--- a/actionpack/lib/abstract_controller/rendering.rb
+++ b/actionpack/lib/abstract_controller/rendering.rb
@@ -1,4 +1,7 @@
require "abstract_controller/base"
+require 'active_support/core_ext/class/attribute'
+require 'active_support/core_ext/module/delegation'
+require 'active_support/core_ext/array/wrap'
module AbstractController
class DoubleRenderError < Error
@@ -13,8 +16,9 @@ module AbstractController
extend ActiveSupport::Concern
included do
- extlib_inheritable_accessor :_view_paths
- self._view_paths ||= ActionView::PathSet.new
+ class_attribute :_view_paths
+ delegate :_view_paths, :to => :'self.class'
+ self._view_paths = ActionView::PathSet.new
end
# An instance of a view class. The default view class is ActionView::Base
@@ -156,7 +160,6 @@ module AbstractController
elsif options.key?(:file)
options[:_template_name] = options[:file]
end
-
name = (options[:_template_name] || options[:action] || action_name).to_s
options[:_prefix] ||= _prefix if (options.keys & [:partial, :file, :template]).empty?
@@ -201,7 +204,7 @@ module AbstractController
# the default view path. You may also provide a custom view path
# (see ActionView::ViewPathSet for more information)
def append_view_path(path)
- self.view_paths << path
+ self.view_paths = view_paths.dup + Array.wrap(path)
end
# Prepend a path to the list of view paths for this controller.
@@ -212,12 +215,12 @@ module AbstractController
# (see ActionView::ViewPathSet for more information)
def prepend_view_path(path)
clear_template_caches!
- self.view_paths.unshift(path)
+ self.view_paths = Array.wrap(path) + view_paths.dup
end
# A list of all of the default view paths for this controller.
def view_paths
- self._view_paths
+ _view_paths
end
# Set the view paths.
@@ -228,7 +231,8 @@ module AbstractController
def view_paths=(paths)
clear_template_caches!
self._view_paths = paths.is_a?(ActionView::PathSet) ? paths : ActionView::Base.process_view_paths(paths)
+ _view_paths.freeze
end
end
end
-end \ No newline at end of file
+end
diff --git a/actionpack/lib/action_controller/metal.rb b/actionpack/lib/action_controller/metal.rb
index 57627a6f0b..2b35e111ec 100644
--- a/actionpack/lib/action_controller/metal.rb
+++ b/actionpack/lib/action_controller/metal.rb
@@ -1,4 +1,4 @@
-require 'active_support/core_ext/class/inheritable_attributes'
+require 'active_support/core_ext/class/attribute'
module ActionController
# ActionController::Metal provides a way to get a valid Rack application from a controller.
@@ -90,7 +90,12 @@ module ActionController
end
end
- extlib_inheritable_accessor(:middleware_stack) { ActionDispatch::MiddlewareStack.new }
+ class_attribute :middleware_stack
+ self.middleware_stack = ActionDispatch::MiddlewareStack.new
+
+ def self.inherited(base)
+ self.middleware_stack = base.middleware_stack.dup
+ end
def self.use(*args)
middleware_stack.use(*args)
diff --git a/actionpack/lib/action_controller/metal/compatibility.rb b/actionpack/lib/action_controller/metal/compatibility.rb
index 2be0fa097e..1d4a719aa6 100644
--- a/actionpack/lib/action_controller/metal/compatibility.rb
+++ b/actionpack/lib/action_controller/metal/compatibility.rb
@@ -15,9 +15,6 @@ module ActionController
cattr_accessor :session_options
self.session_options = {}
- cattr_accessor :allow_concurrency
- self.allow_concurrency = false
-
cattr_accessor :relative_url_root
self.relative_url_root = ENV['RAILS_RELATIVE_URL_ROOT']
@@ -44,9 +41,6 @@ module ActionController
self.page_cache_directory = defined?(Rails.public_path) ? Rails.public_path : ""
- cattr_accessor :consider_all_requests_local
- self.consider_all_requests_local = true
-
# Prepends all the URL-generating helpers from AssetHelper. This makes it possible to easily move javascripts, stylesheets,
# and images to a dedicated asset server away from the main web server. Example:
# ActionController::Base.asset_host = "http://assets.example.com"
@@ -74,6 +68,25 @@ module ActionController
module ClassMethods
def consider_all_requests_local
+ ActiveSupport::Deprecation.warn "ActionController::Base.consider_all_requests_local is deprecated, " <<
+ "use Rails.application.config.consider_all_requests_local instead"
+ Rails.application.config.consider_all_requests_local
+ end
+
+ def consider_all_requests_local=(value)
+ ActiveSupport::Deprecation.warn "ActionController::Base.consider_all_requests_local= is no longer effective. " <<
+ "Please configure it on your application with config.consider_all_requests_local="
+ end
+
+ def allow_concurrency
+ ActiveSupport::Deprecation.warn "ActionController::Base.allow_concurrency is deprecated, " <<
+ "use Rails.application.config.allow_concurrency instead"
+ Rails.application.config.allow_concurrency
+ end
+
+ def allow_concurrency=(value)
+ ActiveSupport::Deprecation.warn "ActionController::Base.allow_concurrency= is no longer effective. " <<
+ "Please configure it on your application with config.allow_concurrency="
end
def rescue_action(env)
@@ -86,6 +99,9 @@ module ActionController
end
end
+ delegate :consider_all_requests_local, :consider_all_requests_local=,
+ :allow_concurrency, :allow_concurrency=, :to => :"self.class"
+
def render_to_body(options)
if options.is_a?(Hash) && options.key?(:template)
options[:template].sub!(/^\//, '')
diff --git a/actionpack/lib/action_controller/metal/helpers.rb b/actionpack/lib/action_controller/metal/helpers.rb
index 05843a061b..1b5a4c3080 100644
--- a/actionpack/lib/action_controller/metal/helpers.rb
+++ b/actionpack/lib/action_controller/metal/helpers.rb
@@ -1,3 +1,5 @@
+require 'active_support/core_ext/class/attribute'
+
module ActionController
# The Rails framework provides a large number of helpers for working with +assets+, +dates+, +forms+,
# +numbers+ and model objects, to name a few. These helpers are available to all templates
@@ -50,7 +52,7 @@ module ActionController
include AbstractController::Helpers
included do
- extlib_inheritable_accessor(:helpers_path)
+ class_attribute :helpers_path
self.helpers_path = []
end
diff --git a/actionpack/lib/action_controller/metal/hide_actions.rb b/actionpack/lib/action_controller/metal/hide_actions.rb
index cdacdc40a6..e893acffdf 100644
--- a/actionpack/lib/action_controller/metal/hide_actions.rb
+++ b/actionpack/lib/action_controller/metal/hide_actions.rb
@@ -1,3 +1,5 @@
+require 'active_support/core_ext/class/attribute'
+
module ActionController
# ActionController::HideActions adds the ability to prevent public methods on a controller
# to be called as actions.
@@ -5,7 +7,8 @@ module ActionController
extend ActiveSupport::Concern
included do
- extlib_inheritable_accessor(:hidden_actions) { Set.new }
+ class_attribute :hidden_actions
+ self.hidden_actions = Set.new
end
private
@@ -14,7 +17,7 @@ module ActionController
# action name is in the list of hidden actions.
def action_method?(action_name)
self.class.visible_action?(action_name) do
- !hidden_actions.include?(action_name) && super
+ !self.class.hidden_actions.include?(action_name) && super
end
end
@@ -24,7 +27,7 @@ module ActionController
# ==== Parameters
# *args<#to_s>:: A list of actions
def hide_action(*args)
- hidden_actions.merge(args.map! {|a| a.to_s })
+ self.hidden_actions = hidden_actions.dup.merge(args.map(&:to_s))
end
def inherited(klass)
diff --git a/actionpack/lib/action_controller/metal/mime_responds.rb b/actionpack/lib/action_controller/metal/mime_responds.rb
index 08599d660e..e70a20b2be 100644
--- a/actionpack/lib/action_controller/metal/mime_responds.rb
+++ b/actionpack/lib/action_controller/metal/mime_responds.rb
@@ -1,11 +1,12 @@
require 'abstract_controller/collector'
+require 'active_support/core_ext/class/attribute'
module ActionController #:nodoc:
module MimeResponds #:nodoc:
extend ActiveSupport::Concern
included do
- extlib_inheritable_accessor :responder, :mimes_for_respond_to, :instance_writer => false
+ class_attribute :responder, :mimes_for_respond_to
self.responder = ActionController::Responder
clear_respond_to
end
@@ -38,18 +39,20 @@ module ActionController #:nodoc:
only_actions = Array(options.delete(:only))
except_actions = Array(options.delete(:except))
+ new = mimes_for_respond_to.dup
mimes.each do |mime|
mime = mime.to_sym
- mimes_for_respond_to[mime] = {}
- mimes_for_respond_to[mime][:only] = only_actions unless only_actions.empty?
- mimes_for_respond_to[mime][:except] = except_actions unless except_actions.empty?
+ new[mime] = {}
+ new[mime][:only] = only_actions unless only_actions.empty?
+ new[mime][:except] = except_actions unless except_actions.empty?
end
+ self.mimes_for_respond_to = new.freeze
end
# Clear all mimes in respond_to.
#
def clear_respond_to
- self.mimes_for_respond_to = ActiveSupport::OrderedHash.new
+ self.mimes_for_respond_to = ActiveSupport::OrderedHash.new.freeze
end
end
@@ -218,12 +221,12 @@ module ActionController #:nodoc:
#
def respond_with(*resources, &block)
raise "In order to use respond_with, first you need to declare the formats your " <<
- "controller responds to in the class level" if mimes_for_respond_to.empty?
+ "controller responds to in the class level" if self.class.mimes_for_respond_to.empty?
if response = retrieve_response_from_mimes(&block)
options = resources.extract_options!
options.merge!(:default_response => response)
- (options.delete(:responder) || responder).call(self, resources, options)
+ (options.delete(:responder) || self.class.responder).call(self, resources, options)
end
end
@@ -235,8 +238,8 @@ module ActionController #:nodoc:
def collect_mimes_from_class_level #:nodoc:
action = action_name.to_sym
- mimes_for_respond_to.keys.select do |mime|
- config = mimes_for_respond_to[mime]
+ self.class.mimes_for_respond_to.keys.select do |mime|
+ config = self.class.mimes_for_respond_to[mime]
if config[:except]
!config[:except].include?(action)
diff --git a/actionpack/lib/action_controller/metal/renderers.rb b/actionpack/lib/action_controller/metal/renderers.rb
index c1ba47927a..639b508746 100644
--- a/actionpack/lib/action_controller/metal/renderers.rb
+++ b/actionpack/lib/action_controller/metal/renderers.rb
@@ -1,3 +1,5 @@
+require 'active_support/core_ext/class/attribute'
+
module ActionController
def self.add_renderer(key, &block)
Renderers.add(key, &block)
@@ -7,8 +9,8 @@ module ActionController
extend ActiveSupport::Concern
included do
- extlib_inheritable_accessor :_renderers
- self._renderers = {}
+ class_attribute :_renderers
+ self._renderers = {}.freeze
end
module ClassMethods
@@ -30,9 +32,11 @@ module ActionController
end
def use_renderers(*args)
+ new = _renderers.dup
args.each do |key|
- _renderers[key] = RENDERERS[key]
+ new[key] = RENDERERS[key]
end
+ self._renderers = new.freeze
_write_render_options
end
alias use_renderer use_renderers
diff --git a/actionpack/lib/action_controller/metal/request_forgery_protection.rb b/actionpack/lib/action_controller/metal/request_forgery_protection.rb
index f1fb4d7ce5..276c703307 100644
--- a/actionpack/lib/action_controller/metal/request_forgery_protection.rb
+++ b/actionpack/lib/action_controller/metal/request_forgery_protection.rb
@@ -1,3 +1,5 @@
+require 'active_support/core_ext/class/attribute'
+
module ActionController #:nodoc:
class InvalidAuthenticityToken < ActionControllerError #:nodoc:
end
@@ -13,7 +15,7 @@ module ActionController #:nodoc:
cattr_accessor :request_forgery_protection_token
# Controls whether request forgergy protection is turned on or not. Turned off by default only in test mode.
- extlib_inheritable_accessor :allow_forgery_protection
+ class_attribute :allow_forgery_protection
self.allow_forgery_protection = true
helper_method :form_authenticity_token
@@ -107,7 +109,7 @@ module ActionController #:nodoc:
end
def protect_against_forgery?
- allow_forgery_protection
+ self.class.allow_forgery_protection
end
end
end
diff --git a/actionpack/lib/action_controller/metal/url_for.rb b/actionpack/lib/action_controller/metal/url_for.rb
index 387e6a554b..51702368c1 100644
--- a/actionpack/lib/action_controller/metal/url_for.rb
+++ b/actionpack/lib/action_controller/metal/url_for.rb
@@ -1,3 +1,5 @@
+require 'active_support/core_ext/class/attribute'
+
module ActionController
# In <b>routes.rb</b> one defines URL-to-controller mappings, but the reverse
# is also possible: an URL can be generated from one of your routing definitions.
@@ -85,9 +87,8 @@ module ActionController
included do
ActionController::Routing::Routes.install_helpers(self)
- extlib_inheritable_accessor :default_url_options,
- :instance_writer => false, :instance_reader => false
- self.default_url_options ||= {}
+ class_attribute :default_url_options
+ self.default_url_options = {}
end
# Overwrite to implement a number of default options that all url_for-based methods will use. The default options should come in
diff --git a/actionpack/lib/action_view.rb b/actionpack/lib/action_view.rb
index 66fc530bec..f5035fe45a 100644
--- a/actionpack/lib/action_view.rb
+++ b/actionpack/lib/action_view.rb
@@ -35,7 +35,6 @@ module ActionView
autoload :Context
autoload :Template
autoload :Helpers
- autoload :SafeBuffer
autoload_under "render" do
autoload :Partials
@@ -56,7 +55,7 @@ module ActionView
autoload :TestCase, 'action_view/test_case'
end
-require 'action_view/erb/util'
+require 'active_support/core_ext/string/output_safety'
require 'action_view/base'
I18n.load_path << "#{File.dirname(__FILE__)}/action_view/locale/en.yml"
diff --git a/actionpack/lib/action_view/base.rb b/actionpack/lib/action_view/base.rb
index 07ef3f2140..4096c296c3 100644
--- a/actionpack/lib/action_view/base.rb
+++ b/actionpack/lib/action_view/base.rb
@@ -1,5 +1,6 @@
require 'active_support/core_ext/module/attr_internal'
require 'active_support/core_ext/module/delegation'
+require 'active_support/core_ext/class/attribute'
module ActionView #:nodoc:
class ActionViewError < StandardError #:nodoc:
@@ -244,7 +245,7 @@ module ActionView #:nodoc:
ActionView::PathSet.new(Array(value))
end
- extlib_inheritable_accessor :helpers
+ class_attribute :helpers
attr_reader :helpers
def self.for_controller(controller)
@@ -284,7 +285,7 @@ module ActionView #:nodoc:
@helpers = self.class.helpers || Module.new
@_controller = controller
- @_content_for = Hash.new {|h,k| h[k] = ActionView::SafeBuffer.new }
+ @_content_for = Hash.new {|h,k| h[k] = ActiveSupport::SafeBuffer.new }
@_virtual_path = nil
self.view_paths = view_paths
end
diff --git a/actionpack/lib/action_view/erb/util.rb b/actionpack/lib/action_view/erb/util.rb
deleted file mode 100644
index aef859b3ac..0000000000
--- a/actionpack/lib/action_view/erb/util.rb
+++ /dev/null
@@ -1,49 +0,0 @@
-require 'erb'
-
-class ERB
- module Util
- HTML_ESCAPE = { '&' => '&amp;', '>' => '&gt;', '<' => '&lt;', '"' => '&quot;' }
- JSON_ESCAPE = { '&' => '\u0026', '>' => '\u003E', '<' => '\u003C' }
-
- # A utility method for escaping HTML tag characters.
- # This method is also aliased as <tt>h</tt>.
- #
- # In your ERb templates, use this method to escape any unsafe content. For example:
- # <%=h @person.name %>
- #
- # ==== Example:
- # puts html_escape("is a > 0 & a < 10?")
- # # => is a &gt; 0 &amp; a &lt; 10?
- def html_escape(s)
- s = s.to_s
- if s.html_safe?
- s
- else
- s.gsub(/[&"><]/) { |special| HTML_ESCAPE[special] }.html_safe!
- end
- end
-
- undef :h
- alias h html_escape
-
- module_function :html_escape
- module_function :h
-
- # A utility method for escaping HTML entities in JSON strings.
- # This method is also aliased as <tt>j</tt>.
- #
- # In your ERb templates, use this method to escape any HTML entities:
- # <%=j @person.to_json %>
- #
- # ==== Example:
- # puts json_escape("is a > 0 & a < 10?")
- # # => is a \u003E 0 \u0026 a \u003C 10?
- def json_escape(s)
- s.to_s.gsub(/[&"><]/) { |special| JSON_ESCAPE[special] }
- end
-
- alias j json_escape
- module_function :j
- module_function :json_escape
- end
-end
diff --git a/actionpack/lib/action_view/helpers/active_model_helper.rb b/actionpack/lib/action_view/helpers/active_model_helper.rb
index 87b7adf6c4..e106bb0897 100644
--- a/actionpack/lib/action_view/helpers/active_model_helper.rb
+++ b/actionpack/lib/action_view/helpers/active_model_helper.rb
@@ -6,7 +6,7 @@ require 'active_support/core_ext/kernel/reporting'
module ActionView
class Base
- @@field_error_proc = Proc.new{ |html_tag, instance| "<div class=\"fieldWithErrors\">#{html_tag}</div>".html_safe! }
+ @@field_error_proc = Proc.new{ |html_tag, instance| "<div class=\"fieldWithErrors\">#{html_tag}</div>".html_safe }
cattr_accessor :field_error_proc
end
@@ -86,12 +86,11 @@ module ActionView
submit_value = options[:submit_value] || options[:action].gsub(/[^\w]/, '').capitalize
contents = form_tag({:action => action}, :method =>(options[:method] || 'post'), :enctype => options[:multipart] ? 'multipart/form-data': nil)
- contents << hidden_field(record_name, :id) unless record.new_record?
- contents << all_input_tags(record, record_name, options)
+ contents.safe_concat hidden_field(record_name, :id) unless record.new_record?
+ contents.safe_concat all_input_tags(record, record_name, options)
yield contents if block_given?
- contents << submit_tag(submit_value)
- contents << '</form>'
- contents.html_safe!
+ contents.safe_concat submit_tag(submit_value)
+ contents.safe_concat('</form>')
end
# Returns a string containing the error message attached to the +method+ on the +object+ if one exists.
diff --git a/actionpack/lib/action_view/helpers/asset_tag_helper.rb b/actionpack/lib/action_view/helpers/asset_tag_helper.rb
index 4df99f8293..96976ce45f 100644
--- a/actionpack/lib/action_view/helpers/asset_tag_helper.rb
+++ b/actionpack/lib/action_view/helpers/asset_tag_helper.rb
@@ -293,7 +293,7 @@ module ActionView
else
sources = expand_javascript_sources(sources, recursive)
ensure_javascript_sources!(sources) if cache
- sources.collect { |source| javascript_src_tag(source, options) }.join("\n").html_safe!
+ sources.collect { |source| javascript_src_tag(source, options) }.join("\n").html_safe
end
end
@@ -444,7 +444,7 @@ module ActionView
else
sources = expand_stylesheet_sources(sources, recursive)
ensure_stylesheet_sources!(sources) if cache
- sources.collect { |source| stylesheet_tag(source, options) }.join("\n").html_safe!
+ sources.collect { |source| stylesheet_tag(source, options) }.join("\n").html_safe
end
end
@@ -588,7 +588,7 @@ module ActionView
if sources.is_a?(Array)
content_tag("video", options) do
- sources.map { |source| tag("source", :src => source) }.join.html_safe!
+ sources.map { |source| tag("source", :src => source) }.join.html_safe
end
else
options[:src] = path_to_video(sources)
diff --git a/actionpack/lib/action_view/helpers/capture_helper.rb b/actionpack/lib/action_view/helpers/capture_helper.rb
index b62df75dbb..8c48300ed3 100644
--- a/actionpack/lib/action_view/helpers/capture_helper.rb
+++ b/actionpack/lib/action_view/helpers/capture_helper.rb
@@ -143,7 +143,7 @@ module ActionView
# Defaults to a new empty string.
def with_output_buffer(buf = nil) #:nodoc:
unless buf
- buf = ActionView::SafeBuffer.new
+ buf = ActiveSupport::SafeBuffer.new
buf.force_encoding(output_buffer.encoding) if buf.respond_to?(:force_encoding)
end
self.output_buffer, old_buffer = buf, output_buffer
diff --git a/actionpack/lib/action_view/helpers/date_helper.rb b/actionpack/lib/action_view/helpers/date_helper.rb
index 34f38b0a8a..8be2f76bd6 100644
--- a/actionpack/lib/action_view/helpers/date_helper.rb
+++ b/actionpack/lib/action_view/helpers/date_helper.rb
@@ -616,7 +616,7 @@ module ActionView
build_selects_from_types(order)
else
- "#{select_date}#{@options[:datetime_separator]}#{select_time}".html_safe!
+ "#{select_date}#{@options[:datetime_separator]}#{select_time}".html_safe
end
end
@@ -835,7 +835,7 @@ module ActionView
select_html << prompt_option_tag(type, @options[:prompt]) + "\n" if @options[:prompt]
select_html << select_options_as_html.to_s
- (content_tag(:select, select_html, select_options) + "\n").html_safe!
+ (content_tag(:select, select_html, select_options) + "\n").html_safe
end
# Builds a prompt option tag with supplied options or from default options
@@ -865,7 +865,7 @@ module ActionView
:id => input_id_from_type(type),
:name => input_name_from_type(type),
:value => value
- }) + "\n").html_safe!
+ }) + "\n").html_safe
end
# Returns the name attribute for the input tag
@@ -896,7 +896,7 @@ module ActionView
separator = separator(type) unless type == order.first # don't add on last field
select.insert(0, separator.to_s + send("select_#{type}").to_s)
end
- select.html_safe!
+ select.html_safe
end
# Returns the separator for a given datetime component
@@ -916,15 +916,15 @@ module ActionView
class InstanceTag #:nodoc:
def to_date_select_tag(options = {}, html_options = {})
- datetime_selector(options, html_options).select_date.html_safe!
+ datetime_selector(options, html_options).select_date.html_safe
end
def to_time_select_tag(options = {}, html_options = {})
- datetime_selector(options, html_options).select_time.html_safe!
+ datetime_selector(options, html_options).select_time.html_safe
end
def to_datetime_select_tag(options = {}, html_options = {})
- datetime_selector(options, html_options).select_datetime.html_safe!
+ datetime_selector(options, html_options).select_datetime.html_safe
end
private
diff --git a/actionpack/lib/action_view/helpers/debug_helper.rb b/actionpack/lib/action_view/helpers/debug_helper.rb
index 885945fde3..e637dc1474 100644
--- a/actionpack/lib/action_view/helpers/debug_helper.rb
+++ b/actionpack/lib/action_view/helpers/debug_helper.rb
@@ -27,10 +27,10 @@ module ActionView
def debug(object)
begin
Marshal::dump(object)
- "<pre class='debug_dump'>#{h(object.to_yaml).gsub(" ", "&nbsp; ")}</pre>".html_safe!
+ "<pre class='debug_dump'>#{h(object.to_yaml).gsub(" ", "&nbsp; ")}</pre>".html_safe
rescue Exception => e # errors from Marshal or YAML
# Object couldn't be dumped, perhaps because of singleton methods -- this is the fallback
- "<code class='debug_dump'>#{h(object.inspect)}</code>".html_safe!
+ "<code class='debug_dump'>#{h(object.inspect)}</code>".html_safe
end
end
end
diff --git a/actionpack/lib/action_view/helpers/form_helper.rb b/actionpack/lib/action_view/helpers/form_helper.rb
index a72357cf3d..76998a6ea1 100644
--- a/actionpack/lib/action_view/helpers/form_helper.rb
+++ b/actionpack/lib/action_view/helpers/form_helper.rb
@@ -311,7 +311,7 @@ module ActionView
concat(form_tag(options.delete(:url) || {}, options.delete(:html) || {}))
fields_for(object_name, *(args << options), &proc)
- concat('</form>'.html_safe!)
+ safe_concat('</form>')
end
def apply_form_for_options!(object_or_array, options) #:nodoc:
@@ -879,7 +879,7 @@ module ActionView
end
hidden = tag("input", "name" => options["name"], "type" => "hidden", "value" => options['disabled'] && checked ? checked_value : unchecked_value)
checkbox = tag("input", options)
- (hidden + checkbox).html_safe!
+ (hidden + checkbox).html_safe
end
def to_boolean_select_tag(options = {})
diff --git a/actionpack/lib/action_view/helpers/form_options_helper.rb b/actionpack/lib/action_view/helpers/form_options_helper.rb
index 02ad637509..0ffe770f5f 100644
--- a/actionpack/lib/action_view/helpers/form_options_helper.rb
+++ b/actionpack/lib/action_view/helpers/form_options_helper.rb
@@ -296,7 +296,7 @@ module ActionView
options << %(<option value="#{html_escape(value.to_s)}"#{selected_attribute}#{disabled_attribute}>#{html_escape(text.to_s)}</option>)
end
- options_for_select.join("\n").html_safe!
+ options_for_select.join("\n").html_safe
end
# Returns a string of option tags that have been compiled by iterating over the +collection+ and assigning the
diff --git a/actionpack/lib/action_view/helpers/form_tag_helper.rb b/actionpack/lib/action_view/helpers/form_tag_helper.rb
index 597cf311cb..9b8471c6c6 100644
--- a/actionpack/lib/action_view/helpers/form_tag_helper.rb
+++ b/actionpack/lib/action_view/helpers/form_tag_helper.rb
@@ -446,7 +446,7 @@ module ActionView
concat(tag(:fieldset, options, true))
concat(content_tag(:legend, legend)) unless legend.blank?
concat(content)
- concat("</fieldset>".html_safe!)
+ safe_concat("</fieldset>")
end
private
@@ -474,14 +474,14 @@ module ActionView
def form_tag_html(html_options)
extra_tags = extra_tags_for_form(html_options)
- (tag(:form, html_options, true) + extra_tags).html_safe!
+ (tag(:form, html_options, true) + extra_tags).html_safe
end
def form_tag_in_block(html_options, &block)
content = capture(&block)
concat(form_tag_html(html_options))
concat(content)
- concat("</form>".html_safe!)
+ safe_concat("</form>")
end
def token_tag
diff --git a/actionpack/lib/action_view/helpers/number_helper.rb b/actionpack/lib/action_view/helpers/number_helper.rb
index 64b71663c3..3d3502a08b 100644
--- a/actionpack/lib/action_view/helpers/number_helper.rb
+++ b/actionpack/lib/action_view/helpers/number_helper.rb
@@ -92,7 +92,7 @@ module ActionView
:precision => precision,
:delimiter => delimiter,
:separator => separator)
- ).gsub(/%u/, unit).html_safe!
+ ).gsub(/%u/, unit).html_safe
rescue
number
end
diff --git a/actionpack/lib/action_view/helpers/prototype_helper.rb b/actionpack/lib/action_view/helpers/prototype_helper.rb
index d335d89274..7eb6bceca0 100644
--- a/actionpack/lib/action_view/helpers/prototype_helper.rb
+++ b/actionpack/lib/action_view/helpers/prototype_helper.rb
@@ -610,7 +610,7 @@ module ActionView
# page.hide 'spinner'
# end
def update_page(&block)
- JavaScriptGenerator.new(@template, &block).to_s.html_safe!
+ JavaScriptGenerator.new(@template, &block).to_s.html_safe
end
# Works like update_page but wraps the generated JavaScript in a <script>
diff --git a/actionpack/lib/action_view/helpers/raw_output_helper.rb b/actionpack/lib/action_view/helpers/raw_output_helper.rb
index 79b0e4ee75..8c7f41177d 100644
--- a/actionpack/lib/action_view/helpers/raw_output_helper.rb
+++ b/actionpack/lib/action_view/helpers/raw_output_helper.rb
@@ -2,7 +2,7 @@ module ActionView #:nodoc:
module Helpers #:nodoc:
module RawOutputHelper
def raw(stringish)
- stringish.to_s.html_safe!
+ stringish.to_s.html_safe
end
end
end
diff --git a/actionpack/lib/action_view/helpers/sanitize_helper.rb b/actionpack/lib/action_view/helpers/sanitize_helper.rb
index 657d26f0a2..28e40f8560 100644
--- a/actionpack/lib/action_view/helpers/sanitize_helper.rb
+++ b/actionpack/lib/action_view/helpers/sanitize_helper.rb
@@ -50,11 +50,7 @@ module ActionView
# confuse browsers.
#
def sanitize(html, options = {})
- returning self.class.white_list_sanitizer.sanitize(html, options) do |sanitized|
- if sanitized
- sanitized.html_safe!
- end
- end
+ self.class.white_list_sanitizer.sanitize(html, options).try(:html_safe)
end
# Sanitizes a block of CSS code. Used by +sanitize+ when it comes across a style attribute.
@@ -77,11 +73,7 @@ module ActionView
# strip_tags("<div id='top-bar'>Welcome to my website!</div>")
# # => Welcome to my website!
def strip_tags(html)
- returning self.class.full_sanitizer.sanitize(html) do |sanitized|
- if sanitized
- sanitized.html_safe!
- end
- end
+ self.class.full_sanitizer.sanitize(html).try(:html_safe)
end
# Strips all link tags from +text+ leaving just the link text.
diff --git a/actionpack/lib/action_view/helpers/tag_helper.rb b/actionpack/lib/action_view/helpers/tag_helper.rb
index ceddbd8cc1..ed80e07c78 100644
--- a/actionpack/lib/action_view/helpers/tag_helper.rb
+++ b/actionpack/lib/action_view/helpers/tag_helper.rb
@@ -1,4 +1,3 @@
-require 'action_view/erb/util'
require 'set'
module ActionView
@@ -41,7 +40,7 @@ module ActionView
# tag("img", { :src => "open &amp; shut.png" }, false, false)
# # => <img src="open &amp; shut.png" />
def tag(name, options = nil, open = false, escape = true)
- "<#{name}#{tag_options(options, escape) if options}#{open ? ">" : " />"}".html_safe!
+ "<#{name}#{tag_options(options, escape) if options}#{open ? ">" : " />"}".html_safe
end
# Returns an HTML block tag of type +name+ surrounding the +content+. Add
@@ -94,7 +93,7 @@ module ActionView
# cdata_section(File.read("hello_world.txt"))
# # => <![CDATA[<hello from a text file]]>
def cdata_section(content)
- "<![CDATA[#{content}]]>".html_safe!
+ "<![CDATA[#{content}]]>".html_safe
end
# Returns an escaped version of +html+ without affecting existing escaped entities.
@@ -128,7 +127,7 @@ module ActionView
def content_tag_string(name, content, options, escape = true)
tag_options = tag_options(options, escape) if options
- "<#{name}#{tag_options}>#{content}</#{name}>".html_safe!
+ "<#{name}#{tag_options}>#{content}</#{name}>".html_safe
end
def tag_options(options, escape = true)
@@ -143,7 +142,7 @@ module ActionView
attrs << %(#{key}="#{final_value}")
end
end
- " #{attrs.sort * ' '}".html_safe! unless attrs.empty?
+ " #{attrs.sort * ' '}".html_safe unless attrs.empty?
end
end
end
diff --git a/actionpack/lib/action_view/helpers/text_helper.rb b/actionpack/lib/action_view/helpers/text_helper.rb
index 814d86812d..412e0c82cb 100644
--- a/actionpack/lib/action_view/helpers/text_helper.rb
+++ b/actionpack/lib/action_view/helpers/text_helper.rb
@@ -24,14 +24,14 @@ module ActionView
# end
# # will either display "Logged in!" or a login link
# %>
- def concat(string, unused_binding = nil)
- if unused_binding
- ActiveSupport::Deprecation.warn("The binding argument of #concat is no longer needed. Please remove it from your views and helpers.", caller)
- end
-
+ def concat(string)
output_buffer << string
end
+ def safe_concat(string)
+ output_buffer.safe_concat(string)
+ end
+
# Truncates a given +text+ after a given <tt>:length</tt> if +text+ is longer than <tt>:length</tt>
# (defaults to 30). The last characters will be replaced with the <tt>:omission</tt> (defaults to "...")
# for a total length not exceeding <tt>:length</tt>.
diff --git a/actionpack/lib/action_view/helpers/translation_helper.rb b/actionpack/lib/action_view/helpers/translation_helper.rb
index ad18339c60..c348ea7a0d 100644
--- a/actionpack/lib/action_view/helpers/translation_helper.rb
+++ b/actionpack/lib/action_view/helpers/translation_helper.rb
@@ -12,7 +12,7 @@ module ActionView
# prepend the key with a period, nothing is converted.
def translate(key, options = {})
options[:raise] = true
- I18n.translate(scope_key_by_partial(key), options).html_safe!
+ I18n.translate(scope_key_by_partial(key), options).html_safe
rescue I18n::MissingTranslationData => e
keys = I18n.send(:normalize_translation_keys, e.locale, e.key, e.options[:scope])
content_tag('span', keys.join(', '), :class => 'translation_missing')
diff --git a/actionpack/lib/action_view/helpers/url_helper.rb b/actionpack/lib/action_view/helpers/url_helper.rb
index 4301647a2c..168a3bdbc0 100644
--- a/actionpack/lib/action_view/helpers/url_helper.rb
+++ b/actionpack/lib/action_view/helpers/url_helper.rb
@@ -98,7 +98,7 @@ module ActionView
polymorphic_path(options)
end
- escape ? escape_once(url).html_safe! : url
+ escape ? escape_once(url).html_safe : url
end
# Creates a link tag of the given +name+ using a URL created by the set
@@ -208,7 +208,7 @@ module ActionView
if block_given?
options = args.first || {}
html_options = args.second
- concat(link_to(capture(&block), options, html_options).html_safe!)
+ safe_concat(link_to(capture(&block), options, html_options))
else
name = args[0]
options = args[1] || {}
@@ -226,7 +226,7 @@ module ActionView
end
href_attr = "href=\"#{url}\"" unless href
- "<a #{href_attr}#{tag_options}>#{ERB::Util.h(name || url)}</a>".html_safe!
+ "<a #{href_attr}#{tag_options}>#{ERB::Util.h(name || url)}</a>".html_safe
end
end
@@ -312,7 +312,7 @@ module ActionView
html_options.merge!("type" => "submit", "value" => name)
("<form method=\"#{form_method}\" action=\"#{escape_once url}\" #{"data-remote=\"true\"" if remote} class=\"button-to\"><div>" +
- method_tag + tag("input", html_options) + request_token_tag + "</div></form>").html_safe!
+ method_tag + tag("input", html_options) + request_token_tag + "</div></form>").html_safe
end
diff --git a/actionpack/lib/action_view/render/partials.rb b/actionpack/lib/action_view/render/partials.rb
index 8c936ae09e..8b6dce0c1c 100644
--- a/actionpack/lib/action_view/render/partials.rb
+++ b/actionpack/lib/action_view/render/partials.rb
@@ -240,7 +240,7 @@ module ActionView
end
result = @template ? collection_with_template : collection_without_template
- result.join(spacer).html_safe!
+ result.join(spacer).html_safe
end
def collection_with_template(template = @template)
diff --git a/actionpack/lib/action_view/safe_buffer.rb b/actionpack/lib/action_view/safe_buffer.rb
deleted file mode 100644
index 6be05b9e1e..0000000000
--- a/actionpack/lib/action_view/safe_buffer.rb
+++ /dev/null
@@ -1,27 +0,0 @@
-module ActionView #:nodoc:
- class SafeBuffer < String
- def <<(value)
- if value.html_safe?
- super(value)
- else
- super(ERB::Util.h(value))
- end
- end
-
- def concat(value)
- self << value
- end
-
- def html_safe?
- true
- end
-
- def html_safe!
- self
- end
-
- def to_s
- self
- end
- end
-end \ No newline at end of file
diff --git a/actionpack/lib/action_view/template/handler.rb b/actionpack/lib/action_view/template/handler.rb
index 221d1bd5c5..8ecc911519 100644
--- a/actionpack/lib/action_view/template/handler.rb
+++ b/actionpack/lib/action_view/template/handler.rb
@@ -1,5 +1,5 @@
-require "active_support/core_ext/class/inheritable_attributes"
require "action_dispatch/http/mime_type"
+require 'active_support/core_ext/class/attribute'
# Legacy TemplateHandler stub
module ActionView
@@ -23,7 +23,7 @@ module ActionView
end
class Template::Handler
- extlib_inheritable_accessor :default_format
+ class_attribute :default_format
self.default_format = Mime::HTML
def self.call(template)
diff --git a/actionpack/lib/action_view/template/handlers/erb.rb b/actionpack/lib/action_view/template/handlers/erb.rb
index 93a4315108..4573a440d1 100644
--- a/actionpack/lib/action_view/template/handlers/erb.rb
+++ b/actionpack/lib/action_view/template/handlers/erb.rb
@@ -6,7 +6,7 @@ module ActionView
module Template::Handlers
class Erubis < ::Erubis::Eruby
def add_preamble(src)
- src << "@output_buffer = ActionView::SafeBuffer.new;"
+ src << "@output_buffer = ActiveSupport::SafeBuffer.new;"
end
def add_text(src, text)
@@ -15,7 +15,11 @@ module ActionView
end
def add_expr_literal(src, code)
- src << '@output_buffer << ((' << code << ').to_s);'
+ if code =~ /\s*raw\s+(.*)/
+ src << "@output_buffer.safe_concat((" << $1 << ").to_s);"
+ else
+ src << '@output_buffer << ((' << code << ').to_s);'
+ end
end
def add_expr_escaped(src, code)
diff --git a/actionpack/lib/action_view/template/resolver.rb b/actionpack/lib/action_view/template/resolver.rb
index af5d6f6d18..6878067f7c 100644
--- a/actionpack/lib/action_view/template/resolver.rb
+++ b/actionpack/lib/action_view/template/resolver.rb
@@ -1,5 +1,6 @@
require "pathname"
require "active_support/core_ext/class"
+require "active_support/core_ext/array/wrap"
require "action_view/template"
module ActionView
@@ -11,7 +12,7 @@ module ActionView
def self.register_detail(name, options = {})
registered_details[name] = lambda do |val|
- val ||= yield
+ val = Array.wrap(val || yield)
val |= [nil] unless options[:allow_nil] == false
val
end
diff --git a/actionpack/lib/action_view/test_case.rb b/actionpack/lib/action_view/test_case.rb
index 3095d84e13..fc29acea6d 100644
--- a/actionpack/lib/action_view/test_case.rb
+++ b/actionpack/lib/action_view/test_case.rb
@@ -53,7 +53,7 @@ module ActionView
setup :setup_with_controller
def setup_with_controller
@controller = TestController.new
- @output_buffer = ActionView::SafeBuffer.new
+ @output_buffer = ActiveSupport::SafeBuffer.new
@rendered = ''
self.class.send(:include_helper_modules!)
diff --git a/actionpack/test/abstract_unit.rb b/actionpack/test/abstract_unit.rb
index 7b04638ccc..867e50d5b9 100644
--- a/actionpack/test/abstract_unit.rb
+++ b/actionpack/test/abstract_unit.rb
@@ -1,10 +1,4 @@
-begin
- require File.expand_path('../../../vendor/gems/environment', __FILE__)
-rescue LoadError
-end
-
-lib = File.expand_path('../../lib', __FILE__)
-$:.unshift(lib) unless $:.include?('lib') || $:.include?(lib)
+require File.expand_path('../../../load_paths', __FILE__)
$:.unshift(File.dirname(__FILE__) + '/lib')
$:.unshift(File.dirname(__FILE__) + '/fixtures/helpers')
@@ -20,9 +14,6 @@ require 'action_view/base'
require 'action_dispatch'
require 'fixture_template'
require 'active_support/dependencies'
-
-activemodel_path = File.expand_path('../../../activemodel/lib', __FILE__)
-$:.unshift(activemodel_path) if File.directory?(activemodel_path) && !$:.include?(activemodel_path)
require 'active_model'
begin
diff --git a/actionpack/test/controller/caching_test.rb b/actionpack/test/controller/caching_test.rb
index 8a13d1e5f1..de92fc56fd 100644
--- a/actionpack/test/controller/caching_test.rb
+++ b/actionpack/test/controller/caching_test.rb
@@ -611,7 +611,7 @@ class FragmentCachingTest < ActionController::TestCase
@store.write('views/expensive', 'fragment content')
fragment_computed = false
- buffer = 'generated till now -> '
+ buffer = 'generated till now -> '.html_safe
@controller.fragment_for(buffer, 'expensive') { fragment_computed = true }
assert fragment_computed
@@ -622,7 +622,7 @@ class FragmentCachingTest < ActionController::TestCase
@store.write('views/expensive', 'fragment content')
fragment_computed = false
- buffer = 'generated till now -> '
+ buffer = 'generated till now -> '.html_safe
@controller.fragment_for(buffer, 'expensive') { fragment_computed = true }
assert !fragment_computed
diff --git a/actionpack/test/controller/new_base/render_template_test.rb b/actionpack/test/controller/new_base/render_template_test.rb
index c81b951c0d..70cebbfd89 100644
--- a/actionpack/test/controller/new_base/render_template_test.rb
+++ b/actionpack/test/controller/new_base/render_template_test.rb
@@ -2,18 +2,19 @@ require 'abstract_unit'
module RenderTemplate
class WithoutLayoutController < ActionController::Base
-
+
self.view_paths = [ActionView::FixtureResolver.new(
"test/basic.html.erb" => "Hello from basic.html.erb",
"shared.html.erb" => "Elastica",
"locals.html.erb" => "The secret is <%= secret %>",
- "xml_template.xml.builder" => "xml.html do\n xml.p 'Hello'\nend"
+ "xml_template.xml.builder" => "xml.html do\n xml.p 'Hello'\nend",
+ "with_raw.html.erb" => "Hello <%=raw '<strong>this is raw</strong>' %>"
)]
-
+
def index
render :template => "test/basic"
end
-
+
def index_without_key
render "test/basic"
end
@@ -25,59 +26,70 @@ module RenderTemplate
def in_top_directory_with_slash
render :template => '/shared'
end
-
+
def in_top_directory_with_slash_without_key
render '/shared'
end
-
+
def with_locals
render :template => "locals", :locals => { :secret => 'area51' }
end
-
+
def builder_template
render :template => "xml_template"
end
+
+ def with_raw
+ render :template => "with_raw"
+ end
end
-
+
class TestWithoutLayout < Rack::TestCase
testing RenderTemplate::WithoutLayoutController
-
+
test "rendering a normal template with full path without layout" do
get :index
assert_response "Hello from basic.html.erb"
end
-
+
test "rendering a normal template with full path without layout without key" do
get :index_without_key
assert_response "Hello from basic.html.erb"
end
-
+
test "rendering a template not in a subdirectory" do
get :in_top_directory
assert_response "Elastica"
end
-
+
test "rendering a template not in a subdirectory with a leading slash" do
get :in_top_directory_with_slash
assert_response "Elastica"
end
-
+
test "rendering a template not in a subdirectory with a leading slash without key" do
get :in_top_directory_with_slash_without_key
assert_response "Elastica"
end
-
+
test "rendering a template with local variables" do
get :with_locals
assert_response "The secret is area51"
end
-
+
test "rendering a builder template" do
get :builder_template, "format" => "xml"
assert_response "<html>\n <p>Hello</p>\n</html>\n"
end
+
+ test "rendering a template with <%=raw stuff %>" do
+ get :with_raw
+
+ assert_body "Hello <strong>this is raw</strong>"
+ assert_status 200
+ end
end
-
+
class WithLayoutController < ::ApplicationController
self.view_paths = [ActionView::FixtureResolver.new(
"test/basic.html.erb" => "Hello from basic.html.erb",
@@ -85,28 +97,28 @@ module RenderTemplate
"layouts/application.html.erb" => "<%= yield %>, I'm here!",
"layouts/greetings.html.erb" => "<%= yield %>, I wish thee well."
)]
-
+
def index
render :template => "test/basic"
end
-
+
def with_layout
render :template => "test/basic", :layout => true
end
-
+
def with_layout_false
render :template => "test/basic", :layout => false
end
-
+
def with_layout_nil
render :template => "test/basic", :layout => nil
end
-
+
def with_custom_layout
render :template => "test/basic", :layout => "greetings"
end
end
-
+
class TestWithLayout < Rack::TestCase
describe "Rendering with :template using implicit or explicit layout"
diff --git a/actionpack/test/controller/output_escaping_test.rb b/actionpack/test/controller/output_escaping_test.rb
index 7332f3f1e3..43a8c05cda 100644
--- a/actionpack/test/controller/output_escaping_test.rb
+++ b/actionpack/test/controller/output_escaping_test.rb
@@ -13,7 +13,7 @@ class OutputEscapingTest < ActiveSupport::TestCase
test "escapeHTML shouldn't touch explicitly safe strings" do
# TODO this seems easier to compose and reason about, but
# this should be verified
- assert_equal "<", ERB::Util.h("<".html_safe!)
+ assert_equal "<", ERB::Util.h("<".html_safe)
end
end
diff --git a/actionpack/test/controller/view_paths_test.rb b/actionpack/test/controller/view_paths_test.rb
index 05d2c8407c..56821332c5 100644
--- a/actionpack/test/controller/view_paths_test.rb
+++ b/actionpack/test/controller/view_paths_test.rb
@@ -142,9 +142,9 @@ class ViewLoadPathsTest < ActionController::TestCase
assert_paths A, "a/path"
assert_paths A, *B.view_paths
assert_paths C, *original_load_paths
-
+
C.view_paths = []
- assert_nothing_raised { C.view_paths << 'c/path' }
+ assert_nothing_raised { C.append_view_path 'c/path' }
assert_paths C, "c/path"
end
end
diff --git a/actionpack/test/template/erb_util_test.rb b/actionpack/test/template/erb_util_test.rb
index fa6b263965..06155b1f30 100644
--- a/actionpack/test/template/erb_util_test.rb
+++ b/actionpack/test/template/erb_util_test.rb
@@ -22,7 +22,7 @@ class ErbUtilTest < Test::Unit::TestCase
end
def test_html_escape_passes_html_escpe_unmodified
- escaped = h("<p>".html_safe!)
+ escaped = h("<p>".html_safe)
assert_equal "<p>", escaped
assert escaped.html_safe?
end
diff --git a/actionpack/test/template/form_helper_test.rb b/actionpack/test/template/form_helper_test.rb
index caeca9db10..aafc318b76 100644
--- a/actionpack/test/template/form_helper_test.rb
+++ b/actionpack/test/template/form_helper_test.rb
@@ -1170,7 +1170,7 @@ class FormHelperTest < ActionView::TestCase
(field_helpers - %w(hidden_field)).each do |selector|
src = <<-END_SRC
def #{selector}(field, *args, &proc)
- ("<label for='\#{field}'>\#{field.to_s.humanize}:</label> " + super + "<br/>").html_safe!
+ ("<label for='\#{field}'>\#{field.to_s.humanize}:</label> " + super + "<br/>").html_safe
end
END_SRC
class_eval src, __FILE__, __LINE__
diff --git a/actionpack/test/template/form_tag_helper_test.rb b/actionpack/test/template/form_tag_helper_test.rb
index 553ec44fad..3635c7548e 100644
--- a/actionpack/test/template/form_tag_helper_test.rb
+++ b/actionpack/test/template/form_tag_helper_test.rb
@@ -335,19 +335,19 @@ class FormTagHelperTest < ActionView::TestCase
expected = %(<fieldset><legend>Your details</legend>Hello world!</fieldset>)
assert_dom_equal expected, output_buffer
- self.output_buffer = ''
+ self.output_buffer = ''.html_safe
field_set_tag { concat "Hello world!" }
expected = %(<fieldset>Hello world!</fieldset>)
assert_dom_equal expected, output_buffer
- self.output_buffer = ''
+ self.output_buffer = ''.html_safe
field_set_tag('') { concat "Hello world!" }
expected = %(<fieldset>Hello world!</fieldset>)
assert_dom_equal expected, output_buffer
- self.output_buffer = ''
+ self.output_buffer = ''.html_safe
field_set_tag('', :class => 'format') { concat "Hello world!" }
expected = %(<fieldset class="format">Hello world!</fieldset>)
diff --git a/actionpack/test/template/safe_buffer_test.rb b/actionpack/test/template/safe_buffer_test.rb
deleted file mode 100644
index 6a18201d16..0000000000
--- a/actionpack/test/template/safe_buffer_test.rb
+++ /dev/null
@@ -1,41 +0,0 @@
-require 'abstract_unit'
-
-class SafeBufferTest < ActionView::TestCase
- def setup
- @buffer = ActionView::SafeBuffer.new
- end
-
- test "Should look like a string" do
- assert @buffer.is_a?(String)
- assert_equal "", @buffer
- end
-
- test "Should escape a raw string which is passed to them" do
- @buffer << "<script>"
- assert_equal "&lt;script&gt;", @buffer
- end
-
- test "Should NOT escape a safe value passed to it" do
- @buffer << "<script>".html_safe!
- assert_equal "<script>", @buffer
- end
-
- test "Should not mess with an innocuous string" do
- @buffer << "Hello"
- assert_equal "Hello", @buffer
- end
-
- test "Should not mess with a previously escape test" do
- @buffer << ERB::Util.html_escape("<script>")
- assert_equal "&lt;script&gt;", @buffer
- end
-
- test "Should be considered safe" do
- assert @buffer.html_safe?
- end
-
- test "Should return a safe buffer when calling to_s" do
- new_buffer = @buffer.to_s
- assert_equal ActionView::SafeBuffer, new_buffer.class
- end
-end
diff --git a/actionpack/test/template/test_case_test.rb b/actionpack/test/template/test_case_test.rb
index 9a448ce328..be2c6b3108 100644
--- a/actionpack/test/template/test_case_test.rb
+++ b/actionpack/test/template/test_case_test.rb
@@ -160,7 +160,7 @@ module ActionView
class AssertionsTest < ActionView::TestCase
def render_from_helper
form_tag('/foo') do
- concat render(:text => '<ul><li>foo</li></ul>').html_safe!
+ safe_concat render(:text => '<ul><li>foo</li></ul>')
end
end
helper_method :render_from_helper