Sha256: 6568287cbbe9895126be733996dbee9248dc2437c48190daeb7cafffb255f31c

Contents?: true

Size: 818 Bytes

Versions: 2

Compression:

Stored size: 818 Bytes

Contents

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

$DBG = true

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

2 entries across 2 versions & 1 rubygems

Version Path
og-0.25.0 test/og/tc_scoped.rb
og-0.26.0 test/og/tc_scoped.rb