Sha256: bc1420c21b635ca824dc99d3f24f066f15e623ec2730d67c2374af97132655ea

Contents?: true

Size: 1.85 KB

Versions: 9

Compression:

Stored size: 1.85 KB

Contents

require File.dirname(__FILE__) + '/../../test_helper'
require 'admin/comments_controller'
require 'dns_mock'

# Re-raise errors caught by the controller.
class Admin::CommentsController; def rescue_action(e) raise e end; end

class Admin::CommentsControllerTest < Test::Unit::TestCase
  fixtures :contents, :users

  def setup
    @controller = Admin::CommentsController.new
    @request    = ActionController::TestRequest.new
    @response   = ActionController::TestResponse.new

    @request.session = { :user => users(:tobi) }
  end

  def test_index
    get :index, :article_id => 2
    assert_rendered_file 'list'
  end

  def test_list
    get :list, :article_id => 2
    assert_rendered_file 'list'
    assert_template_has 'comments'
  end

  def test_show
    get :show, :id => 5, :article_id => 2
    assert_rendered_file 'show'
    assert_template_has 'comment'
    assert_valid_record 'comment'
  end

  def test_new
    get :new, :article_id => 2
    assert_rendered_file 'new'
    assert_template_has 'comment'
  end

  def test_create
    num_comments = Comment.find_all.size

    post(:new, :comment => { 'author' => 'author', 'body' => 'body' },
               :article_id => 2)
    assert_redirected_to :action => 'show'

    assert_equal num_comments + 1, Comment.find_all.size
  end

  def test_edit
    get :edit, :id => 5, :article_id => 2
    assert_rendered_file 'edit'
    assert_template_has 'comment'
    assert_valid_record 'comment'
  end

  def test_update
    post :edit, :id => 5, :article_id => 2
    assert_redirected_to :action => 'show', :id => 5
  end

  def test_destroy
    assert_not_nil Comment.find(5)

    get :destroy, :id => 5, :article_id => 2
    assert_success

    post :destroy, :id => 5, :article_id => 2
    assert_redirected_to :action => 'list'

    assert_raise(ActiveRecord::RecordNotFound) {
      comment = Comment.find(5)
    }
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
typo-3.99.0 test/functional/admin/comments_controller_test.rb
typo-3.99.2 test/functional/admin/comments_controller_test.rb
typo-3.99.3 test/functional/admin/comments_controller_test.rb
typo-3.99.1 test/functional/admin/comments_controller_test.rb
typo-3.99.4 test/functional/admin/comments_controller_test.rb
typo-4.0.1 test/functional/admin/comments_controller_test.rb
typo-4.0.2 test/functional/admin/comments_controller_test.rb
typo-4.0.0 test/functional/admin/comments_controller_test.rb
typo-4.0.3 test/functional/admin/comments_controller_test.rb