Sha256: 0d5b6e455010b22d1f29cb95b5f7097039aa1e912f93efa9cda5d3d3f609d4b1
Contents?: true
Size: 1.43 KB
Versions: 1
Compression:
Stored size: 1.43 KB
Contents
$:.unshift File.join(File.dirname(__FILE__), '..', '..', 'lib') require 'test/unit' require 'ostruct' require 'og' require 'og/mixin/taggable' class Article property :title, :body, String include Og::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
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
og-0.23.0 | test/og/mixin/tc_taggable.rb |