acts-as-taggable-on 1.0.7 → 1.0.8

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.7
1
+ 1.0.8
@@ -141,8 +141,8 @@ module ActiveRecord
141
141
 
142
142
 
143
143
  if options.delete(:exclude)
144
- tags_conditions = "(" + tags.map { |t| sanitize_sql(["#{Tag.table_name}.name LIKE ?", t]) }.join(" OR ") + ")"
145
- conditions << "#{table_name}.#{primary_key} NOT IN (SELECT #{Tagging.table_name}.taggable_id FROM #{Tagging.table_name} JOIN #{Tag.table_name} ON #{Tagging.table_name}.tag_id = #{Tag.table_name}.id AND #{tags_conditions} WHERE #{Tagging.table_name}.taggable_type = #{quote_value(base_class.name)})"
144
+ tags_conditions = tags.map { |t| sanitize_sql(["#{Tag.table_name}.name LIKE ?", t]) }.join(" OR ")
145
+ conditions << "#{table_name}.#{primary_key} NOT IN (SELECT #{Tagging.table_name}.taggable_id FROM #{Tagging.table_name} JOIN #{Tag.table_name} ON #{Tagging.table_name}.tag_id = #{Tag.table_name}.id AND (#{tags_conditions}) WHERE #{Tagging.table_name}.taggable_type = #{quote_value(base_class.name)})"
146
146
 
147
147
  else
148
148
  tags.each do |tag|
@@ -277,10 +277,10 @@ module ActiveRecord
277
277
 
278
278
  def tags_on(context, owner=nil)
279
279
  if owner
280
- opts = {:conditions => ["context = ? AND tagger_id = ? AND tagger_type = ?",
280
+ opts = {:conditions => ["#{Tagging.table_name}.context = ? AND #{Tagging.table_name}.tagger_id = ? AND #{Tagging.table_name}.tagger_type = ?",
281
281
  context.to_s, owner.id, owner.class.to_s]}
282
282
  else
283
- opts = {:conditions => ["context = ?", context.to_s]}
283
+ opts = {:conditions => ["#{Tagging.table_name}.context = ?", context.to_s]}
284
284
  end
285
285
  base_tags.find(:all, opts)
286
286
  end
@@ -60,7 +60,8 @@ describe "Taggable" do
60
60
  @taggable.skill_list = "ruby, rails, css"
61
61
  @taggable.tag_list = "bob, charlie"
62
62
  @taggable.save
63
- TaggableModel.tagged_with("ruby", {}).first.should == @taggable
63
+
64
+ TaggableModel.tagged_with("ruby").first.should == @taggable
64
65
  TaggableModel.tagged_with("bob", :on => :skills).first.should_not == @taggable
65
66
  TaggableModel.tagged_with("bob", :on => :tags).first.should == @taggable
66
67
  end
@@ -98,12 +99,22 @@ describe "Taggable" do
98
99
  bob.tags_on(:rotors).should_not be_empty
99
100
  end
100
101
 
102
+ it "should be able to find tagged" do
103
+ bob = TaggableModel.create(:name => "Bob", :tag_list => "fitter, happier, more productive", :skill_list => "ruby, rails, css")
104
+ frank = TaggableModel.create(:name => "Frank", :tag_list => "weaker, depressed, inefficient", :skill_list => "ruby, rails, css")
105
+ steve = TaggableModel.create(:name => 'Steve', :tag_list => 'fitter, happier, more productive', :skill_list => 'c++, java, ruby')
106
+
107
+ TaggableModel.find_tagged_with("ruby", :order => 'taggable_models.name').should == [bob, frank, steve]
108
+ TaggableModel.find_tagged_with("ruby, rails", :order => 'taggable_models.name').should == [bob, frank]
109
+ TaggableModel.find_tagged_with(["ruby", "rails"], :order => 'taggable_models.name').should == [bob, frank]
110
+ end
111
+
101
112
  it "should be able to find tagged on a custom tag context" do
102
113
  bob = TaggableModel.create(:name => "Bob")
103
114
  bob.set_tag_list_on(:rotors, "spinning, jumping")
104
115
  bob.tag_list_on(:rotors).should == ["spinning","jumping"]
105
116
  bob.save
106
- TaggableModel.find_tagged_with("spinning", :on => :rotors).should_not be_empty
117
+ TaggableModel.find_tagged_with("spinning", :on => :rotors).should == [bob]
107
118
  end
108
119
 
109
120
  it "should be able to use named scopes to chain tag finds" do
@@ -112,9 +123,10 @@ describe "Taggable" do
112
123
  steve = TaggableModel.create(:name => 'Steve', :tag_list => 'fitter, happier, more productive', :skill_list => 'c++, java, python')
113
124
 
114
125
  # Let's only find those productive Rails developers
115
- TaggableModel.tagged_with('rails', :on => :skills).all(:order => 'taggable_models.name').should == [bob, frank]
116
- TaggableModel.tagged_with('happier', :on => :tags).all(:order => 'taggable_models.name').should == [bob, steve]
126
+ TaggableModel.tagged_with('rails', :on => :skills, :order => 'taggable_models.name').should == [bob, frank]
127
+ TaggableModel.tagged_with('happier', :on => :tags, :order => 'taggable_models.name').should == [bob, steve]
117
128
  TaggableModel.tagged_with('rails', :on => :skills).tagged_with('happier', :on => :tags).should == [bob]
129
+ TaggableModel.tagged_with('rails').tagged_with('happier', :on => :tags).should == [bob]
118
130
  end
119
131
 
120
132
  it "should be able to find tagged with only the matching tags" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: acts-as-taggable-on
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.7
4
+ version: 1.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Bleigh
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-11-12 00:00:00 -05:00
12
+ date: 2009-11-13 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies: []
15
15