acts-as-taggable-on 1.0.15 → 1.0.16
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/acts_as_taggable_on/tag_list.rb +2 -2
- data/lib/acts_as_taggable_on/tagging.rb +2 -0
- data/rails/init.rb +1 -3
- data/spec/acts_as_taggable_on/acts_as_taggable_on_spec.rb +0 -14
- data/spec/acts_as_taggable_on/tag_list_spec.rb +12 -0
- data/spec/acts_as_taggable_on/tagging_spec.rb +9 -0
- data/spec/spec_helper.rb +8 -0
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.16
|
@@ -79,8 +79,8 @@ class TagList < Array
|
|
79
79
|
string = string.to_s.dup
|
80
80
|
|
81
81
|
# Parse the quoted tags
|
82
|
-
string.gsub!(/"(.*?)"\s
|
83
|
-
string.gsub!(/'(.*?)'\s
|
82
|
+
string.gsub!(/(\A|#{delimiter})\s*"(.*?)"\s*(#{delimiter}\s*|\z)/) { tag_list << $2; $3 }
|
83
|
+
string.gsub!(/(\A|#{delimiter})\s*'(.*?)'\s*(#{delimiter}\s*|\z)/) { tag_list << $2; $3 }
|
84
84
|
|
85
85
|
tag_list.add(string.split(delimiter))
|
86
86
|
end
|
data/rails/init.rb
CHANGED
@@ -2,6 +2,4 @@ require 'acts-as-taggable-on'
|
|
2
2
|
|
3
3
|
ActiveRecord::Base.send :include, ActiveRecord::Acts::TaggableOn
|
4
4
|
ActiveRecord::Base.send :include, ActiveRecord::Acts::Tagger
|
5
|
-
ActionView::Base.send :include, TagsHelper if defined?(ActionView::Base)
|
6
|
-
|
7
|
-
RAILS_DEFAULT_LOGGER.info "** acts_as_taggable_on: initialized properly."
|
5
|
+
ActionView::Base.send :include, TagsHelper if defined?(ActionView::Base)
|
@@ -176,16 +176,6 @@ describe "Acts As Taggable On" do
|
|
176
176
|
end
|
177
177
|
|
178
178
|
describe 'Tagging Contexts' do
|
179
|
-
before(:all) do
|
180
|
-
class Array
|
181
|
-
def freq
|
182
|
-
k=Hash.new(0)
|
183
|
-
self.each {|e| k[e]+=1}
|
184
|
-
k
|
185
|
-
end
|
186
|
-
end
|
187
|
-
end
|
188
|
-
|
189
179
|
it 'should eliminate duplicate tagging contexts ' do
|
190
180
|
TaggableModel.acts_as_taggable_on(:skills, :skills)
|
191
181
|
TaggableModel.tag_types.freq[:skills].should_not == 3
|
@@ -212,10 +202,6 @@ describe "Acts As Taggable On" do
|
|
212
202
|
TaggableModel.acts_as_taggable_on([nil])
|
213
203
|
}.should_not raise_error
|
214
204
|
end
|
215
|
-
|
216
|
-
after(:all) do
|
217
|
-
class Array; remove_method :freq; end
|
218
|
-
end
|
219
205
|
end
|
220
206
|
|
221
207
|
end
|
@@ -20,6 +20,18 @@ describe TagList do
|
|
20
20
|
@tag_list.include?("wicked").should be_true
|
21
21
|
end
|
22
22
|
|
23
|
+
it "should be able to add delimited list of words with quoted delimiters" do
|
24
|
+
@tag_list.add("'cool, wicked', \"really cool, really wicked\"", :parse => true)
|
25
|
+
@tag_list.include?("cool, wicked").should be_true
|
26
|
+
@tag_list.include?("really cool, really wicked").should be_true
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should be able to handle other uses of quotation marks correctly" do
|
30
|
+
@tag_list.add("john's cool car, mary's wicked toy", :parse => true)
|
31
|
+
@tag_list.include?("john's cool car").should be_true
|
32
|
+
@tag_list.include?("mary's wicked toy").should be_true
|
33
|
+
end
|
34
|
+
|
23
35
|
it "should be able to add an array of words" do
|
24
36
|
@tag_list.add(["cool", "wicked"], :parse => true)
|
25
37
|
@tag_list.include?("cool").should be_true
|
@@ -13,4 +13,13 @@ describe Tagging do
|
|
13
13
|
@tagging.should_not be_valid
|
14
14
|
@tagging.errors.on(:tag_id).should == "can't be blank"
|
15
15
|
end
|
16
|
+
|
17
|
+
it "should not create duplicate taggings" do
|
18
|
+
@taggable = TaggableModel.create(:name => "Bob Jones")
|
19
|
+
@tag = Tag.create(:name => "awesome")
|
20
|
+
|
21
|
+
lambda {
|
22
|
+
2.times { Tagging.create(:taggable => @taggable, :tag => @tag, :context => 'tags') }
|
23
|
+
}.should change(Tagging, :count).by(1)
|
24
|
+
end
|
16
25
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -7,6 +7,14 @@ module Spec::Example::ExampleGroupMethods
|
|
7
7
|
alias :context :describe
|
8
8
|
end
|
9
9
|
|
10
|
+
class Array
|
11
|
+
def freq
|
12
|
+
k=Hash.new(0)
|
13
|
+
each {|e| k[e]+=1}
|
14
|
+
k
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
10
18
|
TEST_DATABASE_FILE = File.join(File.dirname(__FILE__), '..', 'test.sqlite3')
|
11
19
|
|
12
20
|
File.unlink(TEST_DATABASE_FILE) if File.exist?(TEST_DATABASE_FILE)
|
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: 1.0.
|
4
|
+
version: 1.0.16
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Bleigh
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-12-
|
12
|
+
date: 2009-12-25 00:00:00 +01:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|