Sha256: 405a79fdcf871c2984ca5edc8e7f5341902b8f9ddc7fdbcdb2d7338a737c97d5

Contents?: true

Size: 1.17 KB

Versions: 5

Compression:

Stored size: 1.17 KB

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

    expect(article.tags.reload).to eq([pancakes])
  end

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

    article.tags.delete pancakes

    expect(article.tags.reload).to eq([])
  end

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

    article.destroy

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

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

    pancakes.destroy

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

  it 'should have a mean tag cloud' do
    gorillas = Gutentag::Tag.create(:name => 'gorillas')
    another_article = Article.create

    article.tags << pancakes
    expect(Gutentag::Tag.by_weight.first).to eq(pancakes)

    article.tags << gorillas
    another_article.tags << gorillas
    expect(Gutentag::Tag.by_weight.first).to eq(gorillas)
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
gutentag-0.9.0 spec/acceptance/tags_spec.rb
gutentag-0.8.0 spec/acceptance/tags_spec.rb
gutentag-0.7.0 spec/acceptance/tags_spec.rb
gutentag-0.6.0 spec/acceptance/tags_spec.rb
gutentag-0.5.1 spec/acceptance/tags_spec.rb