Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 9226ea68d7
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 42 lines (36 sloc) 1.345 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
require File.dirname(__FILE__) + '/../spec_helper.rb'

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

  it "should have properties: id, tag_id, taggable_id, taggable_type, tagger_id, tagger_type, and tag_context" do
    @tagging.should respond_to(:id)
    @tagging.should respond_to(:tag_id)
    @tagging.should respond_to(:taggable_id)
    @tagging.should respond_to(:taggable_type)
    @tagging.should respond_to(:tag_context)
  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 many_to_one :tag" do
    Tagging.associations.should include(:tag)
    Tagging.association_reflection(:tag)[:class_name].should == "Tag"
  end

  it "should have a method Tagging#taggable which returns the associated taggable instance" do
    @tagging.should respond_to(:taggable)
    @tagging.taggable.should_not be
    @tagging.taggable_id = 11111
    @tagging.taggable_type = "ExampleModel"
    ExampleModel.should_receive(:get!).with(11111)
    @tagging.taggable
  end
end
Something went wrong with that request. Please try again.