Sha256: 76869c3df1686fd3fe55a997148618627f72acc07d3468598df065649ea5abda
Contents?: true
Size: 1.61 KB
Versions: 3
Compression:
Stored size: 1.61 KB
Contents
require_relative '../../../test_helper' class Admin::Blog::CommentsControllerTest < ActionController::TestCase def setup @site = cms_sites(:default) @blog = blog_blogs(:default) @post = blog_posts(:default) @comment = blog_comments(:default) end def test_get_index get :index, :site_id => @site, :blog_id => @blog assert_response :success assert_template :index assert assigns(:comments) assert !assigns(:post) end def test_get_index_for_post get :index, :site_id => @site, :blog_id => @blog, :post_id => @post assert_response :success assert_template :index assert assigns(:post) assert assigns(:comments) end def test_publish assert @comment.is_published? xhr :patch, :toggle_publish, :site_id => @site, :blog_id => @blog, :id => @comment assert_response :success @comment.reload assert !@comment.is_published? xhr :patch, :toggle_publish, :site_id => @site, :blog_id => @blog, :id => @comment assert_response :success @comment.reload assert @comment.is_published? end def test_destroy assert_difference 'Blog::Comment.count', -1 do delete :destroy, :site_id => @site, :blog_id => @blog, :id => @comment assert_response :redirect assert_redirected_to :action => :index assert_equal 'Comment deleted', flash[:success] end end def test_destroy_failure delete :destroy, :site_id => @site, :blog_id => @blog, :id => 'invalid' assert_response :redirect assert_redirected_to :action => :index assert_equal 'Comment not found', flash[:error] end end
Version data entries
3 entries across 3 versions & 1 rubygems