require File.join(File.dirname(__FILE__), '..', 'CONFIG.rb') require 'test/unit' require 'ostruct' require 'og' require 'glue/taggable' class Article property :title, :body, String is Taggable def initialize(title = nil) @title = title end end $og = Og.setup( :store => 'mysql', :name => 'test', :user => 'root', :password => 'navelrulez', :destroy => true ) class TestOgTaggable < Test::Unit::TestCase # :nodoc: all def test_all a1 = Article.create('Hello') a1.tag('navel gmosx sexy') a1.save a2 = Article.create('Other') a2.tag('gmosx', 'rain') a2.save a3 = Article.create('George') a3.tag('phd', 'name') a3.save assert_equal 3, a1.tags.size assert a1.tag_names.include?('navel') assert a1.tagged_with?('navel') assert_equal false, a1.tagged_with?('photo') res = Article.find_with_tags('navel', 'gmosx') assert_equal 1, res.size assert_equal 'Hello', res[0].title res = Article.find_with_tag('gmosx') assert_equal 2, res.size res = res.map { |o| o.title } assert res.include?('Hello') assert res.include?('Other') res = Article.find_with_any_tag('navel', 'gmosx', 'phd') assert_equal 3, res.size =begin TODO: Article.fing_with_no_tag('gmosx') Article.find_by_tags('+name +gmosx -sexy') Article.find_by_tags(:with => '', :any => '', :no => '') =end end end