Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 7968

Show
Ignore:
Timestamp:
10/18/07 23:47:59 (1 year ago)
Author:
bitsweat
Message:

SQL Server: test for affected row count. References #9558 [lawrence, ryepup]

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/activerecord/test/base_test.rb

    r7802 r7968  
    570570  end 
    571571 
    572   # The ADO library doesn't support the number of affected rows 
    573   unless current_adapter?(:SQLServerAdapter) 
    574     def test_update_all 
    575       assert_equal 2, Topic.update_all("content = 'bulk updated!'") 
    576       assert_equal "bulk updated!", Topic.find(1).content 
    577       assert_equal "bulk updated!", Topic.find(2).content 
    578  
    579       assert_equal 2, Topic.update_all(['content = ?', 'bulk updated again!']) 
    580       assert_equal "bulk updated again!", Topic.find(1).content 
    581       assert_equal "bulk updated again!", Topic.find(2).content 
    582  
    583       assert_equal 2, Topic.update_all(['content = ?', nil]) 
    584       assert_nil Topic.find(1).content 
    585     end 
    586  
    587     def test_update_all_with_hash 
    588       assert_not_nil Topic.find(1).last_read 
    589       assert_equal 2, Topic.update_all(:content => 'bulk updated with hash!', :last_read => nil) 
    590       assert_equal "bulk updated with hash!", Topic.find(1).content 
    591       assert_equal "bulk updated with hash!", Topic.find(2).content 
    592       assert_nil Topic.find(1).last_read 
    593       assert_nil Topic.find(2).last_read 
    594     end 
     572  def test_update_all 
     573    assert_equal 2, Topic.update_all("content = 'bulk updated!'") 
     574    assert_equal "bulk updated!", Topic.find(1).content 
     575    assert_equal "bulk updated!", Topic.find(2).content 
     576 
     577    assert_equal 2, Topic.update_all(['content = ?', 'bulk updated again!']) 
     578    assert_equal "bulk updated again!", Topic.find(1).content 
     579    assert_equal "bulk updated again!", Topic.find(2).content 
     580 
     581    assert_equal 2, Topic.update_all(['content = ?', nil]) 
     582    assert_nil Topic.find(1).content 
     583  end 
     584 
     585  def test_update_all_with_hash 
     586    assert_not_nil Topic.find(1).last_read 
     587    assert_equal 2, Topic.update_all(:content => 'bulk updated with hash!', :last_read => nil) 
     588    assert_equal "bulk updated with hash!", Topic.find(1).content 
     589    assert_equal "bulk updated with hash!", Topic.find(2).content 
     590    assert_nil Topic.find(1).last_read 
     591    assert_nil Topic.find(2).last_read 
    595592  end 
    596593 
     
    611608 
    612609  def test_delete_all 
    613     # The ADO library doesn't support the number of affected rows 
    614     return true if current_adapter?(:SQLServerAdapter) 
    615  
    616610    assert_equal 2, Topic.delete_all 
    617611  end