Sha256: 4be3d2850635eee19cdeecb1e284f14da2f93a4a72d5b7cf2f4e0ff9d2666144

Contents?: true

Size: 1014 Bytes

Versions: 4

Compression:

Stored size: 1014 Bytes

Contents

require_relative '../../../test_helper'

class Comfy::Blog::CommentsControllerTest < ActionController::TestCase
  
  def setup
    @blog = comfy_blog_blogs(:default)
    @post = comfy_blog_posts(:default)
  end

  def test_creation
    assert_difference 'Comfy::Blog::Comment.count' do
      post :create, :slug => @post.slug, :comment => {
        :author   => 'Test',
        :email    => 'test@test.test',
        :content  => 'Test Content'
      }
      assert_response :redirect
      assert_redirected_to comfy_blog_post_path
      assert_equal 'Comment created', flash[:success]
      
      comment = Comfy::Blog::Comment.last
      assert_equal 'Test', comment.author
      assert_equal @post, comment.post
    end
  end
  
  def test_creation_failure
    assert_no_difference 'Comfy::Blog::Comment.count' do
      post :create, :slug => @post.slug, :comment => { }
      assert_response :success
      assert_template :show
      assert_equal 'Failed to create Comment', flash[:error]
    end
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
comfy_blog-1.12.3 test/controllers/comfy/blog/comments_controller_test.rb
comfy_blog-1.12.2 test/controllers/comfy/blog/comments_controller_test.rb
comfy_blog-1.12.1 test/controllers/comfy/blog/comments_controller_test.rb
comfy_blog-1.12.0 test/controllers/comfy/blog/comments_controller_test.rb