Skip to content
This repository
Browse code

Deprecate ActiveRecord::Base#class_name [#379 state:committed]

Signed-off-by: José Valim <jose.valim@gmail.com>
  • Loading branch information...
commit ac42e6951f0feb1a9890a3bbf5ebad87ebec08cc 1 parent d0d10f5
David Trasbo authored June 29, 2010 josevalim committed June 29, 2010
2  activerecord/lib/active_record/base.rb
@@ -1285,6 +1285,8 @@ def set_sequence_name(value = nil, &block)
1285 1285
 
1286 1286
       # Turns the +table_name+ back into a class name following the reverse rules of +table_name+.
1287 1287
       def class_name(table_name = table_name) # :nodoc:
  1288
+        ActiveSupport::Deprecation.warn("ActiveRecord::Base#class_name is deprecated and will be removed in Rails 2.3.9.", caller)
  1289
+
1288 1290
         # remove any prefix and/or suffix from the table name
1289 1291
         class_name = table_name[table_name_prefix.length..-(table_name_suffix.length + 1)].camelize
1290 1292
         class_name = class_name.singularize if pluralize_table_names
34  activerecord/test/cases/base_test.rb
@@ -700,22 +700,24 @@ def test_attribute_keys_on_new_instance
700 700
   end
701 701
 
702 702
   def test_class_name
703  
-    assert_equal "Firm", ActiveRecord::Base.class_name("firms")
704  
-    assert_equal "Category", ActiveRecord::Base.class_name("categories")
705  
-    assert_equal "AccountHolder", ActiveRecord::Base.class_name("account_holder")
706  
-
707  
-    ActiveRecord::Base.pluralize_table_names = false
708  
-    assert_equal "Firms", ActiveRecord::Base.class_name( "firms" )
709  
-    ActiveRecord::Base.pluralize_table_names = true
710  
-
711  
-    ActiveRecord::Base.table_name_prefix = "test_"
712  
-    assert_equal "Firm", ActiveRecord::Base.class_name( "test_firms" )
713  
-    ActiveRecord::Base.table_name_suffix = "_tests"
714  
-    assert_equal "Firm", ActiveRecord::Base.class_name( "test_firms_tests" )
715  
-    ActiveRecord::Base.table_name_prefix = ""
716  
-    assert_equal "Firm", ActiveRecord::Base.class_name( "firms_tests" )
717  
-    ActiveRecord::Base.table_name_suffix = ""
718  
-    assert_equal "Firm", ActiveRecord::Base.class_name( "firms" )
  703
+    ActiveSupport::Deprecation.silence do
  704
+      assert_equal "Firm", ActiveRecord::Base.class_name("firms")
  705
+      assert_equal "Category", ActiveRecord::Base.class_name("categories")
  706
+      assert_equal "AccountHolder", ActiveRecord::Base.class_name("account_holder")
  707
+
  708
+      ActiveRecord::Base.pluralize_table_names = false
  709
+      assert_equal "Firms", ActiveRecord::Base.class_name( "firms" )
  710
+      ActiveRecord::Base.pluralize_table_names = true
  711
+
  712
+      ActiveRecord::Base.table_name_prefix = "test_"
  713
+      assert_equal "Firm", ActiveRecord::Base.class_name( "test_firms" )
  714
+      ActiveRecord::Base.table_name_suffix = "_tests"
  715
+      assert_equal "Firm", ActiveRecord::Base.class_name( "test_firms_tests" )
  716
+      ActiveRecord::Base.table_name_prefix = ""
  717
+      assert_equal "Firm", ActiveRecord::Base.class_name( "firms_tests" )
  718
+      ActiveRecord::Base.table_name_suffix = ""
  719
+      assert_equal "Firm", ActiveRecord::Base.class_name( "firms" )
  720
+    end
719 721
   end
720 722
 
721 723
   def test_null_fields

0 notes on commit ac42e69

Please sign in to comment.
Something went wrong with that request. Please try again.