Sha256: 4cc51d74bdbd3928392de9d2f336a420d56d1536d2a800cf84ac6e8492d9c2fe

Contents?: true

Size: 1.08 KB

Versions: 11

Compression:

Stored size: 1.08 KB

Contents

require 'spec_helper'

include DataMapper::Tags

describe Tagging do
  before do
    @tagging = Tagging.new
    @tagged_resource = TaggedModel.create
  end

  it "should be a model which includes DataMapper::Model" do
    Tagging.should be_kind_of(DataMapper::Model)
  end

  it "should validate the presence of tag_id, taggable_id, taggable_type and tag_context" do
    @tagging.should_not be_valid
    @tagging.tag_id = 1
    @tagging.should_not be_valid
    @tagging.taggable_id = 1
    @tagging.should_not be_valid
    @tagging.taggable_type = "TaggedModel"
    @tagging.should_not be_valid
    @tagging.tag_context = "skills"
    @tagging.should be_valid
  end

  it "should belong_to tag" do
    Tagging.relationships[:tag].should be
    Tagging.relationships[:tag].parent_model.should == Tag
  end

  it "should have a method Tagging#taggable which returns the associated taggable instance" do
    @tagging.should respond_to(:taggable)
    @tagging.taggable_id = @tagged_resource.id
    @tagging.taggable_type = @tagged_resource.model.to_s
    @tagging.taggable.should == @tagged_resource
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
dm-tags-1.2.0 spec/dm-tags/tagging_spec.rb
dm-tags-1.2.0.rc2 spec/dm-tags/tagging_spec.rb
dm-tags-1.2.0.rc1 spec/dm-tags/tagging_spec.rb
dm-tags-1.1.0 spec/dm-tags/tagging_spec.rb
dm-tags-1.1.0.rc3 spec/dm-tags/tagging_spec.rb
dm-tags-1.1.0.rc2 spec/dm-tags/tagging_spec.rb
dm-tags-1.1.0.rc1 spec/dm-tags/tagging_spec.rb
dm-tags-1.0.2 spec/dm-tags/tagging_spec.rb
dm-tags-1.0.1 spec/dm-tags/tagging_spec.rb
dm-tags-1.0.0 spec/dm-tags/tagging_spec.rb
dm-tags-1.0.0.rc3 spec/dm-tags/tagging_spec.rb