acts-as-taggable-on 3.1.1 → 3.2.1

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.
Files changed (72) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -1
  3. data/.travis.yml +9 -7
  4. data/Appraisals +13 -8
  5. data/CHANGELOG.md +8 -0
  6. data/Gemfile +1 -2
  7. data/README.md +23 -13
  8. data/Rakefile +5 -17
  9. data/UPGRADING.md +6 -0
  10. data/acts-as-taggable-on.gemspec +13 -13
  11. data/db/migrate/1_acts_as_taggable_on_migration.rb +3 -3
  12. data/db/migrate/2_add_missing_unique_indices.rb +3 -5
  13. data/db/migrate/3_add_taggings_counter_cache_to_tags.rb +1 -1
  14. data/gemfiles/activerecord_3.2.gemfile +15 -0
  15. data/gemfiles/activerecord_4.0.gemfile +15 -0
  16. data/gemfiles/activerecord_4.1.gemfile +15 -0
  17. data/gemfiles/activerecord_edge.gemfile +16 -0
  18. data/lib/acts-as-taggable-on.rb +23 -21
  19. data/lib/acts_as_taggable_on/acts_as_taggable_on/cache.rb +1 -4
  20. data/lib/acts_as_taggable_on/acts_as_taggable_on/collection.rb +29 -20
  21. data/lib/acts_as_taggable_on/acts_as_taggable_on/compatibility.rb +11 -10
  22. data/lib/acts_as_taggable_on/acts_as_taggable_on/core.rb +98 -80
  23. data/lib/acts_as_taggable_on/acts_as_taggable_on/ownership.rb +5 -12
  24. data/lib/acts_as_taggable_on/acts_as_taggable_on/related.rb +7 -7
  25. data/lib/acts_as_taggable_on/engine.rb +0 -1
  26. data/lib/acts_as_taggable_on/tag.rb +24 -19
  27. data/lib/acts_as_taggable_on/tag_list.rb +95 -21
  28. data/lib/acts_as_taggable_on/taggable.rb +28 -30
  29. data/lib/acts_as_taggable_on/tagger.rb +30 -18
  30. data/lib/acts_as_taggable_on/tagging.rb +7 -8
  31. data/lib/acts_as_taggable_on/tags_helper.rb +1 -1
  32. data/lib/acts_as_taggable_on/utils.rb +25 -3
  33. data/lib/acts_as_taggable_on/version.rb +1 -1
  34. data/spec/acts_as_taggable_on/acts_as_taggable_on_spec.rb +133 -138
  35. data/spec/acts_as_taggable_on/acts_as_tagger_spec.rb +55 -58
  36. data/spec/acts_as_taggable_on/caching_spec.rb +34 -35
  37. data/spec/acts_as_taggable_on/related_spec.rb +59 -113
  38. data/spec/acts_as_taggable_on/single_table_inheritance_spec.rb +118 -95
  39. data/spec/acts_as_taggable_on/tag_list_spec.rb +89 -57
  40. data/spec/acts_as_taggable_on/tag_spec.rb +125 -114
  41. data/spec/acts_as_taggable_on/taggable_spec.rb +538 -352
  42. data/spec/acts_as_taggable_on/tagger_spec.rb +81 -78
  43. data/spec/acts_as_taggable_on/tagging_spec.rb +13 -14
  44. data/spec/acts_as_taggable_on/tags_helper_spec.rb +25 -25
  45. data/spec/acts_as_taggable_on/utils_spec.rb +9 -9
  46. data/spec/internal/app/models/altered_inheriting_taggable_model.rb +3 -0
  47. data/spec/internal/app/models/cached_model.rb +3 -0
  48. data/spec/internal/app/models/cached_model_with_array.rb +5 -0
  49. data/spec/internal/app/models/company.rb +15 -0
  50. data/spec/internal/app/models/inheriting_taggable_model.rb +2 -0
  51. data/spec/internal/app/models/market.rb +2 -0
  52. data/spec/{models.rb → internal/app/models/models.rb} +34 -2
  53. data/spec/internal/app/models/non_standard_id_taggable_model.rb +8 -0
  54. data/spec/internal/app/models/ordered_taggable_model.rb +4 -0
  55. data/spec/internal/app/models/other_cached_model.rb +3 -0
  56. data/spec/internal/app/models/other_taggable_model.rb +4 -0
  57. data/spec/internal/app/models/student.rb +2 -0
  58. data/spec/internal/app/models/taggable_model.rb +13 -0
  59. data/spec/internal/app/models/untaggable_model.rb +3 -0
  60. data/spec/internal/app/models/user.rb +3 -0
  61. data/spec/{database.yml.sample → internal/config/database.yml.sample} +2 -2
  62. data/spec/internal/db/schema.rb +97 -0
  63. data/spec/schema.rb +11 -0
  64. data/spec/spec_helper.rb +9 -62
  65. data/spec/support/array.rb +9 -0
  66. data/spec/support/database.rb +42 -0
  67. data/spec/support/database_cleaner.rb +17 -0
  68. metadata +101 -37
  69. data/gemfiles/rails_3.2.gemfile +0 -7
  70. data/gemfiles/rails_4.0.gemfile +0 -7
  71. data/gemfiles/rails_4.1.gemfile +0 -7
  72. data/gemfiles/rails_edge.gemfile +0 -7
@@ -1,137 +1,140 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe "Tagger" do
3
+ describe 'Tagger' do
4
4
  before(:each) do
5
- clean_database!
6
5
  @user = User.create
7
- @taggable = TaggableModel.create(:name => "Bob Jones")
6
+ @taggable = TaggableModel.create(name: 'Bob Jones')
8
7
  end
9
8
 
10
- it "should have taggings" do
11
- @user.tag(@taggable, :with=>'ruby,scheme', :on=>:tags)
12
- @user.owned_taggings.size == 2
9
+
10
+
11
+ it 'should have taggings' do
12
+ @user.tag(@taggable, with: 'ruby,scheme', on: :tags)
13
+ expect(@user.owned_taggings.size).to eq(2)
13
14
  end
14
15
 
15
- it "should have tags" do
16
- @user.tag(@taggable, :with=>'ruby,scheme', :on=>:tags)
17
- @user.owned_tags.size == 2
16
+ it 'should have tags' do
17
+ @user.tag(@taggable, with: 'ruby,scheme', on: :tags)
18
+ expect(@user.owned_tags.size).to eq(2)
18
19
  end
19
20
 
20
- it "should scope objects returned by tagged_with by owners" do
21
- @taggable2 = TaggableModel.create(:name => "Jim Jones")
22
- @taggable3 = TaggableModel.create(:name => "Jane Doe")
21
+ it 'should scope objects returned by tagged_with by owners' do
22
+ @taggable2 = TaggableModel.create(name: 'Jim Jones')
23
+ @taggable3 = TaggableModel.create(name: 'Jane Doe')
23
24
 
24
25
  @user2 = User.new
25
- @user.tag(@taggable, :with => 'ruby, scheme', :on => :tags)
26
- @user2.tag(@taggable2, :with => 'ruby, scheme', :on => :tags)
27
- @user2.tag(@taggable3, :with => 'ruby, scheme', :on => :tags)
26
+ @user.tag(@taggable, with: 'ruby, scheme', on: :tags)
27
+ @user2.tag(@taggable2, with: 'ruby, scheme', on: :tags)
28
+ @user2.tag(@taggable3, with: 'ruby, scheme', on: :tags)
28
29
 
29
- TaggableModel.tagged_with(%w(ruby scheme), :owned_by => @user).count.should == 1
30
- TaggableModel.tagged_with(%w(ruby scheme), :owned_by => @user2).count.should == 2
30
+ expect(TaggableModel.tagged_with(%w(ruby scheme), owned_by: @user).count).to eq(1)
31
+ expect(TaggableModel.tagged_with(%w(ruby scheme), owned_by: @user2).count).to eq(2)
31
32
  end
32
33
 
33
- it "only returns objects tagged by owned_by when any is true" do
34
+ it 'only returns objects tagged by owned_by when any is true' do
34
35
  @user2 = User.new
35
- @taggable2 = TaggableModel.create(:name => "Jim Jones")
36
- @taggable3 = TaggableModel.create(:name => "Jane Doe")
36
+ @taggable2 = TaggableModel.create(name: 'Jim Jones')
37
+ @taggable3 = TaggableModel.create(name: 'Jane Doe')
38
+
39
+ @user.tag(@taggable, with: 'ruby', on: :tags)
40
+ @user.tag(@taggable2, with: 'java', on: :tags)
41
+ @user2.tag(@taggable3, with: 'ruby', on: :tags)
37
42
 
38
- @user.tag(@taggable, :with => 'ruby', :on => :tags)
39
- @user.tag(@taggable2, :with => 'java', :on => :tags)
40
- @user2.tag(@taggable3, :with => 'ruby', :on => :tags)
43
+ tags = TaggableModel.tagged_with(%w(ruby java), owned_by: @user, any: true)
44
+ expect(tags).to include(@taggable, @taggable2)
45
+ expect(tags.size).to eq(2)
41
46
 
42
- tags = TaggableModel.tagged_with(%w(ruby java), :owned_by => @user, :any => true)
43
- tags.should match_array [@taggable, @taggable2]
44
47
  end
45
48
 
46
- it "only returns objects tagged by owned_by when exclude is true" do
49
+ it 'only returns objects tagged by owned_by when exclude is true' do
47
50
  @user2 = User.new
48
- @taggable2 = TaggableModel.create(:name => "Jim Jones")
49
- @taggable3 = TaggableModel.create(:name => "Jane Doe")
51
+ @taggable2 = TaggableModel.create(name: 'Jim Jones')
52
+ @taggable3 = TaggableModel.create(name: 'Jane Doe')
50
53
 
51
- @user.tag(@taggable, :with => 'ruby', :on => :tags)
52
- @user.tag(@taggable2, :with => 'java', :on => :tags)
53
- @user2.tag(@taggable3, :with => 'java', :on => :tags)
54
+ @user.tag(@taggable, with: 'ruby', on: :tags)
55
+ @user.tag(@taggable2, with: 'java', on: :tags)
56
+ @user2.tag(@taggable3, with: 'java', on: :tags)
54
57
 
55
- tags = TaggableModel.tagged_with(%w(ruby), :owned_by => @user, :exclude => true)
56
- tags.should match_array [@taggable2]
58
+ tags = TaggableModel.tagged_with(%w(ruby), owned_by: @user, exclude: true)
59
+ expect(tags).to eq([@taggable2])
57
60
  end
58
61
 
59
- it "should not overlap tags from different taggers" do
62
+ it 'should not overlap tags from different taggers' do
60
63
  @user2 = User.new
61
- lambda{
62
- @user.tag(@taggable, :with => 'ruby, scheme', :on => :tags)
63
- @user2.tag(@taggable, :with => 'java, python, lisp, ruby', :on => :tags)
64
- }.should change(ActsAsTaggableOn::Tagging, :count).by(6)
64
+ expect(-> {
65
+ @user.tag(@taggable, with: 'ruby, scheme', on: :tags)
66
+ @user2.tag(@taggable, with: 'java, python, lisp, ruby', on: :tags)
67
+ }).to change(ActsAsTaggableOn::Tagging, :count).by(6)
65
68
 
66
69
  [@user, @user2, @taggable].each(&:reload)
67
70
 
68
- @user.owned_tags.map(&:name).sort.should == %w(ruby scheme).sort
69
- @user2.owned_tags.map(&:name).sort.should == %w(java python lisp ruby).sort
71
+ expect(@user.owned_tags.map(&:name).sort).to eq(%w(ruby scheme).sort)
72
+ expect(@user2.owned_tags.map(&:name).sort).to eq(%w(java python lisp ruby).sort)
70
73
 
71
- @taggable.tags_from(@user).sort.should == %w(ruby scheme).sort
72
- @taggable.tags_from(@user2).sort.should == %w(java lisp python ruby).sort
74
+ expect(@taggable.tags_from(@user).sort).to eq(%w(ruby scheme).sort)
75
+ expect(@taggable.tags_from(@user2).sort).to eq(%w(java lisp python ruby).sort)
73
76
 
74
- @taggable.all_tags_list.sort.should == %w(ruby scheme java python lisp).sort
75
- @taggable.all_tags_on(:tags).size.should == 5
77
+ expect(@taggable.all_tags_list.sort).to eq(%w(ruby scheme java python lisp).sort)
78
+ expect(@taggable.all_tags_on(:tags).size).to eq(5)
76
79
  end
77
80
 
78
- it "should not lose tags from different taggers" do
81
+ it 'should not lose tags from different taggers' do
79
82
  @user2 = User.create
80
- @user2.tag(@taggable, :with => 'java, python, lisp, ruby', :on => :tags)
81
- @user.tag(@taggable, :with => 'ruby, scheme', :on => :tags)
83
+ @user2.tag(@taggable, with: 'java, python, lisp, ruby', on: :tags)
84
+ @user.tag(@taggable, with: 'ruby, scheme', on: :tags)
82
85
 
83
- lambda {
84
- @user2.tag(@taggable, :with => 'java, python, lisp', :on => :tags)
85
- }.should change(ActsAsTaggableOn::Tagging, :count).by(-1)
86
+ expect(-> {
87
+ @user2.tag(@taggable, with: 'java, python, lisp', on: :tags)
88
+ }).to change(ActsAsTaggableOn::Tagging, :count).by(-1)
86
89
 
87
90
  [@user, @user2, @taggable].each(&:reload)
88
91
 
89
- @taggable.tags_from(@user).sort.should == %w(ruby scheme).sort
90
- @taggable.tags_from(@user2).sort.should == %w(java python lisp).sort
92
+ expect(@taggable.tags_from(@user).sort).to eq(%w(ruby scheme).sort)
93
+ expect(@taggable.tags_from(@user2).sort).to eq(%w(java python lisp).sort)
91
94
 
92
- @taggable.all_tags_list.sort.should == %w(ruby scheme java python lisp).sort
93
- @taggable.all_tags_on(:tags).length.should == 5
95
+ expect(@taggable.all_tags_list.sort).to eq(%w(ruby scheme java python lisp).sort)
96
+ expect(@taggable.all_tags_on(:tags).length).to eq(5)
94
97
  end
95
98
 
96
- it "should not lose tags" do
99
+ it 'should not lose tags' do
97
100
  @user2 = User.create
98
101
 
99
- @user.tag(@taggable, :with => 'awesome', :on => :tags)
100
- @user2.tag(@taggable, :with => 'awesome, epic', :on => :tags)
102
+ @user.tag(@taggable, with: 'awesome', on: :tags)
103
+ @user2.tag(@taggable, with: 'awesome, epic', on: :tags)
101
104
 
102
- lambda {
103
- @user2.tag(@taggable, :with => 'epic', :on => :tags)
104
- }.should change(ActsAsTaggableOn::Tagging, :count).by(-1)
105
+ expect(-> {
106
+ @user2.tag(@taggable, with: 'epic', on: :tags)
107
+ }).to change(ActsAsTaggableOn::Tagging, :count).by(-1)
105
108
 
106
109
  @taggable.reload
107
- @taggable.all_tags_list.should include('awesome')
108
- @taggable.all_tags_list.should include('epic')
110
+ expect(@taggable.all_tags_list).to include('awesome')
111
+ expect(@taggable.all_tags_list).to include('epic')
109
112
  end
110
113
 
111
- it "should not lose tags" do
112
- @taggable.update_attributes(:tag_list => 'ruby')
113
- @user.tag(@taggable, :with => 'ruby, scheme', :on => :tags)
114
+ it 'should not lose tags' do
115
+ @taggable.update_attributes(tag_list: 'ruby')
116
+ @user.tag(@taggable, with: 'ruby, scheme', on: :tags)
114
117
 
115
118
  [@taggable, @user].each(&:reload)
116
- @taggable.tag_list.should == %w(ruby)
117
- @taggable.all_tags_list.sort.should == %w(ruby scheme).sort
119
+ expect(@taggable.tag_list).to eq(%w(ruby))
120
+ expect(@taggable.all_tags_list.sort).to eq(%w(ruby scheme).sort)
118
121
 
119
- lambda {
120
- @taggable.update_attributes(:tag_list => "")
121
- }.should change(ActsAsTaggableOn::Tagging, :count).by(-1)
122
+ expect(-> {
123
+ @taggable.update_attributes(tag_list: '')
124
+ }).to change(ActsAsTaggableOn::Tagging, :count).by(-1)
122
125
 
123
- @taggable.tag_list.should == []
124
- @taggable.all_tags_list.sort.should == %w(ruby scheme).sort
126
+ expect(@taggable.tag_list).to be_empty
127
+ expect(@taggable.all_tags_list.sort).to eq(%w(ruby scheme).sort)
125
128
  end
126
129
 
127
- it "is tagger" do
128
- @user.is_tagger?.should(be_true)
130
+ it 'is tagger' do
131
+ expect(@user.is_tagger?).to be_truthy
129
132
  end
130
133
 
131
- it "should skip save if skip_save is passed as option" do
132
- lambda {
133
- @user.tag(@taggable, :with => 'epic', :on => :tags, :skip_save => true)
134
- }.should_not change(ActsAsTaggableOn::Tagging, :count)
134
+ it 'should skip save if skip_save is passed as option' do
135
+ expect(-> {
136
+ @user.tag(@taggable, with: 'epic', on: :tags, skip_save: true)
137
+ }).to_not change(ActsAsTaggableOn::Tagging, :count)
135
138
  end
136
139
 
137
140
  end
@@ -2,27 +2,26 @@ require 'spec_helper'
2
2
 
3
3
  describe ActsAsTaggableOn::Tagging do
4
4
  before(:each) do
5
- clean_database!
6
5
  @tagging = ActsAsTaggableOn::Tagging.new
7
6
  end
8
7
 
9
- it "should not be valid with a invalid tag" do
10
- @tagging.taggable = TaggableModel.create(:name => "Bob Jones")
11
- @tagging.tag = ActsAsTaggableOn::Tag.new(:name => "")
12
- @tagging.context = "tags"
8
+ it 'should not be valid with a invalid tag' do
9
+ @tagging.taggable = TaggableModel.create(name: 'Bob Jones')
10
+ @tagging.tag = ActsAsTaggableOn::Tag.new(name: '')
11
+ @tagging.context = 'tags'
13
12
 
14
- @tagging.should_not be_valid
15
-
16
- @tagging.errors[:tag_id].should == ["can't be blank"]
13
+ expect(@tagging).to_not be_valid
14
+
15
+ expect(@tagging.errors[:tag_id]).to eq(['can\'t be blank'])
17
16
  end
18
17
 
19
- it "should not create duplicate taggings" do
20
- @taggable = TaggableModel.create(:name => "Bob Jones")
21
- @tag = ActsAsTaggableOn::Tag.create(:name => "awesome")
18
+ it 'should not create duplicate taggings' do
19
+ @taggable = TaggableModel.create(name: 'Bob Jones')
20
+ @tag = ActsAsTaggableOn::Tag.create(name: 'awesome')
22
21
 
23
- lambda {
24
- 2.times { ActsAsTaggableOn::Tagging.create(:taggable => @taggable, :tag => @tag, :context => 'tags') }
25
- }.should change(ActsAsTaggableOn::Tagging, :count).by(1)
22
+ expect(-> {
23
+ 2.times { ActsAsTaggableOn::Tagging.create(taggable: @taggable, tag: @tag, context: 'tags') }
24
+ }).to change(ActsAsTaggableOn::Tagging, :count).by(1)
26
25
  end
27
26
 
28
27
  end
@@ -2,43 +2,43 @@ require 'spec_helper'
2
2
 
3
3
  describe ActsAsTaggableOn::TagsHelper do
4
4
  before(:each) do
5
- clean_database!
6
-
7
- @bob = TaggableModel.create(:name => "Bob Jones", :language_list => "ruby, php")
8
- @tom = TaggableModel.create(:name => "Tom Marley", :language_list => "ruby, java")
9
- @eve = TaggableModel.create(:name => "Eve Nodd", :language_list => "ruby, c++")
10
-
11
- @helper = class Helper
12
- include ActsAsTaggableOn::TagsHelper
13
- end.new
5
+ @bob = TaggableModel.create(name: 'Bob Jones', language_list: 'ruby, php')
6
+ @tom = TaggableModel.create(name: 'Tom Marley', language_list: 'ruby, java')
7
+ @eve = TaggableModel.create(name: 'Eve Nodd', language_list: 'ruby, c++')
8
+
9
+ @helper =
10
+ class Helper
11
+ include ActsAsTaggableOn::TagsHelper
12
+ end.new
14
13
  end
15
14
 
16
- it "should yield the proper css classes" do
17
- tags = { }
18
15
 
19
- @helper.tag_cloud(TaggableModel.tag_counts_on(:languages), ["sucky", "awesome"]) do |tag, css_class|
16
+ it 'should yield the proper css classes' do
17
+ tags = {}
18
+
19
+ @helper.tag_cloud(TaggableModel.tag_counts_on(:languages), %w(sucky awesome)) do |tag, css_class|
20
20
  tags[tag.name] = css_class
21
21
  end
22
22
 
23
- tags["ruby"].should == "awesome"
24
- tags["java"].should == "sucky"
25
- tags["c++"].should == "sucky"
26
- tags["php"].should == "sucky"
23
+ expect(tags['ruby']).to eq('awesome')
24
+ expect(tags['java']).to eq('sucky')
25
+ expect(tags['c++']).to eq('sucky')
26
+ expect(tags['php']).to eq('sucky')
27
27
  end
28
28
 
29
- it "should handle tags with zero counts (build for empty)" do
30
- bob = ActsAsTaggableOn::Tag.create(:name => "php")
31
- tom = ActsAsTaggableOn::Tag.create(:name => "java")
32
- eve = ActsAsTaggableOn::Tag.create(:name => "c++")
29
+ it 'should handle tags with zero counts (build for empty)' do
30
+ ActsAsTaggableOn::Tag.create(name: 'php')
31
+ ActsAsTaggableOn::Tag.create(name: 'java')
32
+ ActsAsTaggableOn::Tag.create(name: 'c++')
33
33
 
34
- tags = { }
34
+ tags = {}
35
35
 
36
- @helper.tag_cloud(ActsAsTaggableOn::Tag.all, ["sucky", "awesome"]) do |tag, css_class|
36
+ @helper.tag_cloud(ActsAsTaggableOn::Tag.all, %w(sucky awesome)) do |tag, css_class|
37
37
  tags[tag.name] = css_class
38
38
  end
39
39
 
40
- tags["java"].should == "sucky"
41
- tags["c++"].should == "sucky"
42
- tags["php"].should == "sucky"
40
+ expect(tags['java']).to eq('sucky')
41
+ expect(tags['c++']).to eq('sucky')
42
+ expect(tags['php']).to eq('sucky')
43
43
  end
44
44
  end
@@ -1,21 +1,21 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe ActsAsTaggableOn::Utils do
4
- describe "like_operator" do
4
+ describe 'like_operator' do
5
5
  before(:each) do
6
- clean_database!
7
6
  TaggableModel.acts_as_taggable_on(:tags, :languages, :skills, :needs, :offerings)
8
- @taggable = TaggableModel.new(:name => "Bob Jones")
7
+ @taggable = TaggableModel.new(name: 'Bob Jones')
9
8
  end
10
9
 
11
- it "should return 'ILIKE' when the adapter is PostgreSQL" do
12
- TaggableModel.connection.stub(:adapter_name).and_return("PostgreSQL")
13
- TaggableModel.send(:like_operator).should == "ILIKE"
10
+
11
+ it 'should return \'ILIKE\' when the adapter is PostgreSQL' do
12
+ allow(TaggableModel.connection).to receive(:adapter_name) { 'PostgreSQL' }
13
+ expect(TaggableModel.send(:like_operator)).to eq('ILIKE')
14
14
  end
15
15
 
16
- it "should return 'LIKE' when the adapter is not PostgreSQL" do
17
- TaggableModel.connection.stub(:adapter_name).and_return("MySQL")
18
- TaggableModel.send(:like_operator).should == "LIKE"
16
+ it 'should return \'LIKE\' when the adapter is not PostgreSQL' do
17
+ allow(TaggableModel.connection).to receive(:adapter_name) { 'MySQL' }
18
+ expect(TaggableModel.send(:like_operator)).to eq('LIKE')
19
19
  end
20
20
  end
21
21
  end
@@ -0,0 +1,3 @@
1
+ class AlteredInheritingTaggableModel < TaggableModel
2
+ acts_as_taggable_on :parts
3
+ end
@@ -0,0 +1,3 @@
1
+ class CachedModel < ActiveRecord::Base
2
+ acts_as_taggable
3
+ end
@@ -0,0 +1,5 @@
1
+ if ActsAsTaggableOn::Utils.using_postgresql?
2
+ class CachedModelWithArray < ActiveRecord::Base
3
+ acts_as_taggable
4
+ end
5
+ end
@@ -0,0 +1,15 @@
1
+ class Company < ActiveRecord::Base
2
+ acts_as_taggable_on :locations, :markets
3
+
4
+ has_many :markets, :through => :market_taggings, :source => :tag
5
+
6
+ private
7
+
8
+ def find_or_create_tags_from_list_with_context(tag_list, context)
9
+ if context.to_sym == :markets
10
+ Market.find_or_create_all_with_like_by_name(tag_list)
11
+ else
12
+ super
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,2 @@
1
+ class InheritingTaggableModel < TaggableModel
2
+ end
@@ -0,0 +1,2 @@
1
+ class Market < ActsAsTaggableOn::Tag
2
+ end
@@ -6,7 +6,8 @@ class TaggableModel < ActiveRecord::Base
6
6
  has_many :untaggable_models
7
7
 
8
8
  attr_reader :tag_list_submethod_called
9
- def tag_list=v
9
+
10
+ def tag_list=(v)
10
11
  @tag_list_submethod_called = true
11
12
  super
12
13
  end
@@ -32,6 +33,25 @@ class AlteredInheritingTaggableModel < TaggableModel
32
33
  acts_as_taggable_on :parts
33
34
  end
34
35
 
36
+ class Market < ActsAsTaggableOn::Tag
37
+ end
38
+
39
+ class Company < ActiveRecord::Base
40
+ acts_as_taggable_on :locations, :markets
41
+
42
+ has_many :markets, :through => :market_taggings, :source => :tag
43
+
44
+ private
45
+
46
+ def find_or_create_tags_from_list_with_context(tag_list, context)
47
+ if context.to_sym == :markets
48
+ Market.find_or_create_all_with_like_by_name(tag_list)
49
+ else
50
+ super
51
+ end
52
+ end
53
+ end
54
+
35
55
  class User < ActiveRecord::Base
36
56
  acts_as_tagger
37
57
  end
@@ -44,7 +64,7 @@ class UntaggableModel < ActiveRecord::Base
44
64
  end
45
65
 
46
66
  class NonStandardIdTaggableModel < ActiveRecord::Base
47
- primary_key = "an_id"
67
+ self.primary_key = :an_id
48
68
  acts_as_taggable
49
69
  acts_as_taggable_on :languages
50
70
  acts_as_taggable_on :skills
@@ -56,3 +76,15 @@ class OrderedTaggableModel < ActiveRecord::Base
56
76
  acts_as_ordered_taggable
57
77
  acts_as_ordered_taggable_on :colours
58
78
  end
79
+
80
+ if ActsAsTaggableOn::Utils.using_postgresql?
81
+ class CachedModelWithArray < ActiveRecord::Base
82
+ acts_as_taggable
83
+ end
84
+ if ActsAsTaggableOn::Utils.postgresql_support_json?
85
+ class TaggableModelWithJson < ActiveRecord::Base
86
+ acts_as_taggable
87
+ acts_as_taggable_on :skills
88
+ end
89
+ end
90
+ end