Sha256: 6c5ade1f7a4ffcfb379cca3fbd16ebf33afb01349b3b27f9ed33d4f565625f5d

Contents?: true

Size: 1.2 KB

Versions: 14

Compression:

Stored size: 1.2 KB

Contents

# frozen_string_literal: true

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

14 entries across 14 versions & 1 rubygems

Version Path
gutentag-2.5.2 spec/acceptance/tags_spec.rb
gutentag-2.5.1 spec/acceptance/tags_spec.rb
gutentag-2.5.0 spec/acceptance/tags_spec.rb
gutentag-2.4.1 spec/acceptance/tags_spec.rb
gutentag-2.4.0 spec/acceptance/tags_spec.rb
gutentag-2.3.2 spec/acceptance/tags_spec.rb
gutentag-2.3.1 spec/acceptance/tags_spec.rb
gutentag-2.3.0 spec/acceptance/tags_spec.rb
gutentag-2.2.1 spec/acceptance/tags_spec.rb
gutentag-2.2.0 spec/acceptance/tags_spec.rb
gutentag-2.1.0 spec/acceptance/tags_spec.rb
gutentag-2.0.0 spec/acceptance/tags_spec.rb
gutentag-1.1.0 spec/acceptance/tags_spec.rb
gutentag-1.0.0 spec/acceptance/tags_spec.rb