diff options
Diffstat (limited to 'redmine/test')
60 files changed, 1595 insertions, 0 deletions
diff --git a/redmine/test/fixtures/attachments.yml b/redmine/test/fixtures/attachments.yml new file mode 100644 index 000000000..8794d28ae --- /dev/null +++ b/redmine/test/fixtures/attachments.yml @@ -0,0 +1,5 @@ +# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html +first: + id: 1 +another: + id: 2 diff --git a/redmine/test/fixtures/custom_fields.yml b/redmine/test/fixtures/custom_fields.yml new file mode 100644 index 000000000..8794d28ae --- /dev/null +++ b/redmine/test/fixtures/custom_fields.yml @@ -0,0 +1,5 @@ +# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html +first: + id: 1 +another: + id: 2 diff --git a/redmine/test/fixtures/documents.yml b/redmine/test/fixtures/documents.yml new file mode 100644 index 000000000..8794d28ae --- /dev/null +++ b/redmine/test/fixtures/documents.yml @@ -0,0 +1,5 @@ +# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html +first: + id: 1 +another: + id: 2 diff --git a/redmine/test/fixtures/enumerations.yml b/redmine/test/fixtures/enumerations.yml new file mode 100644 index 000000000..8794d28ae --- /dev/null +++ b/redmine/test/fixtures/enumerations.yml @@ -0,0 +1,5 @@ +# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html +first: + id: 1 +another: + id: 2 diff --git a/redmine/test/fixtures/issue_categories.yml b/redmine/test/fixtures/issue_categories.yml new file mode 100644 index 000000000..8794d28ae --- /dev/null +++ b/redmine/test/fixtures/issue_categories.yml @@ -0,0 +1,5 @@ +# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html +first: + id: 1 +another: + id: 2 diff --git a/redmine/test/fixtures/issue_custom_fields.yml b/redmine/test/fixtures/issue_custom_fields.yml new file mode 100644 index 000000000..8794d28ae --- /dev/null +++ b/redmine/test/fixtures/issue_custom_fields.yml @@ -0,0 +1,5 @@ +# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html +first: + id: 1 +another: + id: 2 diff --git a/redmine/test/fixtures/issue_custom_values.yml b/redmine/test/fixtures/issue_custom_values.yml new file mode 100644 index 000000000..8794d28ae --- /dev/null +++ b/redmine/test/fixtures/issue_custom_values.yml @@ -0,0 +1,5 @@ +# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html +first: + id: 1 +another: + id: 2 diff --git a/redmine/test/fixtures/issue_histories.yml b/redmine/test/fixtures/issue_histories.yml new file mode 100644 index 000000000..8794d28ae --- /dev/null +++ b/redmine/test/fixtures/issue_histories.yml @@ -0,0 +1,5 @@ +# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html +first: + id: 1 +another: + id: 2 diff --git a/redmine/test/fixtures/issue_statuses.yml b/redmine/test/fixtures/issue_statuses.yml new file mode 100644 index 000000000..8794d28ae --- /dev/null +++ b/redmine/test/fixtures/issue_statuses.yml @@ -0,0 +1,5 @@ +# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html +first: + id: 1 +another: + id: 2 diff --git a/redmine/test/fixtures/issues.yml b/redmine/test/fixtures/issues.yml new file mode 100644 index 000000000..8794d28ae --- /dev/null +++ b/redmine/test/fixtures/issues.yml @@ -0,0 +1,5 @@ +# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html +first: + id: 1 +another: + id: 2 diff --git a/redmine/test/fixtures/mailer/issue_closed b/redmine/test/fixtures/mailer/issue_closed new file mode 100644 index 000000000..bb5e51d95 --- /dev/null +++ b/redmine/test/fixtures/mailer/issue_closed @@ -0,0 +1,3 @@ +Mailer#issue_closed + +Find me in app/views/mailer/issue_closed.rhtml diff --git a/redmine/test/fixtures/members.yml b/redmine/test/fixtures/members.yml new file mode 100644 index 000000000..8794d28ae --- /dev/null +++ b/redmine/test/fixtures/members.yml @@ -0,0 +1,5 @@ +# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html +first: + id: 1 +another: + id: 2 diff --git a/redmine/test/fixtures/news.yml b/redmine/test/fixtures/news.yml new file mode 100644 index 000000000..8794d28ae --- /dev/null +++ b/redmine/test/fixtures/news.yml @@ -0,0 +1,5 @@ +# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html +first: + id: 1 +another: + id: 2 diff --git a/redmine/test/fixtures/permissions.yml b/redmine/test/fixtures/permissions.yml new file mode 100644 index 000000000..8794d28ae --- /dev/null +++ b/redmine/test/fixtures/permissions.yml @@ -0,0 +1,5 @@ +# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html +first: + id: 1 +another: + id: 2 diff --git a/redmine/test/fixtures/projects.yml b/redmine/test/fixtures/projects.yml new file mode 100644 index 000000000..8794d28ae --- /dev/null +++ b/redmine/test/fixtures/projects.yml @@ -0,0 +1,5 @@ +# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html +first: + id: 1 +another: + id: 2 diff --git a/redmine/test/fixtures/roles.yml b/redmine/test/fixtures/roles.yml new file mode 100644 index 000000000..8794d28ae --- /dev/null +++ b/redmine/test/fixtures/roles.yml @@ -0,0 +1,5 @@ +# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html +first: + id: 1 +another: + id: 2 diff --git a/redmine/test/fixtures/trackers.yml b/redmine/test/fixtures/trackers.yml new file mode 100644 index 000000000..8794d28ae --- /dev/null +++ b/redmine/test/fixtures/trackers.yml @@ -0,0 +1,5 @@ +# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html +first: + id: 1 +another: + id: 2 diff --git a/redmine/test/fixtures/users.yml b/redmine/test/fixtures/users.yml new file mode 100644 index 000000000..8794d28ae --- /dev/null +++ b/redmine/test/fixtures/users.yml @@ -0,0 +1,5 @@ +# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html +first: + id: 1 +another: + id: 2 diff --git a/redmine/test/fixtures/versions.yml b/redmine/test/fixtures/versions.yml new file mode 100644 index 000000000..8794d28ae --- /dev/null +++ b/redmine/test/fixtures/versions.yml @@ -0,0 +1,5 @@ +# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html +first: + id: 1 +another: + id: 2 diff --git a/redmine/test/fixtures/workflow.yml b/redmine/test/fixtures/workflow.yml new file mode 100644 index 000000000..8794d28ae --- /dev/null +++ b/redmine/test/fixtures/workflow.yml @@ -0,0 +1,5 @@ +# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html +first: + id: 1 +another: + id: 2 diff --git a/redmine/test/functional/account_controller_test.rb b/redmine/test/functional/account_controller_test.rb new file mode 100644 index 000000000..537eb8ffc --- /dev/null +++ b/redmine/test/functional/account_controller_test.rb @@ -0,0 +1,18 @@ +require File.dirname(__FILE__) + '/../test_helper' +require 'account_controller' + +# Re-raise errors caught by the controller. +class AccountController; def rescue_action(e) raise e end; end + +class AccountControllerTest < Test::Unit::TestCase + def setup + @controller = AccountController.new + @request = ActionController::TestRequest.new + @response = ActionController::TestResponse.new + end + + # Replace this with your real tests. + def test_truth + assert true + end +end diff --git a/redmine/test/functional/admin_controller_test.rb b/redmine/test/functional/admin_controller_test.rb new file mode 100644 index 000000000..e44ac9423 --- /dev/null +++ b/redmine/test/functional/admin_controller_test.rb @@ -0,0 +1,18 @@ +require File.dirname(__FILE__) + '/../test_helper' +require 'admin_controller' + +# Re-raise errors caught by the controller. +class AdminController; def rescue_action(e) raise e end; end + +class AdminControllerTest < Test::Unit::TestCase + def setup + @controller = AdminController.new + @request = ActionController::TestRequest.new + @response = ActionController::TestResponse.new + end + + # Replace this with your real tests. + def test_truth + assert true + end +end diff --git a/redmine/test/functional/custom_fields_controller_test.rb b/redmine/test/functional/custom_fields_controller_test.rb new file mode 100644 index 000000000..f86e32569 --- /dev/null +++ b/redmine/test/functional/custom_fields_controller_test.rb @@ -0,0 +1,88 @@ +require File.dirname(__FILE__) + '/../test_helper' +require 'custom_fields_controller' + +# Re-raise errors caught by the controller. +class CustomFieldsController; def rescue_action(e) raise e end; end + +class CustomFieldsControllerTest < Test::Unit::TestCase + fixtures :custom_fields + + def setup + @controller = CustomFieldsController.new + @request = ActionController::TestRequest.new + @response = ActionController::TestResponse.new + 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(:custom_fields) + end + + def test_show + get :show, :id => 1 + + assert_response :success + assert_template 'show' + + assert_not_nil assigns(:custom_field) + assert assigns(:custom_field).valid? + end + + def test_new + get :new + + assert_response :success + assert_template 'new' + + assert_not_nil assigns(:custom_field) + end + + def test_create + num_custom_fields = CustomField.count + + post :create, :custom_field => {} + + assert_response :redirect + assert_redirected_to :action => 'list' + + assert_equal num_custom_fields + 1, CustomField.count + end + + def test_edit + get :edit, :id => 1 + + assert_response :success + assert_template 'edit' + + assert_not_nil assigns(:custom_field) + assert assigns(:custom_field).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 CustomField.find(1) + + post :destroy, :id => 1 + assert_response :redirect + assert_redirected_to :action => 'list' + + assert_raise(ActiveRecord::RecordNotFound) { + CustomField.find(1) + } + end +end diff --git a/redmine/test/functional/documents_controller_test.rb b/redmine/test/functional/documents_controller_test.rb new file mode 100644 index 000000000..c9bd463d3 --- /dev/null +++ b/redmine/test/functional/documents_controller_test.rb @@ -0,0 +1,88 @@ +require File.dirname(__FILE__) + '/../test_helper' +require 'documents_controller' + +# Re-raise errors caught by the controller. +class DocumentsController; def rescue_action(e) raise e end; end + +class DocumentsControllerTest < Test::Unit::TestCase + fixtures :documents + + def setup + @controller = DocumentsController.new + @request = ActionController::TestRequest.new + @response = ActionController::TestResponse.new + 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(:documents) + end + + def test_show + get :show, :id => 1 + + assert_response :success + assert_template 'show' + + assert_not_nil assigns(:document) + assert assigns(:document).valid? + end + + def test_new + get :new + + assert_response :success + assert_template 'new' + + assert_not_nil assigns(:document) + end + + def test_create + num_documents = Document.count + + post :create, :document => {} + + assert_response :redirect + assert_redirected_to :action => 'list' + + assert_equal num_documents + 1, Document.count + end + + def test_edit + get :edit, :id => 1 + + assert_response :success + assert_template 'edit' + + assert_not_nil assigns(:document) + assert assigns(:document).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 Document.find(1) + + post :destroy, :id => 1 + assert_response :redirect + assert_redirected_to :action => 'list' + + assert_raise(ActiveRecord::RecordNotFound) { + Document.find(1) + } + end +end diff --git a/redmine/test/functional/enumerations_controller_test.rb b/redmine/test/functional/enumerations_controller_test.rb new file mode 100644 index 000000000..e9f4b7660 --- /dev/null +++ b/redmine/test/functional/enumerations_controller_test.rb @@ -0,0 +1,88 @@ +require File.dirname(__FILE__) + '/../test_helper' +require 'enumerations_controller' + +# Re-raise errors caught by the controller. +class EnumerationsController; def rescue_action(e) raise e end; end + +class EnumerationsControllerTest < Test::Unit::TestCase + fixtures :enumerations + + def setup + @controller = EnumerationsController.new + @request = ActionController::TestRequest.new + @response = ActionController::TestResponse.new + 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(:enumerations) + end + + def test_show + get :show, :id => 1 + + assert_response :success + assert_template 'show' + + assert_not_nil assigns(:enumeration) + assert assigns(:enumeration).valid? + end + + def test_new + get :new + + assert_response :success + assert_template 'new' + + assert_not_nil assigns(:enumeration) + end + + def test_create + num_enumerations = Enumeration.count + + post :create, :enumeration => {} + + assert_response :redirect + assert_redirected_to :action => 'list' + + assert_equal num_enumerations + 1, Enumeration.count + end + + def test_edit + get :edit, :id => 1 + + assert_response :success + assert_template 'edit' + + assert_not_nil assigns(:enumeration) + assert assigns(:enumeration).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 Enumeration.find(1) + + post :destroy, :id => 1 + assert_response :redirect + assert_redirected_to :action => 'list' + + assert_raise(ActiveRecord::RecordNotFound) { + Enumeration.find(1) + } + end +end diff --git a/redmine/test/functional/help_controller_test.rb b/redmine/test/functional/help_controller_test.rb new file mode 100644 index 000000000..291838b8f --- /dev/null +++ b/redmine/test/functional/help_controller_test.rb @@ -0,0 +1,18 @@ +require File.dirname(__FILE__) + '/../test_helper' +require 'help_controller' + +# Re-raise errors caught by the controller. +class HelpController; def rescue_action(e) raise e end; end + +class HelpControllerTest < Test::Unit::TestCase + def setup + @controller = HelpController.new + @request = ActionController::TestRequest.new + @response = ActionController::TestResponse.new + end + + # Replace this with your real tests. + def test_truth + assert true + end +end diff --git a/redmine/test/functional/issue_categories_controller_test.rb b/redmine/test/functional/issue_categories_controller_test.rb new file mode 100644 index 000000000..4ea4e1c55 --- /dev/null +++ b/redmine/test/functional/issue_categories_controller_test.rb @@ -0,0 +1,88 @@ +require File.dirname(__FILE__) + '/../test_helper' +require 'issue_categories_controller' + +# Re-raise errors caught by the controller. +class IssueCategoriesController; def rescue_action(e) raise e end; end + +class IssueCategoriesControllerTest < Test::Unit::TestCase + fixtures :issue_categories + + def setup + @controller = IssueCategoriesController.new + @request = ActionController::TestRequest.new + @response = ActionController::TestResponse.new + 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(:issue_categories) + end + + def test_show + get :show, :id => 1 + + assert_response :success + assert_template 'show' + + assert_not_nil assigns(:issue_category) + assert assigns(:issue_category).valid? + end + + def test_new + get :new + + assert_response :success + assert_template 'new' + + assert_not_nil assigns(:issue_category) + end + + def test_create + num_issue_categories = IssueCategory.count + + post :create, :issue_category => {} + + assert_response :redirect + assert_redirected_to :action => 'list' + + assert_equal num_issue_categories + 1, IssueCategory.count + end + + def test_edit + get :edit, :id => 1 + + assert_response :success + assert_template 'edit' + + assert_not_nil assigns(:issue_category) + assert assigns(:issue_category).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 IssueCategory.find(1) + + post :destroy, :id => 1 + assert_response :redirect + assert_redirected_to :action => 'list' + + assert_raise(ActiveRecord::RecordNotFound) { + IssueCategory.find(1) + } + end +end diff --git a/redmine/test/functional/issue_statuses_controller_test.rb b/redmine/test/functional/issue_statuses_controller_test.rb new file mode 100644 index 000000000..17f11ef55 --- /dev/null +++ b/redmine/test/functional/issue_statuses_controller_test.rb @@ -0,0 +1,88 @@ +require File.dirname(__FILE__) + '/../test_helper' +require 'issue_statuses_controller' + +# Re-raise errors caught by the controller. +class IssueStatusesController; def rescue_action(e) raise e end; end + +class IssueStatusesControllerTest < Test::Unit::TestCase + fixtures :issue_statuses + + def setup + @controller = IssueStatusesController.new + @request = ActionController::TestRequest.new + @response = ActionController::TestResponse.new + 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(:issue_statuses) + end + + def test_show + get :show, :id => 1 + + assert_response :success + assert_template 'show' + + assert_not_nil assigns(:issue_status) + assert assigns(:issue_status).valid? + end + + def test_new + get :new + + assert_response :success + assert_template 'new' + + assert_not_nil assigns(:issue_status) + end + + def test_create + num_issue_statuses = IssueStatus.count + + post :create, :issue_status => {} + + assert_response :redirect + assert_redirected_to :action => 'list' + + assert_equal num_issue_statuses + 1, IssueStatus.count + end + + def test_edit + get :edit, :id => 1 + + assert_response :success + assert_template 'edit' + + assert_not_nil assigns(:issue_status) + assert assigns(:issue_status).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 IssueStatus.find(1) + + post :destroy, :id => 1 + assert_response :redirect + assert_redirected_to :action => 'list' + + assert_raise(ActiveRecord::RecordNotFound) { + IssueStatus.find(1) + } + end +end diff --git a/redmine/test/functional/issues_controller_test.rb b/redmine/test/functional/issues_controller_test.rb new file mode 100644 index 000000000..1be41f86a --- /dev/null +++ b/redmine/test/functional/issues_controller_test.rb @@ -0,0 +1,88 @@ +require File.dirname(__FILE__) + '/../test_helper' +require 'issues_controller' + +# Re-raise errors caught by the controller. +class IssuesController; def rescue_action(e) raise e end; end + +class IssuesControllerTest < Test::Unit::TestCase + fixtures :issues + + def setup + @controller = IssuesController.new + @request = ActionController::TestRequest.new + @response = ActionController::TestResponse.new + 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(:issues) + end + + def test_show + get :show, :id => 1 + + assert_response :success + assert_template 'show' + + assert_not_nil assigns(:issue) + assert assigns(:issue).valid? + end + + def test_new + get :new + + assert_response :success + assert_template 'new' + + assert_not_nil assigns(:issue) + end + + def test_create + num_issues = Issue.count + + post :create, :issue => {} + + assert_response :redirect + assert_redirected_to :action => 'list' + + assert_equal num_issues + 1, Issue.count + end + + def test_edit + get :edit, :id => 1 + + assert_response :success + assert_template 'edit' + + assert_not_nil assigns(:issue) + assert assigns(:issue).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 Issue.find(1) + + post :destroy, :id => 1 + assert_response :redirect + assert_redirected_to :action => 'list' + + assert_raise(ActiveRecord::RecordNotFound) { + Issue.find(1) + } + end +end diff --git a/redmine/test/functional/members_controller_test.rb b/redmine/test/functional/members_controller_test.rb new file mode 100644 index 000000000..5f47c358d --- /dev/null +++ b/redmine/test/functional/members_controller_test.rb @@ -0,0 +1,88 @@ +require File.dirname(__FILE__) + '/../test_helper' +require 'members_controller' + +# Re-raise errors caught by the controller. +class MembersController; def rescue_action(e) raise e end; end + +class MembersControllerTest < Test::Unit::TestCase + fixtures :members + + def setup + @controller = MembersController.new + @request = ActionController::TestRequest.new + @response = ActionController::TestResponse.new + 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(:members) + end + + def test_show + get :show, :id => 1 + + assert_response :success + assert_template 'show' + + assert_not_nil assigns(:member) + assert assigns(:member).valid? + end + + def test_new + get :new + + assert_response :success + assert_template 'new' + + assert_not_nil assigns(:member) + end + + def test_create + num_members = Member.count + + post :create, :member => {} + + assert_response :redirect + assert_redirected_to :action => 'list' + + assert_equal num_members + 1, Member.count + end + + def test_edit + get :edit, :id => 1 + + assert_response :success + assert_template 'edit' + + assert_not_nil assigns(:member) + assert assigns(:member).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 Member.find(1) + + post :destroy, :id => 1 + assert_response :redirect + assert_redirected_to :action => 'list' + + assert_raise(ActiveRecord::RecordNotFound) { + Member.find(1) + } + end +end diff --git a/redmine/test/functional/news_controller_test.rb b/redmine/test/functional/news_controller_test.rb new file mode 100644 index 000000000..b360c6cb3 --- /dev/null +++ b/redmine/test/functional/news_controller_test.rb @@ -0,0 +1,88 @@ +require File.dirname(__FILE__) + '/../test_helper' +require 'news_controller' + +# Re-raise errors caught by the controller. +class NewsController; def rescue_action(e) raise e end; end + +class NewsControllerTest < Test::Unit::TestCase + fixtures :news + + def setup + @controller = NewsController.new + @request = ActionController::TestRequest.new + @response = ActionController::TestResponse.new + 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(:news) + end + + def test_show + get :show, :id => 1 + + assert_response :success + assert_template 'show' + + assert_not_nil assigns(:news) + assert assigns(:news).valid? + end + + def test_new + get :new + + assert_response :success + assert_template 'new' + + assert_not_nil assigns(:news) + end + + def test_create + num_news = News.count + + post :create, :news => {} + + assert_response :redirect + assert_redirected_to :action => 'list' + + assert_equal num_news + 1, News.count + end + + def test_edit + get :edit, :id => 1 + + assert_response :success + assert_template 'edit' + + assert_not_nil assigns(:news) + assert assigns(:news).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 News.find(1) + + post :destroy, :id => 1 + assert_response :redirect + assert_redirected_to :action => 'list' + + assert_raise(ActiveRecord::RecordNotFound) { + News.find(1) + } + end +end diff --git a/redmine/test/functional/projects_controller_test.rb b/redmine/test/functional/projects_controller_test.rb new file mode 100644 index 000000000..8da34ec7e --- /dev/null +++ b/redmine/test/functional/projects_controller_test.rb @@ -0,0 +1,88 @@ +require File.dirname(__FILE__) + '/../test_helper' +require 'projects_controller' + +# Re-raise errors caught by the controller. +class ProjectsController; def rescue_action(e) raise e end; end + +class ProjectsControllerTest < Test::Unit::TestCase + fixtures :projects + + def setup + @controller = ProjectsController.new + @request = ActionController::TestRequest.new + @response = ActionController::TestResponse.new + 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(:projects) + end + + def test_show + get :show, :id => 1 + + assert_response :success + assert_template 'show' + + assert_not_nil assigns(:project) + assert assigns(:project).valid? + end + + def test_new + get :new + + assert_response :success + assert_template 'new' + + assert_not_nil assigns(:project) + end + + def test_create + num_projects = Project.count + + post :create, :project => {} + + assert_response :redirect + assert_redirected_to :action => 'list' + + assert_equal num_projects + 1, Project.count + end + + def test_edit + get :edit, :id => 1 + + assert_response :success + assert_template 'edit' + + assert_not_nil assigns(:project) + assert assigns(:project).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 Project.find(1) + + post :destroy, :id => 1 + assert_response :redirect + assert_redirected_to :action => 'list' + + assert_raise(ActiveRecord::RecordNotFound) { + Project.find(1) + } + end +end diff --git a/redmine/test/functional/reports_controller_test.rb b/redmine/test/functional/reports_controller_test.rb new file mode 100644 index 000000000..4b52ffab3 --- /dev/null +++ b/redmine/test/functional/reports_controller_test.rb @@ -0,0 +1,18 @@ +require File.dirname(__FILE__) + '/../test_helper' +require 'reports_controller' + +# Re-raise errors caught by the controller. +class ReportsController; def rescue_action(e) raise e end; end + +class ReportsControllerTest < Test::Unit::TestCase + def setup + @controller = ReportsController.new + @request = ActionController::TestRequest.new + @response = ActionController::TestResponse.new + end + + # Replace this with your real tests. + def test_truth + assert true + end +end diff --git a/redmine/test/functional/roles_controller_test.rb b/redmine/test/functional/roles_controller_test.rb new file mode 100644 index 000000000..299aef211 --- /dev/null +++ b/redmine/test/functional/roles_controller_test.rb @@ -0,0 +1,88 @@ +require File.dirname(__FILE__) + '/../test_helper' +require 'roles_controller' + +# Re-raise errors caught by the controller. +class RolesController; def rescue_action(e) raise e end; end + +class RolesControllerTest < Test::Unit::TestCase + fixtures :roles + + def setup + @controller = RolesController.new + @request = ActionController::TestRequest.new + @response = ActionController::TestResponse.new + 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(:roles) + end + + def test_show + get :show, :id => 1 + + assert_response :success + assert_template 'show' + + assert_not_nil assigns(:role) + assert assigns(:role).valid? + end + + def test_new + get :new + + assert_response :success + assert_template 'new' + + assert_not_nil assigns(:role) + end + + def test_create + num_roles = Role.count + + post :create, :role => {} + + assert_response :redirect + assert_redirected_to :action => 'list' + + assert_equal num_roles + 1, Role.count + end + + def test_edit + get :edit, :id => 1 + + assert_response :success + assert_template 'edit' + + assert_not_nil assigns(:role) + assert assigns(:role).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 Role.find(1) + + post :destroy, :id => 1 + assert_response :redirect + assert_redirected_to :action => 'list' + + assert_raise(ActiveRecord::RecordNotFound) { + Role.find(1) + } + end +end diff --git a/redmine/test/functional/trackers_controller_test.rb b/redmine/test/functional/trackers_controller_test.rb new file mode 100644 index 000000000..75063c6c5 --- /dev/null +++ b/redmine/test/functional/trackers_controller_test.rb @@ -0,0 +1,88 @@ +require File.dirname(__FILE__) + '/../test_helper' +require 'trackers_controller' + +# Re-raise errors caught by the controller. +class TrackersController; def rescue_action(e) raise e end; end + +class TrackersControllerTest < Test::Unit::TestCase + fixtures :trackers + + def setup + @controller = TrackersController.new + @request = ActionController::TestRequest.new + @response = ActionController::TestResponse.new + 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(:trackers) + end + + def test_show + get :show, :id => 1 + + assert_response :success + assert_template 'show' + + assert_not_nil assigns(:tracker) + assert assigns(:tracker).valid? + end + + def test_new + get :new + + assert_response :success + assert_template 'new' + + assert_not_nil assigns(:tracker) + end + + def test_create + num_trackers = Tracker.count + + post :create, :tracker => {} + + assert_response :redirect + assert_redirected_to :action => 'list' + + assert_equal num_trackers + 1, Tracker.count + end + + def test_edit + get :edit, :id => 1 + + assert_response :success + assert_template 'edit' + + assert_not_nil assigns(:tracker) + assert assigns(:tracker).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 Tracker.find(1) + + post :destroy, :id => 1 + assert_response :redirect + assert_redirected_to :action => 'list' + + assert_raise(ActiveRecord::RecordNotFound) { + Tracker.find(1) + } + end +end diff --git a/redmine/test/functional/users_controller_test.rb b/redmine/test/functional/users_controller_test.rb new file mode 100644 index 000000000..f1e22817b --- /dev/null +++ b/redmine/test/functional/users_controller_test.rb @@ -0,0 +1,88 @@ +require File.dirname(__FILE__) + '/../test_helper' +require 'users_controller' + +# Re-raise errors caught by the controller. +class UsersController; def rescue_action(e) raise e end; end + +class UsersControllerTest < Test::Unit::TestCase + fixtures :users + + def setup + @controller = UsersController.new + @request = ActionController::TestRequest.new + @response = ActionController::TestResponse.new + 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(:users) + end + + def test_show + get :show, :id => 1 + + assert_response :success + assert_template 'show' + + assert_not_nil assigns(:user) + assert assigns(:user).valid? + end + + def test_new + get :new + + assert_response :success + assert_template 'new' + + assert_not_nil assigns(:user) + end + + def test_create + num_users = User.count + + post :create, :user => {} + + assert_response :redirect + assert_redirected_to :action => 'list' + + assert_equal num_users + 1, User.count + end + + def test_edit + get :edit, :id => 1 + + assert_response :success + assert_template 'edit' + + assert_not_nil assigns(:user) + assert assigns(:user).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 User.find(1) + + post :destroy, :id => 1 + assert_response :redirect + assert_redirected_to :action => 'list' + + assert_raise(ActiveRecord::RecordNotFound) { + User.find(1) + } + end +end diff --git a/redmine/test/functional/versions_controller_test.rb b/redmine/test/functional/versions_controller_test.rb new file mode 100644 index 000000000..85b2ef76c --- /dev/null +++ b/redmine/test/functional/versions_controller_test.rb @@ -0,0 +1,88 @@ +require File.dirname(__FILE__) + '/../test_helper' +require 'versions_controller' + +# Re-raise errors caught by the controller. +class VersionsController; def rescue_action(e) raise e end; end + +class VersionsControllerTest < Test::Unit::TestCase + fixtures :versions + + def setup + @controller = VersionsController.new + @request = ActionController::TestRequest.new + @response = ActionController::TestResponse.new + 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(:versions) + end + + def test_show + get :show, :id => 1 + + assert_response :success + assert_template 'show' + + assert_not_nil assigns(:version) + assert assigns(:version).valid? + end + + def test_new + get :new + + assert_response :success + assert_template 'new' + + assert_not_nil assigns(:version) + end + + def test_create + num_versions = Version.count + + post :create, :version => {} + + assert_response :redirect + assert_redirected_to :action => 'list' + + assert_equal num_versions + 1, Version.count + end + + def test_edit + get :edit, :id => 1 + + assert_response :success + assert_template 'edit' + + assert_not_nil assigns(:version) + assert assigns(:version).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 Version.find(1) + + post :destroy, :id => 1 + assert_response :redirect + assert_redirected_to :action => 'list' + + assert_raise(ActiveRecord::RecordNotFound) { + Version.find(1) + } + end +end diff --git a/redmine/test/functional/welcome_controller_test.rb b/redmine/test/functional/welcome_controller_test.rb new file mode 100644 index 000000000..d773945e1 --- /dev/null +++ b/redmine/test/functional/welcome_controller_test.rb @@ -0,0 +1,18 @@ +require File.dirname(__FILE__) + '/../test_helper' +require 'welcome_controller' + +# Re-raise errors caught by the controller. +class WelcomeController; def rescue_action(e) raise e end; end + +class WelcomeControllerTest < Test::Unit::TestCase + def setup + @controller = WelcomeController.new + @request = ActionController::TestRequest.new + @response = ActionController::TestResponse.new + end + + # Replace this with your real tests. + def test_truth + assert true + end +end diff --git a/redmine/test/test_helper.rb b/redmine/test/test_helper.rb new file mode 100644 index 000000000..a299c7f6d --- /dev/null +++ b/redmine/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/redmine/test/unit/attachment_test.rb b/redmine/test/unit/attachment_test.rb new file mode 100644 index 000000000..6f66833d3 --- /dev/null +++ b/redmine/test/unit/attachment_test.rb @@ -0,0 +1,10 @@ +require File.dirname(__FILE__) + '/../test_helper' + +class AttachmentTest < Test::Unit::TestCase + fixtures :attachments + + # Replace this with your real tests. + def test_truth + assert true + end +end diff --git a/redmine/test/unit/custom_field_test.rb b/redmine/test/unit/custom_field_test.rb new file mode 100644 index 000000000..886bd517f --- /dev/null +++ b/redmine/test/unit/custom_field_test.rb @@ -0,0 +1,10 @@ +require File.dirname(__FILE__) + '/../test_helper' + +class CustomFieldTest < Test::Unit::TestCase + fixtures :custom_fields + + # Replace this with your real tests. + def test_truth + assert_kind_of CustomField, custom_fields(:first) + end +end diff --git a/redmine/test/unit/document_test.rb b/redmine/test/unit/document_test.rb new file mode 100644 index 000000000..acd96ddba --- /dev/null +++ b/redmine/test/unit/document_test.rb @@ -0,0 +1,10 @@ +require File.dirname(__FILE__) + '/../test_helper' + +class DocumentTest < Test::Unit::TestCase + fixtures :documents + + # Replace this with your real tests. + def test_truth + assert true + end +end diff --git a/redmine/test/unit/enumeration_test.rb b/redmine/test/unit/enumeration_test.rb new file mode 100644 index 000000000..ea8c01405 --- /dev/null +++ b/redmine/test/unit/enumeration_test.rb @@ -0,0 +1,10 @@ +require File.dirname(__FILE__) + '/../test_helper' + +class EnumerationTest < Test::Unit::TestCase + fixtures :enumerations + + # Replace this with your real tests. + def test_truth + assert true + end +end diff --git a/redmine/test/unit/issue_category_test.rb b/redmine/test/unit/issue_category_test.rb new file mode 100644 index 000000000..6f5051be9 --- /dev/null +++ b/redmine/test/unit/issue_category_test.rb @@ -0,0 +1,10 @@ +require File.dirname(__FILE__) + '/../test_helper' + +class IssueCategoryTest < Test::Unit::TestCase + fixtures :issue_categories + + # Replace this with your real tests. + def test_truth + assert true + end +end diff --git a/redmine/test/unit/issue_custom_field_test.rb b/redmine/test/unit/issue_custom_field_test.rb new file mode 100644 index 000000000..2adee1061 --- /dev/null +++ b/redmine/test/unit/issue_custom_field_test.rb @@ -0,0 +1,10 @@ +require File.dirname(__FILE__) + '/../test_helper' + +class IssueCustomFieldTest < Test::Unit::TestCase + fixtures :issue_custom_fields + + # Replace this with your real tests. + def test_truth + assert_kind_of IssueCustomField, issue_custom_fields(:first) + end +end diff --git a/redmine/test/unit/issue_custom_value_test.rb b/redmine/test/unit/issue_custom_value_test.rb new file mode 100644 index 000000000..09c0551b6 --- /dev/null +++ b/redmine/test/unit/issue_custom_value_test.rb @@ -0,0 +1,10 @@ +require File.dirname(__FILE__) + '/../test_helper' + +class IssueCustomValueTest < Test::Unit::TestCase + fixtures :issue_custom_values + + # Replace this with your real tests. + def test_truth + assert true + end +end diff --git a/redmine/test/unit/issue_history_test.rb b/redmine/test/unit/issue_history_test.rb new file mode 100644 index 000000000..3da38e73c --- /dev/null +++ b/redmine/test/unit/issue_history_test.rb @@ -0,0 +1,10 @@ +require File.dirname(__FILE__) + '/../test_helper' + +class IssueHistoryTest < Test::Unit::TestCase + fixtures :issue_histories + + # Replace this with your real tests. + def test_truth + assert_kind_of IssueHistory, issue_histories(:first) + end +end diff --git a/redmine/test/unit/issue_status_test.rb b/redmine/test/unit/issue_status_test.rb new file mode 100644 index 000000000..8e7c0b97b --- /dev/null +++ b/redmine/test/unit/issue_status_test.rb @@ -0,0 +1,10 @@ +require File.dirname(__FILE__) + '/../test_helper' + +class IssueStatusTest < Test::Unit::TestCase + fixtures :issue_statuses + + # Replace this with your real tests. + def test_truth + assert_kind_of IssueStatus, issue_statuses(:first) + end +end diff --git a/redmine/test/unit/issue_test.rb b/redmine/test/unit/issue_test.rb new file mode 100644 index 000000000..3b318778e --- /dev/null +++ b/redmine/test/unit/issue_test.rb @@ -0,0 +1,10 @@ +require File.dirname(__FILE__) + '/../test_helper' + +class IssueTest < Test::Unit::TestCase + fixtures :issues + + # Replace this with your real tests. + def test_truth + assert_kind_of Issue, issues(:first) + end +end diff --git a/redmine/test/unit/mailer_test.rb b/redmine/test/unit/mailer_test.rb new file mode 100644 index 000000000..70615d712 --- /dev/null +++ b/redmine/test/unit/mailer_test.rb @@ -0,0 +1,35 @@ +require File.dirname(__FILE__) + '/../test_helper' +require 'mailer' + +class MailerTest < Test::Unit::TestCase + FIXTURES_PATH = File.dirname(__FILE__) + '/../fixtures' + CHARSET = "utf-8" + + include ActionMailer::Quoting + + def setup + ActionMailer::Base.delivery_method = :test + ActionMailer::Base.perform_deliveries = true + ActionMailer::Base.deliveries = [] + + @expected = TMail::Mail.new + @expected.set_content_type "text", "plain", { "charset" => CHARSET } + end + + def test_issue_closed + @expected.subject = 'Mailer#issue_closed' + @expected.body = read_fixture('issue_closed') + @expected.date = Time.now + + assert_equal @expected.encoded, Mailer.create_issue_closed(@expected.date).encoded + end + + private + def read_fixture(action) + IO.readlines("#{FIXTURES_PATH}/mailer/#{action}") + end + + def encode(subject) + quoted_printable(subject, CHARSET) + end +end diff --git a/redmine/test/unit/member_test.rb b/redmine/test/unit/member_test.rb new file mode 100644 index 000000000..443c096ec --- /dev/null +++ b/redmine/test/unit/member_test.rb @@ -0,0 +1,10 @@ +require File.dirname(__FILE__) + '/../test_helper' + +class MemberTest < Test::Unit::TestCase + fixtures :members + + # Replace this with your real tests. + def test_truth + assert_kind_of Member, members(:first) + end +end diff --git a/redmine/test/unit/news_test.rb b/redmine/test/unit/news_test.rb new file mode 100644 index 000000000..db9b3ab0d --- /dev/null +++ b/redmine/test/unit/news_test.rb @@ -0,0 +1,10 @@ +require File.dirname(__FILE__) + '/../test_helper' + +class NewsTest < Test::Unit::TestCase + fixtures :news + + # Replace this with your real tests. + def test_truth + assert_kind_of News, news(:first) + end +end diff --git a/redmine/test/unit/packages_test.rb b/redmine/test/unit/packages_test.rb new file mode 100644 index 000000000..a5ebcdf1b --- /dev/null +++ b/redmine/test/unit/packages_test.rb @@ -0,0 +1,10 @@ +require File.dirname(__FILE__) + '/../test_helper' + +class PackagesTest < Test::Unit::TestCase + fixtures :packages + + # Replace this with your real tests. + def test_truth + assert_kind_of Packages, packages(:first) + end +end diff --git a/redmine/test/unit/permission_test.rb b/redmine/test/unit/permission_test.rb new file mode 100644 index 000000000..306c2e61c --- /dev/null +++ b/redmine/test/unit/permission_test.rb @@ -0,0 +1,10 @@ +require File.dirname(__FILE__) + '/../test_helper' + +class PermissionTest < Test::Unit::TestCase + fixtures :permissions + + # Replace this with your real tests. + def test_truth + assert_kind_of Permission, permissions(:first) + end +end diff --git a/redmine/test/unit/project_test.rb b/redmine/test/unit/project_test.rb new file mode 100644 index 000000000..8a9912576 --- /dev/null +++ b/redmine/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_kind_of Project, projects(:first) + end +end diff --git a/redmine/test/unit/role_test.rb b/redmine/test/unit/role_test.rb new file mode 100644 index 000000000..90565ae80 --- /dev/null +++ b/redmine/test/unit/role_test.rb @@ -0,0 +1,10 @@ +require File.dirname(__FILE__) + '/../test_helper' + +class RoleTest < Test::Unit::TestCase + fixtures :roles + + # Replace this with your real tests. + def test_truth + assert_kind_of Role, roles(:first) + end +end diff --git a/redmine/test/unit/tracker_test.rb b/redmine/test/unit/tracker_test.rb new file mode 100644 index 000000000..f738f288b --- /dev/null +++ b/redmine/test/unit/tracker_test.rb @@ -0,0 +1,10 @@ +require File.dirname(__FILE__) + '/../test_helper' + +class TrackerTest < Test::Unit::TestCase + fixtures :trackers + + # Replace this with your real tests. + def test_truth + assert true + end +end diff --git a/redmine/test/unit/user_test.rb b/redmine/test/unit/user_test.rb new file mode 100644 index 000000000..d6a2a2245 --- /dev/null +++ b/redmine/test/unit/user_test.rb @@ -0,0 +1,10 @@ +require File.dirname(__FILE__) + '/../test_helper' + +class UserTest < Test::Unit::TestCase + fixtures :users + + # Replace this with your real tests. + def test_truth + assert_kind_of User, users(:first) + end +end diff --git a/redmine/test/unit/version_test.rb b/redmine/test/unit/version_test.rb new file mode 100644 index 000000000..91c52d4a0 --- /dev/null +++ b/redmine/test/unit/version_test.rb @@ -0,0 +1,10 @@ +require File.dirname(__FILE__) + '/../test_helper' + +class VersionTest < Test::Unit::TestCase + fixtures :versions + + # Replace this with your real tests. + def test_truth + assert_kind_of Version, versions(:first) + end +end diff --git a/redmine/test/unit/workflow_test.rb b/redmine/test/unit/workflow_test.rb new file mode 100644 index 000000000..ff88a9763 --- /dev/null +++ b/redmine/test/unit/workflow_test.rb @@ -0,0 +1,10 @@ +require File.dirname(__FILE__) + '/../test_helper' + +class WorkflowTest < Test::Unit::TestCase + fixtures :workflows + + # Replace this with your real tests. + def test_truth + assert_kind_of Workflow, workflows(:first) + end +end |