Sha256: 9f94783f1376c3c6e352057169fb13a0e5d68c3430356be461db12b590547ca3

Contents?: true

Size: 1.94 KB

Versions: 29

Compression:

Stored size: 1.94 KB

Contents

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

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

class WorkAccountsControllerTest < Test::Unit::TestCase
  main_scenario

  def setup
    @controller = WorkAccountsController.new
    @request    = ActionController::TestRequest.new
    @response   = ActionController::TestResponse.new
    @request.session[:user_id] = 1000001

    @first_id = work_accounts(:one).id
  end

  def test_index
    get :index
    assert_response :success
    assert_template 'list'
  end

  def test_list
    get :list

    assert_response :success
    assert_template 'list'

    assert_not_nil assigns(:work_accounts)
  end

  def test_show
    get :show, :id => @first_id

    assert_response :success
    assert_template 'show'

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

  def test_new
    get :new

    assert_response :success
    assert_template 'new'

    assert_not_nil assigns(:work_account)
  end

  def test_create
    num_work_accounts = WorkAccount.count

    post :create, :work_account => {:name => 'TimeKeeper'}

    assert_response :redirect
    assert_redirected_to :action => 'list'

    assert_equal num_work_accounts + 1, WorkAccount.count
  end

  def test_edit
    get :edit, :id => @first_id

    assert_response :success
    assert_template 'edit'

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

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

  def test_destroy
    assert_nothing_raised {
      WorkAccount.find(@first_id)
    }

    post :destroy, :id => @first_id
    assert_response :redirect
    assert_redirected_to :action => 'list'

    assert_raise(ActiveRecord::RecordNotFound) {
      WorkAccount.find(@first_id)
    }
  end
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
backlog-0.12.1 test/functional/work_accounts_controller_test.rb
backlog-0.12.2 test/functional/work_accounts_controller_test.rb
backlog-0.12.4 test/functional/work_accounts_controller_test.rb
backlog-0.12.3 test/functional/work_accounts_controller_test.rb
backlog-0.13.1 test/functional/work_accounts_controller_test.rb
backlog-0.14.0 test/functional/work_accounts_controller_test.rb
backlog-0.13.0 test/functional/work_accounts_controller_test.rb
backlog-0.14.2 test/functional/work_accounts_controller_test.rb
backlog-0.14.1 test/functional/work_accounts_controller_test.rb
backlog-0.14.3 test/functional/work_accounts_controller_test.rb
backlog-0.15.0 test/functional/work_accounts_controller_test.rb
backlog-0.14.4 test/functional/work_accounts_controller_test.rb
backlog-0.16.0 test/functional/work_accounts_controller_test.rb
backlog-0.15.1 test/functional/work_accounts_controller_test.rb
backlog-0.17.0 test/functional/work_accounts_controller_test.rb
backlog-0.17.2 test/functional/work_accounts_controller_test.rb
backlog-0.17.1 test/functional/work_accounts_controller_test.rb
backlog-0.17.3 test/functional/work_accounts_controller_test.rb
backlog-0.17.4 test/functional/work_accounts_controller_test.rb
backlog-0.17.5 test/functional/work_accounts_controller_test.rb