ibm_db 2.5.9-x86-mingw32 → 2.5.10-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
@@ -21,9 +21,19 @@ require 'models/parrot'
21
21
  require 'models/person'
22
22
  require 'models/edge'
23
23
  require 'models/joke'
24
+ require 'models/bulb'
25
+ require 'models/bird'
24
26
  require 'rexml/document'
25
27
  require 'active_support/core_ext/exception'
28
+ require 'bcrypt'
26
29
 
30
+ class FirstAbstractClass < ActiveRecord::Base
31
+ self.abstract_class = true
32
+ end
33
+ class SecondAbstractClass < FirstAbstractClass
34
+ self.abstract_class = true
35
+ end
36
+ class Photo < SecondAbstractClass; end
27
37
  class Category < ActiveRecord::Base; end
28
38
  class Categorization < ActiveRecord::Base; end
29
39
  class Smarts < ActiveRecord::Base; end
@@ -53,9 +63,28 @@ class Weird < ActiveRecord::Base; end
53
63
 
54
64
  class Boolean < ActiveRecord::Base; end
55
65
 
66
+ class LintTest < ActiveRecord::TestCase
67
+ include ActiveModel::Lint::Tests
68
+
69
+ class LintModel < ActiveRecord::Base; end
70
+
71
+ def setup
72
+ @model = LintModel.new
73
+ end
74
+ end
75
+
56
76
  class BasicsTest < ActiveRecord::TestCase
57
77
  fixtures :topics, :companies, :developers, :projects, :computers, :accounts, :minimalistics, 'warehouse_things', :authors, :categorizations, :categories, :posts
58
78
 
79
+ def test_generated_methods_modules
80
+ modules = Computer.ancestors
81
+ assert modules.include?(Computer::GeneratedFeatureMethods)
82
+ assert_equal(Computer::GeneratedFeatureMethods, Computer.generated_feature_methods)
83
+ assert(modules.index(Computer.generated_attribute_methods) > modules.index(Computer.generated_feature_methods),
84
+ "generated_attribute_methods must be higher in inheritance hierarchy than generated_feature_methods")
85
+ assert_not_equal Computer.generated_feature_methods, Post.generated_feature_methods
86
+ end
87
+
59
88
  def test_column_names_are_escaped
60
89
  conn = ActiveRecord::Base.connection
61
90
  classname = conn.class.name[/[^:]*$/]
@@ -257,6 +286,41 @@ class BasicsTest < ActiveRecord::TestCase
257
286
  end
258
287
  end
259
288
 
289
+ def test_create_after_initialize_without_block
290
+ cb = CustomBulb.create(:name => 'Dude')
291
+ assert_equal('Dude', cb.name)
292
+ assert_equal(true, cb.frickinawesome)
293
+ end
294
+
295
+ def test_create_after_initialize_with_block
296
+ cb = CustomBulb.create {|c| c.name = 'Dude' }
297
+ assert_equal('Dude', cb.name)
298
+ assert_equal(true, cb.frickinawesome)
299
+ end
300
+
301
+ def test_first_or_create
302
+ parrot = Bird.first_or_create(:color => 'green', :name => 'parrot')
303
+ assert parrot.persisted?
304
+ the_same_parrot = Bird.first_or_create(:color => 'yellow', :name => 'macaw')
305
+ assert_equal parrot, the_same_parrot
306
+ end
307
+
308
+ def test_first_or_create_bang
309
+ assert_raises(ActiveRecord::RecordInvalid) { Bird.first_or_create! }
310
+ parrot = Bird.first_or_create!(:color => 'green', :name => 'parrot')
311
+ assert parrot.persisted?
312
+ the_same_parrot = Bird.first_or_create!(:color => 'yellow', :name => 'macaw')
313
+ assert_equal parrot, the_same_parrot
314
+ end
315
+
316
+ def test_first_or_initialize
317
+ parrot = Bird.first_or_initialize(:color => 'green', :name => 'parrot')
318
+ assert_kind_of Bird, parrot
319
+ assert !parrot.persisted?
320
+ assert parrot.new_record?
321
+ assert parrot.valid?
322
+ end
323
+
260
324
  def test_load
261
325
  topics = Topic.find(:all, :order => 'id')
262
326
  assert_equal(4, topics.size)
@@ -516,17 +580,12 @@ class BasicsTest < ActiveRecord::TestCase
516
580
  weird = Weird.create('a$b' => 'value')
517
581
  weird.reload
518
582
  assert_equal 'value', weird.send('a$b')
583
+ assert_equal 'value', weird.read_attribute('a$b')
519
584
 
520
585
  weird.update_column('a$b', 'value2')
521
586
  weird.reload
522
587
  assert_equal 'value2', weird.send('a$b')
523
- end
524
-
525
- def test_attributes_guard_protected_attributes_is_deprecated
526
- attributes = { "title" => "An amazing title" }
527
- post = ProtectedTitlePost.new
528
- assert_deprecated { post.send(:attributes=, attributes, false) }
529
- assert_equal "An amazing title", post.title
588
+ assert_equal 'value2', weird.read_attribute('a$b')
530
589
  end
531
590
 
532
591
  def test_multiparameter_attributes_on_date
@@ -544,7 +603,7 @@ class BasicsTest < ActiveRecord::TestCase
544
603
  topic.attributes = attributes
545
604
  # note that extra #to_date call allows test to pass for Oracle, which
546
605
  # treats dates/times the same
547
- assert_date_from_db Date.new(1, 6, 24), topic.last_read.to_date
606
+ assert_nil topic.last_read
548
607
  end
549
608
 
550
609
  def test_multiparameter_attributes_on_date_with_empty_month
@@ -553,7 +612,7 @@ class BasicsTest < ActiveRecord::TestCase
553
612
  topic.attributes = attributes
554
613
  # note that extra #to_date call allows test to pass for Oracle, which
555
614
  # treats dates/times the same
556
- assert_date_from_db Date.new(2004, 1, 24), topic.last_read.to_date
615
+ assert_nil topic.last_read
557
616
  end
558
617
 
559
618
  def test_multiparameter_attributes_on_date_with_empty_day
@@ -562,7 +621,7 @@ class BasicsTest < ActiveRecord::TestCase
562
621
  topic.attributes = attributes
563
622
  # note that extra #to_date call allows test to pass for Oracle, which
564
623
  # treats dates/times the same
565
- assert_date_from_db Date.new(2004, 6, 1), topic.last_read.to_date
624
+ assert_nil topic.last_read
566
625
  end
567
626
 
568
627
  def test_multiparameter_attributes_on_date_with_empty_day_and_year
@@ -571,7 +630,7 @@ class BasicsTest < ActiveRecord::TestCase
571
630
  topic.attributes = attributes
572
631
  # note that extra #to_date call allows test to pass for Oracle, which
573
632
  # treats dates/times the same
574
- assert_date_from_db Date.new(1, 6, 1), topic.last_read.to_date
633
+ assert_nil topic.last_read
575
634
  end
576
635
 
577
636
  def test_multiparameter_attributes_on_date_with_empty_day_and_month
@@ -580,7 +639,7 @@ class BasicsTest < ActiveRecord::TestCase
580
639
  topic.attributes = attributes
581
640
  # note that extra #to_date call allows test to pass for Oracle, which
582
641
  # treats dates/times the same
583
- assert_date_from_db Date.new(2004, 1, 1), topic.last_read.to_date
642
+ assert_nil topic.last_read
584
643
  end
585
644
 
586
645
  def test_multiparameter_attributes_on_date_with_empty_year_and_month
@@ -589,7 +648,7 @@ class BasicsTest < ActiveRecord::TestCase
589
648
  topic.attributes = attributes
590
649
  # note that extra #to_date call allows test to pass for Oracle, which
591
650
  # treats dates/times the same
592
- assert_date_from_db Date.new(1, 1, 24), topic.last_read.to_date
651
+ assert_nil topic.last_read
593
652
  end
594
653
 
595
654
  def test_multiparameter_attributes_on_date_with_all_empty
@@ -682,12 +741,7 @@ class BasicsTest < ActiveRecord::TestCase
682
741
  }
683
742
  topic = Topic.find(1)
684
743
  topic.attributes = attributes
685
- assert_equal 1, topic.written_on.year
686
- assert_equal 1, topic.written_on.month
687
- assert_equal 1, topic.written_on.day
688
- assert_equal 0, topic.written_on.hour
689
- assert_equal 12, topic.written_on.min
690
- assert_equal 2, topic.written_on.sec
744
+ assert_nil topic.written_on
691
745
  end
692
746
 
693
747
  def test_multiparameter_attributes_on_time_will_ignore_date_if_empty
@@ -697,12 +751,7 @@ class BasicsTest < ActiveRecord::TestCase
697
751
  }
698
752
  topic = Topic.find(1)
699
753
  topic.attributes = attributes
700
- assert_equal 1, topic.written_on.year
701
- assert_equal 1, topic.written_on.month
702
- assert_equal 1, topic.written_on.day
703
- assert_equal 16, topic.written_on.hour
704
- assert_equal 24, topic.written_on.min
705
- assert_equal 0, topic.written_on.sec
754
+ assert_nil topic.written_on
706
755
  end
707
756
  def test_multiparameter_attributes_on_time_with_seconds_will_ignore_date_if_empty
708
757
  attributes = {
@@ -711,12 +760,7 @@ class BasicsTest < ActiveRecord::TestCase
711
760
  }
712
761
  topic = Topic.find(1)
713
762
  topic.attributes = attributes
714
- assert_equal 1, topic.written_on.year
715
- assert_equal 1, topic.written_on.month
716
- assert_equal 1, topic.written_on.day
717
- assert_equal 16, topic.written_on.hour
718
- assert_equal 12, topic.written_on.min
719
- assert_equal 02, topic.written_on.sec
763
+ assert_nil topic.written_on
720
764
  end
721
765
 
722
766
  def test_multiparameter_attributes_on_time_with_utc
@@ -1170,19 +1214,6 @@ class BasicsTest < ActiveRecord::TestCase
1170
1214
  assert(auto.id > 0)
1171
1215
  end
1172
1216
 
1173
- def quote_column_name(name)
1174
- "<#{name}>"
1175
- end
1176
-
1177
- def test_quote_keys
1178
- ar = AutoId.new
1179
- source = {"foo" => "bar", "baz" => "quux"}
1180
- actual = ar.send(:quote_columns, self, source)
1181
- inverted = actual.invert
1182
- assert_equal("<foo>", inverted["bar"])
1183
- assert_equal("<baz>", inverted["quux"])
1184
- end
1185
-
1186
1217
  def test_sql_injection_via_find
1187
1218
  assert_raise(ActiveRecord::RecordNotFound, ActiveRecord::StatementInvalid) do
1188
1219
  Topic.find("123456 OR id > 0")
@@ -1220,6 +1251,42 @@ class BasicsTest < ActiveRecord::TestCase
1220
1251
  assert_equal(myobj, topic.content)
1221
1252
  end
1222
1253
 
1254
+ def test_serialized_attribute_in_base_class
1255
+ Topic.serialize("content", Hash)
1256
+
1257
+ hash = { 'content1' => 'value1', 'content2' => 'value2' }
1258
+ important_topic = ImportantTopic.create("content" => hash)
1259
+ assert_equal(hash, important_topic.content)
1260
+
1261
+ important_topic.reload
1262
+ assert_equal(hash, important_topic.content)
1263
+ end
1264
+
1265
+ # This test was added to fix GH #4004. Obviously the value returned
1266
+ # is not really the value 'before type cast' so we should maybe think
1267
+ # about changing that in the future.
1268
+ def test_serialized_attribute_before_type_cast_returns_unserialized_value
1269
+ klass = Class.new(ActiveRecord::Base)
1270
+ klass.table_name = "topics"
1271
+ klass.serialize :content, Hash
1272
+
1273
+ t = klass.new(:content => { :foo => :bar })
1274
+ assert_equal({ :foo => :bar }, t.content_before_type_cast)
1275
+ t.save!
1276
+ t.reload
1277
+ assert_equal({ :foo => :bar }, t.content_before_type_cast)
1278
+ end
1279
+
1280
+ def test_serialized_attribute_declared_in_subclass
1281
+ hash = { 'important1' => 'value1', 'important2' => 'value2' }
1282
+ important_topic = ImportantTopic.create("important" => hash)
1283
+ assert_equal(hash, important_topic.important)
1284
+
1285
+ important_topic.reload
1286
+ assert_equal(hash, important_topic.important)
1287
+ assert_equal(hash, important_topic.read_attribute(:important))
1288
+ end
1289
+
1223
1290
  def test_serialized_time_attribute
1224
1291
  myobj = Time.local(2008,1,1,1,0)
1225
1292
  topic = Topic.create("content" => myobj).reload
@@ -1386,88 +1453,211 @@ class BasicsTest < ActiveRecord::TestCase
1386
1453
  assert_equal dev, dev.reload
1387
1454
  end
1388
1455
 
1389
- def test_define_attr_method_with_value
1390
- k = Class.new( ActiveRecord::Base )
1391
- k.send(:define_attr_method, :table_name, "foo")
1392
- assert_equal "foo", k.table_name
1393
- end
1394
-
1395
- def test_define_attr_method_with_block
1396
- k = Class.new( ActiveRecord::Base ) do
1397
- class << self
1398
- attr_accessor :foo_key
1399
- end
1400
- end
1401
- k.foo_key = "id"
1402
- k.send(:define_attr_method, :foo_key) { "sys_" + original_foo_key }
1403
- assert_equal "sys_id", k.foo_key
1404
- end
1405
-
1406
1456
  def test_set_table_name_with_value
1407
1457
  k = Class.new( ActiveRecord::Base )
1408
1458
  k.table_name = "foo"
1409
1459
  assert_equal "foo", k.table_name
1410
- k.set_table_name "bar"
1460
+
1461
+ assert_deprecated do
1462
+ k.set_table_name "bar"
1463
+ end
1411
1464
  assert_equal "bar", k.table_name
1412
1465
  end
1413
1466
 
1414
1467
  def test_switching_between_table_name
1415
1468
  assert_difference("GoodJoke.count") do
1416
- Joke.set_table_name "cold_jokes"
1469
+ Joke.table_name = "cold_jokes"
1417
1470
  Joke.create
1418
1471
 
1419
- Joke.set_table_name "funny_jokes"
1472
+ Joke.table_name = "funny_jokes"
1420
1473
  Joke.create
1421
1474
  end
1422
1475
  end
1423
1476
 
1477
+ def test_set_table_name_symbol_converted_to_string
1478
+ Joke.table_name = :cold_jokes
1479
+ assert_equal 'cold_jokes', Joke.table_name
1480
+ end
1481
+
1424
1482
  def test_quoted_table_name_after_set_table_name
1425
1483
  klass = Class.new(ActiveRecord::Base)
1426
1484
 
1427
- klass.set_table_name "foo"
1485
+ klass.table_name = "foo"
1428
1486
  assert_equal "foo", klass.table_name
1429
1487
  assert_equal klass.connection.quote_table_name("foo"), klass.quoted_table_name
1430
1488
 
1431
- klass.set_table_name "bar"
1489
+ klass.table_name = "bar"
1432
1490
  assert_equal "bar", klass.table_name
1433
1491
  assert_equal klass.connection.quote_table_name("bar"), klass.quoted_table_name
1434
1492
  end
1435
1493
 
1436
1494
  def test_set_table_name_with_block
1437
1495
  k = Class.new( ActiveRecord::Base )
1438
- k.set_table_name { "ks" }
1439
- assert_equal "ks", k.table_name
1496
+ assert_deprecated do
1497
+ k.set_table_name "foo"
1498
+ k.set_table_name do
1499
+ ActiveSupport::Deprecation.silence { original_table_name } + "ks"
1500
+ end
1501
+ end
1502
+ assert_equal "fooks", k.table_name
1503
+ end
1504
+
1505
+ def test_set_table_name_with_inheritance
1506
+ k = Class.new( ActiveRecord::Base )
1507
+ def k.name; "Foo"; end
1508
+ def k.table_name; super + "ks"; end
1509
+ assert_equal "foosks", k.table_name
1510
+ end
1511
+
1512
+ def test_original_table_name
1513
+ k = Class.new(ActiveRecord::Base)
1514
+ def k.name; "Foo"; end
1515
+ k.table_name = "bar"
1516
+
1517
+ assert_deprecated do
1518
+ assert_equal "foos", k.original_table_name
1519
+ end
1520
+
1521
+ k = Class.new(ActiveRecord::Base)
1522
+ k.table_name = "omg"
1523
+ k.table_name = "wtf"
1524
+
1525
+ assert_deprecated do
1526
+ assert_equal "omg", k.original_table_name
1527
+ end
1440
1528
  end
1441
1529
 
1442
1530
  def test_set_primary_key_with_value
1443
1531
  k = Class.new( ActiveRecord::Base )
1444
1532
  k.primary_key = "foo"
1445
1533
  assert_equal "foo", k.primary_key
1446
- k.set_primary_key "bar"
1534
+
1535
+ assert_deprecated do
1536
+ k.set_primary_key "bar"
1537
+ end
1447
1538
  assert_equal "bar", k.primary_key
1448
1539
  end
1449
1540
 
1450
1541
  def test_set_primary_key_with_block
1451
1542
  k = Class.new( ActiveRecord::Base )
1452
1543
  k.primary_key = 'id'
1453
- k.set_primary_key { "sys_" + original_primary_key }
1544
+
1545
+ assert_deprecated do
1546
+ k.set_primary_key do
1547
+ "sys_" + ActiveSupport::Deprecation.silence { original_primary_key }
1548
+ end
1549
+ end
1454
1550
  assert_equal "sys_id", k.primary_key
1455
1551
  end
1456
1552
 
1553
+ def test_original_primary_key
1554
+ k = Class.new(ActiveRecord::Base)
1555
+ def k.name; "Foo"; end
1556
+ k.table_name = "posts"
1557
+ k.primary_key = "bar"
1558
+
1559
+ assert_deprecated do
1560
+ assert_equal "id", k.original_primary_key
1561
+ end
1562
+
1563
+ k = Class.new(ActiveRecord::Base)
1564
+ k.primary_key = "omg"
1565
+ k.primary_key = "wtf"
1566
+
1567
+ assert_deprecated do
1568
+ assert_equal "omg", k.original_primary_key
1569
+ end
1570
+ end
1571
+
1457
1572
  def test_set_inheritance_column_with_value
1458
1573
  k = Class.new( ActiveRecord::Base )
1459
1574
  k.inheritance_column = "foo"
1460
1575
  assert_equal "foo", k.inheritance_column
1461
- k.set_inheritance_column "bar"
1576
+
1577
+ assert_deprecated do
1578
+ k.set_inheritance_column "bar"
1579
+ end
1462
1580
  assert_equal "bar", k.inheritance_column
1463
1581
  end
1464
1582
 
1465
1583
  def test_set_inheritance_column_with_block
1466
1584
  k = Class.new( ActiveRecord::Base )
1467
- k.set_inheritance_column { original_inheritance_column + "_id" }
1585
+ assert_deprecated do
1586
+ k.set_inheritance_column do
1587
+ ActiveSupport::Deprecation.silence { original_inheritance_column } + "_id"
1588
+ end
1589
+ end
1468
1590
  assert_equal "type_id", k.inheritance_column
1469
1591
  end
1470
1592
 
1593
+ def test_original_inheritance_column
1594
+ k = Class.new(ActiveRecord::Base)
1595
+ def k.name; "Foo"; end
1596
+ k.inheritance_column = "omg"
1597
+
1598
+ assert_deprecated do
1599
+ assert_equal "type", k.original_inheritance_column
1600
+ end
1601
+ end
1602
+
1603
+ def test_set_sequence_name_with_value
1604
+ k = Class.new( ActiveRecord::Base )
1605
+ k.sequence_name = "foo"
1606
+ assert_equal "foo", k.sequence_name
1607
+
1608
+ assert_deprecated do
1609
+ k.set_sequence_name "bar"
1610
+ end
1611
+ assert_equal "bar", k.sequence_name
1612
+ end
1613
+
1614
+ def test_set_sequence_name_with_block
1615
+ k = Class.new( ActiveRecord::Base )
1616
+ k.table_name = "projects"
1617
+ orig_name = k.sequence_name
1618
+ return skip "sequences not supported by db" unless orig_name
1619
+
1620
+ assert_deprecated do
1621
+ k.set_sequence_name do
1622
+ ActiveSupport::Deprecation.silence { original_sequence_name } + "_lol"
1623
+ end
1624
+ end
1625
+ assert_equal orig_name + "_lol", k.sequence_name
1626
+ end
1627
+
1628
+ def test_original_sequence_name
1629
+ k = Class.new(ActiveRecord::Base)
1630
+ k.table_name = "projects"
1631
+ orig_name = k.sequence_name
1632
+ return skip "sequences not supported by db" unless orig_name
1633
+
1634
+ k = Class.new(ActiveRecord::Base)
1635
+ k.table_name = "projects"
1636
+ k.sequence_name = "omg"
1637
+
1638
+ assert_deprecated do
1639
+ assert_equal orig_name, k.original_sequence_name
1640
+ end
1641
+
1642
+ k = Class.new(ActiveRecord::Base)
1643
+ k.table_name = "projects"
1644
+ k.sequence_name = "omg"
1645
+ k.sequence_name = "wtf"
1646
+ assert_deprecated do
1647
+ assert_equal "omg", k.original_sequence_name
1648
+ end
1649
+ end
1650
+
1651
+ def test_sequence_name_with_abstract_class
1652
+ ak = Class.new(ActiveRecord::Base)
1653
+ ak.abstract_class = true
1654
+ k = Class.new(ak)
1655
+ k.table_name = "projects"
1656
+ orig_name = k.sequence_name
1657
+ return skip "sequences not supported by db" unless orig_name
1658
+ assert_equal k.reset_sequence_name, orig_name
1659
+ end
1660
+
1471
1661
  def test_count_with_join
1472
1662
  res = Post.count_by_sql "SELECT COUNT(*) FROM posts LEFT JOIN comments ON posts.id=comments.post_id WHERE posts.#{QUOTED_TYPE} = 'Post'"
1473
1663
 
@@ -1717,7 +1907,7 @@ class BasicsTest < ActiveRecord::TestCase
1717
1907
 
1718
1908
  def test_inspect_instance
1719
1909
  topic = topics(:first)
1720
- assert_equal %(#<Topic id: 1, title: "The First Topic", author_name: "David", author_email_address: "david@loudthinking.com", written_on: "#{topic.written_on.to_s(:db)}", bonus_time: "#{topic.bonus_time.to_s(:db)}", last_read: "#{topic.last_read.to_s(:db)}", content: "Have a nice day", approved: false, replies_count: 1, parent_id: nil, parent_title: nil, type: nil, group: nil, created_at: "#{topic.created_at.to_s(:db)}", updated_at: "#{topic.updated_at.to_s(:db)}">), topic.inspect
1910
+ assert_equal %(#<Topic id: 1, title: "The First Topic", author_name: "David", author_email_address: "david@loudthinking.com", written_on: "#{topic.written_on.to_s(:db)}", bonus_time: "#{topic.bonus_time.to_s(:db)}", last_read: "#{topic.last_read.to_s(:db)}", content: "Have a nice day", important: nil, approved: false, replies_count: 1, parent_id: nil, parent_title: nil, type: nil, group: nil, created_at: "#{topic.created_at.to_s(:db)}", updated_at: "#{topic.updated_at.to_s(:db)}">), topic.inspect
1721
1911
  end
1722
1912
 
1723
1913
  def test_inspect_new_instance
@@ -1746,6 +1936,14 @@ class BasicsTest < ActiveRecord::TestCase
1746
1936
  assert_equal "The First Topic", topics(:first).becomes(Reply).title
1747
1937
  end
1748
1938
 
1939
+ def test_becomes_includes_errors
1940
+ company = Company.new(:name => nil)
1941
+ assert !company.valid?
1942
+ original_errors = company.errors
1943
+ client = company.becomes(Client)
1944
+ assert_equal original_errors, client.errors
1945
+ end
1946
+
1749
1947
  def test_silence_sets_log_level_to_error_in_block
1750
1948
  original_logger = ActiveRecord::Base.logger
1751
1949
  log = StringIO.new
@@ -1791,7 +1989,9 @@ class BasicsTest < ActiveRecord::TestCase
1791
1989
  original_logger = ActiveRecord::Base.logger
1792
1990
  log = StringIO.new
1793
1991
  ActiveRecord::Base.logger = Logger.new(log)
1794
- ActiveRecord::Base.benchmark("Logging", :level => :debug, :silence => true) { ActiveRecord::Base.logger.debug "Loud" }
1992
+ assert_deprecated do
1993
+ ActiveRecord::Base.benchmark("Logging", :level => :debug, :silence => true) { ActiveRecord::Base.logger.debug "Loud" }
1994
+ end
1795
1995
  ActiveRecord::Base.benchmark("Logging", :level => :debug, :silence => false) { ActiveRecord::Base.logger.debug "Quiet" }
1796
1996
  assert_no_match(/Loud/, log.string)
1797
1997
  assert_match(/Quiet/, log.string)
@@ -1825,9 +2025,9 @@ class BasicsTest < ActiveRecord::TestCase
1825
2025
 
1826
2026
  def test_clear_cache!
1827
2027
  # preheat cache
1828
- c1 = Post.columns
2028
+ c1 = Post.connection.schema_cache.columns['posts']
1829
2029
  ActiveRecord::Base.clear_cache!
1830
- c2 = Post.columns
2030
+ c2 = Post.connection.schema_cache.columns['posts']
1831
2031
  assert_not_equal c1, c2
1832
2032
  end
1833
2033
 
@@ -1844,6 +2044,11 @@ class BasicsTest < ActiveRecord::TestCase
1844
2044
  end
1845
2045
 
1846
2046
  def test_marshal_round_trip
2047
+ if ENV['TRAVIS'] && RUBY_VERSION == "1.8.7"
2048
+ return skip("Marshalling tests disabled for Ruby 1.8.7 on Travis CI due to what appears " \
2049
+ "to be a Ruby bug.")
2050
+ end
2051
+
1847
2052
  expected = posts(:welcome)
1848
2053
  marshalled = Marshal.dump(expected)
1849
2054
  actual = Marshal.load(marshalled)
@@ -1852,6 +2057,11 @@ class BasicsTest < ActiveRecord::TestCase
1852
2057
  end
1853
2058
 
1854
2059
  def test_marshal_new_record_round_trip
2060
+ if ENV['TRAVIS'] && RUBY_VERSION == "1.8.7"
2061
+ return skip("Marshalling tests disabled for Ruby 1.8.7 on Travis CI due to what appears " \
2062
+ "to be a Ruby bug.")
2063
+ end
2064
+
1855
2065
  marshalled = Marshal.dump(Post.new)
1856
2066
  post = Marshal.load(marshalled)
1857
2067
 
@@ -1859,6 +2069,11 @@ class BasicsTest < ActiveRecord::TestCase
1859
2069
  end
1860
2070
 
1861
2071
  def test_marshalling_with_associations
2072
+ if ENV['TRAVIS'] && RUBY_VERSION == "1.8.7"
2073
+ return skip("Marshalling tests disabled for Ruby 1.8.7 on Travis CI due to what appears " \
2074
+ "to be a Ruby bug.")
2075
+ end
2076
+
1862
2077
  post = Post.new
1863
2078
  post.comments.build
1864
2079
 
@@ -1903,6 +2118,16 @@ class BasicsTest < ActiveRecord::TestCase
1903
2118
  def test_cache_key_format_for_existing_record_with_nil_updated_at
1904
2119
  dev = Developer.first
1905
2120
  dev.update_attribute(:updated_at, nil)
1906
- assert_match /\/#{dev.id}$/, dev.cache_key
2121
+ assert_match(/\/#{dev.id}$/, dev.cache_key)
2122
+ end
2123
+
2124
+ def test_uniq_delegates_to_scoped
2125
+ scope = stub
2126
+ Bird.stubs(:scoped).returns(mock(:uniq => scope))
2127
+ assert_equal scope, Bird.uniq
2128
+ end
2129
+
2130
+ def test_table_name_with_2_abstract_subclasses
2131
+ assert_equal "photos", Photo.table_name
1907
2132
  end
1908
2133
  end