acts-as-taggable-on 12.0.0 → 13.0.0

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 (60) hide show
  1. checksums.yaml +4 -4
  2. data/lib/acts-as-taggable-on/tag.rb +5 -13
  3. data/lib/acts-as-taggable-on/tag_list.rb +1 -1
  4. data/lib/acts-as-taggable-on/taggable/core.rb +0 -3
  5. data/lib/acts-as-taggable-on/taggable/tagged_with_query.rb +0 -5
  6. data/lib/acts-as-taggable-on/version.rb +1 -1
  7. data/lib/acts-as-taggable-on.rb +1 -1
  8. metadata +10 -170
  9. data/.github/workflows/spec.yml +0 -73
  10. data/.gitignore +0 -13
  11. data/.rspec +0 -2
  12. data/Appraisals +0 -23
  13. data/CHANGELOG.md +0 -379
  14. data/CONTRIBUTING.md +0 -57
  15. data/Gemfile +0 -11
  16. data/Guardfile +0 -5
  17. data/README.md +0 -596
  18. data/Rakefile +0 -21
  19. data/acts-as-taggable-on.gemspec +0 -32
  20. data/docker-compose.yml +0 -15
  21. data/gemfiles/activerecord_7.1.gemfile +0 -18
  22. data/gemfiles/activerecord_7.2.gemfile +0 -18
  23. data/gemfiles/activerecord_8.0.gemfile +0 -19
  24. data/spec/acts_as_taggable_on/acts_as_taggable_on_spec.rb +0 -272
  25. data/spec/acts_as_taggable_on/acts_as_tagger_spec.rb +0 -112
  26. data/spec/acts_as_taggable_on/caching_spec.rb +0 -125
  27. data/spec/acts_as_taggable_on/default_parser_spec.rb +0 -47
  28. data/spec/acts_as_taggable_on/dirty_spec.rb +0 -142
  29. data/spec/acts_as_taggable_on/generic_parser_spec.rb +0 -14
  30. data/spec/acts_as_taggable_on/related_spec.rb +0 -99
  31. data/spec/acts_as_taggable_on/single_table_inheritance_spec.rb +0 -231
  32. data/spec/acts_as_taggable_on/tag_list_spec.rb +0 -176
  33. data/spec/acts_as_taggable_on/tag_spec.rb +0 -398
  34. data/spec/acts_as_taggable_on/taggable_spec.rb +0 -828
  35. data/spec/acts_as_taggable_on/tagger_spec.rb +0 -153
  36. data/spec/acts_as_taggable_on/tagging_spec.rb +0 -169
  37. data/spec/acts_as_taggable_on/tags_helper_spec.rb +0 -45
  38. data/spec/acts_as_taggable_on/utils_spec.rb +0 -23
  39. data/spec/internal/app/models/altered_inheriting_taggable_model.rb +0 -5
  40. data/spec/internal/app/models/cached_model.rb +0 -3
  41. data/spec/internal/app/models/cached_model_with_array.rb +0 -11
  42. data/spec/internal/app/models/columns_override_model.rb +0 -5
  43. data/spec/internal/app/models/company.rb +0 -15
  44. data/spec/internal/app/models/inheriting_taggable_model.rb +0 -4
  45. data/spec/internal/app/models/market.rb +0 -2
  46. data/spec/internal/app/models/non_standard_id_taggable_model.rb +0 -8
  47. data/spec/internal/app/models/ordered_taggable_model.rb +0 -4
  48. data/spec/internal/app/models/other_cached_model.rb +0 -3
  49. data/spec/internal/app/models/other_taggable_model.rb +0 -4
  50. data/spec/internal/app/models/student.rb +0 -4
  51. data/spec/internal/app/models/taggable_model.rb +0 -16
  52. data/spec/internal/app/models/untaggable_model.rb +0 -3
  53. data/spec/internal/app/models/user.rb +0 -3
  54. data/spec/internal/config/database.yml.sample +0 -15
  55. data/spec/internal/db/schema.rb +0 -113
  56. data/spec/spec_helper.rb +0 -20
  57. data/spec/support/0-helpers.rb +0 -32
  58. data/spec/support/array.rb +0 -9
  59. data/spec/support/database.rb +0 -38
  60. data/spec/support/database_cleaner.rb +0 -25
@@ -1,19 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "activerecord", "~> 8.0.0.beta1"
6
- gem "railties", "~> 8.0.0.beta1"
7
- gem "pg"
8
- gem "sqlite3", "~> 2.1"
9
- gem "mysql2", "~> 0.5"
10
-
11
- group :local_development do
12
- gem "guard"
13
- gem "guard-rspec"
14
- gem "appraisal"
15
- gem "rake"
16
- gem "byebug", platforms: [:mri]
17
- end
18
-
19
- gemspec path: "../"
@@ -1,272 +0,0 @@
1
- # -*- encoding : utf-8 -*-
2
- require 'spec_helper'
3
-
4
- describe 'Acts As Taggable On' do
5
-
6
- it "should provide a class method 'taggable?' that is false for untaggable models" do
7
- expect(UntaggableModel).to_not be_taggable
8
- end
9
-
10
- describe 'Taggable Method Generation To Preserve Order' do
11
- before(:each) do
12
- TaggableModel.tag_types = []
13
- TaggableModel.preserve_tag_order = false
14
- TaggableModel.acts_as_ordered_taggable_on(:ordered_tags)
15
- @taggable = TaggableModel.new(name: 'Bob Jones')
16
- end
17
-
18
- it "should respond 'true' to preserve_tag_order?" do
19
- expect(@taggable.class.preserve_tag_order?).to be_truthy
20
- end
21
- end
22
-
23
- describe 'Taggable Method Generation' do
24
- before(:each) do
25
- TaggableModel.tag_types = []
26
- TaggableModel.acts_as_taggable_on(:tags, :languages, :skills, :needs, :offerings)
27
- @taggable = TaggableModel.new(name: 'Bob Jones')
28
- end
29
-
30
- it "should respond 'true' to taggable?" do
31
- expect(@taggable.class).to be_taggable
32
- end
33
-
34
- it 'should create a class attribute for tag types' do
35
- expect(@taggable.class).to respond_to(:tag_types)
36
- end
37
-
38
- it 'should create an instance attribute for tag types' do
39
- expect(@taggable).to respond_to(:tag_types)
40
- end
41
-
42
- it 'should have all tag types' do
43
- expect(@taggable.tag_types).to eq([:tags, :languages, :skills, :needs, :offerings])
44
- end
45
-
46
- it 'should create a class attribute for preserve tag order' do
47
- expect(@taggable.class).to respond_to(:preserve_tag_order?)
48
- end
49
-
50
- it 'should create an instance attribute for preserve tag order' do
51
- expect(@taggable).to respond_to(:preserve_tag_order?)
52
- end
53
-
54
- it "should respond 'false' to preserve_tag_order?" do
55
- expect(@taggable.class.preserve_tag_order?).to be_falsy
56
- end
57
-
58
- it 'should generate an association for each tag type' do
59
- expect(@taggable).to respond_to(:tags, :skills, :languages)
60
- end
61
-
62
- it 'should add tagged_with and tag_counts to singleton' do
63
- expect(TaggableModel).to respond_to(:tagged_with, :tag_counts)
64
- end
65
-
66
- it 'should generate a tag_list accessor/setter for each tag type' do
67
- expect(@taggable).to respond_to(:tag_list, :skill_list, :language_list)
68
- expect(@taggable).to respond_to(:tag_list=, :skill_list=, :language_list=)
69
- end
70
-
71
- it 'should generate a tag_list accessor, that includes owned tags, for each tag type' do
72
- expect(@taggable).to respond_to(:all_tags_list, :all_skills_list, :all_languages_list)
73
- end
74
- end
75
-
76
- describe 'Matching Contexts' do
77
- it 'should find objects with tags of matching contexts' do
78
- taggable1 = TaggableModel.create!(name: 'Taggable 1')
79
- taggable2 = TaggableModel.create!(name: 'Taggable 2')
80
- taggable3 = TaggableModel.create!(name: 'Taggable 3')
81
-
82
- taggable1.offering_list = 'one, two'
83
- taggable1.save!
84
-
85
- taggable2.need_list = 'one, two'
86
- taggable2.save!
87
-
88
- taggable3.offering_list = 'one, two'
89
- taggable3.save!
90
-
91
- expect(taggable1.find_matching_contexts(:offerings, :needs)).to include(taggable2)
92
- expect(taggable1.find_matching_contexts(:offerings, :needs)).to_not include(taggable3)
93
- end
94
-
95
- it 'should find other related objects with tags of matching contexts' do
96
- taggable1 = TaggableModel.create!(name: 'Taggable 1')
97
- taggable2 = OtherTaggableModel.create!(name: 'Taggable 2')
98
- taggable3 = OtherTaggableModel.create!(name: 'Taggable 3')
99
-
100
- taggable1.offering_list = 'one, two'
101
- taggable1.save
102
-
103
- taggable2.need_list = 'one, two'
104
- taggable2.save
105
-
106
- taggable3.offering_list = 'one, two'
107
- taggable3.save
108
-
109
- expect(taggable1.find_matching_contexts_for(OtherTaggableModel, :offerings, :needs)).to include(taggable2)
110
- expect(taggable1.find_matching_contexts_for(OtherTaggableModel, :offerings, :needs)).to_not include(taggable3)
111
- end
112
-
113
- it 'should not include the object itself in the list of related objects with tags of matching contexts' do
114
- taggable1 = TaggableModel.create!(name: 'Taggable 1')
115
- taggable2 = TaggableModel.create!(name: 'Taggable 2')
116
-
117
- taggable1.offering_list = 'one, two'
118
- taggable1.need_list = 'one, two'
119
- taggable1.save
120
-
121
- taggable2.need_list = 'one, two'
122
- taggable2.save
123
-
124
- expect(taggable1.find_matching_contexts_for(TaggableModel, :offerings, :needs)).to include(taggable2)
125
- expect(taggable1.find_matching_contexts_for(TaggableModel, :offerings, :needs)).to_not include(taggable1)
126
- end
127
-
128
- it 'should ensure joins to multiple taggings maintain their contexts when aliasing' do
129
- taggable1 = TaggableModel.create!(name: 'Taggable 1')
130
-
131
- taggable1.offering_list = 'one'
132
- taggable1.need_list = 'two'
133
-
134
- taggable1.save
135
-
136
- column = TaggableModel.connection.quote_column_name("context")
137
- offer_alias = TaggableModel.connection.quote_table_name(ActsAsTaggableOn.taggings_table)
138
- need_alias = TaggableModel.connection.quote_table_name("need_taggings_taggable_models_join")
139
-
140
- expect(TaggableModel.joins(:offerings, :needs).to_sql).to include "#{offer_alias}.#{column}"
141
- expect(TaggableModel.joins(:offerings, :needs).to_sql).to include "#{need_alias}.#{column}"
142
- end
143
-
144
- end
145
-
146
- describe 'Tagging Contexts' do
147
- it 'should eliminate duplicate tagging contexts ' do
148
- TaggableModel.acts_as_taggable_on(:skills, :skills)
149
- expect(TaggableModel.tag_types.freq[:skills]).to eq(1)
150
- end
151
-
152
- it 'should not contain embedded/nested arrays' do
153
- TaggableModel.acts_as_taggable_on([:array], [:array])
154
- expect(TaggableModel.tag_types.freq[[:array]]).to eq(0)
155
- end
156
-
157
- it 'should _flatten_ the content of arrays' do
158
- TaggableModel.acts_as_taggable_on([:array], [:array])
159
- expect(TaggableModel.tag_types.freq[:array]).to eq(1)
160
- end
161
-
162
- it 'should not raise an error when passed nil' do
163
- expect(-> {
164
- TaggableModel.acts_as_taggable_on
165
- }).to_not raise_error
166
- end
167
-
168
- it 'should not raise an error when passed [nil]' do
169
- expect(-> {
170
- TaggableModel.acts_as_taggable_on([nil])
171
- }).to_not raise_error
172
- end
173
-
174
- it 'should include dynamic contexts in tagging_contexts' do
175
- taggable = TaggableModel.create!(name: 'Dynamic Taggable')
176
- taggable.set_tag_list_on :colors, 'tag1, tag2, tag3'
177
- expect(taggable.tagging_contexts).to eq(%w(tags languages skills needs offerings array colors))
178
- taggable.save
179
- taggable = TaggableModel.where(name: 'Dynamic Taggable').first
180
- expect(taggable.tagging_contexts).to eq(%w(tags languages skills needs offerings array colors))
181
- end
182
- end
183
-
184
- context 'when tagging context ends in an "s" when singular (ex. "status", "glass", etc.)' do
185
- describe 'caching' do
186
- before { @taggable = OtherCachedModel.new(name: 'John Smith') }
187
- subject { @taggable }
188
-
189
- it { should respond_to(:save_cached_tag_list) }
190
- its(:cached_language_list) { should be_blank }
191
- its(:cached_status_list) { should be_blank }
192
- its(:cached_glass_list) { should be_blank }
193
-
194
- context 'language taggings cache after update' do
195
- before { @taggable.update(language_list: 'ruby, .net') }
196
- subject { @taggable }
197
-
198
- its(:language_list) { should == ['ruby', '.net']}
199
- its(:cached_language_list) { should == 'ruby, .net' } # passes
200
- its(:instance_variables) { should include(:@language_list) }
201
- end
202
-
203
- context 'status taggings cache after update' do
204
- before { @taggable.update(status_list: 'happy, married') }
205
- subject { @taggable }
206
-
207
- its(:status_list) { should == ['happy', 'married'] }
208
- its(:cached_status_list) { should == 'happy, married' } # fails
209
- its(:cached_status_list) { should_not == '' } # fails, is blank
210
- its(:instance_variables) { should include(:@status_list) }
211
- its(:instance_variables) { should_not include(:@statu_list) } # fails, note: one "s"
212
-
213
- end
214
-
215
- context 'glass taggings cache after update' do
216
- before do
217
- @taggable.update(glass_list: 'rectangle, aviator')
218
- end
219
-
220
- subject { @taggable }
221
- its(:glass_list) { should == ['rectangle', 'aviator'] }
222
- its(:cached_glass_list) { should == 'rectangle, aviator' } # fails
223
- its(:cached_glass_list) { should_not == '' } # fails, is blank
224
- its(:instance_variables) { should include(:@glass_list) }
225
- its(:instance_variables) { should_not include(:@glas_list) } # fails, note: one "s"
226
-
227
- end
228
- end
229
- end
230
-
231
- describe 'taggings' do
232
- before(:each) do
233
- @taggable = TaggableModel.new(name: 'Art Kram')
234
- end
235
-
236
- it 'should return no taggings' do
237
- expect(@taggable.taggings).to be_empty
238
- end
239
- end
240
-
241
- describe '@@remove_unused_tags' do
242
- before do
243
- @taggable = TaggableModel.create(name: 'Bob Jones')
244
- @tag = ActsAsTaggableOn::Tag.create(name: 'awesome')
245
-
246
- @tagging = ActsAsTaggableOn::Tagging.create(taggable: @taggable, tag: @tag, context: 'tags')
247
- end
248
-
249
- context 'if set to true' do
250
- before do
251
- ActsAsTaggableOn.remove_unused_tags = true
252
- end
253
-
254
- it 'should remove unused tags after removing taggings' do
255
- @tagging.destroy
256
- expect(ActsAsTaggableOn::Tag.find_by_name('awesome')).to be_nil
257
- end
258
- end
259
-
260
- context 'if set to false' do
261
- before do
262
- ActsAsTaggableOn.remove_unused_tags = false
263
- end
264
-
265
- it 'should not remove unused tags after removing taggings' do
266
- @tagging.destroy
267
- expect(ActsAsTaggableOn::Tag.find_by_name('awesome')).to eq(@tag)
268
- end
269
- end
270
- end
271
-
272
- end
@@ -1,112 +0,0 @@
1
- # -*- encoding : utf-8 -*-
2
- require 'spec_helper'
3
-
4
- describe 'acts_as_tagger' do
5
-
6
- describe 'Tagger Method Generation' do
7
- before(:each) do
8
- @tagger = User.new
9
- end
10
-
11
- it 'should add #is_tagger? query method to the class-side' do
12
- expect(User).to respond_to(:is_tagger?)
13
- end
14
-
15
- it 'should return true from the class-side #is_tagger?' do
16
- expect(User.is_tagger?).to be_truthy
17
- end
18
-
19
- it 'should return false from the base #is_tagger?' do
20
- expect(ActiveRecord::Base.is_tagger?).to be_falsy
21
- end
22
-
23
- it 'should add #is_tagger? query method to the singleton' do
24
- expect(@tagger).to respond_to(:is_tagger?)
25
- end
26
-
27
- it 'should add #tag method on the instance-side' do
28
- expect(@tagger).to respond_to(:tag)
29
- end
30
-
31
- it 'should generate an association for #owned_taggings and #owned_tags' do
32
- expect(@tagger).to respond_to(:owned_taggings, :owned_tags)
33
- end
34
- end
35
-
36
- describe '#tag' do
37
- context 'when called with a non-existent tag context' do
38
- before(:each) do
39
- @tagger = User.new
40
- @taggable = TaggableModel.new(name: 'Richard Prior')
41
- end
42
-
43
- it 'should by default not throw an exception ' do
44
- expect(@taggable.tag_list_on(:foo)).to be_empty
45
- expect(-> {
46
- @tagger.tag(@taggable, with: 'this, and, that', on: :foo)
47
- }).to_not raise_error
48
- end
49
-
50
- it 'should by default create the tag context on-the-fly' do
51
- expect(@taggable.tag_list_on(:here_ond_now)).to be_empty
52
- @tagger.tag(@taggable, with: 'that', on: :here_ond_now)
53
- expect(@taggable.tag_list_on(:here_ond_now)).to_not include('that')
54
- expect(@taggable.all_tags_list_on(:here_ond_now)).to include('that')
55
- end
56
-
57
- it 'should show all the tag list when both public and owned tags exist' do
58
- @taggable.tag_list = 'ruby, python'
59
- @tagger.tag(@taggable, with: 'java, lisp', on: :tags)
60
- expect(@taggable.all_tags_on(:tags).map(&:name).sort).to eq(%w(ruby python java lisp).sort)
61
- end
62
-
63
- it 'should not add owned tags to the common list' do
64
- @taggable.tag_list = 'ruby, python'
65
- @tagger.tag(@taggable, with: 'java, lisp', on: :tags)
66
- expect(@taggable.tag_list).to eq(%w(ruby python))
67
- @tagger.tag(@taggable, with: '', on: :tags)
68
- expect(@taggable.tag_list).to eq(%w(ruby python))
69
- end
70
-
71
- it 'should throw an exception when the default is over-ridden' do
72
- expect(@taggable.tag_list_on(:foo_boo)).to be_empty
73
- expect {
74
- @tagger.tag(@taggable, with: 'this, and, that', on: :foo_boo, force: false)
75
- }.to raise_error(RuntimeError)
76
- end
77
-
78
- it 'should not create the tag context on-the-fly when the default is over-ridden' do
79
- expect(@taggable.tag_list_on(:foo_boo)).to be_empty
80
- @tagger.tag(@taggable, with: 'this, and, that', on: :foo_boo, force: false) rescue
81
- expect(@taggable.tag_list_on(:foo_boo)).to be_empty
82
- end
83
- end
84
-
85
- describe "when called by multiple tagger's" do
86
- before(:each) do
87
- @user_x = User.create(name: 'User X')
88
- @user_y = User.create(name: 'User Y')
89
- @taggable = TaggableModel.create(name: 'acts_as_taggable_on', tag_list: 'plugin')
90
-
91
- @user_x.tag(@taggable, with: 'ruby, rails', on: :tags)
92
- @user_y.tag(@taggable, with: 'ruby, plugin', on: :tags)
93
-
94
- @user_y.tag(@taggable, with: '', on: :tags)
95
- @user_y.tag(@taggable, with: '', on: :tags)
96
- end
97
-
98
- it 'should delete owned tags' do
99
- expect(@user_y.owned_tags).to be_empty
100
- end
101
-
102
- it 'should not delete other taggers tags' do
103
- expect(@user_x.owned_tags.count).to eq(2)
104
- end
105
-
106
- it 'should not delete original tags' do
107
- expect(@taggable.all_tags_list_on(:tags)).to include('plugin')
108
- end
109
- end
110
- end
111
-
112
- end
@@ -1,125 +0,0 @@
1
- # -*- encoding : utf-8 -*-
2
- require 'spec_helper'
3
-
4
- describe 'Acts As Taggable On' do
5
-
6
- describe 'Caching' do
7
- before(:each) do
8
- @taggable = CachedModel.new(name: 'Bob Jones')
9
- @another_taggable = OtherCachedModel.new(name: 'John Smith')
10
- end
11
-
12
- it 'should add saving of tag lists and cached tag lists to the instance' do
13
- expect(@taggable).to respond_to(:save_cached_tag_list)
14
- expect(@another_taggable).to respond_to(:save_cached_tag_list)
15
-
16
- expect(@taggable).to respond_to(:save_tags)
17
- end
18
-
19
- it 'should generate a cached column checker for each tag type' do
20
- expect(CachedModel).to respond_to(:caching_tag_list?)
21
- expect(OtherCachedModel).to respond_to(:caching_language_list?)
22
- end
23
-
24
- it 'should not have cached tags' do
25
- expect(@taggable.cached_tag_list).to be_blank
26
- expect(@another_taggable.cached_language_list).to be_blank
27
- end
28
-
29
- it 'should cache tags' do
30
- @taggable.update(tag_list: 'awesome, epic')
31
- expect(@taggable.cached_tag_list).to eq('awesome, epic')
32
-
33
- @another_taggable.update(language_list: 'ruby, .net')
34
- expect(@another_taggable.cached_language_list).to eq('ruby, .net')
35
- end
36
-
37
- it 'should keep the cache' do
38
- @taggable.update(tag_list: 'awesome, epic')
39
- @taggable = CachedModel.find(@taggable.id)
40
- @taggable.save!
41
- expect(@taggable.cached_tag_list).to eq('awesome, epic')
42
- end
43
-
44
- it 'should update the cache' do
45
- @taggable.update(tag_list: 'awesome, epic')
46
- @taggable.update(tag_list: 'awesome')
47
- expect(@taggable.cached_tag_list).to eq('awesome')
48
- end
49
-
50
- it 'should remove the cache' do
51
- @taggable.update(tag_list: 'awesome, epic')
52
- @taggable.update(tag_list: '')
53
- expect(@taggable.cached_tag_list).to be_blank
54
- end
55
-
56
- it 'should have a tag list' do
57
- @taggable.update(tag_list: 'awesome, epic')
58
- @taggable = CachedModel.find(@taggable.id)
59
- expect(@taggable.tag_list.sort).to eq(%w(awesome epic).sort)
60
- end
61
-
62
- it 'should keep the tag list' do
63
- @taggable.update(tag_list: 'awesome, epic')
64
- @taggable = CachedModel.find(@taggable.id)
65
- @taggable.save!
66
- expect(@taggable.tag_list.sort).to eq(%w(awesome epic).sort)
67
- end
68
-
69
- it 'should clear the cache on reset_column_information' do
70
- CachedModel.column_names
71
- CachedModel.reset_column_information
72
- expect(CachedModel.instance_variable_get(:@acts_as_taggable_on_cache_columns)).to eql(nil)
73
- end
74
-
75
- it 'should not override a user-defined columns method' do
76
- expect(ColumnsOverrideModel.columns.map(&:name)).not_to include('ignored_column')
77
- ColumnsOverrideModel.acts_as_taggable
78
- expect(ColumnsOverrideModel.columns.map(&:name)).not_to include('ignored_column')
79
- end
80
- end
81
-
82
- describe 'with a custom delimiter' do
83
- before(:each) do
84
- @taggable = CachedModel.new(name: 'Bob Jones')
85
- @another_taggable = OtherCachedModel.new(name: 'John Smith')
86
- ActsAsTaggableOn.delimiter = ';'
87
- end
88
-
89
- after(:all) do
90
- ActsAsTaggableOn.delimiter = ','
91
- end
92
-
93
- it 'should cache tags with custom delimiter' do
94
- @taggable.update(tag_list: 'awesome; epic')
95
- expect(@taggable.tag_list).to eq(['awesome', 'epic'])
96
- expect(@taggable.cached_tag_list).to eq('awesome; epic')
97
-
98
- @taggable = CachedModel.find_by_name('Bob Jones')
99
- expect(@taggable.tag_list).to eq(['awesome', 'epic'])
100
- expect(@taggable.cached_tag_list).to eq('awesome; epic')
101
- end
102
- end
103
-
104
- describe 'Cache methods initialization on new models' do
105
- before(:all) do
106
- ActiveRecord::Base.connection.execute(
107
- 'INSERT INTO cache_methods_injected_models (cached_tag_list) VALUES (\'ciao\')'
108
- )
109
- class CacheMethodsInjectedModel < ActiveRecord::Base
110
- acts_as_taggable
111
- end
112
- end
113
- after(:all) { Object.send(:remove_const, :CacheMethodsInjectedModel) }
114
-
115
- it 'cached_tag_list_on? get injected correctly' do
116
- expect do
117
- CacheMethodsInjectedModel.first.tag_list
118
- end.not_to raise_error
119
- end
120
- end
121
-
122
- describe 'CachingWithArray' do
123
- pending '#TODO'
124
- end
125
- end
@@ -1,47 +0,0 @@
1
- # -*- encoding : utf-8 -*-
2
- require 'spec_helper'
3
-
4
- describe ActsAsTaggableOn::DefaultParser do
5
- it '#parse should return empty array if empty array is passed' do
6
- parser = ActsAsTaggableOn::DefaultParser.new([])
7
- expect(parser.parse).to be_empty
8
- end
9
-
10
- describe 'Multiple Delimiter' do
11
- before do
12
- @old_delimiter = ActsAsTaggableOn.delimiter
13
- end
14
-
15
- after do
16
- ActsAsTaggableOn.delimiter = @old_delimiter
17
- end
18
-
19
- it 'should separate tags by delimiters' do
20
- ActsAsTaggableOn.delimiter = [',', ' ', '\|']
21
- parser = ActsAsTaggableOn::DefaultParser.new('cool, data|I have')
22
- expect(parser.parse.to_s).to eq('cool, data, I, have')
23
- end
24
-
25
- it 'should escape quote' do
26
- ActsAsTaggableOn.delimiter = [',', ' ', '\|']
27
- parser = ActsAsTaggableOn::DefaultParser.new("'I have'|cool, data")
28
- expect(parser.parse.to_s).to eq('"I have", cool, data')
29
-
30
- parser = ActsAsTaggableOn::DefaultParser.new('"I, have"|cool, data')
31
- expect(parser.parse.to_s).to eq('"I, have", cool, data')
32
- end
33
-
34
- it 'should work for utf8 delimiter and long delimiter' do
35
- ActsAsTaggableOn.delimiter = [',', '的', '可能是']
36
- parser = ActsAsTaggableOn::DefaultParser.new('我的东西可能是不见了,还好有备份')
37
- expect(parser.parse.to_s).to eq('我, 东西, 不见了, 还好有备份')
38
- end
39
-
40
- it 'should work for multiple quoted tags' do
41
- ActsAsTaggableOn.delimiter = [',']
42
- parser = ActsAsTaggableOn::DefaultParser.new('"Ruby Monsters","eat Katzenzungen"')
43
- expect(parser.parse.to_s).to eq('Ruby Monsters, eat Katzenzungen')
44
- end
45
- end
46
-
47
- end