Sha256: 9cc403e7d3f4a3099d64955d433b905e0ae98e25383cbc09267b003e2122161d

Contents?: true

Size: 1.04 KB

Versions: 5

Compression:

Stored size: 1.04 KB

Contents

require File.dirname(__FILE__) + '/abstract_unit'

class TagTest < Test::Unit::TestCase
  fixtures :tags, :taggings, :users, :photos, :posts
  
  def test_name_required
    t = Tag.create
    assert_match /blank/, t.errors[:name].to_s
  end
  
  def test_name_unique
    t = Tag.create!(:name => "My tag")
    duplicate = t.clone
    
    assert !duplicate.save
    assert_match /taken/, duplicate.errors[:name].to_s
  end
  
  def test_taggings
    assert_equivalent [taggings(:jonathan_sky_good), taggings(:sam_flowers_good), taggings(:sam_flower_good), taggings(:ruby_good)], tags(:good).taggings
    assert_equivalent [taggings(:sam_ground_bad), taggings(:jonathan_bad_cat_bad)], tags(:bad).taggings
  end
  
  def test_to_s
    assert_equal tags(:good).name, tags(:good).to_s
  end
  
  def test_equality
    assert_equal tags(:good), tags(:good)
    assert_equal Tag.find(1), Tag.find(1)
    assert_equal Tag.new(:name => 'A'), Tag.new(:name => 'A')
    assert_not_equal Tag.new(:name => 'A'), Tag.new(:name => 'B')
  end
end

Version data entries

5 entries across 5 versions & 4 rubygems

Version Path
elight-acts_as_taggable_on_steroids-1.1 test/tag_test.rb
ggoodale-acts_as_taggable_on_steroids-1.1.1 test/tag_test.rb
ggoodale-acts_as_taggable_on_steroids-1.1 test/tag_test.rb
rotuka-taggable-0.0.1 test/tag_test.rb
pictrails-0.5.0 vendor/plugins/acts_as_taggable_on_steroids/test/tag_test.rb