Skip to content

Commit

Permalink
some fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
alexis committed May 7, 2012
1 parent 0b9b328 commit 2f626e1
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 21 deletions.
2 changes: 1 addition & 1 deletion lib/is_taggable/mixin.rb
Expand Up @@ -25,7 +25,7 @@ def set_tag_list(kind, list)
end

def get_tag_list(kind)
set_tag_list(kind, tags.of_kind(kind).map(&:qname)) if tag_list_instance_variable(kind).nil?
set_tag_list(kind, tags.of_kind(kind).map(&:name)) if tag_list_instance_variable(kind).nil?
tag_list_instance_variable(kind)
end

Expand Down
2 changes: 1 addition & 1 deletion lib/is_taggable/tag_list/base.rb
Expand Up @@ -9,7 +9,7 @@ def initialize(tags, options)
list = split_tags(tags).map{ |t| normalize_tag(t) }.reject{ |t| reject_tag(t) }
end

super(list)
super(list.uniq)
end

def to_s
Expand Down
4 changes: 0 additions & 4 deletions lib/tag.rb
Expand Up @@ -18,10 +18,6 @@ def name=(name)
super self.class.collapse_whitespace(name)
end

def qname
name.match(/\s|,/) ? '"'+name+'"' : name
end

protected

def self.collapse_whitespace(name)
Expand Down
6 changes: 0 additions & 6 deletions test/is_taggable_test.rb
Expand Up @@ -43,14 +43,8 @@
p.tag_list
end

expect ["something", "something"] do
p = Post.new :tag_list => "something something"
p.tag_list
end

expect ["something"] do
p = Post.new :tag_list => "something something"
p.save
p.tag_list
end

Expand Down
10 changes: 9 additions & 1 deletion test/is_taggable_youtube_test.rb
Expand Up @@ -20,11 +20,19 @@
# quoted tags in youtube style comment
expect ["some", "is_taggable has", "quoted tags"] do
IsTaggable.configure_tag_list(:youtube)
n = Comment.new :tag_list => "\"is_taggable has\" some \" quoted tags\" "
n = Comment.new :tag_list => '"is_taggable has" some " quoted tags" '
IsTaggable.configure_tag_list
n.tag_list
end

# quoted tags in youtube style comment (saved correctly?)
expect ["some", "is_taggable has", "quoted tags"] do
IsTaggable.configure_tag_list(:youtube)
n = Comment.create :tag_list => '"is_taggable has" some " quoted tags" '
n2 = Comment.find(n)
IsTaggable.configure_tag_list
n2.tag_list
end
# youtube tag with comma delimiter in comment
expect ["is_taggable", "has 'tags' by default"] do
IsTaggable.configure_tag_list(:youtube)
Expand Down
2 changes: 1 addition & 1 deletion test/tag_test.rb
@@ -1,4 +1,4 @@
require File.dirname(__FILE__) + '/test_helper'
require 'test_helper'

Expectations do
expect Tagging do
Expand Down
14 changes: 7 additions & 7 deletions test/tagging_test.rb
@@ -1,28 +1,28 @@
require File.dirname(__FILE__) + '/test_helper'
require 'test_helper'

Expectations do
expect Tag do
t = Tagging.new :tag => Tag.new(:name => 'some_tag')
t.tag
end

expect Post do
t = Tagging.new :taggable => Post.new
t.taggable
end

expect 2 do
2.times { Post.create(:tag_list => "interesting") }
Tag.find_by_name("interesting").taggings.count
end

expect 1 do
p1 = Post.create(:tag_list => "witty")
p2 = Post.create(:tag_list => "witty")

p2.destroy
Tag.find_by_name("witty").taggings.count
end
end

expect 2 do
p1 = Post.create(:tag_list => "smart, pretty")
Expand All @@ -34,5 +34,5 @@

Tag.find_by_name('inappropriate').destroy
p1.taggings.count
end
end
end

0 comments on commit 2f626e1

Please sign in to comment.