Sha256: eb0075e79e2fb983afae86360b96155782355f53faa5814b4f7aab154a054312

Contents?: true

Size: 744 Bytes

Versions: 4

Compression:

Stored size: 744 Bytes

Contents

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

describe Tagging do
  before(:each) do
    clean_database!
    @tagging = Tagging.new
  end
  
  it "should not be valid with a invalid tag" do
    @tagging.taggable = TaggableModel.create(:name => "Bob Jones")
    @tagging.tag = Tag.new(:name => "")
    @tagging.context = "tags"

    @tagging.should_not be_valid
    @tagging.errors.on(:tag_id).should == "can't be blank"
  end
  
  it "should not create duplicate taggings" do
    @taggable = TaggableModel.create(:name => "Bob Jones")
    @tag = Tag.create(:name => "awesome")
    
    lambda {
      2.times { Tagging.create(:taggable => @taggable, :tag => @tag, :context => 'tags') }
    }.should change(Tagging, :count).by(1)
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
acts-as-taggable-on-1.1.9 spec/acts_as_taggable_on/tagging_spec.rb
acts-as-taggable-on-1.1.8 spec/acts_as_taggable_on/tagging_spec.rb
acts-as-taggable-on-1.1.7 spec/acts_as_taggable_on/tagging_spec.rb
acts-as-taggable-on-1.1.6 spec/acts_as_taggable_on/tagging_spec.rb