aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@gmail.com>2011-09-08 20:49:08 +0200
committerJosé Valim <jose.valim@gmail.com>2011-09-08 20:54:30 +0200
commit6b010c2690de9ffce4878a9471c8adb33d4a21a1 (patch)
treeb6f6053d93b64672334701a6ff3d5aae5d41dfa8 /activesupport/test
parent0d254915819a9e5711895e410e1597177216c903 (diff)
downloadrails-6b010c2690de9ffce4878a9471c8adb33d4a21a1.tar.gz
rails-6b010c2690de9ffce4878a9471c8adb33d4a21a1.tar.bz2
rails-6b010c2690de9ffce4878a9471c8adb33d4a21a1.zip
Revert removing gsub and sub from safe buffer.
Diffstat (limited to 'activesupport/test')
-rw-r--r--activesupport/test/inflector_test.rb22
-rw-r--r--activesupport/test/inflector_test_cases.rb7
-rw-r--r--activesupport/test/safe_buffer_test.rb41
3 files changed, 34 insertions, 36 deletions
diff --git a/activesupport/test/inflector_test.rb b/activesupport/test/inflector_test.rb
index 6484811d34..b9e299af75 100644
--- a/activesupport/test/inflector_test.rb
+++ b/activesupport/test/inflector_test.rb
@@ -10,7 +10,7 @@ module Ace
end
end
-class InflectorTest < ActiveSupport::TestCase
+class InflectorTest < Test::Unit::TestCase
include InflectorTestCases
def test_pluralize_plurals
@@ -248,6 +248,12 @@ class InflectorTest < ActiveSupport::TestCase
end
end
+ def test_classify_with_symbol
+ assert_nothing_raised do
+ assert_equal 'FooBar', ActiveSupport::Inflector.classify(:foo_bars)
+ end
+ end
+
def test_classify_with_leading_schema_name
assert_equal 'FooBar', ActiveSupport::Inflector.classify('schema.foo_bar')
end
@@ -313,6 +319,12 @@ class InflectorTest < ActiveSupport::TestCase
end
end
+ def test_symbol_to_lower_camel
+ SymbolToLowerCamel.each do |symbol, lower_camel|
+ assert_equal(lower_camel, ActiveSupport::Inflector.camelize(symbol, false))
+ end
+ end
+
%w{plurals singulars uncountables humans}.each do |inflection_type|
class_eval <<-RUBY, __FILE__, __LINE__ + 1
def test_clear_#{inflection_type}
@@ -368,14 +380,6 @@ class InflectorTest < ActiveSupport::TestCase
ActiveSupport::Inflector.inflections.instance_variable_set :@humans, cached_values[3]
end
- [:pluralize, :singularize, :camelize, :underscore, :humanize, :titleize, :tableize, :classify, :dasherize, :demodulize].each do |method|
- test "should deprecate symbols on #{method}" do
- assert_deprecated(/Using symbols in inflections is deprecated/) do
- ActiveSupport::Inflector.send(method, :foo)
- end
- end
- end
-
Irregularities.each do |irregularity|
singular, plural = *irregularity
ActiveSupport::Inflector.inflections do |inflect|
diff --git a/activesupport/test/inflector_test_cases.rb b/activesupport/test/inflector_test_cases.rb
index 62e0ccd355..0cb1f70657 100644
--- a/activesupport/test/inflector_test_cases.rb
+++ b/activesupport/test/inflector_test_cases.rb
@@ -120,6 +120,13 @@ module InflectorTestCases
"area51_controller" => "area51Controller"
}
+ SymbolToLowerCamel = {
+ :product => 'product',
+ :special_guest => 'specialGuest',
+ :application_controller => 'applicationController',
+ :area51_controller => 'area51Controller'
+ }
+
CamelToUnderscoreWithoutReverse = {
"HTMLTidy" => "html_tidy",
"HTMLTidyGenerator" => "html_tidy_generator",
diff --git a/activesupport/test/safe_buffer_test.rb b/activesupport/test/safe_buffer_test.rb
index f2cd67749a..8f77999d25 100644
--- a/activesupport/test/safe_buffer_test.rb
+++ b/activesupport/test/safe_buffer_test.rb
@@ -67,41 +67,42 @@ class SafeBufferTest < ActiveSupport::TestCase
assert_equal "my_test", str
end
- test "Should not return safe buffer from capitalize" do
- altered_buffer = "asdf".html_safe.capitalize
- assert_equal 'Asdf', altered_buffer
+ test "Should not return safe buffer from gsub" do
+ altered_buffer = @buffer.gsub('', 'asdf')
+ assert_equal 'asdf', altered_buffer
assert !altered_buffer.html_safe?
end
test "Should not return safe buffer from gsub!" do
- string = "asdf"
- string.capitalize!
- assert_equal 'Asdf', string
- assert !string.html_safe?
+ @buffer.gsub!('', 'asdf')
+ assert_equal 'asdf', @buffer
+ assert !@buffer.html_safe?
end
test "Should escape dirty buffers on add" do
clean = "hello".html_safe
- assert_equal "hello&lt;&gt;", clean + '<>'
+ @buffer.gsub!('', '<>')
+ assert_equal "hello&lt;&gt;", clean + @buffer
end
test "Should concat as a normal string when dirty" do
clean = "hello".html_safe
- assert_equal "<>hello", '<>' + clean
+ @buffer.gsub!('', '<>')
+ assert_equal "<>hello", @buffer + clean
end
test "Should preserve dirty? status on copy" do
- dirty = "<>"
- assert !dirty.dup.html_safe?
+ @buffer.gsub!('', '<>')
+ assert !@buffer.dup.html_safe?
end
test "Should raise an error when safe_concat is called on dirty buffers" do
- @buffer.capitalize!
+ @buffer.gsub!('', '<>')
assert_raise ActiveSupport::SafeBuffer::SafeConcatError do
@buffer.safe_concat "BUSTED"
end
end
-
+
test "should not fail if the returned object is not a string" do
assert_kind_of NilClass, @buffer.slice("chipchop")
end
@@ -111,18 +112,4 @@ class SafeBufferTest < ActiveSupport::TestCase
assert_not_nil dirty
assert !dirty
end
-
- ["gsub", "sub"].each do |unavailable_method|
- test "should raise on #{unavailable_method}" do
- assert_raise NoMethodError, "#{unavailable_method} cannot be used with a safe string. You should use object.to_str.#{unavailable_method}" do
- @buffer.send(unavailable_method, '', '<>')
- end
- end
-
- test "should raise on #{unavailable_method}!" do
- assert_raise NoMethodError, "#{unavailable_method}! cannot be used with a safe string. You should use object.to_str.#{unavailable_method}!" do
- @buffer.send("#{unavailable_method}!", '', '<>')
- end
- end
- end
end