acts-as-taggable-on 3.2.5 → 3.2.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Appraisals +0 -4
- data/acts-as-taggable-on.gemspec +0 -1
- data/gemfiles/activerecord_3.2.gemfile +0 -1
- data/gemfiles/activerecord_4.0.gemfile +0 -1
- data/gemfiles/activerecord_4.1.gemfile +0 -1
- data/gemfiles/activerecord_edge.gemfile +0 -1
- data/lib/acts-as-taggable-on.rb +1 -1
- data/lib/acts_as_taggable_on/taggable/core.rb +7 -3
- data/lib/acts_as_taggable_on/version.rb +1 -1
- data/spec/acts_as_taggable_on/taggable/dirty_spec.rb +127 -0
- data/spec/acts_as_taggable_on/taggable_spec.rb +7 -108
- metadata +4 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c207ddc1c1646d4ad2e7ea2acb1b187ae59c7dfe
|
4
|
+
data.tar.gz: 71f15406a4e299bedca0c8e23d473d02cab5b1d8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e78b1c9f8d1b3ccc32567edd4f2e5703b34ea21c4ecf13bbc723647dedcfb2674177927955ffd6b0fd10a0e249d5e7e4ff85d4a72886a7d5016290bbab146862
|
7
|
+
data.tar.gz: b5e3f003ac97a1e11bad401cd8c0734570d6d0e647eed0c8c64d2c17cc7e88cfcc1204d0bf3e70b52641096cf79e84b0e9b190e19e667b938abea182e10fdf96
|
data/Appraisals
CHANGED
@@ -1,20 +1,16 @@
|
|
1
1
|
appraise "activerecord-3.2" do
|
2
2
|
gem "activerecord", "~> 3.2"
|
3
|
-
gem "actionpack", "~> 3.2"
|
4
3
|
end
|
5
4
|
|
6
5
|
appraise "activerecord-4.0" do
|
7
6
|
gem "activerecord", "~> 4.0"
|
8
|
-
gem "actionpack", "~> 4.0"
|
9
7
|
end
|
10
8
|
|
11
9
|
appraise "activerecord-4.1" do
|
12
10
|
gem "activerecord", "~> 4.1"
|
13
|
-
gem "actionpack", "~> 4.1"
|
14
11
|
end
|
15
12
|
|
16
13
|
appraise "activerecord-edge" do
|
17
14
|
gem "activerecord", github: "rails/rails"
|
18
|
-
gem "actionpack", github: "rails/rails"
|
19
15
|
gem 'arel', github: 'rails/arel'
|
20
16
|
end
|
data/acts-as-taggable-on.gemspec
CHANGED
@@ -23,7 +23,6 @@ Gem::Specification.new do |gem|
|
|
23
23
|
end
|
24
24
|
|
25
25
|
gem.add_runtime_dependency 'activerecord', ['>= 3', '< 5']
|
26
|
-
gem.add_runtime_dependency 'actionpack', ['>= 3', '< 5']
|
27
26
|
|
28
27
|
gem.add_development_dependency 'sqlite3'
|
29
28
|
gem.add_development_dependency 'mysql2', '~> 0.3.7'
|
data/lib/acts-as-taggable-on.rb
CHANGED
@@ -153,7 +153,7 @@ module ActsAsTaggableOn::Taggable
|
|
153
153
|
end
|
154
154
|
|
155
155
|
joins << tagging_join
|
156
|
-
unless any == 'distinct'
|
156
|
+
unless any == 'distinct' # Fix issue #544
|
157
157
|
group = "#{table_name}.#{primary_key}"
|
158
158
|
select_clause << group
|
159
159
|
end
|
@@ -329,8 +329,12 @@ module ActsAsTaggableOn::Taggable
|
|
329
329
|
old = changed_attributes[attrib]
|
330
330
|
changed_attributes.delete(attrib) if old.to_s == value.to_s
|
331
331
|
else
|
332
|
-
old = tag_list_on(context)
|
333
|
-
|
332
|
+
old = tag_list_on(context)
|
333
|
+
if self.class.preserve_tag_order
|
334
|
+
changed_attributes[attrib] = old if old.to_s != value.to_s
|
335
|
+
else
|
336
|
+
changed_attributes[attrib] = old.to_s if old.sort != ActsAsTaggableOn::TagListParser.parse(value).sort
|
337
|
+
end
|
334
338
|
end
|
335
339
|
end
|
336
340
|
|
@@ -0,0 +1,127 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe ActsAsTaggableOn::Taggable::Dirty do
|
5
|
+
context 'with un-contexted tags' do
|
6
|
+
before(:each) do
|
7
|
+
@taggable = TaggableModel.create(tag_list: 'awesome, epic')
|
8
|
+
end
|
9
|
+
|
10
|
+
context 'when tag_list changed' do
|
11
|
+
before(:each) do
|
12
|
+
expect(@taggable.changes).to be_empty
|
13
|
+
@taggable.tag_list = 'one'
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'should show changes of dirty object' do
|
17
|
+
expect(@taggable.changes).to eq({'tag_list' => ['awesome, epic', ['one']]})
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'flags tag_list as changed' do
|
21
|
+
expect(@taggable.tag_list_changed?).to be_truthy
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'preserves original value' do
|
25
|
+
expect(@taggable.tag_list_was).to eq('awesome, epic')
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'shows what the change was' do
|
29
|
+
expect(@taggable.tag_list_change).to eq(['awesome, epic', ['one']])
|
30
|
+
end
|
31
|
+
|
32
|
+
context 'without order' do
|
33
|
+
it 'should not mark attribute if order change ' do
|
34
|
+
taggable = TaggableModel.create(name: 'Dirty Harry', tag_list: %w(d c b a))
|
35
|
+
taggable.tag_list = %w(a b c d)
|
36
|
+
expect(taggable.tag_list_changed?).to be_falsey
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
context 'with order' do
|
41
|
+
it 'should mark attribute if order change' do
|
42
|
+
taggable = OrderedTaggableModel.create(name: 'Clean Harry', tag_list: 'd,c,b,a')
|
43
|
+
taggable.save
|
44
|
+
taggable.tag_list = %w(a b c d)
|
45
|
+
expect(taggable.tag_list_changed?).to be_truthy
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
context 'when tag_list is the same' do
|
51
|
+
before(:each) do
|
52
|
+
@taggable.tag_list = 'awesome, epic'
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'is not flagged as changed' do
|
56
|
+
expect(@taggable.tag_list_changed?).to be_falsy
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'does not show any changes to the taggable item' do
|
60
|
+
expect(@taggable.changes).to be_empty
|
61
|
+
end
|
62
|
+
|
63
|
+
context "and using a delimiter different from a ','" do
|
64
|
+
before do
|
65
|
+
@old_delimiter = ActsAsTaggableOn.delimiter
|
66
|
+
ActsAsTaggableOn.delimiter = ';'
|
67
|
+
end
|
68
|
+
|
69
|
+
after do
|
70
|
+
ActsAsTaggableOn.delimiter = @old_delimiter
|
71
|
+
end
|
72
|
+
|
73
|
+
it 'does not show any changes to the taggable item when using array assignments' do
|
74
|
+
@taggable.tag_list = %w(awesome epic)
|
75
|
+
expect(@taggable.changes).to be_empty
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
context 'with context tags' do
|
82
|
+
before(:each) do
|
83
|
+
@taggable = TaggableModel.create('language_list' => 'awesome, epic')
|
84
|
+
end
|
85
|
+
|
86
|
+
context 'when language_list changed' do
|
87
|
+
before(:each) do
|
88
|
+
expect(@taggable.changes).to be_empty
|
89
|
+
@taggable.language_list = 'one'
|
90
|
+
end
|
91
|
+
|
92
|
+
it 'should show changes of dirty object' do
|
93
|
+
expect(@taggable.changes).to eq({'language_list' => ['awesome, epic', ['one']]})
|
94
|
+
end
|
95
|
+
|
96
|
+
it 'flags language_list as changed' do
|
97
|
+
expect(@taggable.language_list_changed?).to be_truthy
|
98
|
+
end
|
99
|
+
|
100
|
+
it 'preserves original value' do
|
101
|
+
expect(@taggable.language_list_was).to eq('awesome, epic')
|
102
|
+
end
|
103
|
+
|
104
|
+
it 'shows what the change was' do
|
105
|
+
expect(@taggable.language_list_change).to eq(['awesome, epic', ['one']])
|
106
|
+
end
|
107
|
+
|
108
|
+
it 'shows what the changes were' do
|
109
|
+
expect(@taggable.language_list_changes).to eq(['awesome, epic', ['one']])
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
context 'when language_list is the same' do
|
114
|
+
before(:each) do
|
115
|
+
@taggable.language_list = 'awesome, epic'
|
116
|
+
end
|
117
|
+
|
118
|
+
it 'is not flagged as changed' do
|
119
|
+
expect(@taggable.language_list_changed?).to be_falsy
|
120
|
+
end
|
121
|
+
|
122
|
+
it 'does not show any changes to the taggable item' do
|
123
|
+
expect(@taggable.changes).to be_empty
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
@@ -506,6 +506,13 @@ describe 'Taggable' do
|
|
506
506
|
expect(options).to eq({:exclude => true})
|
507
507
|
end
|
508
508
|
|
509
|
+
it 'should not delete tags if not updated' do
|
510
|
+
model = TaggableModel.create(name: 'foo', tag_list: 'ruby, rails, programming')
|
511
|
+
model.update_attributes(name: 'bar')
|
512
|
+
model.reload
|
513
|
+
expect(model.tag_list.sort).to eq(%w(ruby rails programming).sort)
|
514
|
+
end
|
515
|
+
|
509
516
|
context 'Duplicates' do
|
510
517
|
context 'should not create duplicate taggings' do
|
511
518
|
let(:bob) { TaggableModel.create(name: 'Bob') }
|
@@ -703,114 +710,6 @@ describe 'Taggable' do
|
|
703
710
|
end
|
704
711
|
end
|
705
712
|
|
706
|
-
describe 'Dirty Objects' do
|
707
|
-
context 'with un-contexted tags' do
|
708
|
-
before(:each) do
|
709
|
-
@taggable = TaggableModel.create(tag_list: 'awesome, epic')
|
710
|
-
end
|
711
|
-
|
712
|
-
context 'when tag_list changed' do
|
713
|
-
before(:each) do
|
714
|
-
expect(@taggable.changes).to be_empty
|
715
|
-
@taggable.tag_list = 'one'
|
716
|
-
end
|
717
|
-
|
718
|
-
it 'should show changes of dirty object' do
|
719
|
-
expect(@taggable.changes).to eq({'tag_list' => ['awesome, epic', ['one']]})
|
720
|
-
end
|
721
|
-
|
722
|
-
it 'flags tag_list as changed' do
|
723
|
-
expect(@taggable.tag_list_changed?).to be_truthy
|
724
|
-
end
|
725
|
-
|
726
|
-
it 'preserves original value' do
|
727
|
-
expect(@taggable.tag_list_was).to eq('awesome, epic')
|
728
|
-
end
|
729
|
-
|
730
|
-
it 'shows what the change was' do
|
731
|
-
expect(@taggable.tag_list_change).to eq(['awesome, epic', ['one']])
|
732
|
-
end
|
733
|
-
end
|
734
|
-
|
735
|
-
context 'when tag_list is the same' do
|
736
|
-
before(:each) do
|
737
|
-
@taggable.tag_list = 'awesome, epic'
|
738
|
-
end
|
739
|
-
|
740
|
-
it 'is not flagged as changed' do
|
741
|
-
expect(@taggable.tag_list_changed?).to be_falsy
|
742
|
-
end
|
743
|
-
|
744
|
-
it 'does not show any changes to the taggable item' do
|
745
|
-
expect(@taggable.changes).to be_empty
|
746
|
-
end
|
747
|
-
|
748
|
-
context "and using a delimiter different from a ','" do
|
749
|
-
before do
|
750
|
-
@old_delimiter = ActsAsTaggableOn.delimiter
|
751
|
-
ActsAsTaggableOn.delimiter = ';'
|
752
|
-
end
|
753
|
-
|
754
|
-
after do
|
755
|
-
ActsAsTaggableOn.delimiter = @old_delimiter
|
756
|
-
end
|
757
|
-
|
758
|
-
it 'does not show any changes to the taggable item when using array assignments' do
|
759
|
-
@taggable.tag_list = %w(awesome epic)
|
760
|
-
expect(@taggable.changes).to be_empty
|
761
|
-
end
|
762
|
-
end
|
763
|
-
end
|
764
|
-
end
|
765
|
-
|
766
|
-
context 'with context tags' do
|
767
|
-
before(:each) do
|
768
|
-
@taggable = TaggableModel.create('language_list' => 'awesome, epic')
|
769
|
-
end
|
770
|
-
|
771
|
-
context 'when language_list changed' do
|
772
|
-
before(:each) do
|
773
|
-
expect(@taggable.changes).to be_empty
|
774
|
-
@taggable.language_list = 'one'
|
775
|
-
end
|
776
|
-
|
777
|
-
it 'should show changes of dirty object' do
|
778
|
-
expect(@taggable.changes).to eq({'language_list' => ['awesome, epic', ['one']]})
|
779
|
-
end
|
780
|
-
|
781
|
-
it 'flags language_list as changed' do
|
782
|
-
expect(@taggable.language_list_changed?).to be_truthy
|
783
|
-
end
|
784
|
-
|
785
|
-
it 'preserves original value' do
|
786
|
-
expect(@taggable.language_list_was).to eq('awesome, epic')
|
787
|
-
end
|
788
|
-
|
789
|
-
it 'shows what the change was' do
|
790
|
-
expect(@taggable.language_list_change).to eq(['awesome, epic', ['one']])
|
791
|
-
end
|
792
|
-
|
793
|
-
it 'shows what the changes were' do
|
794
|
-
expect(@taggable.language_list_changes).to eq(['awesome, epic', ['one']])
|
795
|
-
end
|
796
|
-
end
|
797
|
-
|
798
|
-
context 'when language_list is the same' do
|
799
|
-
before(:each) do
|
800
|
-
@taggable.language_list = 'awesome, epic'
|
801
|
-
end
|
802
|
-
|
803
|
-
it 'is not flagged as changed' do
|
804
|
-
expect(@taggable.language_list_changed?).to be_falsy
|
805
|
-
end
|
806
|
-
|
807
|
-
it 'does not show any changes to the taggable item' do
|
808
|
-
expect(@taggable.changes).to be_empty
|
809
|
-
end
|
810
|
-
end
|
811
|
-
end
|
812
|
-
end
|
813
|
-
|
814
713
|
describe 'Autogenerated methods' do
|
815
714
|
it 'should be overridable' do
|
816
715
|
expect(TaggableModel.create(tag_list: 'woo').tag_list_submethod_called).to be_truthy
|
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.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Bleigh
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-05-
|
12
|
+
date: 2014-05-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activerecord
|
@@ -31,26 +31,6 @@ dependencies:
|
|
31
31
|
- - "<"
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '5'
|
34
|
-
- !ruby/object:Gem::Dependency
|
35
|
-
name: actionpack
|
36
|
-
requirement: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - ">="
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '3'
|
41
|
-
- - "<"
|
42
|
-
- !ruby/object:Gem::Version
|
43
|
-
version: '5'
|
44
|
-
type: :runtime
|
45
|
-
prerelease: false
|
46
|
-
version_requirements: !ruby/object:Gem::Requirement
|
47
|
-
requirements:
|
48
|
-
- - ">="
|
49
|
-
- !ruby/object:Gem::Version
|
50
|
-
version: '3'
|
51
|
-
- - "<"
|
52
|
-
- !ruby/object:Gem::Version
|
53
|
-
version: '5'
|
54
34
|
- !ruby/object:Gem::Dependency
|
55
35
|
name: sqlite3
|
56
36
|
requirement: !ruby/object:Gem::Requirement
|
@@ -219,6 +199,7 @@ files:
|
|
219
199
|
- spec/acts_as_taggable_on/tag_list_parser_spec.rb
|
220
200
|
- spec/acts_as_taggable_on/tag_list_spec.rb
|
221
201
|
- spec/acts_as_taggable_on/tag_spec.rb
|
202
|
+
- spec/acts_as_taggable_on/taggable/dirty_spec.rb
|
222
203
|
- spec/acts_as_taggable_on/taggable_spec.rb
|
223
204
|
- spec/acts_as_taggable_on/tagger_spec.rb
|
224
205
|
- spec/acts_as_taggable_on/tagging_spec.rb
|
@@ -292,6 +273,7 @@ test_files:
|
|
292
273
|
- spec/acts_as_taggable_on/tag_list_parser_spec.rb
|
293
274
|
- spec/acts_as_taggable_on/tag_list_spec.rb
|
294
275
|
- spec/acts_as_taggable_on/tag_spec.rb
|
276
|
+
- spec/acts_as_taggable_on/taggable/dirty_spec.rb
|
295
277
|
- spec/acts_as_taggable_on/taggable_spec.rb
|
296
278
|
- spec/acts_as_taggable_on/tagger_spec.rb
|
297
279
|
- spec/acts_as_taggable_on/tagging_spec.rb
|