acts-as-taggable-on 3.2.2 → 3.2.3
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/.travis.yml +20 -1
- data/Gemfile +1 -0
- data/acts-as-taggable-on.gemspec +1 -1
- data/gemfiles/activerecord_3.2.gemfile +1 -0
- data/gemfiles/activerecord_4.0.gemfile +1 -0
- data/gemfiles/activerecord_4.1.gemfile +1 -0
- data/gemfiles/activerecord_edge.gemfile +1 -0
- data/lib/acts_as_taggable_on/acts_as_taggable_on/collection.rb +2 -0
- data/lib/acts_as_taggable_on/acts_as_taggable_on/core.rb +2 -1
- data/lib/acts_as_taggable_on/acts_as_taggable_on/related.rb +1 -1
- data/lib/acts_as_taggable_on/tag.rb +1 -1
- data/lib/acts_as_taggable_on/tagging.rb +6 -0
- data/lib/acts_as_taggable_on/version.rb +1 -1
- data/spec/acts_as_taggable_on/taggable_spec.rb +6 -0
- data/spec/acts_as_taggable_on/tagging_spec.rb +26 -2
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 755e4d829ddc31ccd6ffb8385594ed8c5c64971f
|
|
4
|
+
data.tar.gz: 1ce12972b7d9d436484d619843a7bdf316a5c3b7
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c8f129a07903598bcb765b260bd14db168b4a6fbf6989cef816157ae6350cadd733f75ca6cc0169e00fa8c19b59710198b868f52044f07efca451c44aa9a046c
|
|
7
|
+
data.tar.gz: 578b3d36b654b9343a36df3a7086b40b3ef32f6b43973d92c0f31251ea095405b692d2ef131ba74086366d117eef0fcd2334b51ce8f7ce3c0266481819a0a2a1
|
data/.travis.yml
CHANGED
|
@@ -3,15 +3,19 @@ rvm:
|
|
|
3
3
|
- 2.0.0
|
|
4
4
|
- 2.1.1
|
|
5
5
|
- rbx-2
|
|
6
|
+
- ruby-head
|
|
7
|
+
|
|
6
8
|
env:
|
|
7
9
|
- DB=sqlite3
|
|
8
10
|
- DB=mysql
|
|
9
11
|
- DB=postgresql
|
|
12
|
+
|
|
10
13
|
gemfile:
|
|
11
14
|
- gemfiles/activerecord_3.2.gemfile
|
|
12
15
|
- gemfiles/activerecord_4.0.gemfile
|
|
13
16
|
- gemfiles/activerecord_4.1.gemfile
|
|
14
17
|
- gemfiles/activerecord_edge.gemfile
|
|
18
|
+
|
|
15
19
|
cache: bundler
|
|
16
20
|
script: bundle exec rake
|
|
17
21
|
before_install: gem install bundler
|
|
@@ -20,4 +24,19 @@ matrix:
|
|
|
20
24
|
fast_finish: true
|
|
21
25
|
allow_failures:
|
|
22
26
|
- gemfile: gemfiles/activerecord_edge.gemfile
|
|
23
|
-
- rvm: rbx-2
|
|
27
|
+
- rvm: rbx-2
|
|
28
|
+
exclude:
|
|
29
|
+
- rvm: 1.9.3
|
|
30
|
+
gemfile: ci/Gemfile.activerecord-4.0.x
|
|
31
|
+
- rvm: 1.9.3
|
|
32
|
+
gemfile: ci/Gemfile.activerecord-4.1.x
|
|
33
|
+
- rvm: 1.9.3
|
|
34
|
+
gemfile: ci/Gemfile.activerecord-edge
|
|
35
|
+
- rvm: rbx-2
|
|
36
|
+
gemfile: ci/Gemfile.activerecord-3.2.x
|
|
37
|
+
- rvm: ruby-head
|
|
38
|
+
gemfile: ci/Gemfile.activerecord-3.2.x
|
|
39
|
+
- rvm: ruby-head
|
|
40
|
+
gemfile: ci/Gemfile.activerecord-4.0.x
|
|
41
|
+
- rvm: ruby-head
|
|
42
|
+
gemfile: ci/Gemfile.activerecord-4.1.x
|
data/Gemfile
CHANGED
data/acts-as-taggable-on.gemspec
CHANGED
|
@@ -29,7 +29,7 @@ Gem::Specification.new do |gem|
|
|
|
29
29
|
gem.add_development_dependency 'mysql2'
|
|
30
30
|
gem.add_development_dependency 'pg'
|
|
31
31
|
|
|
32
|
-
gem.add_development_dependency 'rspec-rails' , '~> 3.0.0.
|
|
32
|
+
gem.add_development_dependency 'rspec-rails' , '~> 3.0.0.beta1'
|
|
33
33
|
gem.add_development_dependency 'rspec-its', '~> 1.0'
|
|
34
34
|
gem.add_development_dependency 'rspec', '3.0.0.beta2'
|
|
35
35
|
gem.add_development_dependency 'ammeter', '~> 1.0'
|
|
@@ -53,6 +53,7 @@ module ActsAsTaggableOn::Taggable
|
|
|
53
53
|
# * :order - A piece of SQL to order by. Eg 'tags.count desc' or 'taggings.created_at desc'
|
|
54
54
|
# * :on - Scope the find to only include a certain context
|
|
55
55
|
def all_tags(options = {})
|
|
56
|
+
options = options.dup
|
|
56
57
|
options.assert_valid_keys :start_at, :end_at, :conditions, :order, :limit, :on
|
|
57
58
|
|
|
58
59
|
## Generate conditions:
|
|
@@ -87,6 +88,7 @@ module ActsAsTaggableOn::Taggable
|
|
|
87
88
|
# * :at_most - Exclude tags with a frequency greater than the given value
|
|
88
89
|
# * :on - Scope the find to only include a certain context
|
|
89
90
|
def all_tag_counts(options = {})
|
|
91
|
+
options = options.dup
|
|
90
92
|
options.assert_valid_keys :start_at, :end_at, :conditions, :at_least, :at_most, :order, :limit, :on, :id
|
|
91
93
|
|
|
92
94
|
## Generate conditions:
|
|
@@ -83,6 +83,7 @@ module ActsAsTaggableOn::Taggable
|
|
|
83
83
|
# User.tagged_with("awesome", "cool", :owned_by => foo ) # Users that are tagged with just awesome and cool by 'foo'
|
|
84
84
|
def tagged_with(tags, options = {})
|
|
85
85
|
tag_list = ActsAsTaggableOn::TagList.from(tags)
|
|
86
|
+
options = options.dup
|
|
86
87
|
empty_result = where('1 = 0')
|
|
87
88
|
|
|
88
89
|
return empty_result if tag_list.empty?
|
|
@@ -382,7 +383,7 @@ module ActsAsTaggableOn::Taggable
|
|
|
382
383
|
|
|
383
384
|
# Destroy old taggings:
|
|
384
385
|
if old_tags.present?
|
|
385
|
-
|
|
386
|
+
self.taggings.not_owned.by_context(context).destroy_all(tag_id: old_tags)
|
|
386
387
|
end
|
|
387
388
|
|
|
388
389
|
# Create new taggings:
|
|
@@ -41,7 +41,7 @@ module ActsAsTaggableOn::Taggable
|
|
|
41
41
|
end
|
|
42
42
|
|
|
43
43
|
def related_tags_for(context, klass, options = {})
|
|
44
|
-
tags_to_ignore = Array.wrap(options
|
|
44
|
+
tags_to_ignore = Array.wrap(options[:ignore]).map(&:to_s) || []
|
|
45
45
|
tags_to_find = tags_on(context).map { |t| t.name }.reject { |t| tags_to_ignore.include? t }
|
|
46
46
|
related_where(klass, ["#{exclude_self(klass, id)} #{klass.table_name}.#{klass.primary_key} = #{ActsAsTaggableOn::Tagging.table_name}.taggable_id AND #{ActsAsTaggableOn::Tagging.table_name}.taggable_type = '#{klass.base_class}' AND #{ActsAsTaggableOn::Tagging.table_name}.tag_id = #{ActsAsTaggableOn::Tag.table_name}.#{ActsAsTaggableOn::Tag.primary_key} AND #{ActsAsTaggableOn::Tag.table_name}.name IN (?)", tags_to_find])
|
|
47
47
|
end
|
|
@@ -15,6 +15,12 @@ module ActsAsTaggableOn
|
|
|
15
15
|
belongs_to :taggable, polymorphic: true
|
|
16
16
|
belongs_to :tagger, polymorphic: true
|
|
17
17
|
|
|
18
|
+
scope :owned_by, ->(owner) { where(tagger: owner) }
|
|
19
|
+
scope :not_owned, -> { where(tagger_id: nil, tagger_type: nil) }
|
|
20
|
+
|
|
21
|
+
scope :by_contexts, ->(contexts = ['tags']) { where(context: contexts) }
|
|
22
|
+
scope :by_context, ->(context= 'tags') { by_contexts(context.to_s) }
|
|
23
|
+
|
|
18
24
|
validates_presence_of :context
|
|
19
25
|
validates_presence_of :tag_id
|
|
20
26
|
|
|
@@ -494,6 +494,12 @@ describe 'Taggable' do
|
|
|
494
494
|
end
|
|
495
495
|
end
|
|
496
496
|
|
|
497
|
+
it 'should options key not be deleted' do
|
|
498
|
+
options = {:exclude => true}
|
|
499
|
+
TaggableModel.tagged_with("foo", options)
|
|
500
|
+
expect(options).to eq({:exclude => true})
|
|
501
|
+
end
|
|
502
|
+
|
|
497
503
|
context 'Duplicates' do
|
|
498
504
|
context 'should not create duplicate taggings' do
|
|
499
505
|
let(:bob) { TaggableModel.create(name: 'Bob') }
|
|
@@ -23,5 +23,29 @@ describe ActsAsTaggableOn::Tagging do
|
|
|
23
23
|
2.times { ActsAsTaggableOn::Tagging.create(taggable: @taggable, tag: @tag, context: 'tags') }
|
|
24
24
|
}).to change(ActsAsTaggableOn::Tagging, :count).by(1)
|
|
25
25
|
end
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
|
|
27
|
+
it 'should not delete tags of other records' do
|
|
28
|
+
6.times { TaggableModel.create(name: 'Bob Jones', tag_list: 'very, serious, bug') }
|
|
29
|
+
expect(ActsAsTaggableOn::Tag.count).to eq(3)
|
|
30
|
+
taggable = TaggableModel.first
|
|
31
|
+
taggable.tag_list = 'bug'
|
|
32
|
+
taggable.save
|
|
33
|
+
|
|
34
|
+
expect(taggable.tag_list).to eq(['bug'])
|
|
35
|
+
|
|
36
|
+
another_taggable = TaggableModel.where('id != ?', taggable.id).sample
|
|
37
|
+
expect(another_taggable.tag_list.sort).to eq(%w(very serious bug).sort)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
pending 'context scopes' do
|
|
41
|
+
describe '.by_context'
|
|
42
|
+
|
|
43
|
+
describe '.by_contexts'
|
|
44
|
+
|
|
45
|
+
describe '.owned_by'
|
|
46
|
+
|
|
47
|
+
describe '.not_owned'
|
|
48
|
+
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: acts-as-taggable-on
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.2.
|
|
4
|
+
version: 3.2.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Michael Bleigh
|
|
@@ -99,14 +99,14 @@ dependencies:
|
|
|
99
99
|
requirements:
|
|
100
100
|
- - "~>"
|
|
101
101
|
- !ruby/object:Gem::Version
|
|
102
|
-
version: 3.0.0.
|
|
102
|
+
version: 3.0.0.beta1
|
|
103
103
|
type: :development
|
|
104
104
|
prerelease: false
|
|
105
105
|
version_requirements: !ruby/object:Gem::Requirement
|
|
106
106
|
requirements:
|
|
107
107
|
- - "~>"
|
|
108
108
|
- !ruby/object:Gem::Version
|
|
109
|
-
version: 3.0.0.
|
|
109
|
+
version: 3.0.0.beta1
|
|
110
110
|
- !ruby/object:Gem::Dependency
|
|
111
111
|
name: rspec-its
|
|
112
112
|
requirement: !ruby/object:Gem::Requirement
|