acts-as-taggable-on 1.1.5 → 1.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -89,6 +89,9 @@ also improves compatibility with the will_paginate gem:
89
89
  User.tagged_with("awesome").by_date
90
90
  User.tagged_with("awesome").by_date.paginate(:page => params[:page], :per_page => 20)
91
91
 
92
+ #Find a user with matching all tags, not just one
93
+ User.tagged_with(["awesome", "cool"], :match_all => :true)
94
+
92
95
  === Relationships
93
96
 
94
97
  You can find objects of the same type based on similar tags on certain contexts.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.5
1
+ 1.1.6
@@ -398,12 +398,12 @@ module ActiveRecord
398
398
 
399
399
  cache.each do |owner, list|
400
400
  new_tags = Tag.find_or_create_all_with_like_by_name(list.uniq)
401
- taggings = Tagging.find(:all, :conditions => { :taggable_id => self.id, :taggable_type => self.class.to_s })
401
+ taggings = Tagging.find(:all, :conditions => { :taggable_id => self.id, :taggable_type => self.class.base_class.to_s })
402
402
 
403
403
  # Destroy old taggings:
404
404
  if owner
405
405
  old_tags = tags_on(context, owner) - new_tags
406
- old_taggings = Tagging.find(:all, :conditions => { :taggable_id => self.id, :taggable_type => self.class.to_s, :tag_id => old_tags, :tagger_id => owner.id, :tagger_type => owner.class.to_s, :context => context })
406
+ old_taggings = Tagging.find(:all, :conditions => { :taggable_id => self.id, :taggable_type => self.class.base_class.to_s, :tag_id => old_tags, :tagger_id => owner.id, :tagger_type => owner.class.to_s, :context => context })
407
407
 
408
408
  Tagging.destroy_all :id => old_taggings.map(&:id)
409
409
  else
@@ -1,6 +1,10 @@
1
1
  require File.dirname(__FILE__) + '/../spec_helper'
2
2
 
3
3
  describe "Acts As Taggable On" do
4
+ before(:each) do
5
+ clean_database!
6
+ end
7
+
4
8
  it "should provide a class method 'taggable?' that is false for untaggable models" do
5
9
  UntaggableModel.should_not be_taggable
6
10
  end
@@ -2,7 +2,7 @@ require File.dirname(__FILE__) + '/../spec_helper'
2
2
 
3
3
  describe "acts_as_tagger" do
4
4
  before(:each) do
5
- [TaggableUser, TaggableModel, Tagging, Tag].each(&:destroy_all)
5
+ clean_database!
6
6
  end
7
7
 
8
8
  context "Tagger Method Generation" do
@@ -85,18 +85,19 @@ describe "acts_as_tagger" do
85
85
 
86
86
  context "when called by multiple tagger's" do
87
87
  before(:each) do
88
- @user_x = TaggableUser.new(:name => "User X")
89
- @user_y = TaggableUser.new(:name => "User Y")
90
- @taggable = TaggableModel.new(:name => 'acts_as_taggable_on', :tag_list => 'plugin')
88
+ @user_x = TaggableUser.create(:name => "User X")
89
+ @user_y = TaggableUser.create(:name => "User Y")
90
+ @taggable = TaggableModel.create(:name => 'acts_as_taggable_on', :tag_list => 'plugin')
91
91
 
92
92
  @user_x.tag(@taggable, :with => 'ruby, rails', :on => :tags)
93
93
  @user_y.tag(@taggable, :with => 'ruby, plugin', :on => :tags)
94
94
 
95
95
  @user_y.tag(@taggable, :with => '', :on => :tags)
96
+ @user_y.tag(@taggable, :with => '', :on => :tags)
96
97
  end
97
98
 
98
99
  it "should delete owned tags" do
99
- @user_y.owned_tags.should be_empty
100
+ @user_y.owned_tags.should == []
100
101
  end
101
102
 
102
103
  it "should not delete other taggers tags" do
@@ -1,6 +1,9 @@
1
1
  require File.dirname(__FILE__) + '/../spec_helper'
2
2
 
3
3
  describe "Group Helper" do
4
+ before(:each) do
5
+ clean_database!
6
+ end
4
7
 
5
8
  describe "grouped_column_names_for method" do
6
9
  before(:each) do
@@ -2,9 +2,9 @@ require File.dirname(__FILE__) + '/../spec_helper'
2
2
 
3
3
  describe Tag do
4
4
  before(:each) do
5
+ clean_database!
5
6
  @tag = Tag.new
6
- @user = TaggableModel.create(:name => "Pablo")
7
- Tag.delete_all
7
+ @user = TaggableModel.create(:name => "Pablo")
8
8
  end
9
9
 
10
10
  describe "named like any" do
@@ -2,7 +2,7 @@ require File.dirname(__FILE__) + '/../spec_helper'
2
2
 
3
3
  describe "Taggable" do
4
4
  before(:each) do
5
- [TaggableModel, Tag, Tagging, TaggableUser].each(&:delete_all)
5
+ clean_database!
6
6
  @taggable = TaggableModel.new(:name => "Bob Jones")
7
7
  end
8
8
 
@@ -247,5 +247,15 @@ describe "Taggable" do
247
247
  AlteredInheritingTaggableModel.tag_counts_on(:tags).map(&:name).should == %w(fork spoon)
248
248
  TaggableModel.tag_counts_on(:tags).map(&:name).should == %w(bob kelso fork spoon)
249
249
  end
250
+
251
+ it 'should store same tag without validation conflict' do
252
+ @taggable.tag_list = 'one'
253
+ @taggable.save!
254
+
255
+ @inherited_same.tag_list = 'one'
256
+ @inherited_same.save!
257
+
258
+ @inherited_same.update_attributes! :name => 'foo'
259
+ end
250
260
  end
251
261
  end
@@ -2,7 +2,7 @@ require File.dirname(__FILE__) + '/../spec_helper'
2
2
 
3
3
  describe "Tagger" do
4
4
  before(:each) do
5
- [TaggableModel, Tag, Tagging, TaggableUser].each(&:delete_all)
5
+ clean_database!
6
6
  @user = TaggableUser.new
7
7
  @taggable = TaggableModel.new(:name => "Bob Jones")
8
8
  end
@@ -2,6 +2,7 @@ require File.dirname(__FILE__) + '/../spec_helper'
2
2
 
3
3
  describe Tagging do
4
4
  before(:each) do
5
+ clean_database!
5
6
  @tagging = Tagging.new
6
7
  end
7
8
 
@@ -2,7 +2,7 @@ require File.dirname(__FILE__) + '/../spec_helper'
2
2
 
3
3
  describe TagsHelper do
4
4
  before(:each) do
5
- [TaggableModel, Tag, Tagging].each(&:delete_all)
5
+ clean_database!
6
6
 
7
7
  @bob = TaggableModel.create(:name => "Bob Jones", :language_list => "ruby, php")
8
8
  @tom = TaggableModel.create(:name => "Tom Marley", :language_list => "ruby, java")
@@ -56,4 +56,13 @@ class TaggableUser < ActiveRecord::Base
56
56
  end
57
57
 
58
58
  class UntaggableModel < ActiveRecord::Base
59
+ end
60
+
61
+ def clean_database!
62
+ $debug = false
63
+ models = [Tag, Tagging, TaggableModel, OtherTaggableModel, InheritingTaggableModel,
64
+ AlteredInheritingTaggableModel, TaggableUser]
65
+ models.each do |model|
66
+ model.destroy_all
67
+ end
59
68
  end
metadata CHANGED
@@ -1,7 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: acts-as-taggable-on
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.5
4
+ prerelease: false
5
+ segments:
6
+ - 1
7
+ - 1
8
+ - 6
9
+ version: 1.1.6
5
10
  platform: ruby
6
11
  authors:
7
12
  - Michael Bleigh
@@ -9,7 +14,7 @@ autorequire:
9
14
  bindir: bin
10
15
  cert_chain: []
11
16
 
12
- date: 2010-02-13 00:00:00 +01:00
17
+ date: 2010-02-27 00:00:00 +01:00
13
18
  default_executable:
14
19
  dependencies: []
15
20
 
@@ -63,18 +68,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
63
68
  requirements:
64
69
  - - ">="
65
70
  - !ruby/object:Gem::Version
71
+ segments:
72
+ - 0
66
73
  version: "0"
67
- version:
68
74
  required_rubygems_version: !ruby/object:Gem::Requirement
69
75
  requirements:
70
76
  - - ">="
71
77
  - !ruby/object:Gem::Version
78
+ segments:
79
+ - 0
72
80
  version: "0"
73
- version:
74
81
  requirements: []
75
82
 
76
83
  rubyforge_project:
77
- rubygems_version: 1.3.5
84
+ rubygems_version: 1.3.6
78
85
  signing_key:
79
86
  specification_version: 3
80
87
  summary: ActsAsTaggableOn is a tagging plugin for Rails that provides multiple tagging contexts on a single model.