added mailing_list model and controller

git-svn-id: http://redmine.rubyforge.org/svn/branches/work@264 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang
2007-02-25 10:13:48 +00:00
parent 94e6de465c
commit 73e822834d
13 changed files with 300 additions and 0 deletions
+5
View File
@@ -0,0 +1,5 @@
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
one:
id: 1
two:
id: 2
@@ -0,0 +1,92 @@
require File.dirname(__FILE__) + '/../test_helper'
require 'mailing_lists_controller'
# Re-raise errors caught by the controller.
class MailingListsController; def rescue_action(e) raise e end; end
class MailingListsControllerTest < Test::Unit::TestCase
fixtures :mailing_lists
def setup
@controller = MailingListsController.new
@request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new
@first_id = mailing_lists(: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(:mailing_lists)
end
def test_show
get :show, :id => @first_id
assert_response :success
assert_template 'show'
assert_not_nil assigns(:mailing_list)
assert assigns(:mailing_list).valid?
end
def test_new
get :new
assert_response :success
assert_template 'new'
assert_not_nil assigns(:mailing_list)
end
def test_create
num_mailing_lists = MailingList.count
post :create, :mailing_list => {}
assert_response :redirect
assert_redirected_to :action => 'list'
assert_equal num_mailing_lists + 1, MailingList.count
end
def test_edit
get :edit, :id => @first_id
assert_response :success
assert_template 'edit'
assert_not_nil assigns(:mailing_list)
assert assigns(:mailing_list).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 {
MailingList.find(@first_id)
}
post :destroy, :id => @first_id
assert_response :redirect
assert_redirected_to :action => 'list'
assert_raise(ActiveRecord::RecordNotFound) {
MailingList.find(@first_id)
}
end
end
@@ -0,0 +1,10 @@
require File.dirname(__FILE__) + '/../test_helper'
class MailingListTest < Test::Unit::TestCase
fixtures :mailing_lists
# Replace this with your real tests.
def test_truth
assert true
end
end