db_populate/test/db_populate_test.rb

30 lines
660 B
Ruby
Raw Normal View History

2008-09-16 01:08:50 +00:00
require File.dirname(__FILE__) + '/test_helper.rb'
require 'test/unit'
require 'rubygems'
require 'mocha'
2008-10-12 00:05:39 +00:00
class User < ActiveRecord::Base
end
class DbPopulateTest < Test::Unit::TestCase
def test_creates_new_record
User.delete_all
User.create_or_update(:id => 1, :name => "Fred")
assert_equal User.count, 1
u = User.find(:first)
assert_equal u.name, "Fred"
end
def test_updates_existing_record
User.delete_all
User.create_or_update(:id => 1, :name => "Fred")
User.create_or_update(:id => 1, :name => "George")
assert_equal User.count, 1
u = User.find(:first)
assert_equal u.name, "George"
end
2008-09-16 01:08:50 +00:00
end