Sha256: ad2d8467b5d3099b6d150918ad272745582f711534cebd3da35ee54cff872a52

Contents?: true

Size: 1.77 KB

Versions: 1

Compression:

Stored size: 1.77 KB

Contents

require File.dirname(__FILE__) + '/../test_helper'
require 'backlogs_controller'

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

class BacklogsControllerTest < Test::Unit::TestCase
  fixtures :users, :backlogs, :periods, :tasks, :works, :estimates

  def setup
    @user_controller = UserController.new
    @controller = BacklogsController.new
    @request    = ActionController::TestRequest.new
    @response   = ActionController::TestResponse.new
    @request.session[:user_id] = 1000001
  end

  def test_index
    get :index
    assert_response :redirect
    assert_redirected_to :controller => 'tasks', :action => :list_started
  end

  def test_show
    get :show, :id => 1

    assert_response :redirect
    assert_redirected_to :controller => 'periods', :action => :show
  end

  def test_new
    get :new

    assert_response :success
    assert_template 'new'

    assert_not_nil assigns(:backlog)
  end

  def test_create
    num_backlogs = Backlog.count
    @request.session[:user_id] = 1000001
    post :create, :backlog => {:name => 'house work'}

    assert_response :redirect
    assert_redirected_to :action => :show

    assert_equal num_backlogs + 1, Backlog.count
  end

  def test_edit
    get :edit, :id => 1

    assert_response :success
    assert_template 'edit'

    assert_not_nil assigns(:backlog)
    assert assigns(:backlog).valid?
  end

  def test_update
    post :update, :id => 1
    assert_response :redirect
    assert_redirected_to :action => 'show', :id => 1
  end

  def test_destroy
    assert_not_nil Backlog.find(1)

    post :destroy, :id => 1
    assert_response :redirect
    assert_redirected_to :action => :index

    assert_raise(ActiveRecord::RecordNotFound) {
      Backlog.find(1)
    }
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
backlog-0.0.4 test/functional/backlogs_controller_test.rb