acts-as-taggable-on 6.0.0 → 6.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +17 -7
- data/Appraisals +4 -0
- data/CHANGELOG.md +179 -140
- data/README.md +10 -1
- data/acts-as-taggable-on.gemspec +2 -2
- data/db/migrate/1_acts_as_taggable_on_migration.rb +8 -7
- data/db/migrate/2_add_missing_unique_indices.rb +8 -8
- data/db/migrate/3_add_taggings_counter_cache_to_tags.rb +3 -3
- data/db/migrate/4_add_missing_taggable_index.rb +2 -2
- data/db/migrate/5_change_collation_for_tag_names.rb +1 -1
- data/db/migrate/6_add_missing_indexes_on_taggings.rb +9 -9
- data/gemfiles/activerecord_5.0.gemfile +2 -4
- data/gemfiles/activerecord_5.1.gemfile +2 -4
- data/gemfiles/activerecord_5.2.gemfile +2 -4
- data/gemfiles/activerecord_6.0.gemfile +21 -0
- data/lib/acts-as-taggable-on.rb +5 -1
- data/lib/acts_as_taggable_on/tag.rb +9 -18
- data/lib/acts_as_taggable_on/taggable/cache.rb +38 -34
- data/lib/acts_as_taggable_on/taggable/collection.rb +8 -6
- data/lib/acts_as_taggable_on/taggable/core.rb +11 -5
- data/lib/acts_as_taggable_on/taggable/tag_list_type.rb +4 -0
- data/lib/acts_as_taggable_on/tagging.rb +3 -1
- data/lib/acts_as_taggable_on/utils.rb +4 -0
- data/lib/acts_as_taggable_on/version.rb +1 -2
- data/spec/acts_as_taggable_on/acts_as_taggable_on_spec.rb +4 -12
- data/spec/acts_as_taggable_on/caching_spec.rb +16 -10
- data/spec/acts_as_taggable_on/single_table_inheritance_spec.rb +12 -7
- data/spec/acts_as_taggable_on/taggable_spec.rb +9 -9
- data/spec/acts_as_taggable_on/tagger_spec.rb +2 -2
- data/spec/internal/app/models/altered_inheriting_taggable_model.rb +2 -0
- data/spec/internal/app/models/cached_model_with_array.rb +6 -0
- data/spec/internal/app/models/columns_override_model.rb +5 -0
- data/spec/internal/app/models/company.rb +1 -1
- data/spec/internal/app/models/inheriting_taggable_model.rb +2 -0
- data/spec/internal/app/models/market.rb +1 -1
- data/spec/internal/app/models/non_standard_id_taggable_model.rb +1 -1
- data/spec/internal/app/models/student.rb +2 -0
- data/spec/internal/app/models/taggable_model.rb +1 -0
- data/spec/internal/app/models/user.rb +1 -1
- data/spec/internal/db/schema.rb +11 -5
- data/spec/spec_helper.rb +0 -1
- data/spec/support/database.rb +3 -3
- metadata +16 -9
- data/spec/internal/app/models/models.rb +0 -90
@@ -94,16 +94,18 @@ module ActsAsTaggableOn::Taggable
|
|
94
94
|
## Generate conditions:
|
95
95
|
options[:conditions] = sanitize_sql(options[:conditions]) if options[:conditions]
|
96
96
|
|
97
|
-
## Generate joins:
|
98
|
-
taggable_join = "INNER JOIN #{table_name} ON #{table_name}.#{primary_key} = #{ActsAsTaggableOn::Tagging.table_name}.taggable_id"
|
99
|
-
taggable_join << " AND #{table_name}.#{inheritance_column} = '#{name}'" unless descends_from_active_record? # Current model is STI descendant, so add type checking to the join condition
|
100
|
-
|
101
97
|
## Generate scope:
|
102
98
|
tagging_scope = ActsAsTaggableOn::Tagging.select("#{ActsAsTaggableOn::Tagging.table_name}.tag_id, COUNT(#{ActsAsTaggableOn::Tagging.table_name}.tag_id) AS tags_count")
|
103
99
|
tag_scope = ActsAsTaggableOn::Tag.select("#{ActsAsTaggableOn::Tag.table_name}.*, #{ActsAsTaggableOn::Tagging.table_name}.tags_count AS count").order(options[:order]).limit(options[:limit])
|
104
100
|
|
105
|
-
#
|
106
|
-
|
101
|
+
# Current model is STI descendant, so add type checking to the join condition
|
102
|
+
unless descends_from_active_record?
|
103
|
+
taggable_join = "INNER JOIN #{table_name} ON #{table_name}.#{primary_key} = #{ActsAsTaggableOn::Tagging.table_name}.taggable_id"
|
104
|
+
taggable_join << " AND #{table_name}.#{inheritance_column} = '#{name}'"
|
105
|
+
tagging_scope = tagging_scope.joins(taggable_join)
|
106
|
+
end
|
107
|
+
|
108
|
+
# Conditions
|
107
109
|
tagging_conditions(options).each { |condition| tagging_scope = tagging_scope.where(condition) }
|
108
110
|
tag_scope = tag_scope.where(options[:conditions])
|
109
111
|
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require_relative 'tagged_with_query'
|
2
|
+
require_relative 'tag_list_type'
|
2
3
|
|
3
4
|
module ActsAsTaggableOn::Taggable
|
4
5
|
module Core
|
@@ -38,7 +39,7 @@ module ActsAsTaggableOn::Taggable
|
|
38
39
|
through: context_taggings,
|
39
40
|
source: :tag
|
40
41
|
|
41
|
-
attribute "#{tags_type.singularize}_list".to_sym,
|
42
|
+
attribute "#{tags_type.singularize}_list".to_sym, ActsAsTaggableOn::Taggable::TagListType.new
|
42
43
|
end
|
43
44
|
|
44
45
|
taggable_mixin.class_eval <<-RUBY, __FILE__, __LINE__ + 1
|
@@ -49,8 +50,14 @@ module ActsAsTaggableOn::Taggable
|
|
49
50
|
def #{tag_type}_list=(new_tags)
|
50
51
|
parsed_new_list = ActsAsTaggableOn.default_parser.new(new_tags).parse
|
51
52
|
|
52
|
-
if self.class.preserve_tag_order? || parsed_new_list.sort != #{tag_type}_list.sort
|
53
|
-
|
53
|
+
if self.class.preserve_tag_order? || (parsed_new_list.sort != #{tag_type}_list.sort)
|
54
|
+
if ActsAsTaggableOn::Utils.legacy_activerecord?
|
55
|
+
set_attribute_was("#{tag_type}_list", #{tag_type}_list)
|
56
|
+
else
|
57
|
+
unless #{tag_type}_list_changed?
|
58
|
+
@attributes["#{tag_type}_list"] = ActiveModel::Attribute.from_user("#{tag_type}_list", #{tag_type}_list, ActsAsTaggableOn::Taggable::TagListType.new)
|
59
|
+
end
|
60
|
+
end
|
54
61
|
write_attribute("#{tag_type}_list", parsed_new_list)
|
55
62
|
end
|
56
63
|
|
@@ -103,9 +110,8 @@ module ActsAsTaggableOn::Taggable
|
|
103
110
|
def tagged_with(tags, options = {})
|
104
111
|
tag_list = ActsAsTaggableOn.default_parser.new(tags).parse
|
105
112
|
options = options.dup
|
106
|
-
empty_result = where('1 = 0')
|
107
113
|
|
108
|
-
return
|
114
|
+
return none if tag_list.empty?
|
109
115
|
|
110
116
|
::ActsAsTaggableOn::Taggable::TaggedWithQuery.build(self, ActsAsTaggableOn::Tag, ActsAsTaggableOn::Tagging, tag_list, options)
|
111
117
|
end
|
@@ -1,10 +1,12 @@
|
|
1
1
|
module ActsAsTaggableOn
|
2
2
|
class Tagging < ::ActiveRecord::Base #:nodoc:
|
3
|
+
self.table_name = ActsAsTaggableOn.taggings_table
|
4
|
+
|
3
5
|
DEFAULT_CONTEXT = 'tags'
|
4
6
|
belongs_to :tag, class_name: '::ActsAsTaggableOn::Tag', counter_cache: ActsAsTaggableOn.tags_counter
|
5
7
|
belongs_to :taggable, polymorphic: true
|
6
8
|
|
7
|
-
belongs_to :tagger, {polymorphic: true
|
9
|
+
belongs_to :tagger, { polymorphic: true, optional: true }
|
8
10
|
|
9
11
|
scope :owned_by, ->(owner) { where(tagger: owner) }
|
10
12
|
scope :not_owned, -> { where(tagger_id: nil, tagger_type: nil) }
|
@@ -24,6 +24,10 @@ module ActsAsTaggableOn
|
|
24
24
|
using_postgresql? ? 'ILIKE' : 'LIKE'
|
25
25
|
end
|
26
26
|
|
27
|
+
def legacy_activerecord?
|
28
|
+
ActiveRecord.version <= Gem::Version.new('5.3.0')
|
29
|
+
end
|
30
|
+
|
27
31
|
# escape _ and % characters in strings, since these are wildcards in SQL.
|
28
32
|
def escape_like(str)
|
29
33
|
str.gsub(/[!%_]/) { |x| '!' + x }
|
@@ -73,14 +73,6 @@ describe 'Acts As Taggable On' do
|
|
73
73
|
end
|
74
74
|
end
|
75
75
|
|
76
|
-
describe 'Reloading' do
|
77
|
-
it 'should save a model instantiated by Model.find' do
|
78
|
-
taggable = TaggableModel.create!(name: 'Taggable')
|
79
|
-
found_taggable = TaggableModel.find(taggable.id)
|
80
|
-
found_taggable.save
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
76
|
describe 'Matching Contexts' do
|
85
77
|
it 'should find objects with tags of matching contexts' do
|
86
78
|
taggable1 = TaggableModel.create!(name: 'Taggable 1')
|
@@ -142,7 +134,7 @@ describe 'Acts As Taggable On' do
|
|
142
134
|
taggable1.save
|
143
135
|
|
144
136
|
column = TaggableModel.connection.quote_column_name("context")
|
145
|
-
offer_alias = TaggableModel.connection.quote_table_name(
|
137
|
+
offer_alias = TaggableModel.connection.quote_table_name(ActsAsTaggableOn.taggings_table)
|
146
138
|
need_alias = TaggableModel.connection.quote_table_name("need_taggings_taggable_models_join")
|
147
139
|
|
148
140
|
expect(TaggableModel.joins(:offerings, :needs).to_sql).to include "#{offer_alias}.#{column}"
|
@@ -200,7 +192,7 @@ describe 'Acts As Taggable On' do
|
|
200
192
|
its(:cached_glass_list) { should be_blank }
|
201
193
|
|
202
194
|
context 'language taggings cache after update' do
|
203
|
-
before { @taggable.
|
195
|
+
before { @taggable.update(language_list: 'ruby, .net') }
|
204
196
|
subject { @taggable }
|
205
197
|
|
206
198
|
its(:language_list) { should == ['ruby', '.net']}
|
@@ -209,7 +201,7 @@ describe 'Acts As Taggable On' do
|
|
209
201
|
end
|
210
202
|
|
211
203
|
context 'status taggings cache after update' do
|
212
|
-
before { @taggable.
|
204
|
+
before { @taggable.update(status_list: 'happy, married') }
|
213
205
|
subject { @taggable }
|
214
206
|
|
215
207
|
its(:status_list) { should == ['happy', 'married'] }
|
@@ -222,7 +214,7 @@ describe 'Acts As Taggable On' do
|
|
222
214
|
|
223
215
|
context 'glass taggings cache after update' do
|
224
216
|
before do
|
225
|
-
@taggable.
|
217
|
+
@taggable.update(glass_list: 'rectangle, aviator')
|
226
218
|
end
|
227
219
|
|
228
220
|
subject { @taggable }
|
@@ -31,40 +31,40 @@ describe 'Acts As Taggable On' do
|
|
31
31
|
end
|
32
32
|
|
33
33
|
it 'should cache tags' do
|
34
|
-
@taggable.
|
34
|
+
@taggable.update(tag_list: 'awesome, epic')
|
35
35
|
expect(@taggable.cached_tag_list).to eq('awesome, epic')
|
36
36
|
|
37
|
-
@another_taggable.
|
37
|
+
@another_taggable.update(language_list: 'ruby, .net')
|
38
38
|
expect(@another_taggable.cached_language_list).to eq('ruby, .net')
|
39
39
|
end
|
40
40
|
|
41
41
|
it 'should keep the cache' do
|
42
|
-
@taggable.
|
42
|
+
@taggable.update(tag_list: 'awesome, epic')
|
43
43
|
@taggable = CachedModel.find(@taggable.id)
|
44
44
|
@taggable.save!
|
45
45
|
expect(@taggable.cached_tag_list).to eq('awesome, epic')
|
46
46
|
end
|
47
47
|
|
48
48
|
it 'should update the cache' do
|
49
|
-
@taggable.
|
50
|
-
@taggable.
|
49
|
+
@taggable.update(tag_list: 'awesome, epic')
|
50
|
+
@taggable.update(tag_list: 'awesome')
|
51
51
|
expect(@taggable.cached_tag_list).to eq('awesome')
|
52
52
|
end
|
53
53
|
|
54
54
|
it 'should remove the cache' do
|
55
|
-
@taggable.
|
56
|
-
@taggable.
|
55
|
+
@taggable.update(tag_list: 'awesome, epic')
|
56
|
+
@taggable.update(tag_list: '')
|
57
57
|
expect(@taggable.cached_tag_list).to be_blank
|
58
58
|
end
|
59
59
|
|
60
60
|
it 'should have a tag list' do
|
61
|
-
@taggable.
|
61
|
+
@taggable.update(tag_list: 'awesome, epic')
|
62
62
|
@taggable = CachedModel.find(@taggable.id)
|
63
63
|
expect(@taggable.tag_list.sort).to eq(%w(awesome epic).sort)
|
64
64
|
end
|
65
65
|
|
66
66
|
it 'should keep the tag list' do
|
67
|
-
@taggable.
|
67
|
+
@taggable.update(tag_list: 'awesome, epic')
|
68
68
|
@taggable = CachedModel.find(@taggable.id)
|
69
69
|
@taggable.save!
|
70
70
|
expect(@taggable.tag_list.sort).to eq(%w(awesome epic).sort)
|
@@ -75,6 +75,12 @@ describe 'Acts As Taggable On' do
|
|
75
75
|
CachedModel.reset_column_information
|
76
76
|
expect(CachedModel.instance_variable_get(:@acts_as_taggable_on_cache_columns)).to eql(nil)
|
77
77
|
end
|
78
|
+
|
79
|
+
it 'should not override a user-defined columns method' do
|
80
|
+
expect(ColumnsOverrideModel.columns.map(&:name)).not_to include('ignored_column')
|
81
|
+
ColumnsOverrideModel.acts_as_taggable
|
82
|
+
expect(ColumnsOverrideModel.columns.map(&:name)).not_to include('ignored_column')
|
83
|
+
end
|
78
84
|
end
|
79
85
|
|
80
86
|
describe 'with a custom delimiter' do
|
@@ -89,7 +95,7 @@ describe 'Acts As Taggable On' do
|
|
89
95
|
end
|
90
96
|
|
91
97
|
it 'should cache tags with custom delimiter' do
|
92
|
-
@taggable.
|
98
|
+
@taggable.update(tag_list: 'awesome; epic')
|
93
99
|
expect(@taggable.tag_list).to eq(['awesome', 'epic'])
|
94
100
|
expect(@taggable.cached_tag_list).to eq('awesome; epic')
|
95
101
|
|
@@ -127,9 +127,9 @@ describe 'Single Table Inheritance' do
|
|
127
127
|
altered_inheriting.tag_list = 'fork, spoon'
|
128
128
|
altered_inheriting.save!
|
129
129
|
|
130
|
-
expect(InheritingTaggableModel.tag_counts_on(:tags, order:
|
131
|
-
expect(AlteredInheritingTaggableModel.tag_counts_on(:tags, order:
|
132
|
-
expect(TaggableModel.tag_counts_on(:tags, order:
|
130
|
+
expect(InheritingTaggableModel.tag_counts_on(:tags, order: "#{ActsAsTaggableOn.tags_table}.id").map(&:name)).to eq(%w(bob kelso))
|
131
|
+
expect(AlteredInheritingTaggableModel.tag_counts_on(:tags, order: "#{ActsAsTaggableOn.tags_table}.id").map(&:name)).to eq(%w(fork spoon))
|
132
|
+
expect(TaggableModel.tag_counts_on(:tags, order: "#{ActsAsTaggableOn.tags_table}.id").map(&:name)).to eq(%w(bob kelso fork spoon))
|
133
133
|
end
|
134
134
|
|
135
135
|
it 'should have different tags_on for inherited models' do
|
@@ -138,9 +138,9 @@ describe 'Single Table Inheritance' do
|
|
138
138
|
altered_inheriting.tag_list = 'fork, spoon'
|
139
139
|
altered_inheriting.save!
|
140
140
|
|
141
|
-
expect(InheritingTaggableModel.tags_on(:tags, order:
|
142
|
-
expect(AlteredInheritingTaggableModel.tags_on(:tags, order:
|
143
|
-
expect(TaggableModel.tags_on(:tags, order:
|
141
|
+
expect(InheritingTaggableModel.tags_on(:tags, order: "#{ActsAsTaggableOn.tags_table}.id").map(&:name)).to eq(%w(bob kelso))
|
142
|
+
expect(AlteredInheritingTaggableModel.tags_on(:tags, order: "#{ActsAsTaggableOn.tags_table}.id").map(&:name)).to eq(%w(fork spoon))
|
143
|
+
expect(TaggableModel.tags_on(:tags, order: "#{ActsAsTaggableOn.tags_table}.id").map(&:name)).to eq(%w(bob kelso fork spoon))
|
144
144
|
end
|
145
145
|
|
146
146
|
it 'should store same tag without validation conflict' do
|
@@ -150,7 +150,12 @@ describe 'Single Table Inheritance' do
|
|
150
150
|
inheriting_model.tag_list = 'one'
|
151
151
|
inheriting_model.save!
|
152
152
|
|
153
|
-
inheriting_model.
|
153
|
+
inheriting_model.update! name: 'foo'
|
154
|
+
end
|
155
|
+
|
156
|
+
it "should only join with taggable's table to check type for inherited models" do
|
157
|
+
expect(TaggableModel.tag_counts_on(:tags).to_sql).to_not match /INNER JOIN taggable_models ON/
|
158
|
+
expect(InheritingTaggableModel.tag_counts_on(:tags).to_sql).to match /INNER JOIN taggable_models ON/
|
154
159
|
end
|
155
160
|
end
|
156
161
|
|
@@ -200,8 +200,8 @@ describe 'Taggable' do
|
|
200
200
|
@taggables[1].skill_list = 'css'
|
201
201
|
@taggables.each { |taggable| taggable.save }
|
202
202
|
|
203
|
-
@found_taggables_by_tag = TaggableModel.joins(:tags).where(
|
204
|
-
@found_taggables_by_skill = TaggableModel.joins(:skills).where(
|
203
|
+
@found_taggables_by_tag = TaggableModel.joins(:tags).where(ActsAsTaggableOn.tags_table => {name: ['bob']})
|
204
|
+
@found_taggables_by_skill = TaggableModel.joins(:skills).where(ActsAsTaggableOn.tags_table => {name: ['ruby']})
|
205
205
|
|
206
206
|
expect(@found_taggables_by_tag).to include @taggables[0]
|
207
207
|
expect(@found_taggables_by_tag).to_not include @taggables[1]
|
@@ -338,7 +338,7 @@ describe 'Taggable' do
|
|
338
338
|
TaggableModel.create(name: 'Charlie', skill_list: 'ruby')
|
339
339
|
|
340
340
|
expect(TaggableModel.all_tag_counts).to_not be_empty
|
341
|
-
expect(TaggableModel.all_tag_counts(order:
|
341
|
+
expect(TaggableModel.all_tag_counts(order: "#{ActsAsTaggableOn.tags_table}.id").first.count).to eq(3) # ruby
|
342
342
|
end
|
343
343
|
|
344
344
|
it 'should be able to get all tags on model as whole' do
|
@@ -347,7 +347,7 @@ describe 'Taggable' do
|
|
347
347
|
TaggableModel.create(name: 'Charlie', skill_list: 'ruby')
|
348
348
|
|
349
349
|
expect(TaggableModel.all_tags).to_not be_empty
|
350
|
-
expect(TaggableModel.all_tags(order:
|
350
|
+
expect(TaggableModel.all_tags(order: "#{ActsAsTaggableOn.tags_table}.id").first.name).to eq('ruby')
|
351
351
|
end
|
352
352
|
|
353
353
|
it 'should be able to use named scopes to chain tag finds by any tags by context' do
|
@@ -369,7 +369,7 @@ describe 'Taggable' do
|
|
369
369
|
TaggableModel.create(name: 'Frank', tag_list: 'ruby, rails')
|
370
370
|
TaggableModel.create(name: 'Charlie', skill_list: 'ruby')
|
371
371
|
|
372
|
-
expect(TaggableModel.tagged_with('ruby').tag_counts(order:
|
372
|
+
expect(TaggableModel.tagged_with('ruby').tag_counts(order: "#{ActsAsTaggableOn.tags_table}.id").first.count).to eq(2) # ruby
|
373
373
|
expect(TaggableModel.tagged_with('ruby').skill_counts.first.count).to eq(1) # ruby
|
374
374
|
end
|
375
375
|
|
@@ -378,7 +378,7 @@ describe 'Taggable' do
|
|
378
378
|
TaggableModel.create(name: 'Frank', tag_list: 'ruby, rails')
|
379
379
|
TaggableModel.create(name: 'Charlie', skill_list: 'ruby')
|
380
380
|
|
381
|
-
expect(TaggableModel.tagged_with('ruby').all_tag_counts(order:
|
381
|
+
expect(TaggableModel.tagged_with('ruby').all_tag_counts(order: "#{ActsAsTaggableOn.tags_table}.id").first.count).to eq(3) # ruby
|
382
382
|
end
|
383
383
|
|
384
384
|
it 'should be able to get all scoped tags' do
|
@@ -386,7 +386,7 @@ describe 'Taggable' do
|
|
386
386
|
TaggableModel.create(name: 'Frank', tag_list: 'ruby, rails')
|
387
387
|
TaggableModel.create(name: 'Charlie', skill_list: 'ruby')
|
388
388
|
|
389
|
-
expect(TaggableModel.tagged_with('ruby').all_tags(order:
|
389
|
+
expect(TaggableModel.tagged_with('ruby').all_tags(order: "#{ActsAsTaggableOn.tags_table}.id").first.name).to eq('ruby')
|
390
390
|
end
|
391
391
|
|
392
392
|
it 'should only return tag counts for the available scope' do
|
@@ -541,7 +541,7 @@ describe 'Taggable' do
|
|
541
541
|
|
542
542
|
it 'should not delete tags if not updated' do
|
543
543
|
model = TaggableModel.create(name: 'foo', tag_list: 'ruby, rails, programming')
|
544
|
-
model.
|
544
|
+
model.update(name: 'bar')
|
545
545
|
model.reload
|
546
546
|
expect(model.tag_list.sort).to eq(%w(ruby rails programming).sort)
|
547
547
|
end
|
@@ -672,7 +672,7 @@ describe 'Taggable' do
|
|
672
672
|
# NOTE: type column supports an STI Tag subclass in the test suite, though
|
673
673
|
# isn't included by default in the migration generator
|
674
674
|
expect(@taggable.grouped_column_names_for(ActsAsTaggableOn::Tag))
|
675
|
-
.to eq(
|
675
|
+
.to eq("#{ActsAsTaggableOn.tags_table}.id, #{ActsAsTaggableOn.tags_table}.name, #{ActsAsTaggableOn.tags_table}.taggings_count, #{ActsAsTaggableOn.tags_table}.type")
|
676
676
|
end
|
677
677
|
|
678
678
|
it 'should return all column names joined for TaggableModel GROUP clause' do
|
@@ -112,7 +112,7 @@ describe 'Tagger' do
|
|
112
112
|
end
|
113
113
|
|
114
114
|
it 'should not lose tags' do
|
115
|
-
@taggable.
|
115
|
+
@taggable.update(tag_list: 'ruby')
|
116
116
|
@user.tag(@taggable, with: 'ruby, scheme', on: :tags)
|
117
117
|
|
118
118
|
[@taggable, @user].each(&:reload)
|
@@ -120,7 +120,7 @@ describe 'Tagger' do
|
|
120
120
|
expect(@taggable.all_tags_list.sort).to eq(%w(ruby scheme).sort)
|
121
121
|
|
122
122
|
expect(-> {
|
123
|
-
@taggable.
|
123
|
+
@taggable.update(tag_list: '')
|
124
124
|
}).to change(ActsAsTaggableOn::Tagging, :count).by(-1)
|
125
125
|
|
126
126
|
expect(@taggable.tag_list).to be_empty
|
@@ -1,2 +1,2 @@
|
|
1
1
|
class Market < ActsAsTaggableOn::Tag
|
2
|
-
end
|
2
|
+
end
|
data/spec/internal/db/schema.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
ActiveRecord::Schema.define version: 0 do
|
2
|
-
create_table
|
2
|
+
create_table ActsAsTaggableOn.tags_table, force: true do |t|
|
3
3
|
t.string :name
|
4
4
|
t.integer :taggings_count, default: 0
|
5
5
|
t.string :type
|
6
6
|
end
|
7
|
-
add_index
|
7
|
+
add_index ActsAsTaggableOn.tags_table, ['name'], name: 'index_tags_on_name', unique: true
|
8
8
|
|
9
|
-
create_table
|
9
|
+
create_table ActsAsTaggableOn.taggings_table, force: true do |t|
|
10
10
|
t.integer :tag_id
|
11
11
|
|
12
12
|
# You should make sure that the column created is
|
@@ -23,10 +23,10 @@ ActiveRecord::Schema.define version: 0 do
|
|
23
23
|
|
24
24
|
t.datetime :created_at
|
25
25
|
end
|
26
|
-
add_index
|
26
|
+
add_index ActsAsTaggableOn.taggings_table,
|
27
27
|
['tag_id', 'taggable_id', 'taggable_type', 'context', 'tagger_id', 'tagger_type'],
|
28
28
|
unique: true, name: 'taggings_idx'
|
29
|
-
add_index
|
29
|
+
add_index ActsAsTaggableOn.taggings_table, :tag_id , name: 'index_taggings_on_tag_id'
|
30
30
|
|
31
31
|
# above copied from
|
32
32
|
# generators/acts_as_taggable_on/migration/migration_generator
|
@@ -36,6 +36,12 @@ ActiveRecord::Schema.define version: 0 do
|
|
36
36
|
t.column :type, :string
|
37
37
|
end
|
38
38
|
|
39
|
+
create_table :columns_override_models, force: true do |t|
|
40
|
+
t.column :name, :string
|
41
|
+
t.column :type, :string
|
42
|
+
t.column :ignored_column, :string
|
43
|
+
end
|
44
|
+
|
39
45
|
create_table :non_standard_id_taggable_models, primary_key: 'an_id', force: true do |t|
|
40
46
|
t.column :name, :string
|
41
47
|
t.column :type, :string
|