Sha256: 40651dba8aa53cc9146fc58ab651f3ea465fda3dcf454d48bdae5961b0dfc6a7

Contents?: true

Size: 857 Bytes

Versions: 13

Compression:

Stored size: 857 Bytes

Contents

require File.expand_path('../../spec_helper', __FILE__)

describe ActsAsTaggableOn::Tagging do
  before(:each) do
    clean_database!
    @tagging = ActsAsTaggableOn::Tagging.new
  end

  it "should not be valid with a invalid tag" do
    @tagging.taggable = TaggableModel.create(:name => "Bob Jones")
    @tagging.tag = ActsAsTaggableOn::Tag.new(:name => "")
    @tagging.context = "tags"

    @tagging.should_not be_valid
    
    @tagging.errors[:tag_id].should == ["can't be blank"]
  end

  it "should not create duplicate taggings" do
    @taggable = TaggableModel.create(:name => "Bob Jones")
    @tag = ActsAsTaggableOn::Tag.create(:name => "awesome")

    lambda {
      2.times { ActsAsTaggableOn::Tagging.create(:taggable => @taggable, :tag => @tag, :context => 'tags') }
    }.should change(ActsAsTaggableOn::Tagging, :count).by(1)
  end
  
end

Version data entries

13 entries across 13 versions & 3 rubygems

Version Path
acts-as-taggable-on-2.4.0 spec/acts_as_taggable_on/tagging_spec.rb
acts-as-taggable-on-2.4.0.beta spec/acts_as_taggable_on/tagging_spec.rb
crowdint_acts-as-taggable-on-2.3.5 spec/acts_as_taggable_on/tagging_spec.rb
acts-as-taggable-on-2.3.3 spec/acts_as_taggable_on/tagging_spec.rb
acts-as-taggable-on-2.3.2 spec/acts_as_taggable_on/tagging_spec.rb
crowdint_acts-as-taggable-on-2.3.4 spec/acts_as_taggable_on/tagging_spec.rb
crowdint_acts-as-taggable-on-2.3.3 spec/acts_as_taggable_on/tagging_spec.rb
crowdint_acts-as-taggable-on-2.3.2 spec/acts_as_taggable_on/tagging_spec.rb
acts-as-taggable-on-2.3.1 spec/acts_as_taggable_on/tagging_spec.rb
acts-as-taggable-on-2.3.0 spec/acts_as_taggable_on/tagging_spec.rb
bborn-acts-as-taggable-on-2.2.1 spec/acts_as_taggable_on/tagging_spec.rb
acts-as-taggable-on-2.2.2 spec/acts_as_taggable_on/tagging_spec.rb
acts-as-taggable-on-2.2.1 spec/acts_as_taggable_on/tagging_spec.rb