Sha256: 631ee634ddb2b8bd0f6c56397ebd7eaf0720b359dbafe3796a3b01e77532a693

Contents?: true

Size: 1.95 KB

Versions: 31

Compression:

Stored size: 1.95 KB

Contents

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

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

class WorkLocksControllerTest < Test::Unit::TestCase
  fixtures :work_locks

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

    @first_id = work_locks(: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_locks)
  end

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

    assert_response :success
    assert_template 'show'

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

  def test_new
    get :new

    assert_response :success
    assert_template 'new'

    assert_not_nil assigns(:work_lock)
  end

  def test_create
    num_work_locks = WorkLock.count

    post :create, :work_lock => {:user_id => '1000001', :start_on => '2008-01-28', :end_on => '2008-01-28'}

    assert_response :redirect
    assert_redirected_to :action => 'list'

    assert_equal num_work_locks + 1, WorkLock.count
  end

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

    assert_response :success
    assert_template 'edit'

    assert_not_nil assigns(:work_lock)
    assert assigns(:work_lock).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 {
      WorkLock.find(@first_id)
    }

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

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

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
backlog-0.19.0 test/functional/work_locks_controller_test.rb
backlog-0.20.0 test/functional/work_locks_controller_test.rb
backlog-0.20.1 test/functional/work_locks_controller_test.rb
backlog-0.21.0 test/functional/work_locks_controller_test.rb
backlog-0.21.2 test/functional/work_locks_controller_test.rb
backlog-0.21.1 test/functional/work_locks_controller_test.rb
backlog-0.21.3 test/functional/work_locks_controller_test.rb
backlog-0.22.1 test/functional/work_locks_controller_test.rb
backlog-0.22.0 test/functional/work_locks_controller_test.rb
backlog-0.23.0 test/functional/work_locks_controller_test.rb
backlog-0.24.0 test/functional/work_locks_controller_test.rb
backlog-0.23.1 test/functional/work_locks_controller_test.rb
backlog-0.25.0 test/functional/work_locks_controller_test.rb
backlog-0.26.0 test/functional/work_locks_controller_test.rb
backlog-0.28.0 test/functional/work_locks_controller_test.rb
backlog-0.29.0 test/functional/work_locks_controller_test.rb
backlog-0.31.0 test/functional/work_locks_controller_test.rb
backlog-0.30.0 test/functional/work_locks_controller_test.rb
backlog-0.32.0 test/functional/work_locks_controller_test.rb
backlog-0.31.1 test/functional/work_locks_controller_test.rb