Sha256: a52f9840c54f8857bd636214473523e7238b4192c8f2ccf1434b42e0bebac144

Contents?: true

Size: 844 Bytes

Versions: 4

Compression:

Stored size: 844 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
    
  $og1.manage_classes(User, Article)

  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

4 entries across 4 versions & 1 rubygems

Version Path
og-0.28.0 test/og/tc_scoped.rb
og-0.29.0 test/og/tc_scoped.rb
og-0.31.0 test/og/tc_scoped.rb
og-0.30.0 test/og/tc_scoped.rb