Sha256: dcf7d02fe49833d2dba3cd54fae0fef4f642509775da172cfb1002bae309a2a2

Contents?: true

Size: 612 Bytes

Versions: 5

Compression:

Stored size: 612 Bytes

Contents

# frozen_string_literal: true

require "spec_helper"

RSpec.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

5 entries across 5 versions & 1 rubygems

Version Path
gutentag-2.6.2 spec/models/gutentag/tagging_spec.rb
gutentag-2.6.1 spec/models/gutentag/tagging_spec.rb
gutentag-2.6.0 spec/models/gutentag/tagging_spec.rb
gutentag-2.5.4 spec/models/gutentag/tagging_spec.rb
gutentag-2.5.3 spec/models/gutentag/tagging_spec.rb