Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'master' of https://github.com/teddyzetterlund/mongoid_t…

…aggable into teddyzetterlund-master
  • Loading branch information...
commit 234c06944b1dcf9400394dae23b6ca33279a4f14 2 parents c6d9352 + 187087b
@wilkerlucio wilkerlucio authored
Showing with 6 additions and 1 deletion.
  1. +1 −1  lib/mongoid/taggable.rb
  2. +5 −0 spec/mongoid/taggable_spec.rb
View
2  lib/mongoid/taggable.rb
@@ -100,7 +100,7 @@ def tags
end
def tags=(tags)
- self.tags_array = tags.split(self.class.tags_separator).map(&:strip)
+ self.tags_array = tags.split(self.class.tags_separator).map(&:strip).reject(&:blank?)
end
end
end
View
5 spec/mongoid/taggable_spec.rb
@@ -39,6 +39,11 @@ class MyModel
@m.tags = "now , with, some spaces , in places "
@m.tags_array.should == ["now", "with", "some spaces", "in places"]
end
+
+ it "should not put empty tags in array" do
+ @m.tags = "repetitive,, commas, shouldn't cause,,, empty tags"
+ @m.tags_array.should == ["repetitive", "commas", "shouldn't cause", "empty tags"]
+ end
end
context "changing separator" do
Please sign in to comment.
Something went wrong with that request. Please try again.