acts-as-taggable-on 1.1.6 → 1.1.7
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +10 -0
- data/VERSION +1 -1
- data/lib/acts_as_taggable_on/acts_as_taggable_on.rb +2 -11
- data/lib/acts_as_taggable_on/tag.rb +1 -1
- data/spec/acts_as_taggable_on/group_helper_spec.rb +1 -1
- data/spec/acts_as_taggable_on/taggable_spec.rb +14 -3
- data/spec/schema.rb +4 -2
- data/spec/spec_helper.rb +3 -2
- metadata +3 -3
data/README.rdoc
CHANGED
@@ -31,6 +31,16 @@ To install the gem, add this to your config/environment.rb:
|
|
31
31
|
|
32
32
|
After that, you can run "rake gems:install" to install the gem if you don't already have it.
|
33
33
|
|
34
|
+
== Rails 3.0
|
35
|
+
|
36
|
+
Acts As Taggable On is now useable in Rails 3.0, thanks to the excellent work of Szymon Nowak
|
37
|
+
and Jelle Vandebeeck. Because backwards compatibility is hard to maintain, their work is available
|
38
|
+
in the feature/rails3_compatibility branch.
|
39
|
+
|
40
|
+
A Rails 3.0 compatible version of the gem is also available:
|
41
|
+
|
42
|
+
gem install acts-as-taggable-on -v=2.0.0.pre1
|
43
|
+
|
34
44
|
=== Post Installation (Rails)
|
35
45
|
|
36
46
|
1. script/generate acts_as_taggable_on_migration
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.1.
|
1
|
+
1.1.7
|
@@ -106,7 +106,6 @@ module ActiveRecord
|
|
106
106
|
|
107
107
|
include ActiveRecord::Acts::TaggableOn::InstanceMethods
|
108
108
|
extend ActiveRecord::Acts::TaggableOn::SingletonMethods
|
109
|
-
alias_method_chain :reload, :tag_list
|
110
109
|
end
|
111
110
|
end
|
112
111
|
end
|
@@ -383,8 +382,8 @@ module ActiveRecord
|
|
383
382
|
|
384
383
|
def save_cached_tag_list
|
385
384
|
self.class.tag_types.map(&:to_s).each do |tag_type|
|
386
|
-
if self.class.send("caching_#{tag_type.singularize}_list?")
|
387
|
-
|
385
|
+
if self.class.send("caching_#{tag_type.singularize}_list?")
|
386
|
+
send(:"cached_#{tag_type.singularize}_list=", tag_list_cache_on(tag_type.singularize).to_a.flatten.compact.join(', '))
|
388
387
|
end
|
389
388
|
end
|
390
389
|
end
|
@@ -429,14 +428,6 @@ module ActiveRecord
|
|
429
428
|
|
430
429
|
true
|
431
430
|
end
|
432
|
-
|
433
|
-
def reload_with_tag_list(*args)
|
434
|
-
self.class.tag_types.each do |tag_type|
|
435
|
-
instance_variable_set("@#{tag_type.to_s.singularize}_list", nil)
|
436
|
-
end
|
437
|
-
|
438
|
-
reload_without_tag_list(*args)
|
439
|
-
end
|
440
431
|
end
|
441
432
|
end
|
442
433
|
end
|
@@ -30,7 +30,7 @@ class Tag < ActiveRecord::Base
|
|
30
30
|
return [] if list.empty?
|
31
31
|
|
32
32
|
existing_tags = Tag.named_any(list).all
|
33
|
-
new_tag_names = list.reject { |name| existing_tags.any? { |tag| tag.name.downcase == name.downcase } }
|
33
|
+
new_tag_names = list.reject { |name| existing_tags.any? { |tag| tag.name.mb_chars.downcase == name.mb_chars.downcase } }
|
34
34
|
created_tags = new_tag_names.map { |name| Tag.create(:name => name) }
|
35
35
|
|
36
36
|
existing_tags + created_tags
|
@@ -15,7 +15,7 @@ describe "Group Helper" do
|
|
15
15
|
end
|
16
16
|
|
17
17
|
it "should return all column names joined for TaggableModel GROUP clause" do
|
18
|
-
@taggable.grouped_column_names_for(TaggableModel).should == "taggable_models.id, taggable_models.name, taggable_models.type"
|
18
|
+
@taggable.grouped_column_names_for(TaggableModel).should == "taggable_models.id, taggable_models.name, taggable_models.type, taggable_models.cached_tag_list"
|
19
19
|
end
|
20
20
|
end
|
21
21
|
end
|
@@ -19,8 +19,8 @@ describe "Taggable" do
|
|
19
19
|
@taggable.tag_list = ["awesome", "epic"]
|
20
20
|
@taggable.save
|
21
21
|
|
22
|
-
TaggableModel.tag_counts_on(:tags).
|
23
|
-
@taggable.tag_counts_on(:tags).
|
22
|
+
TaggableModel.tag_counts_on(:tags).length.should == 2
|
23
|
+
@taggable.tag_counts_on(:tags).length.should == 2
|
24
24
|
end
|
25
25
|
|
26
26
|
it "should be able to create tags" do
|
@@ -210,9 +210,20 @@ describe "Taggable" do
|
|
210
210
|
}.should change(Tagging, :count).by(1)
|
211
211
|
end
|
212
212
|
|
213
|
+
describe "Associations" do
|
214
|
+
before(:each) do
|
215
|
+
@taggable = TaggableModel.create(:tag_list => "awesome, epic")
|
216
|
+
end
|
217
|
+
|
218
|
+
it "should not remove tags when creating associated objects" do
|
219
|
+
@taggable.untaggable_models.create!
|
220
|
+
@taggable.reload
|
221
|
+
@taggable.tag_list.should have(2).items
|
222
|
+
end
|
223
|
+
end
|
224
|
+
|
213
225
|
describe "Single Table Inheritance" do
|
214
226
|
before do
|
215
|
-
[TaggableModel, Tag, Tagging, TaggableUser].each(&:delete_all)
|
216
227
|
@taggable = TaggableModel.new(:name => "taggable")
|
217
228
|
@inherited_same = InheritingTaggableModel.new(:name => "inherited same")
|
218
229
|
@inherited_different = AlteredInheritingTaggableModel.new(:name => "inherited different")
|
data/spec/schema.rb
CHANGED
@@ -19,7 +19,10 @@ ActiveRecord::Schema.define :version => 0 do
|
|
19
19
|
create_table :taggable_models, :force => true do |t|
|
20
20
|
t.column :name, :string
|
21
21
|
t.column :type, :string
|
22
|
-
|
22
|
+
t.column :cached_tag_list, :string
|
23
|
+
end
|
24
|
+
create_table :untaggable_models, :force => true do |t|
|
25
|
+
t.column :taggable_model_id, :integer
|
23
26
|
end
|
24
27
|
create_table :taggable_users, :force => true do |t|
|
25
28
|
t.column :name, :string
|
@@ -27,6 +30,5 @@ ActiveRecord::Schema.define :version => 0 do
|
|
27
30
|
create_table :other_taggable_models, :force => true do |t|
|
28
31
|
t.column :name, :string
|
29
32
|
t.column :type, :string
|
30
|
-
#t.column :cached_tag_list, :string
|
31
33
|
end
|
32
34
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -22,7 +22,7 @@ ActiveRecord::Base.establish_connection(
|
|
22
22
|
"adapter" => "sqlite3", "database" => TEST_DATABASE_FILE
|
23
23
|
)
|
24
24
|
|
25
|
-
|
25
|
+
ActiveRecord::Base.logger = Logger.new(File.join(File.dirname(__FILE__), "debug.log"))
|
26
26
|
|
27
27
|
ActiveRecord::Base.silence do
|
28
28
|
ActiveRecord::Migration.verbose = false
|
@@ -37,6 +37,7 @@ class TaggableModel < ActiveRecord::Base
|
|
37
37
|
acts_as_taggable_on :languages
|
38
38
|
acts_as_taggable_on :skills
|
39
39
|
acts_as_taggable_on :needs, :offerings
|
40
|
+
has_many :untaggable_models
|
40
41
|
end
|
41
42
|
|
42
43
|
class OtherTaggableModel < ActiveRecord::Base
|
@@ -56,10 +57,10 @@ class TaggableUser < ActiveRecord::Base
|
|
56
57
|
end
|
57
58
|
|
58
59
|
class UntaggableModel < ActiveRecord::Base
|
60
|
+
belongs_to :taggable_model, :touch => true
|
59
61
|
end
|
60
62
|
|
61
63
|
def clean_database!
|
62
|
-
$debug = false
|
63
64
|
models = [Tag, Tagging, TaggableModel, OtherTaggableModel, InheritingTaggableModel,
|
64
65
|
AlteredInheritingTaggableModel, TaggableUser]
|
65
66
|
models.each do |model|
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 1
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 1.1.
|
8
|
+
- 7
|
9
|
+
version: 1.1.7
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Michael Bleigh
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-
|
17
|
+
date: 2010-03-08 00:00:00 +01:00
|
18
18
|
default_executable:
|
19
19
|
dependencies: []
|
20
20
|
|