Sha256: eee43e766aeadfa57bbe8f660b773c732160e94f9bb7e9be74c9cabd9f1fa5f0

Contents?: true

Size: 1.06 KB

Versions: 6

Compression:

Stored size: 1.06 KB

Contents

require File.dirname(__FILE__) + '/../spec_helper'

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

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

  it 'returns its relative URL' do
    @blog.posts.new(:slug => 'foo').full_path.should == '/my-blog/foo'
  end

  it 'returns its formatted slug' do
    @blog.posts.new(:slug => 'foo').humanize_path.should == '/foo'
  end

  it 'publishes, setting its publication date' do
    post = @blog.posts.create(Post.make.attributes)
    post.publish!
    post.status.should == 'Published'
    post.publication_date.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 its desired slug to its title' do
    post = @blog.posts.new(
      :title => 'Test Post',
      :summary => 'Foo',
      :content => 'Bar'
    )
    post.save.should be_true
    post.slug.should == 'test-post'
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
blog_logic-1.2.1 spec/models/post_spec.rb
blog_logic-1.2.0 spec/models/post_spec.rb
blog_logic-1.1.9 spec/models/post_spec.rb
blog_logic-1.1.8 spec/models/post_spec.rb
blog_logic-1.1.7 spec/models/post_spec.rb
blog_logic-1.1.6 spec/models/post_spec.rb