Sha256: 0ed836636d13013dc156b221ad37c8208bae962d4727eeb4212e6c18c5657ced

Contents?: true

Size: 575 Bytes

Versions: 4

Compression:

Stored size: 575 Bytes

Contents

require 'spec_helper'

describe Gutentag::Tagging, :type => :model do
  describe '#valid?' do
    let(:tag)      { Gutentag::Tag.create! :name => 'pancakes' }
    let(:taggable) { Article.create! }

    it "ensures tags are unique for any given taggable" do
      tagging = Gutentag::Tagging.new
      tagging.tag      = tag
      tagging.taggable = taggable
      tagging.save!

      tagging = Gutentag::Tagging.new
      tagging.tag      = tag
      tagging.taggable = taggable

      tagging.valid?
      expect(tagging.errors[:tag_id].length).to eq(1)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
gutentag-0.9.0 spec/models/gutentag/tagging_spec.rb
gutentag-0.8.0 spec/models/gutentag/tagging_spec.rb
gutentag-0.7.0 spec/models/gutentag/tagging_spec.rb
gutentag-0.6.0 spec/models/gutentag/tagging_spec.rb