Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge remote branch 'miloops/warnings'

  • Loading branch information...
commit 0bbf9029e8089356aed0e3be2f859d56951a89cf 2 parents 006cef7 + 17599ab
@josevalim josevalim authored
Showing with 90 additions and 109 deletions.
  1. +1 −1  actionpack/Rakefile
  2. +1 −0  actionpack/lib/abstract_controller/layouts.rb
  3. +1 −1  actionpack/lib/abstract_controller/rendering.rb
  4. +5 −3 actionpack/lib/action_controller/test_case.rb
  5. +5 −3 actionpack/lib/action_dispatch/middleware/callbacks.rb
  6. +2 −2 actionpack/lib/action_dispatch/middleware/session/abstract_store.rb
  7. +2 −3 actionpack/lib/action_dispatch/middleware/stack.rb
  8. +1 −0  actionpack/lib/action_dispatch/middleware/static.rb
  9. +2 −2 actionpack/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb
  10. +3 −3 actionpack/lib/action_dispatch/middleware/templates/rescues/_trace.erb
  11. +1 −1  actionpack/lib/action_dispatch/routing/route_set.rb
  12. +1 −0  actionpack/lib/action_dispatch/routing/url_for.rb
  13. +3 −1 actionpack/lib/action_dispatch/testing/assertions/selector.rb
  14. +1 −1  actionpack/lib/action_dispatch/testing/integration.rb
  15. +5 −1 actionpack/lib/action_view/helpers/form_helper.rb
  16. +1 −0  actionpack/lib/action_view/template/error.rb
  17. +1 −0  actionpack/lib/action_view/template/resolver.rb
  18. +4 −2 actionpack/lib/action_view/test_case.rb
  19. +4 −2 actionpack/test/abstract/callbacks_test.rb
  20. +0 −32 actionpack/test/activerecord/render_partial_with_record_identification_test.rb
  21. +2 −2 actionpack/test/controller/action_pack_assertions_test.rb
  22. +1 −0  actionpack/test/controller/caching_test.rb
  23. +4 −0 actionpack/test/controller/capture_test.rb
  24. +1 −1  actionpack/test/controller/filters_test.rb
  25. +1 −0  actionpack/test/controller/render_other_test.rb
  26. +8 −1 actionpack/test/controller/render_test.rb
  27. +2 −0  actionpack/test/controller/rescue_test.rb
  28. +1 −0  actionpack/test/controller/webservice_test.rb
  29. +0 −1  actionpack/test/dispatch/mime_type_test.rb
  30. +1 −1  actionpack/test/dispatch/request/multipart_params_parsing_test.rb
  31. +1 −0  actionpack/test/dispatch/request/xml_params_parsing_test.rb
  32. +1 −0  actionpack/test/dispatch/request_test.rb
  33. +1 −1  actionpack/test/fixtures/alternate_helpers/foo_helper.rb
  34. +0 −1  actionpack/test/fixtures/test/hello_world_from_rxml.builder
  35. +0 −20 actionpack/test/template/date_helper_test.rb
  36. +1 −2  actionpack/test/template/form_helper_test.rb
  37. +2 −2 actionpack/test/template/html-scanner/tag_node_test.rb
  38. +0 −2  actionpack/test/template/javascript_helper_test.rb
  39. +5 −5 actionpack/test/template/number_helper_i18n_test.rb
  40. +1 −1  actionpack/test/template/prototype_helper_test.rb
  41. +3 −2 actionpack/test/template/render_test.rb
  42. +1 −1  actionpack/test/template/tag_helper_test.rb
  43. +9 −8 actionpack/test/template/template_test.rb
View
2  actionpack/Rakefile
@@ -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
View
1  actionpack/lib/abstract_controller/layouts.rb
@@ -345,6 +345,7 @@ def _layout_for_option(name)
# * <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,
View
2  actionpack/lib/abstract_controller/rendering.rb
@@ -66,7 +66,7 @@ def view_context_class
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(*)
View
8 actionpack/lib/action_controller/test_case.rb
@@ -462,9 +462,11 @@ def build_request_uri(action, parameters)
# 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
View
8 actionpack/lib/action_dispatch/middleware/callbacks.rb
@@ -19,9 +19,11 @@ class Callbacks
# 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
View
4 actionpack/lib/action_dispatch/middleware/session/abstract_store.rb
@@ -102,8 +102,8 @@ def loaded?
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
View
5 actionpack/lib/action_dispatch/middleware/stack.rb
@@ -41,9 +41,8 @@ def normalize(object)
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)
View
1  actionpack/lib/action_dispatch/middleware/static.rb
@@ -7,6 +7,7 @@ def initialize(at, root)
@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)
View
4 actionpack/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb
@@ -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>
View
6 actionpack/lib/action_dispatch/middleware/templates/rescues/_trace.erb
@@ -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 %>
View
2  actionpack/lib/action_dispatch/routing/route_set.rb
@@ -313,7 +313,7 @@ class << self
# 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 }
View
1  actionpack/lib/action_dispatch/routing/url_for.rb
@@ -136,6 +136,7 @@ def url_for(options = nil)
protected
def _with_routes(routes)
+ @_routes ||= nil
old_routes, @_routes = @_routes, routes
yield
ensure
View
4 actionpack/lib/action_dispatch/testing/assertions/selector.rb
@@ -67,7 +67,7 @@ def css_select(*args)
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 @@ def css_select(*args)
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 @@ def assert_select_rjs(*args, &block)
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
View
2  actionpack/lib/action_dispatch/testing/integration.rb
@@ -308,7 +308,7 @@ module Runner
include ActionDispatch::Assertions
def app
- @app
+ @app ||= nil
end
# Reset the current session. This is useful for testing multiple sessions
View
6 actionpack/lib/action_view/helpers/form_helper.rb
@@ -991,7 +991,11 @@ def to_content_tag(tag_name, options = {})
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.
View
1  actionpack/lib/action_view/template/error.rb
@@ -52,6 +52,7 @@ class Error < ActionViewError #:nodoc:
def initialize(template, assigns, original_exception)
@template, @assigns, @original_exception = template, assigns.dup, original_exception
+ @sub_templates = nil
@backtrace = original_exception.backtrace
end
View
1  actionpack/lib/action_view/template/resolver.rb
@@ -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
View
6 actionpack/lib/action_view/test_case.rb
@@ -137,8 +137,10 @@ def protect_against_forgery?
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
View
6 actionpack/test/abstract/callbacks_test.rb
@@ -47,6 +47,7 @@ def aroundz
end
def index
+ @text ||= nil
self.response_body = @text.to_s
end
end
@@ -152,7 +153,7 @@ def setup
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 @@ def setup
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 @@ class ChangedConditions < Callback2
before_filter :first, :only => :index
def not_index
+ @text ||= nil
self.response_body = @text.to_s
end
end
View
32 actionpack/test/activerecord/render_partial_with_record_identification_test.rb
@@ -93,38 +93,6 @@ def test_rendering_partial_with_has_one_association
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
View
4 actionpack/test/controller/action_pack_assertions_test.rb
@@ -234,13 +234,13 @@ def test_assert_redirected_to_top_level_named_route_with_same_controller_name_in
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
View
1  actionpack/test/controller/caching_test.rb
@@ -185,6 +185,7 @@ def forbidden
def with_layout
@cache_this = MockTime.now.to_f.to_s
+ @title = nil
render :text => @cache_this, :layout => true
end
View
4 actionpack/test/controller/capture_test.rb
@@ -6,18 +6,22 @@ def self.controller_name; "test"; end
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
View
2  actionpack/test/controller/filters_test.rb
@@ -669,7 +669,7 @@ def test_conditional_skipping_of_filters
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
View
1  actionpack/test/controller/render_other_test.rb
@@ -120,6 +120,7 @@ def render_simon_says
private
def default_render
+ @alternate_default_render ||= nil
if @alternate_default_render
@alternate_default_render.call
else
View
9 actionpack/test/controller/render_test.rb
@@ -276,6 +276,7 @@ def layout_test
# :ported:
def builder_layout_test
+ @name = nil
render :action => "hello", :layout => "layouts/builder"
end
@@ -327,6 +328,7 @@ def render_to_string_test
end
def default_render
+ @alternate_default_render ||= nil
if @alternate_default_render
@alternate_default_render.call
else
@@ -339,14 +341,17 @@ def render_action_hello_world_as_symbol
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 @@ def rendering_without_layout
end
def layout_overriding_layout
+ @variable_for_layout = nil
render :action => "hello_world", :layout => "standard"
end
@@ -643,6 +649,7 @@ def render_with_filters
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 @@ def test_rendering_nothing_on_layout
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
View
2  actionpack/test/controller/rescue_test.rb
@@ -3,10 +3,12 @@
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
View
1  actionpack/test/controller/webservice_test.rb
@@ -24,6 +24,7 @@ def rescue_action(e) raise end
def setup
@controller = TestController.new
+ @integration_session = nil
end
def test_check_parameters
View
1  actionpack/test/dispatch/mime_type_test.rb
@@ -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
View
2  actionpack/test/dispatch/request/multipart_params_parsing_test.rb
@@ -68,7 +68,7 @@ def teardown
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
View
1  actionpack/test/dispatch/request/xml_params_parsing_test.rb
@@ -18,6 +18,7 @@ def teardown
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>"
View
1  actionpack/test/dispatch/request_test.rb
@@ -474,6 +474,7 @@ class RequestTest < ActiveSupport::TestCase
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)
View
2  actionpack/test/fixtures/alternate_helpers/foo_helper.rb
@@ -1,3 +1,3 @@
module FooHelper
- def baz() end
+ redefine_method(:baz) {}
end
View
1  actionpack/test/fixtures/test/hello_world_from_rxml.builder
@@ -1,4 +1,3 @@
xml.html do
xml.p "Hello"
end
-"String return value"
View
20 actionpack/test/template/date_helper_test.rb
@@ -1497,26 +1497,6 @@ def test_date_select_with_nil_and_blank_and_order
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)
View
3  actionpack/test/template/form_helper_test.rb
@@ -106,7 +106,6 @@ def url_for(object)
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 @@ def test_hidden_field_with_nil_value
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
View
4 actionpack/test/template/html-scanner/tag_node_test.rb
@@ -55,7 +55,7 @@ def test_attributes_with_escaped_quotes
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 @@ def test_match_sibling_after
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)
View
2  actionpack/test/template/javascript_helper_test.rb
@@ -22,8 +22,6 @@ def teardown
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'))
View
10 actionpack/test/template/number_helper_i18n_test.rb
@@ -41,7 +41,7 @@ def setup
: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 @@ def test_number_to_currency_with_clean_i18n_settings
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 @@ def test_number_with_precision
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 @@ def test_number_to_percentage
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'))
View
2  actionpack/test/template/prototype_helper_test.rb
@@ -71,7 +71,7 @@ def protect_against_forgery?
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
View
5 actionpack/test/template/render_test.rb
@@ -319,10 +319,11 @@ def test_render_utf8_template_with_partial_with_incompatible_encoding
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
View
2  actionpack/test/template/tag_helper_test.rb
@@ -103,7 +103,7 @@ def test_tag_honors_html_safe_for_param_values
def test_skip_invalid_escaped_attributes
['&1;', '&#1dfa3;', '& #123;'].each do |escaped|
- assert_equal %(<a href="#{escaped.gsub /&/, '&amp;'}" />), tag('a', :href => escaped)
+ assert_equal %(<a href="#{escaped.gsub(/&/, '&amp;')}" />), tag('a', :href => escaped)
end
end
View
17 actionpack/test/template/template_test.rb
@@ -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 @@ def test_no_magic_comment_word_with_utf_8
# 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 @@ def test_error_when_template_isnt_valid_utf8
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
Please sign in to comment.
Something went wrong with that request. Please try again.