Sha256: d22efc5062283118987c33da8b41606a08cd88e43cac6424e54868375a6bdb6e
Contents?: true
Size: 1.2 KB
Versions: 1
Compression:
Stored size: 1.2 KB
Contents
require 'helper' class TestSlugizer < Test::Unit::TestCase context "working with slugs" do setup do BlogPost.delete_all @blogpost = BlogPost.create(:title => "%bLog pOSt tiTLe!", :body => "HeRe is tHe Body of the bLog pOsT") end should "generate the slug" do @blogpost.slug.should =~ /\w+-blog-post-title/ end should "not generate the slug if the slug key is blank" do @empty_blogpost = BlogPost.new @empty_blogpost.slug.should be_nil end should "return the slug as param" do @blogpost.to_param =~ /\w+-blog-post-title/ end should "return the id if slug was not generated" do @blogpost.slug = nil @blogpost.to_param.should == @blogpost.id end end context "finding objects" do setup do BlogPost.delete_all @blogpost = BlogPost.create(:title => "%bLog pOSt tiTLe!", :body => "HeRe is tHe Body of the bLog pOsT") end should "be able to find by slug" do BlogPost.by_slug(@blogpost.slug).should == @blogpost end should "be able to find by id" do BlogPost.by_slug(@blogpost.id).should == @blogpost end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
mongomapper_ext-0.1.4 | test/test_slugizer.rb |