Sha256: 163e85337d3a65946ae851621097168e29e3e699e4ad2dbcab36a28aef230d9e

Contents?: true

Size: 823 Bytes

Versions: 5

Compression:

Stored size: 823 Bytes

Contents

require 'spec_helper'

describe 'Adding and removing tags' do
  let(:article)  { Article.create }
  let(:pancakes) { Gutentag::Tag.create :name => 'pancakes' }

  it "stores new tags" do
    article.tags << pancakes

    article.tags.reload.should == [pancakes]
  end

  it "removes existing tags" do
    article.tags << pancakes

    article.tags.delete pancakes

    article.tags.reload.should == []
  end

  it "removes taggings when an article is deleted" do
    article.tags << pancakes

    article.destroy

    Gutentag::Tagging.where(
      :taggable_type => 'Article', :taggable_id => article.id
    ).count.should be_zero
  end

  it "removes taggings when a tag is deleted" do
    article.tags << pancakes

    pancakes.destroy

    Gutentag::Tagging.where(:tag_id => pancakes.id).count.should be_zero
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
gutentag-0.3.0 spec/acceptance/tags_spec.rb
gutentag-0.2.2 spec/acceptance/tags_spec.rb
gutentag-0.2.1 spec/acceptance/tags_spec.rb
gutentag-0.2.0 spec/acceptance/tags_spec.rb
gutentag-0.1.0 spec/acceptance/tags_spec.rb