summaryrefslogtreecommitdiffstats
path: root/test/functional/trackers_controller_test.rb
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2009-01-29 14:22:56 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2009-01-29 14:22:56 +0000
commit945ec8942a4c43ed41aa4302cbe74ad45f1ff08c (patch)
tree2e2f45b48ee4277e6e1920d094c337a7b7191738 /test/functional/trackers_controller_test.rb
parent32d4378198b83a10bab53c8e7cee2e4ec8adb818 (diff)
downloadredmine-945ec8942a4c43ed41aa4302cbe74ad45f1ff08c.tar.gz
redmine-945ec8942a4c43ed41aa4302cbe74ad45f1ff08c.zip
Adds projects association on tracker form (#2578).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2335 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/functional/trackers_controller_test.rb')
-rw-r--r--test/functional/trackers_controller_test.rb68
1 files changed, 68 insertions, 0 deletions
diff --git a/test/functional/trackers_controller_test.rb b/test/functional/trackers_controller_test.rb
new file mode 100644
index 000000000..89bbf228f
--- /dev/null
+++ b/test/functional/trackers_controller_test.rb
@@ -0,0 +1,68 @@
+# Redmine - project management software
+# Copyright (C) 2006-2009 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+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, :projects, :projects_trackers, :users
+
+ def setup
+ @controller = TrackersController.new
+ @request = ActionController::TestRequest.new
+ @response = ActionController::TestResponse.new
+ User.current = nil
+ @request.session[:user_id] = 1 # admin
+ end
+
+ def test_get_edit
+ Tracker.find(1).project_ids = [1, 3]
+
+ get :edit, :id => 1
+ assert_response :success
+ assert_template 'edit'
+
+ assert_tag :input, :attributes => { :name => 'tracker[project_ids][]',
+ :value => '1',
+ :checked => 'checked' }
+
+ assert_tag :input, :attributes => { :name => 'tracker[project_ids][]',
+ :value => '2',
+ :checked => nil }
+
+ assert_tag :input, :attributes => { :name => 'tracker[project_ids][]',
+ :value => '',
+ :type => 'hidden'}
+ end
+
+ def test_post_edit
+ post :edit, :id => 1, :tracker => { :name => 'Renamed',
+ :project_ids => ['1', '2', ''] }
+ assert_redirected_to '/trackers/list'
+ assert_equal [1, 2], Tracker.find(1).project_ids.sort
+ end
+
+ def test_post_edit_without_projects
+ post :edit, :id => 1, :tracker => { :name => 'Renamed',
+ :project_ids => [''] }
+ assert_redirected_to '/trackers/list'
+ assert Tracker.find(1).project_ids.empty?
+ end
+end