mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Merge remote branch 'miloops/warnings'
This commit is contained in:
commit
0bbf9029e8
43 changed files with 90 additions and 109 deletions
|
@ -18,7 +18,7 @@ Rake::TestTask.new(:test_action_pack) do |t|
|
|||
# this will not happen automatically and the tests (as a whole) will error
|
||||
t.test_files = Dir.glob('test/{abstract,controller,dispatch,template}/**/*_test.rb').sort
|
||||
|
||||
#t.warning = true
|
||||
t.warning = true
|
||||
t.verbose = true
|
||||
end
|
||||
|
||||
|
|
|
@ -345,6 +345,7 @@ module AbstractController
|
|||
# * <tt>template</tt> - The template object for the default layout (or nil)
|
||||
def _default_layout(require_layout = false)
|
||||
begin
|
||||
@_layout ||= nil
|
||||
layout_name = _layout if action_has_layout?
|
||||
rescue NameError => e
|
||||
raise NoMethodError,
|
||||
|
|
|
@ -66,7 +66,7 @@ module AbstractController
|
|||
attr_writer :view_context_class
|
||||
|
||||
def view_context_class
|
||||
@view_context_class || self.class.view_context_class
|
||||
(@view_context_class ||= nil) || self.class.view_context_class
|
||||
end
|
||||
|
||||
def initialize(*)
|
||||
|
|
|
@ -462,9 +462,11 @@ module ActionController
|
|||
# The exception is stored in the exception accessor for further inspection.
|
||||
module RaiseActionExceptions
|
||||
def self.included(base)
|
||||
base.class_eval do
|
||||
attr_accessor :exception
|
||||
protected :exception, :exception=
|
||||
unless base.method_defined?(:exception) && base.method_defined?(:exception=)
|
||||
base.class_eval do
|
||||
attr_accessor :exception
|
||||
protected :exception, :exception=
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -19,9 +19,11 @@ module ActionDispatch
|
|||
# replace the existing callback. Passing an identifier is a suggested
|
||||
# practice if the code adding a preparation block may be reloaded.
|
||||
def self.to_prepare(*args, &block)
|
||||
if args.first.is_a?(Symbol) && block_given?
|
||||
define_method :"__#{args.first}", &block
|
||||
set_callback(:prepare, :"__#{args.first}")
|
||||
first_arg = args.first
|
||||
if first_arg.is_a?(Symbol) && block_given?
|
||||
remove_method :"__#{first_arg}" if method_defined?(:"__#{first_arg}")
|
||||
define_method :"__#{first_arg}", &block
|
||||
set_callback(:prepare, :"__#{first_arg}")
|
||||
else
|
||||
set_callback(:prepare, *args, &block)
|
||||
end
|
||||
|
|
|
@ -102,8 +102,8 @@ module ActionDispatch
|
|||
|
||||
def destroy
|
||||
clear
|
||||
@by.send(:destroy, @env) if @by
|
||||
@env[ENV_SESSION_OPTIONS_KEY][:id] = nil if @env && @env[ENV_SESSION_OPTIONS_KEY]
|
||||
@by.send(:destroy, @env) if defined?(@by) && @by
|
||||
@env[ENV_SESSION_OPTIONS_KEY][:id] = nil if defined?(@env) && @env && @env[ENV_SESSION_OPTIONS_KEY]
|
||||
@loaded = false
|
||||
end
|
||||
|
||||
|
|
|
@ -41,9 +41,8 @@ module ActionDispatch
|
|||
end
|
||||
end
|
||||
|
||||
def initialize(*args, &block)
|
||||
super(*args)
|
||||
block.call(self) if block_given?
|
||||
def initialize(*args)
|
||||
yield(self) if block_given?
|
||||
end
|
||||
|
||||
def insert(index, *args, &block)
|
||||
|
|
|
@ -7,6 +7,7 @@ module ActionDispatch
|
|||
@compiled_at = Regexp.compile(/^#{Regexp.escape(at)}/) unless @at.blank?
|
||||
@compiled_root = Regexp.compile(/^#{Regexp.escape(root)}/)
|
||||
@file_server = ::Rack::File.new(root)
|
||||
@compiled_at ||= nil
|
||||
end
|
||||
|
||||
def match?(path)
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
def debug_hash(hash)
|
||||
hash.sort_by { |k, v| k.to_s }.map { |k, v| "#{k}: #{v.inspect rescue $!.message}" }.join("\n")
|
||||
end
|
||||
end unless self.class.method_defined?(:debug_hash)
|
||||
%>
|
||||
|
||||
<h2 style="margin-top: 30px">Request</h2>
|
||||
|
@ -28,4 +28,4 @@
|
|||
|
||||
|
||||
<h2 style="margin-top: 30px">Response</h2>
|
||||
<p><b>Headers</b>: <pre><%=h @response ? @response.headers.inspect.gsub(',', ",\n") : 'None' %></pre></p>
|
||||
<p><b>Headers</b>: <pre><%=h defined?(@response) ? @response.headers.inspect.gsub(',', ",\n") : 'None' %></pre></p>
|
||||
|
|
|
@ -12,14 +12,14 @@
|
|||
<div id="traces">
|
||||
<% names.each do |name| %>
|
||||
<%
|
||||
show = "document.getElementById('#{name.gsub /\s/, '-'}').style.display='block';"
|
||||
hide = (names - [name]).collect {|hide_name| "document.getElementById('#{hide_name.gsub /\s/, '-'}').style.display='none';"}
|
||||
show = "document.getElementById('#{name.gsub(/\s/, '-')}').style.display='block';"
|
||||
hide = (names - [name]).collect {|hide_name| "document.getElementById('#{hide_name.gsub(/\s/, '-')}').style.display='none';"}
|
||||
%>
|
||||
<a href="#" onclick="<%= hide.join %><%= show %>; return false;"><%= name %></a> <%= '|' unless names.last == name %>
|
||||
<% end %>
|
||||
|
||||
<% traces.each do |name, trace| %>
|
||||
<div id="<%= name.gsub /\s/, '-' %>" style="display: <%= name == "Application Trace" ? 'block' : 'none' %>;">
|
||||
<div id="<%= name.gsub(/\s/, '-') %>" style="display: <%= (name == "Application Trace") ? 'block' : 'none' %>;">
|
||||
<pre><code><%=h trace.join "\n" %></code></pre>
|
||||
</div>
|
||||
<% end %>
|
||||
|
|
|
@ -313,7 +313,7 @@ module ActionDispatch
|
|||
# Yes plz - JP
|
||||
included do
|
||||
routes.install_helpers(self)
|
||||
singleton_class.send(:define_method, :_routes) { routes }
|
||||
singleton_class.send(:redefine_method, :_routes) { routes }
|
||||
end
|
||||
|
||||
define_method(:_routes) { @_routes || routes }
|
||||
|
|
|
@ -136,6 +136,7 @@ module ActionDispatch
|
|||
|
||||
protected
|
||||
def _with_routes(routes)
|
||||
@_routes ||= nil
|
||||
old_routes, @_routes = @_routes, routes
|
||||
yield
|
||||
ensure
|
||||
|
|
|
@ -67,7 +67,7 @@ module ActionDispatch
|
|||
arg = args.shift
|
||||
elsif arg == nil
|
||||
raise ArgumentError, "First argument is either selector or element to select, but nil found. Perhaps you called assert_select with an element that does not exist?"
|
||||
elsif @selected
|
||||
elsif defined?(@selected) && @selected
|
||||
matches = []
|
||||
|
||||
@selected.each do |selected|
|
||||
|
@ -187,6 +187,7 @@ module ActionDispatch
|
|||
def assert_select(*args, &block)
|
||||
# Start with optional element followed by mandatory selector.
|
||||
arg = args.shift
|
||||
@selected ||= nil
|
||||
|
||||
if arg.is_a?(HTML::Node)
|
||||
# First argument is a node (tag or text, but also HTML root),
|
||||
|
@ -442,6 +443,7 @@ module ActionDispatch
|
|||
assert_block("") { true } # to count the assertion
|
||||
if block_given? && !([:remove, :show, :hide, :toggle].include? rjs_type)
|
||||
begin
|
||||
@selected ||= nil
|
||||
in_scope, @selected = @selected, matches
|
||||
yield matches
|
||||
ensure
|
||||
|
|
|
@ -308,7 +308,7 @@ module ActionDispatch
|
|||
include ActionDispatch::Assertions
|
||||
|
||||
def app
|
||||
@app
|
||||
@app ||= nil
|
||||
end
|
||||
|
||||
# Reset the current session. This is useful for testing multiple sessions
|
||||
|
|
|
@ -991,7 +991,11 @@ module ActionView
|
|||
end
|
||||
|
||||
def object
|
||||
@object || @template_object.instance_variable_get("@#{@object_name}")
|
||||
if @object
|
||||
@object
|
||||
elsif @template_object.instance_variable_defined?("@#{@object_name}")
|
||||
@template_object.instance_variable_get("@#{@object_name}")
|
||||
end
|
||||
rescue NameError
|
||||
# As @object_name may contain the nested syntax (item[subobject]) we
|
||||
# need to fallback to nil.
|
||||
|
|
|
@ -52,6 +52,7 @@ module ActionView
|
|||
|
||||
def initialize(template, assigns, original_exception)
|
||||
@template, @assigns, @original_exception = template, assigns.dup, original_exception
|
||||
@sub_templates = nil
|
||||
@backtrace = original_exception.backtrace
|
||||
end
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ module ActionView
|
|||
# = Action View Resolver
|
||||
class Resolver
|
||||
def initialize
|
||||
@path = nil
|
||||
@cached = Hash.new { |h1,k1| h1[k1] =
|
||||
Hash.new { |h2,k2| h2[k2] = Hash.new { |h3, k3| h3[k3] = {} } } }
|
||||
end
|
||||
|
|
|
@ -137,8 +137,10 @@ module ActionView
|
|||
def make_test_case_available_to_view!
|
||||
test_case_instance = self
|
||||
_helpers.module_eval do
|
||||
define_method(:_test_case) { test_case_instance }
|
||||
private :_test_case
|
||||
unless private_method_defined?(:_test_case)
|
||||
define_method(:_test_case) { test_case_instance }
|
||||
private :_test_case
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -47,6 +47,7 @@ module AbstractController
|
|||
end
|
||||
|
||||
def index
|
||||
@text ||= nil
|
||||
self.response_body = @text.to_s
|
||||
end
|
||||
end
|
||||
|
@ -152,7 +153,7 @@ module AbstractController
|
|||
|
||||
test "when :except is specified, an after filter is not triggered on that action" do
|
||||
result = @controller.process(:index)
|
||||
assert_nil @controller.instance_variable_get("@authenticated")
|
||||
assert !@controller.instance_variable_defined?("@authenticated")
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -196,7 +197,7 @@ module AbstractController
|
|||
|
||||
test "when :except is specified with an array, an after filter is not triggered on that action" do
|
||||
result = @controller.process(:index)
|
||||
assert_nil @controller.instance_variable_get("@authenticated")
|
||||
assert !@controller.instance_variable_defined?("@authenticated")
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -204,6 +205,7 @@ module AbstractController
|
|||
before_filter :first, :only => :index
|
||||
|
||||
def not_index
|
||||
@text ||= nil
|
||||
self.response_body = @text.to_s
|
||||
end
|
||||
end
|
||||
|
|
|
@ -93,38 +93,6 @@ class RenderPartialWithRecordIdentificationTest < ActiveRecordTestCase
|
|||
end
|
||||
end
|
||||
|
||||
class RenderPartialWithRecordIdentificationController < ActionController::Base
|
||||
def render_with_has_many_and_belongs_to_association
|
||||
@developer = Developer.find(1)
|
||||
render :partial => @developer.projects
|
||||
end
|
||||
|
||||
def render_with_has_many_association
|
||||
@topic = Topic.find(1)
|
||||
render :partial => @topic.replies
|
||||
end
|
||||
|
||||
def render_with_has_many_through_association
|
||||
@developer = Developer.find(:first)
|
||||
render :partial => @developer.topics
|
||||
end
|
||||
|
||||
def render_with_belongs_to_association
|
||||
@reply = Reply.find(1)
|
||||
render :partial => @reply.topic
|
||||
end
|
||||
|
||||
def render_with_record
|
||||
@developer = Developer.find(:first)
|
||||
render :partial => @developer
|
||||
end
|
||||
|
||||
def render_with_record_collection
|
||||
@developers = Developer.find(:all)
|
||||
render :partial => @developers
|
||||
end
|
||||
end
|
||||
|
||||
class Game < Struct.new(:name, :id)
|
||||
extend ActiveModel::Naming
|
||||
include ActiveModel::Conversion
|
||||
|
|
|
@ -234,13 +234,13 @@ class ActionPackAssertionsControllerTest < ActionController::TestCase
|
|||
|
||||
def test_template_objects_exist
|
||||
process :assign_this
|
||||
assert !@controller.instance_variable_get(:"@hi")
|
||||
assert !@controller.instance_variable_defined?(:"@hi")
|
||||
assert @controller.instance_variable_get(:"@howdy")
|
||||
end
|
||||
|
||||
def test_template_objects_missing
|
||||
process :nothing
|
||||
assert_nil @controller.instance_variable_get(:@howdy)
|
||||
assert !@controller.instance_variable_defined?(:@howdy)
|
||||
end
|
||||
|
||||
def test_empty_flash
|
||||
|
|
|
@ -185,6 +185,7 @@ class ActionCachingTestController < CachingController
|
|||
|
||||
def with_layout
|
||||
@cache_this = MockTime.now.to_f.to_s
|
||||
@title = nil
|
||||
render :text => @cache_this, :layout => true
|
||||
end
|
||||
|
||||
|
|
|
@ -6,18 +6,22 @@ class CaptureController < ActionController::Base
|
|||
def self.controller_path; "test"; end
|
||||
|
||||
def content_for
|
||||
@title = nil
|
||||
render :layout => "talk_from_action"
|
||||
end
|
||||
|
||||
def content_for_with_parameter
|
||||
@title = nil
|
||||
render :layout => "talk_from_action"
|
||||
end
|
||||
|
||||
def content_for_concatenated
|
||||
@title = nil
|
||||
render :layout => "talk_from_action"
|
||||
end
|
||||
|
||||
def non_erb_block_content_for
|
||||
@title = nil
|
||||
render :layout => "talk_from_action"
|
||||
end
|
||||
|
||||
|
|
|
@ -669,7 +669,7 @@ class FilterTest < ActionController::TestCase
|
|||
assert_equal %w( ensure_login find_user ), assigns["ran_filter"]
|
||||
|
||||
test_process(ConditionalSkippingController, "login")
|
||||
assert_nil @controller.instance_variable_get("@ran_after_filter")
|
||||
assert !@controller.instance_variable_defined?("@ran_after_filter")
|
||||
test_process(ConditionalSkippingController, "change_password")
|
||||
assert_equal %w( clean_up ), @controller.instance_variable_get("@ran_after_filter")
|
||||
end
|
||||
|
|
|
@ -120,6 +120,7 @@ class RenderOtherTest < ActionController::TestCase
|
|||
|
||||
private
|
||||
def default_render
|
||||
@alternate_default_render ||= nil
|
||||
if @alternate_default_render
|
||||
@alternate_default_render.call
|
||||
else
|
||||
|
|
|
@ -276,6 +276,7 @@ class TestController < ActionController::Base
|
|||
|
||||
# :ported:
|
||||
def builder_layout_test
|
||||
@name = nil
|
||||
render :action => "hello", :layout => "layouts/builder"
|
||||
end
|
||||
|
||||
|
@ -327,6 +328,7 @@ class TestController < ActionController::Base
|
|||
end
|
||||
|
||||
def default_render
|
||||
@alternate_default_render ||= nil
|
||||
if @alternate_default_render
|
||||
@alternate_default_render.call
|
||||
else
|
||||
|
@ -339,14 +341,17 @@ class TestController < ActionController::Base
|
|||
end
|
||||
|
||||
def layout_test_with_different_layout
|
||||
@variable_for_layout = nil
|
||||
render :action => "hello_world", :layout => "standard"
|
||||
end
|
||||
|
||||
def layout_test_with_different_layout_and_string_action
|
||||
@variable_for_layout = nil
|
||||
render "hello_world", :layout => "standard"
|
||||
end
|
||||
|
||||
def layout_test_with_different_layout_and_symbol_action
|
||||
@variable_for_layout = nil
|
||||
render :hello_world, :layout => "standard"
|
||||
end
|
||||
|
||||
|
@ -355,6 +360,7 @@ class TestController < ActionController::Base
|
|||
end
|
||||
|
||||
def layout_overriding_layout
|
||||
@variable_for_layout = nil
|
||||
render :action => "hello_world", :layout => "standard"
|
||||
end
|
||||
|
||||
|
@ -643,6 +649,7 @@ class TestController < ActionController::Base
|
|||
private
|
||||
|
||||
def determine_layout
|
||||
@variable_for_layout ||= nil
|
||||
case action_name
|
||||
when "hello_world", "layout_test", "rendering_without_layout",
|
||||
"rendering_nothing_on_layout", "render_text_hello_world",
|
||||
|
@ -1020,7 +1027,7 @@ class RenderTest < ActionController::TestCase
|
|||
assert_equal " ", @response.body
|
||||
end
|
||||
|
||||
def test_render_to_string
|
||||
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
|
||||
|
|
|
@ -3,10 +3,12 @@ require 'abstract_unit'
|
|||
module ActionDispatch
|
||||
class ShowExceptions
|
||||
private
|
||||
remove_method :public_path
|
||||
def public_path
|
||||
"#{FIXTURE_LOAD_PATH}/public"
|
||||
end
|
||||
|
||||
remove_method :logger
|
||||
# Silence logger
|
||||
def logger
|
||||
nil
|
||||
|
|
|
@ -24,6 +24,7 @@ class WebServiceTest < ActionDispatch::IntegrationTest
|
|||
|
||||
def setup
|
||||
@controller = TestController.new
|
||||
@integration_session = nil
|
||||
end
|
||||
|
||||
def test_check_parameters
|
||||
|
|
|
@ -41,7 +41,6 @@ class MimeTypeTest < ActiveSupport::TestCase
|
|||
begin
|
||||
Mime::Type.register("image/gif", :gif)
|
||||
assert_nothing_raised do
|
||||
Mime::GIF
|
||||
assert_equal Mime::GIF, Mime::SET.last
|
||||
end
|
||||
ensure
|
||||
|
|
|
@ -68,7 +68,7 @@ class MultipartParamsParsingTest < ActionDispatch::IntegrationTest
|
|||
|
||||
assert_equal 'file.txt', file.original_filename
|
||||
assert_equal "text/plain", file.content_type
|
||||
assert ('a' * 20480) == file.read
|
||||
assert_equal(('a' * 20480), file.read)
|
||||
end
|
||||
|
||||
test "parses binary file" do
|
||||
|
|
|
@ -18,6 +18,7 @@ class XmlParamsParsingTest < ActionDispatch::IntegrationTest
|
|||
|
||||
test "parses a strict rack.input" do
|
||||
class Linted
|
||||
undef call if method_defined?(:call)
|
||||
def call(env)
|
||||
bar = env['action_dispatch.request.request_parameters']['foo']
|
||||
result = "<ok>#{bar}</ok>"
|
||||
|
|
|
@ -474,6 +474,7 @@ protected
|
|||
|
||||
def stub_request(env = {})
|
||||
ip_spoofing_check = env.key?(:ip_spoofing_check) ? env.delete(:ip_spoofing_check) : true
|
||||
@trusted_proxies ||= nil
|
||||
ip_app = ActionDispatch::RemoteIp.new(Proc.new { }, ip_spoofing_check, @trusted_proxies)
|
||||
tld_length = env.key?(:tld_length) ? env.delete(:tld_length) : 1
|
||||
ip_app.call(env)
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
module FooHelper
|
||||
def baz() end
|
||||
redefine_method(:baz) {}
|
||||
end
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
xml.html do
|
||||
xml.p "Hello"
|
||||
end
|
||||
"String return value"
|
||||
|
|
|
@ -1497,26 +1497,6 @@ class DateHelperTest < ActionView::TestCase
|
|||
assert_dom_equal expected, date_select("post", "written_on", :order=>[:year, :month], :include_blank=>true)
|
||||
end
|
||||
|
||||
def test_date_select_with_nil_and_blank_and_order
|
||||
@post = Post.new
|
||||
|
||||
start_year = Time.now.year-5
|
||||
end_year = Time.now.year+5
|
||||
|
||||
expected = '<input name="post[written_on(3i)]" type="hidden" id="post_written_on_3i"/>' + "\n"
|
||||
expected << %{<select id="post_written_on_1i" name="post[written_on(1i)]">\n}
|
||||
expected << "<option value=\"\"></option>\n"
|
||||
start_year.upto(end_year) { |i| expected << %(<option value="#{i}">#{i}</option>\n) }
|
||||
expected << "</select>\n"
|
||||
|
||||
expected << %{<select id="post_written_on_2i" name="post[written_on(2i)]">\n}
|
||||
expected << "<option value=\"\"></option>\n"
|
||||
1.upto(12) { |i| expected << %(<option value="#{i}">#{Date::MONTHNAMES[i]}</option>\n) }
|
||||
expected << "</select>\n"
|
||||
|
||||
assert_dom_equal expected, date_select("post", "written_on", :order=>[:year, :month], :include_blank=>true)
|
||||
end
|
||||
|
||||
def test_date_select_cant_override_discard_hour
|
||||
@post = Post.new
|
||||
@post.written_on = Date.new(2004, 6, 15)
|
||||
|
|
|
@ -106,7 +106,6 @@ class FormHelperTest < ActionView::TestCase
|
|||
if object.is_a?(Hash) && object[:use_route].blank? && object[:controller].blank?
|
||||
object.merge!(:controller => "main", :action => "index")
|
||||
end
|
||||
object
|
||||
super
|
||||
end
|
||||
|
||||
|
@ -269,7 +268,7 @@ class FormHelperTest < ActionView::TestCase
|
|||
assert_dom_equal expected, hidden_field("post", "title", :value => nil)
|
||||
end
|
||||
|
||||
def test_text_field_with_options
|
||||
def test_hidden_field_with_options
|
||||
assert_dom_equal '<input id="post_title" name="post[title]" type="hidden" value="Something Else" />',
|
||||
hidden_field("post", "title", :value => "Something Else")
|
||||
end
|
||||
|
|
|
@ -55,7 +55,7 @@ class TagNodeTest < Test::Unit::TestCase
|
|||
|
||||
def test_to_s
|
||||
node = tag("<a b=c d='f' g=\"h 'i'\" />")
|
||||
assert_equal %(<a b='c' d='f' g='h \\'i\\'' />), node.to_s
|
||||
assert_equal %(<a b="c" d="f" g="h 'i'" />), node.to_s
|
||||
end
|
||||
|
||||
def test_tag
|
||||
|
@ -221,7 +221,7 @@ class TagNodeTest < Test::Unit::TestCase
|
|||
assert !m.match(:after => {:tag => "span", :attributes => {:k => true}})
|
||||
end
|
||||
|
||||
def test_to_s
|
||||
def test_tag_to_s
|
||||
t = tag("<b x='foo'>")
|
||||
tag("hello", t)
|
||||
tag("<hr />", t)
|
||||
|
|
|
@ -22,8 +22,6 @@ class JavaScriptHelperTest < ActionView::TestCase
|
|||
ActiveSupport.escape_html_entities_in_json = false
|
||||
end
|
||||
|
||||
def _evaluate_assigns_and_ivars() end
|
||||
|
||||
def test_escape_javascript
|
||||
assert_equal '', escape_javascript(nil)
|
||||
assert_equal %(This \\"thing\\" is really\\n netos\\'), escape_javascript(%(This "thing" is really\n netos'))
|
||||
|
|
|
@ -41,7 +41,7 @@ class NumberHelperTest < ActionView::TestCase
|
|||
:custom_units_for_number_to_human => {:mili => "mm", :centi => "cm", :deci => "dm", :unit => "m", :ten => "dam", :hundred => "hm", :thousand => "km"}
|
||||
end
|
||||
|
||||
def test_number_to_currency
|
||||
def test_number_to_i18n_currency
|
||||
assert_equal("&$ - 10.00", number_to_currency(10, :locale => 'ts'))
|
||||
end
|
||||
|
||||
|
@ -51,7 +51,7 @@ class NumberHelperTest < ActionView::TestCase
|
|||
end
|
||||
end
|
||||
|
||||
def test_number_with_precision
|
||||
def test_number_with_i18n_precision
|
||||
#Delimiter was set to ""
|
||||
assert_equal("10000", number_with_precision(10000, :locale => 'ts'))
|
||||
|
||||
|
@ -60,12 +60,12 @@ class NumberHelperTest < ActionView::TestCase
|
|||
|
||||
end
|
||||
|
||||
def test_number_with_delimiter
|
||||
def test_number_with_i18n_delimiter
|
||||
#Delimiter "," and separator "."
|
||||
assert_equal("1,000,000.234", number_with_delimiter(1000000.234, :locale => 'ts'))
|
||||
end
|
||||
|
||||
def test_number_to_percentage
|
||||
def test_number_to_i18n_percentage
|
||||
# to see if strip_insignificant_zeros is true
|
||||
assert_equal("1%", number_to_percentage(1, :locale => 'ts'))
|
||||
# precision is 2, significant should be inherited
|
||||
|
@ -74,7 +74,7 @@ class NumberHelperTest < ActionView::TestCase
|
|||
assert_equal("12434%", number_to_percentage(12434, :locale => 'ts'))
|
||||
end
|
||||
|
||||
def test_number_to_human_size
|
||||
def test_number_to_i18n_human_size
|
||||
#b for bytes and k for kbytes
|
||||
assert_equal("2 k", number_to_human_size(2048, :locale => 'ts'))
|
||||
assert_equal("42 b", number_to_human_size(42, :locale => 'ts'))
|
||||
|
|
|
@ -71,7 +71,7 @@ class PrototypeHelperBaseTest < ActionView::TestCase
|
|||
end
|
||||
|
||||
def create_generator
|
||||
block = Proc.new { |*args| yield *args if block_given? }
|
||||
block = Proc.new { |*args| yield(*args) if block_given? }
|
||||
JavaScriptGenerator.new self, &block
|
||||
end
|
||||
end
|
||||
|
|
|
@ -319,10 +319,11 @@ class LazyViewRenderTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
def with_external_encoding(encoding)
|
||||
old, Encoding.default_external = Encoding.default_external, encoding
|
||||
old = Encoding.default_external
|
||||
silence_warnings { Encoding.default_external = encoding }
|
||||
yield
|
||||
ensure
|
||||
Encoding.default_external = old
|
||||
silence_warnings { Encoding.default_external = old }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -103,7 +103,7 @@ class TagHelperTest < ActionView::TestCase
|
|||
|
||||
def test_skip_invalid_escaped_attributes
|
||||
['&1;', 'dfa3;', '& #123;'].each do |escaped|
|
||||
assert_equal %(<a href="#{escaped.gsub /&/, '&'}" />), tag('a', :href => escaped)
|
||||
assert_equal %(<a href="#{escaped.gsub(/&/, '&')}" />), tag('a', :href => escaped)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ class TestERBTemplate < ActiveSupport::TestCase
|
|||
class Context
|
||||
def initialize
|
||||
@output_buffer = "original"
|
||||
@_virtual_path = nil
|
||||
end
|
||||
|
||||
def hello
|
||||
|
@ -82,12 +83,11 @@ class TestERBTemplate < ActiveSupport::TestCase
|
|||
# is set to something other than UTF-8, we don't
|
||||
# get any errors and get back a UTF-8 String.
|
||||
def test_default_external_works
|
||||
Encoding.default_external = "ISO-8859-1"
|
||||
@template = new_template("hello \xFCmlat")
|
||||
assert_equal Encoding::UTF_8, render.encoding
|
||||
assert_equal "hello \u{fc}mlat", render
|
||||
ensure
|
||||
Encoding.default_external = "UTF-8"
|
||||
with_external_encoding "ISO-8859-1" do
|
||||
@template = new_template("hello \xFCmlat")
|
||||
assert_equal Encoding::UTF_8, render.encoding
|
||||
assert_equal "hello \u{fc}mlat", render
|
||||
end
|
||||
end
|
||||
|
||||
def test_encoding_can_be_specified_with_magic_comment
|
||||
|
@ -123,10 +123,11 @@ class TestERBTemplate < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
def with_external_encoding(encoding)
|
||||
old, Encoding.default_external = Encoding.default_external, encoding
|
||||
old = Encoding.default_external
|
||||
silence_warnings { Encoding.default_external = encoding }
|
||||
yield
|
||||
ensure
|
||||
Encoding.default_external = old
|
||||
silence_warnings { Encoding.default_external = old }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue