Sha256: 6a6033b94eed2927d17e03700d2347cc805e52506d7df652cdd6cb0be32493c1

Contents?: true

Size: 1.2 KB

Versions: 9

Compression:

Stored size: 1.2 KB

Contents

require File.expand_path('../test_helper', File.dirname(__FILE__))

class CommentTest < ActiveSupport::TestCase
  
  def test_fixtures_validity
    Blog::Comment.all.each do |comment|
      assert comment.valid?, comment.errors.full_messages.to_s
    end
  end
  
  def test_validations
    comment = Blog::Comment.new
    assert comment.invalid?
    assert_has_errors_on comment, [:post_id, :content, :author, :email]
  end
  
  def test_creation
    assert_difference 'Blog::Comment.count' do
      comment = blog_posts(:default).comments.create(
        :content  => 'Test Content',
        :author   => 'Tester',
        :email    => 'test@test.test'
      )
      assert !comment.is_published?
    end
  end
  
  def test_creation_with_auto_publishing
    ComfyBlog.config.auto_publish_comments = true
    
    comment = blog_posts(:default).comments.create(
      :content  => 'Test Content',
      :author   => 'Tester',
      :email    => 'test@test.test'
    )
    assert comment.is_published?
  end
  
  def test_scope_published
    assert_equal 1, Blog::Comment.published.count
    
    blog_comments(:default).update_attribute(:is_published, false)
    assert_equal 0, Blog::Comment.published.count
  end
  
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
comfy_blog-0.1.8 test/unit/comment_test.rb
comfy_blog-0.1.7 test/unit/comment_test.rb
comfy_blog-0.1.6 test/unit/comment_test.rb
comfy_blog-0.1.5 test/unit/comment_test.rb
comfy_blog-0.1.4 test/unit/comment_test.rb
comfy_blog-0.1.3 test/unit/comment_test.rb
comfy_blog-0.1.2 test/unit/comment_test.rb
comfy_blog-0.1.1 test/unit/comment_test.rb
comfy_blog-0.1.0 test/unit/comment_test.rb