Sha256: 0d7043ed0be292d68c8b77f2a078312ec52a26438d14ccfb2c0474659aeeb09a

Contents?: true

Size: 856 Bytes

Versions: 4

Compression:

Stored size: 856 Bytes

Contents

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

module Enki

  describe Tagging do
    before(:each) do
      @taggable = Post.create!(:title => 'My Post', :body => 'body', :tag_list => 'oblong, square, triangle')
    end

    it 'destroys unused tags on taggable update' do
      @taggable.tag_list = ''
      @taggable.save
      Tag.where(:taggings_count => 0).count.should == 0
    end

    it 'destroys unused tags on taggable destroy' do
      Enki::Tag.remove_unused = true
      
      @taggable.destroy
      Tag.where(:taggings_count => 0).count.should == 0
    end
  
    it 'does not destroy tags if they are still in use' do
      another_taggable = Post.create!(:title => 'My Post', :body => 'body', :tag_list => 'oblong, square')
      @taggable.destroy
      Tag.where(:name => ['oblong', 'square']).count.should == 2
    end
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
enki-engine-0.0.5 spec/models/tagging_spec.rb
enki-engine-0.0.4 spec/models/tagging_spec.rb
enki-engine-0.0.3 spec/models/tagging_spec.rb
enki-engine-0.0.2 spec/models/tagging_spec.rb