Sha256: 92fbddde4d614ce2f97e709583c13aa5152490d51606c2cbbf3851b9ad23b2d4

Contents?: true

Size: 910 Bytes

Versions: 8

Compression:

Stored size: 910 Bytes

Contents

require 'spec_helper'

describe Post do
  before :all do
    Post.delete_all
    @blog = Blog.make
  end

  it 'recognizes its draft status' do
    @blog.posts.new.draft?.should be_true
  end

  it 'returns its path' do
    @blog.posts.new(:slug => 'foo').path.should == "/#{@blog.title.to_url}/foo"
  end

  it 'publishes, setting its publication date' do
    post = @blog.posts.create(Post.make.attributes)
    post.publish!
    post.status.should == 'Published'
    post.published_at.to_s(:concise).should == Time.now.to_s(:concise)
  end

  it 'unpublishes, clearing its publication date' do
    post = @blog.posts.create(Post.make.attributes)
    post.publish!
    post.unpublish!
    post.status.should == 'Draft'
  end

  it 'defaults slug to its title' do
    post = @blog.posts.new(
      :title => 'Test Post',
      :content => 'Bar'
    )
    post.save
    post.slug.should == 'test-post'
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
blog_logic-1.4.8 spec/models/post_spec.rb
blog_logic-1.4.7 spec/models/post_spec.rb
blog_logic-1.4.6 spec/models/post_spec.rb
blog_logic-1.4.5 spec/models/post_spec.rb
blog_logic-1.4.4 spec/models/post_spec.rb
blog_logic-1.4.3 spec/models/post_spec.rb
blog_logic-1.4.2 spec/models/post_spec.rb
blog_logic-1.4.1 spec/models/post_spec.rb