Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

51 lines (35 sloc) 1.194 kb
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
Jump to Line
Something went wrong with that request. Please try again.