spec/lib/slug_spec.rb in wulffeld_slug-0.0.25 vs spec/lib/slug_spec.rb in wulffeld_slug-0.0.26
- old
+ new
@@ -38,9 +38,33 @@
it "creates a slug without superfluous spaces" do
article.title = " The Shawshank Redemption "
article.valid?
article.slug.should == "the-shawshank-redemption"
end
+
+ describe ":blank_loop_start and :blank_loop_chunk options" do
+ it "should generate correct slugs with a blank string part" do
+ 71.times do |i|
+ Article.create!(:title => "하")
+ end
+ a = Article.create!(:title => "하")
+ a.save!
+ a.slug.should == '72'
+
+ Article.all.map(&:slug).sort.should == 72.times.map { |i| "#{i + 1}"}.sort
+ end
+
+ it "should generate correct slugs with a blank string part" do
+ 21.times do |i|
+ Article.create!(:title => "하")
+ end
+ a = Article.create!(:title => "하")
+ a.save!
+ a.slug.should == '22'
+
+ Article.all.map(&:slug).sort.should == 22.times.map { |i| "#{i + 1}"}.sort
+ end
+ end
end
context "dynamic slug fields" do
it "should create a slug based on the non-nil field(s)" do
user = User.new(:login => "deckard")