Sha256: bc1ffca5f18ff07d7453566a75a6d345fe8e4bbb48f566c9f9c64a49c5938e11

Contents?: true

Size: 1.11 KB

Versions: 9

Compression:

Stored size: 1.11 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'
    post.publication_date.nil?.should be_true
  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

9 entries across 9 versions & 1 rubygems

Version Path
blog_logic-1.1.1 spec/models/post_spec.rb
blog_logic-1.1.0 spec/models/post_spec.rb
blog_logic-1.0.0 spec/models/post_spec.rb
blog_logic-0.7.7 spec/models/post_spec.rb
blog_logic-0.7.6 spec/models/post_spec.rb
blog_logic-0.7.5 spec/models/post_spec.rb
blog_logic-0.7.4 spec/models/post_spec.rb
blog_logic-0.7.3 spec/models/post_spec.rb
blog_logic-0.7.2 spec/models/post_spec.rb