diff options
Diffstat (limited to 'projects/devdashboard/test')
11 files changed, 272 insertions, 0 deletions
diff --git a/projects/devdashboard/test/fixtures/developers.yml b/projects/devdashboard/test/fixtures/developers.yml new file mode 100644 index 0000000..b49c4eb --- /dev/null +++ b/projects/devdashboard/test/fixtures/developers.yml @@ -0,0 +1,5 @@ +# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html +one: + id: 1 +two: + id: 2 diff --git a/projects/devdashboard/test/fixtures/herds.yml b/projects/devdashboard/test/fixtures/herds.yml new file mode 100644 index 0000000..b49c4eb --- /dev/null +++ b/projects/devdashboard/test/fixtures/herds.yml @@ -0,0 +1,5 @@ +# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html +one: + id: 1 +two: + id: 2 diff --git a/projects/devdashboard/test/fixtures/project_members.yml b/projects/devdashboard/test/fixtures/project_members.yml new file mode 100644 index 0000000..b49c4eb --- /dev/null +++ b/projects/devdashboard/test/fixtures/project_members.yml @@ -0,0 +1,5 @@ +# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html +one: + id: 1 +two: + id: 2 diff --git a/projects/devdashboard/test/fixtures/projects.yml b/projects/devdashboard/test/fixtures/projects.yml new file mode 100644 index 0000000..b49c4eb --- /dev/null +++ b/projects/devdashboard/test/fixtures/projects.yml @@ -0,0 +1,5 @@ +# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html +one: + id: 1 +two: + id: 2 diff --git a/projects/devdashboard/test/functional/developers_controller_test.rb b/projects/devdashboard/test/functional/developers_controller_test.rb new file mode 100644 index 0000000..955b872 --- /dev/null +++ b/projects/devdashboard/test/functional/developers_controller_test.rb @@ -0,0 +1,92 @@ +require File.dirname(__FILE__) + '/../test_helper' +require 'developers_controller' + +# Re-raise errors caught by the controller. +class DevelopersController; def rescue_action(e) raise e end; end + +class DevelopersControllerTest < Test::Unit::TestCase + fixtures :developers + + def setup + @controller = DevelopersController.new + @request = ActionController::TestRequest.new + @response = ActionController::TestResponse.new + + @first_id = developers(:first).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(:developers) + end + + def test_show + get :show, :id => @first_id + + assert_response :success + assert_template 'show' + + assert_not_nil assigns(:developer) + assert assigns(:developer).valid? + end + + def test_new + get :new + + assert_response :success + assert_template 'new' + + assert_not_nil assigns(:developer) + end + + def test_create + num_developers = Developer.count + + post :create, :developer => {} + + assert_response :redirect + assert_redirected_to :action => 'list' + + assert_equal num_developers + 1, Developer.count + end + + def test_edit + get :edit, :id => @first_id + + assert_response :success + assert_template 'edit' + + assert_not_nil assigns(:developer) + assert assigns(:developer).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 { + Developer.find(@first_id) + } + + post :destroy, :id => @first_id + assert_response :redirect + assert_redirected_to :action => 'list' + + assert_raise(ActiveRecord::RecordNotFound) { + Developer.find(@first_id) + } + end +end diff --git a/projects/devdashboard/test/functional/herds_controller_test.rb b/projects/devdashboard/test/functional/herds_controller_test.rb new file mode 100644 index 0000000..e52d464 --- /dev/null +++ b/projects/devdashboard/test/functional/herds_controller_test.rb @@ -0,0 +1,92 @@ +require File.dirname(__FILE__) + '/../test_helper' +require 'herds_controller' + +# Re-raise errors caught by the controller. +class HerdsController; def rescue_action(e) raise e end; end + +class HerdsControllerTest < Test::Unit::TestCase + fixtures :herds + + def setup + @controller = HerdsController.new + @request = ActionController::TestRequest.new + @response = ActionController::TestResponse.new + + @first_id = herds(:first).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(:herds) + end + + def test_show + get :show, :id => @first_id + + assert_response :success + assert_template 'show' + + assert_not_nil assigns(:herd) + assert assigns(:herd).valid? + end + + def test_new + get :new + + assert_response :success + assert_template 'new' + + assert_not_nil assigns(:herd) + end + + def test_create + num_herds = Herd.count + + post :create, :herd => {} + + assert_response :redirect + assert_redirected_to :action => 'list' + + assert_equal num_herds + 1, Herd.count + end + + def test_edit + get :edit, :id => @first_id + + assert_response :success + assert_template 'edit' + + assert_not_nil assigns(:herd) + assert assigns(:herd).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 { + Herd.find(@first_id) + } + + post :destroy, :id => @first_id + assert_response :redirect + assert_redirected_to :action => 'list' + + assert_raise(ActiveRecord::RecordNotFound) { + Herd.find(@first_id) + } + end +end diff --git a/projects/devdashboard/test/test_helper.rb b/projects/devdashboard/test/test_helper.rb new file mode 100644 index 0000000..a299c7f --- /dev/null +++ b/projects/devdashboard/test/test_helper.rb @@ -0,0 +1,28 @@ +ENV["RAILS_ENV"] = "test" +require File.expand_path(File.dirname(__FILE__) + "/../config/environment") +require 'test_help' + +class Test::Unit::TestCase + # Transactional fixtures accelerate your tests by wrapping each test method + # in a transaction that's rolled back on completion. This ensures that the + # test database remains unchanged so your fixtures don't have to be reloaded + # between every test method. Fewer database queries means faster tests. + # + # Read Mike Clark's excellent walkthrough at + # http://clarkware.com/cgi/blosxom/2005/10/24#Rails10FastTesting + # + # Every Active Record database supports transactions except MyISAM tables + # in MySQL. Turn off transactional fixtures in this case; however, if you + # don't care one way or the other, switching from MyISAM to InnoDB tables + # is recommended. + self.use_transactional_fixtures = true + + # Instantiated fixtures are slow, but give you @david where otherwise you + # would need people(:david). If you don't want to migrate your existing + # test cases which use the @david style and don't mind the speed hit (each + # instantiated fixtures translates to a database query per test method), + # then set this back to true. + self.use_instantiated_fixtures = false + + # Add more helper methods to be used by all tests here... +end diff --git a/projects/devdashboard/test/unit/developer_test.rb b/projects/devdashboard/test/unit/developer_test.rb new file mode 100644 index 0000000..43df6b2 --- /dev/null +++ b/projects/devdashboard/test/unit/developer_test.rb @@ -0,0 +1,10 @@ +require File.dirname(__FILE__) + '/../test_helper' + +class DeveloperTest < Test::Unit::TestCase + fixtures :developers + + # Replace this with your real tests. + def test_truth + assert true + end +end diff --git a/projects/devdashboard/test/unit/herd_test.rb b/projects/devdashboard/test/unit/herd_test.rb new file mode 100644 index 0000000..6220c13 --- /dev/null +++ b/projects/devdashboard/test/unit/herd_test.rb @@ -0,0 +1,10 @@ +require File.dirname(__FILE__) + '/../test_helper' + +class HerdTest < Test::Unit::TestCase + fixtures :herds + + # Replace this with your real tests. + def test_truth + assert true + end +end diff --git a/projects/devdashboard/test/unit/project_member_test.rb b/projects/devdashboard/test/unit/project_member_test.rb new file mode 100644 index 0000000..2aeece7 --- /dev/null +++ b/projects/devdashboard/test/unit/project_member_test.rb @@ -0,0 +1,10 @@ +require File.dirname(__FILE__) + '/../test_helper' + +class ProjectMemberTest < Test::Unit::TestCase + fixtures :project_members + + # Replace this with your real tests. + def test_truth + assert true + end +end diff --git a/projects/devdashboard/test/unit/project_test.rb b/projects/devdashboard/test/unit/project_test.rb new file mode 100644 index 0000000..4282037 --- /dev/null +++ b/projects/devdashboard/test/unit/project_test.rb @@ -0,0 +1,10 @@ +require File.dirname(__FILE__) + '/../test_helper' + +class ProjectTest < Test::Unit::TestCase + fixtures :projects + + # Replace this with your real tests. + def test_truth + assert true + end +end |