acts-as-taggable-on 6.5.0 → 9.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.
- checksums.yaml +4 -4
- data/.github/workflows/spec.yml +76 -0
- data/Appraisals +13 -9
- data/CHANGELOG.md +35 -5
- data/Gemfile +1 -0
- data/README.md +34 -9
- data/acts-as-taggable-on.gemspec +2 -2
- data/db/migrate/1_acts_as_taggable_on_migration.rb +5 -7
- data/db/migrate/2_add_missing_unique_indices.rb +6 -8
- data/db/migrate/3_add_taggings_counter_cache_to_tags.rb +3 -6
- data/db/migrate/4_add_missing_taggable_index.rb +5 -7
- data/db/migrate/5_change_collation_for_tag_names.rb +4 -6
- data/db/migrate/6_add_missing_indexes_on_taggings.rb +15 -13
- data/db/migrate/7_add_tenant_to_taggings.rb +13 -0
- data/docker-compose.yml +15 -0
- data/gemfiles/activerecord_6.0.gemfile +5 -8
- data/gemfiles/{activerecord_5.2.gemfile → activerecord_6.1.gemfile} +6 -9
- data/gemfiles/{activerecord_5.0.gemfile → activerecord_7.0.gemfile} +6 -9
- data/lib/acts-as-taggable-on.rb +1 -1
- data/lib/acts_as_taggable_on/default_parser.rb +8 -10
- data/lib/acts_as_taggable_on/engine.rb +2 -0
- data/lib/acts_as_taggable_on/generic_parser.rb +2 -0
- data/lib/acts_as_taggable_on/tag.rb +34 -28
- data/lib/acts_as_taggable_on/tag_list.rb +8 -11
- data/lib/acts_as_taggable_on/taggable/cache.rb +64 -62
- data/lib/acts_as_taggable_on/taggable/collection.rb +178 -142
- data/lib/acts_as_taggable_on/taggable/core.rb +250 -236
- data/lib/acts_as_taggable_on/taggable/ownership.rb +110 -98
- data/lib/acts_as_taggable_on/taggable/related.rb +60 -47
- data/lib/acts_as_taggable_on/taggable/tag_list_type.rb +6 -2
- data/lib/acts_as_taggable_on/taggable/tagged_with_query/all_tags_query.rb +110 -106
- data/lib/acts_as_taggable_on/taggable/tagged_with_query/any_tags_query.rb +57 -53
- data/lib/acts_as_taggable_on/taggable/tagged_with_query/exclude_tags_query.rb +63 -60
- data/lib/acts_as_taggable_on/taggable/tagged_with_query/query_base.rb +54 -46
- data/lib/acts_as_taggable_on/taggable/tagged_with_query.rb +14 -8
- data/lib/acts_as_taggable_on/taggable.rb +30 -12
- data/lib/acts_as_taggable_on/tagger.rb +10 -6
- data/lib/acts_as_taggable_on/tagging.rb +9 -5
- data/lib/acts_as_taggable_on/tags_helper.rb +3 -1
- data/lib/acts_as_taggable_on/utils.rb +4 -2
- data/lib/acts_as_taggable_on/version.rb +3 -1
- data/spec/acts_as_taggable_on/tag_spec.rb +16 -1
- data/spec/acts_as_taggable_on/taggable_spec.rb +7 -3
- data/spec/acts_as_taggable_on/tagging_spec.rb +26 -0
- data/spec/internal/app/models/taggable_model.rb +2 -0
- data/spec/internal/config/database.yml.sample +4 -8
- data/spec/internal/db/schema.rb +3 -0
- data/spec/support/database.rb +36 -26
- metadata +16 -24
- data/.travis.yml +0 -43
- data/UPGRADING.md +0 -8
- data/gemfiles/activerecord_5.1.gemfile +0 -21
@@ -109,6 +109,10 @@ describe 'Taggable' do
|
|
109
109
|
expect(@taggable.tag_types).to eq(TaggableModel.tag_types)
|
110
110
|
end
|
111
111
|
|
112
|
+
it 'should have tenant column' do
|
113
|
+
expect(TaggableModel.tenant_column).to eq(:tenant_id)
|
114
|
+
end
|
115
|
+
|
112
116
|
it 'should have tag_counts_on' do
|
113
117
|
expect(TaggableModel.tag_counts_on(:tags)).to be_empty
|
114
118
|
|
@@ -477,7 +481,7 @@ describe 'Taggable' do
|
|
477
481
|
|
478
482
|
expect(TaggableModel.tagged_with(%w(bob tricia), wild: true, any: true).to_a.sort_by { |o| o.id }).to eq([bob, frank, steve])
|
479
483
|
expect(TaggableModel.tagged_with(%w(bob tricia), wild: true, exclude: true).to_a).to eq([jim])
|
480
|
-
expect(TaggableModel.tagged_with('ji', wild: true, any: true).to_a
|
484
|
+
expect(TaggableModel.tagged_with('ji', wild: true, any: true).to_a).to match_array([frank, jim])
|
481
485
|
end
|
482
486
|
end
|
483
487
|
|
@@ -676,11 +680,11 @@ describe 'Taggable' do
|
|
676
680
|
end
|
677
681
|
|
678
682
|
it 'should return all column names joined for TaggableModel GROUP clause' do
|
679
|
-
expect(@taggable.grouped_column_names_for(TaggableModel)).to eq('taggable_models.id, taggable_models.name, taggable_models.type')
|
683
|
+
expect(@taggable.grouped_column_names_for(TaggableModel)).to eq('taggable_models.id, taggable_models.name, taggable_models.type, taggable_models.tenant_id')
|
680
684
|
end
|
681
685
|
|
682
686
|
it 'should return all column names joined for NonStandardIdTaggableModel GROUP clause' do
|
683
|
-
expect(@taggable.grouped_column_names_for(TaggableModel)).to eq("taggable_models.#{TaggableModel.primary_key}, taggable_models.name, taggable_models.type")
|
687
|
+
expect(@taggable.grouped_column_names_for(TaggableModel)).to eq("taggable_models.#{TaggableModel.primary_key}, taggable_models.name, taggable_models.type, taggable_models.tenant_id")
|
684
688
|
end
|
685
689
|
end
|
686
690
|
|
@@ -49,6 +49,22 @@ describe ActsAsTaggableOn::Tagging do
|
|
49
49
|
ActsAsTaggableOn.remove_unused_tags = previous_setting
|
50
50
|
end
|
51
51
|
|
52
|
+
it 'should destroy unused tags after tagging destroyed when not using tags_counter' do
|
53
|
+
remove_unused_tags_previous_setting = ActsAsTaggableOn.remove_unused_tags
|
54
|
+
tags_counter_previous_setting = ActsAsTaggableOn.tags_counter
|
55
|
+
ActsAsTaggableOn.remove_unused_tags = true
|
56
|
+
ActsAsTaggableOn.tags_counter = false
|
57
|
+
|
58
|
+
ActsAsTaggableOn::Tag.destroy_all
|
59
|
+
@taggable = TaggableModel.create(name: 'Bob Jones')
|
60
|
+
@taggable.update_attribute :tag_list, 'aaa,bbb,ccc'
|
61
|
+
@taggable.update_attribute :tag_list, ''
|
62
|
+
expect(ActsAsTaggableOn::Tag.count).to eql(0)
|
63
|
+
|
64
|
+
ActsAsTaggableOn.remove_unused_tags = remove_unused_tags_previous_setting
|
65
|
+
ActsAsTaggableOn.tags_counter = tags_counter_previous_setting
|
66
|
+
end
|
67
|
+
|
52
68
|
describe 'context scopes' do
|
53
69
|
before do
|
54
70
|
@tagging_2 = ActsAsTaggableOn::Tagging.new
|
@@ -61,12 +77,14 @@ describe ActsAsTaggableOn::Tagging do
|
|
61
77
|
@tagging.tag = ActsAsTaggableOn::Tag.create(name: "Physics")
|
62
78
|
@tagging.tagger = @tagger
|
63
79
|
@tagging.context = 'Science'
|
80
|
+
@tagging.tenant = 'account1'
|
64
81
|
@tagging.save
|
65
82
|
|
66
83
|
@tagging_2.taggable = TaggableModel.create(name: "Satellites")
|
67
84
|
@tagging_2.tag = ActsAsTaggableOn::Tag.create(name: "Technology")
|
68
85
|
@tagging_2.tagger = @tagger_2
|
69
86
|
@tagging_2.context = 'Science'
|
87
|
+
@tagging_2.tenant = 'account1'
|
70
88
|
@tagging_2.save
|
71
89
|
|
72
90
|
@tagging_3.taggable = TaggableModel.create(name: "Satellites")
|
@@ -98,6 +116,14 @@ describe ActsAsTaggableOn::Tagging do
|
|
98
116
|
end
|
99
117
|
end
|
100
118
|
|
119
|
+
describe '.by_tenant' do
|
120
|
+
it "should find taggings by tenant" do
|
121
|
+
expect(ActsAsTaggableOn::Tagging.by_tenant('account1').length).to eq(2);
|
122
|
+
expect(ActsAsTaggableOn::Tagging.by_tenant('account1').first).to eq(@tagging);
|
123
|
+
expect(ActsAsTaggableOn::Tagging.by_tenant('account1').second).to eq(@tagging_2);
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
101
127
|
describe '.not_owned' do
|
102
128
|
before do
|
103
129
|
@tagging_4 = ActsAsTaggableOn::Tagging.new
|
@@ -4,16 +4,12 @@ sqlite3:
|
|
4
4
|
|
5
5
|
mysql:
|
6
6
|
adapter: mysql2
|
7
|
-
host:
|
7
|
+
host: 127.0.0.1
|
8
8
|
username: root
|
9
9
|
password:
|
10
10
|
database: acts_as_taggable_on
|
11
|
-
|
11
|
+
encoding: utf8
|
12
12
|
|
13
13
|
postgresql:
|
14
|
-
|
15
|
-
|
16
|
-
username: postgres
|
17
|
-
password:
|
18
|
-
database: acts_as_taggable_on
|
19
|
-
encoding: utf8
|
14
|
+
# Needs to be given as a URL to force connection via TCP
|
15
|
+
url: postgresql://postgres:postgres@127.0.0.1:5432/acts_as_taggable_on?encoding=utf8
|
data/spec/internal/db/schema.rb
CHANGED
@@ -21,6 +21,8 @@ ActiveRecord::Schema.define version: 0 do
|
|
21
21
|
# length for MyISAM table type: http://bit.ly/vgW2Ql
|
22
22
|
t.string :context, limit: 128
|
23
23
|
|
24
|
+
t.string :tenant , limit: 128
|
25
|
+
|
24
26
|
t.datetime :created_at
|
25
27
|
end
|
26
28
|
add_index ActsAsTaggableOn.taggings_table,
|
@@ -34,6 +36,7 @@ ActiveRecord::Schema.define version: 0 do
|
|
34
36
|
create_table :taggable_models, force: true do |t|
|
35
37
|
t.column :name, :string
|
36
38
|
t.column :type, :string
|
39
|
+
t.column :tenant_id, :integer
|
37
40
|
end
|
38
41
|
|
39
42
|
create_table :columns_override_models, force: true do |t|
|
data/spec/support/database.rb
CHANGED
@@ -1,36 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# set adapter to use, default is sqlite3
|
2
4
|
# to use an alternative adapter run => rake spec DB='postgresql'
|
3
5
|
db_name = ENV['DB'] || 'sqlite3'
|
4
|
-
database_yml = File.expand_path('
|
6
|
+
database_yml = File.expand_path('../internal/config/database.yml', __dir__)
|
5
7
|
|
6
|
-
|
8
|
+
unless File.exist?(database_yml)
|
9
|
+
raise "Please create #{database_yml} first to configure your database. Take a look at: #{database_yml}.sample"
|
10
|
+
end
|
7
11
|
|
8
|
-
|
12
|
+
ActiveRecord::Base.configurations = YAML.load_file(database_yml)
|
13
|
+
ActiveRecord::Base.logger = Logger.new(File.join(File.dirname(__FILE__), '../debug.log'))
|
14
|
+
ActiveRecord::Base.logger.level = ENV['CI'] ? ::Logger::ERROR : ::Logger::DEBUG
|
15
|
+
ActiveRecord::Migration.verbose = false
|
16
|
+
if ActiveRecord.version >= Gem::Version.new('7.0.0.alpha2')
|
17
|
+
ActiveRecord.default_timezone = :utc
|
18
|
+
else
|
9
19
|
ActiveRecord::Base.default_timezone = :utc
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
ActiveRecord::Base.establish_connection(db_name.to_sym)
|
17
|
-
ActiveRecord::Base.connection
|
18
|
-
rescue
|
19
|
-
case db_name
|
20
|
-
when /mysql/
|
21
|
-
ActiveRecord::Base.establish_connection(config.merge('database' => nil))
|
22
|
-
ActiveRecord::Base.connection.create_database(config['database'], {charset: 'utf8', collation: 'utf8_unicode_ci'})
|
23
|
-
when 'postgresql'
|
24
|
-
ActiveRecord::Base.establish_connection(config.merge('database' => 'postgres', 'schema_search_path' => 'public'))
|
25
|
-
ActiveRecord::Base.connection.create_database(config['database'], config.merge('encoding' => 'utf8'))
|
26
|
-
end
|
20
|
+
end
|
21
|
+
config = if ActiveRecord.version >= Gem::Version.new('6.1.0')
|
22
|
+
ActiveRecord::Base.configurations.configs_for(env_name: db_name)
|
23
|
+
else
|
24
|
+
ActiveSupport::HashWithIndifferentAccess.new(ActiveRecord::Base.configurations[db_name])
|
25
|
+
end
|
27
26
|
|
28
|
-
|
27
|
+
begin
|
28
|
+
ActiveRecord::Base.establish_connection(db_name.to_sym)
|
29
|
+
ActiveRecord::Base.connection
|
30
|
+
rescue StandardError
|
31
|
+
case db_name
|
32
|
+
when /mysql/
|
33
|
+
ActiveRecord::Base.establish_connection(config.merge('database' => nil))
|
34
|
+
ActiveRecord::Base.connection.create_database(config['database'],
|
35
|
+
{ charset: 'utf8', collation: 'utf8_unicode_ci' })
|
36
|
+
when 'postgresql'
|
37
|
+
ActiveRecord::Base.establish_connection(config.merge('database' => 'postgres',
|
38
|
+
'schema_search_path' => 'public'))
|
39
|
+
ActiveRecord::Base.connection.create_database(config['database'], config.merge('encoding' => 'utf8'))
|
29
40
|
end
|
30
41
|
|
31
|
-
|
32
|
-
Dir[File.dirname(__dir__) + '/internal/app/models/*.rb'].each { |f| require f }
|
33
|
-
|
34
|
-
else
|
35
|
-
fail "Please create #{database_yml} first to configure your database. Take a look at: #{database_yml}.sample"
|
42
|
+
ActiveRecord::Base.establish_connection(config)
|
36
43
|
end
|
44
|
+
|
45
|
+
require "#{File.dirname(__FILE__)}/../internal/db/schema.rb"
|
46
|
+
Dir["#{File.dirname(__dir__)}/internal/app/models/*.rb"].each { |f| require f }
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: acts-as-taggable-on
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 9.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Bleigh
|
8
8
|
- Joost Baaij
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2022-01-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activerecord
|
@@ -17,20 +17,20 @@ dependencies:
|
|
17
17
|
requirements:
|
18
18
|
- - ">="
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version: '
|
20
|
+
version: '6.0'
|
21
21
|
- - "<"
|
22
22
|
- !ruby/object:Gem::Version
|
23
|
-
version: '
|
23
|
+
version: '7.1'
|
24
24
|
type: :runtime
|
25
25
|
prerelease: false
|
26
26
|
version_requirements: !ruby/object:Gem::Requirement
|
27
27
|
requirements:
|
28
28
|
- - ">="
|
29
29
|
- !ruby/object:Gem::Version
|
30
|
-
version: '
|
30
|
+
version: '6.0'
|
31
31
|
- - "<"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '7.1'
|
34
34
|
- !ruby/object:Gem::Dependency
|
35
35
|
name: rspec-rails
|
36
36
|
requirement: !ruby/object:Gem::Requirement
|
@@ -110,9 +110,9 @@ executables: []
|
|
110
110
|
extensions: []
|
111
111
|
extra_rdoc_files: []
|
112
112
|
files:
|
113
|
+
- ".github/workflows/spec.yml"
|
113
114
|
- ".gitignore"
|
114
115
|
- ".rspec"
|
115
|
-
- ".travis.yml"
|
116
116
|
- Appraisals
|
117
117
|
- CHANGELOG.md
|
118
118
|
- CONTRIBUTING.md
|
@@ -121,7 +121,6 @@ files:
|
|
121
121
|
- LICENSE.md
|
122
122
|
- README.md
|
123
123
|
- Rakefile
|
124
|
-
- UPGRADING.md
|
125
124
|
- acts-as-taggable-on.gemspec
|
126
125
|
- db/migrate/1_acts_as_taggable_on_migration.rb
|
127
126
|
- db/migrate/2_add_missing_unique_indices.rb
|
@@ -129,10 +128,11 @@ files:
|
|
129
128
|
- db/migrate/4_add_missing_taggable_index.rb
|
130
129
|
- db/migrate/5_change_collation_for_tag_names.rb
|
131
130
|
- db/migrate/6_add_missing_indexes_on_taggings.rb
|
132
|
-
-
|
133
|
-
-
|
134
|
-
- gemfiles/activerecord_5.2.gemfile
|
131
|
+
- db/migrate/7_add_tenant_to_taggings.rb
|
132
|
+
- docker-compose.yml
|
135
133
|
- gemfiles/activerecord_6.0.gemfile
|
134
|
+
- gemfiles/activerecord_6.1.gemfile
|
135
|
+
- gemfiles/activerecord_7.0.gemfile
|
136
136
|
- lib/acts-as-taggable-on.rb
|
137
137
|
- lib/acts_as_taggable_on.rb
|
138
138
|
- lib/acts_as_taggable_on/default_parser.rb
|
@@ -199,15 +199,7 @@ homepage: https://github.com/mbleigh/acts-as-taggable-on
|
|
199
199
|
licenses:
|
200
200
|
- MIT
|
201
201
|
metadata: {}
|
202
|
-
post_install_message:
|
203
|
-
When upgrading
|
204
|
-
|
205
|
-
Re-run the migrations generator
|
206
|
-
|
207
|
-
rake acts_as_taggable_on_engine:install:migrations
|
208
|
-
|
209
|
-
This will create any new migrations and skip existing ones
|
210
|
-
Version 3.5.0 has a migration for mysql adapter
|
202
|
+
post_install_message:
|
211
203
|
rdoc_options: []
|
212
204
|
require_paths:
|
213
205
|
- lib
|
@@ -215,15 +207,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
215
207
|
requirements:
|
216
208
|
- - ">="
|
217
209
|
- !ruby/object:Gem::Version
|
218
|
-
version: 2.
|
210
|
+
version: 2.5.0
|
219
211
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
220
212
|
requirements:
|
221
213
|
- - ">="
|
222
214
|
- !ruby/object:Gem::Version
|
223
215
|
version: '0'
|
224
216
|
requirements: []
|
225
|
-
rubygems_version: 3.
|
226
|
-
signing_key:
|
217
|
+
rubygems_version: 3.2.22
|
218
|
+
signing_key:
|
227
219
|
specification_version: 4
|
228
220
|
summary: Advanced tagging for Rails.
|
229
221
|
test_files:
|
data/.travis.yml
DELETED
@@ -1,43 +0,0 @@
|
|
1
|
-
language: ruby
|
2
|
-
cache: bundler
|
3
|
-
|
4
|
-
addons:
|
5
|
-
postgresql: '10'
|
6
|
-
|
7
|
-
services:
|
8
|
-
- mysql
|
9
|
-
- postgresql
|
10
|
-
|
11
|
-
rvm:
|
12
|
-
- 2.6.5
|
13
|
-
- 2.5.5
|
14
|
-
- 2.4.6
|
15
|
-
- 2.3.7
|
16
|
-
|
17
|
-
env:
|
18
|
-
- DB=sqlite3
|
19
|
-
- DB=mysql
|
20
|
-
- DB=postgresql
|
21
|
-
|
22
|
-
gemfile:
|
23
|
-
- gemfiles/activerecord_5.2.gemfile
|
24
|
-
- gemfiles/activerecord_5.1.gemfile
|
25
|
-
- gemfiles/activerecord_5.0.gemfile
|
26
|
-
- gemfiles/activerecord_6.0.gemfile
|
27
|
-
|
28
|
-
bundler_args: '--without local_development --jobs 3 --retry 3'
|
29
|
-
|
30
|
-
before_install:
|
31
|
-
- gem install bundler
|
32
|
-
|
33
|
-
script: bundle exec rake
|
34
|
-
|
35
|
-
matrix:
|
36
|
-
allow_failures:
|
37
|
-
- rvm: ruby-head
|
38
|
-
fast_finish: true
|
39
|
-
exclude:
|
40
|
-
- rvm: 2.3.7
|
41
|
-
gemfile: gemfiles/activerecord_6.0.gemfile
|
42
|
-
- rvm: 2.4.6
|
43
|
-
gemfile: gemfiles/activerecord_6.0.gemfile
|
data/UPGRADING.md
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
source "https://rubygems.org"
|
2
|
-
|
3
|
-
gem "activerecord", "~> 5.1.1"
|
4
|
-
case ENV["DB"]
|
5
|
-
when "postgresql"
|
6
|
-
gem 'pg'
|
7
|
-
when "mysql"
|
8
|
-
gem 'mysql2', '~> 0.3'
|
9
|
-
else
|
10
|
-
gem "sqlite3", "~> 1.3", "< 1.4"
|
11
|
-
end
|
12
|
-
|
13
|
-
group :local_development do
|
14
|
-
gem "guard"
|
15
|
-
gem "guard-rspec"
|
16
|
-
gem "appraisal"
|
17
|
-
gem "rake"
|
18
|
-
gem "byebug", platforms: [:mri]
|
19
|
-
end
|
20
|
-
|
21
|
-
gemspec path: "../"
|