<commit_before>require File.dirname(__FILE__) + '/../spec_helper'

describe "acts_as_taggable_on" do
  context "Taggable Method Generation" do
    before(:each) do
      @taggable = TaggableModel.new(:name => "<NAME>")
    end
  
    it "should create a class attribute for tag types" do
      @taggable.class.should respond_to(:tag_types)
    end
  
    it "should generate an association for each tag type" do
      @taggable.should respond_to(:tags, :skills, :languages)
    end
    
    it "should generate a cached column checker for each tag type" do
     TaggableModel.should respond_to(:caching_tag_list?, :caching_skill_list?, :caching_language_list?)
    end
    
    it "should add tagged_with and tag_counts to singleton" do
      TaggableModel.should respond_to(:find_tagged_with, :tag_counts)
    end
    
    it "should add saving of tag lists and cached tag lists to the instance" do
      @taggable.should respond_to(:save_cached_tag_list)
      @taggable.should respond_to(:save_tags)
    end
  
    it "should generate a tag_list accessor/setter for each tag type" do
      @taggable.should respond_to(:tag_list, :skill_list, :language_list)
      @taggable.should respond_to(:tag_list=, :skill_list=, :language_list=)
    end
  end
  
  context "reloading" do
    it "should save a model instantiated by Model.find" do
      taggable = TaggableModel.create!(:name => "Taggable")
      found_taggable = TaggableModel.find(taggable.id)
      found_taggable.save
    end
  end
end<commit_msg>Adding in a simple spec for relationships<commit_after>require File.dirname(__FILE__) + '/../spec_helper'

describe "acts_as_taggable_on" do
  context "Taggable Method Generation" do
    before(:each) do
      @taggable = TaggableModel.new(:name => "<NAME>")
    end
  
    it "should create a class attribute for tag types" do
      @taggable.class.should respond_to(:tag_types)
    end
  
    it "should generate an association for each tag type" do
      @taggable.should respond_to(:tags, :skills, :languages)
    end
    
    it "should generate a cached column checker for each tag type" do
     TaggableModel.should respond_to(:caching_tag_list?, :caching_skill_list?, :caching_language_list?)
    end
    
    it "should add tagged_with and tag_counts to singleton" do
      TaggableModel.should respond_to(:find_tagged_with, :tag_counts)
    end
    
    it "should add saving of tag lists and cached tag lists to the instance" do
      @taggable.should respond_to(:save_cached_tag_list)
      @taggable.should respond_to(:save_tags)
    end
  
    it "should generate a tag_list accessor/setter for each tag type" do
      @taggable.should respond_to(:tag_list, :skill_list, :language_list)
      @taggable.should respond_to(:tag_list=, :skill_list=, :language_list=)
    end
  end
  
  context "reloading" do
    it "should save a model instantiated by Model.find" do
      taggable = TaggableModel.create!(:name => "Taggable")
      found_taggable = TaggableModel.find(taggable.id)
      found_taggable.save
    end
  end
  
  context "related" do
    it "should find related objects based on tag names on context" do
      taggable1 = TaggableModel.create!(:name => "Taggable 1")
      taggable2 = TaggableModel.create!(:name => "Taggable 2")
      taggable3 = TaggableModel.create!(:name => "Taggable 3")

      taggable1.tag_list = "one, two"
      taggable1.save
      
      taggable2.tag_list = "three, four"
      taggable2.save
      
      taggable3.tag_list = "one, four"
      taggable3.save
      
      taggable1.find_related_tags.should include(taggable3)
      taggable1.find_related_tags.should_not include(taggable2)
    end
  end
end
{'fraction_non_alphanumeric': 0.08660130718954248, 'fraction_numerical': 0.004357298474945534, 'mean_word_length': 3.3467455621301774, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4818587', 'n_tokens_mistral': 1220, 'n_tokens_neox': 1212, 'n_words': 324}