Sha256: d71e1f5d580a4d60996cc8d2d2b41d2e6fd5d32d8069e9cb46802857ceedfb97
Contents?: true
Size: 1.33 KB
Versions: 6
Compression:
Stored size: 1.33 KB
Contents
require File.join(File.dirname(__FILE__), 'CONFIG.rb') # $DBG = true require 'rubygems' require 'facets' require 'test/unit' require 'og' class TC_OgFinder < Test::Unit::TestCase # :nodoc: all class User property :name, String property :age, Fixnum property :father, String end $og1.manage_classes User def test_all User.find_by_name('tml') User.find_by_name_and_age('tml', 3) User.find_all_by_name_and_age('tml', 3) User.find_all_by_name_and_age('tml', 3, :name_op => 'LIKE', :age_op => '>', :limit => 4) User.find_or_create_by_name_and_age('tml', 3) User.find_or_create_by_name_and_age('stella', 5) User.find_or_create_by_name_and_age('tml', 3) assert_equal 2, User.all.size # Basic check that tml is just right. u = User.find_by_name('tml') assert_equal('tml', u.name) assert_equal(3, u.age) assert_equal(nil, u.father) # Block form initialization works. u2 = User.find_or_create_by_name_and_age('tommy', 9) {|x| x.father = 'jack' } assert_equal('tommy', u2.name) assert_equal(9, u2.age) assert_equal('jack', u2.father) # Doesn't create another object same object. u3 = User.find_or_create_by_name_and_age('tommy', 9) {|x| x.father = 'jack' } assert_equal(1, User.find_all_by_name('tommy').size) end end
Version data entries
6 entries across 6 versions & 1 rubygems
Version | Path |
---|---|
og-0.41.0 | test/og/tc_finder.rb |
og-0.28.0 | test/og/tc_finder.rb |
og-0.29.0 | test/og/tc_finder.rb |
og-0.30.0 | test/og/tc_finder.rb |
og-0.31.0 | test/og/tc_finder.rb |
og-0.40.0 | test/og/tc_finder.rb |