Sha256: d0b7cf3448017fd78e2df5af62e93ba4bf71c22ced0915fa2a3bc77f505de02d

Contents?: true

Size: 854 Bytes

Versions: 1

Compression:

Stored size: 854 Bytes

Contents

require File.join(File.dirname(__FILE__), 'CONFIG.rb')

$DBG = true

require 'rubygems'
require 'facets'
require 'test/unit'

require 'og'

class TC_OgScoped < Test::Unit::TestCase # :nodoc: all

  class User
    property :name, String
    has_many :articles
    
    def initialize(name = nil)
      @name = name
    end
  end

  class Article
    property :hits, Fixnum
    belongs_to :user
    
    def initialize(hits = nil)
      @hits = hits
    end
  end
    
  def setup
    @og = Og.setup($og_config)
  end

  def test_all
    u = User.create('tml')
    a1 = Article.create(10)
    a2 = Article.create(20)
    u.articles << a1
    u.articles << a2
    
    assert_equal 2, u.articles.size
    assert_equal 1, u.articles.find(:condition => 'hits > 15').size
    assert_equal 20, u.articles.find(:condition => 'hits > 15').first.hits
  end
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
og-0.27.0 test/og/tc_scoped.rb