Sha256: 5be91a8ee9d62e8ec2ad9e66cd967b43638699db3289d7f349f24e009ca157cf

Contents?: true

Size: 1.21 KB

Versions: 4

Compression:

Stored size: 1.21 KB

Contents

require_relative '../test_helper'

class BlogCommentsTest < ActiveSupport::TestCase
  
  def test_fixtures_validity
    Comfy::Blog::Comment.all.each do |comment|
      assert comment.valid?, comment.errors.full_messages.to_s
    end
  end
  
  def test_validations
    comment = Comfy::Blog::Comment.new
    assert comment.invalid?
    assert_errors_on comment, [:post_id, :content, :author, :email]
  end
  
  def test_creation
    assert_difference 'Comfy::Blog::Comment.count' do
      comment = comfy_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 = comfy_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, Comfy::Blog::Comment.published.count
    comfy_blog_comments(:default).update_attribute(:is_published, false)
    assert_equal 0, Comfy::Blog::Comment.published.count
  end
  
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
comfy_blog-1.12.3 test/models/comments_test.rb
comfy_blog-1.12.2 test/models/comments_test.rb
comfy_blog-1.12.1 test/models/comments_test.rb
comfy_blog-1.12.0 test/models/comments_test.rb