summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2009-12-18 15:41:32 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2009-12-18 15:41:32 +0000
commit6bf0723d0654e58bc6c8fc19759ff8fb6502a18f (patch)
treea90c2bb695ca772be91cab3fb07d79f7ea2de30d /test
parent6a369f28ddab41673f51c1b7a640ad6054d8e258 (diff)
downloadredmine-6bf0723d0654e58bc6c8fc19759ff8fb6502a18f.tar.gz
redmine-6bf0723d0654e58bc6c8fc19759ff8fb6502a18f.zip
By default, only show statuses that are used by the tracker on the workflow edit view.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3188 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test')
-rw-r--r--test/functional/workflows_controller_test.rb38
-rw-r--r--test/unit/tracker_test.rb18
2 files changed, 50 insertions, 6 deletions
diff --git a/test/functional/workflows_controller_test.rb b/test/functional/workflows_controller_test.rb
index 2b5216f55..802d10d6c 100644
--- a/test/functional/workflows_controller_test.rb
+++ b/test/functional/workflows_controller_test.rb
@@ -22,7 +22,7 @@ require 'workflows_controller'
class WorkflowsController; def rescue_action(e) raise e end; end
class WorkflowsControllerTest < ActionController::TestCase
- fixtures :roles, :trackers, :workflows, :users
+ fixtures :roles, :trackers, :workflows, :users, :issue_statuses
def setup
@controller = WorkflowsController.new
@@ -51,18 +51,46 @@ class WorkflowsControllerTest < ActionController::TestCase
end
def test_get_edit_with_role_and_tracker
+ Workflow.delete_all
+ Workflow.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 2, :new_status_id => 3)
+ Workflow.create!(:role_id => 2, :tracker_id => 1, :old_status_id => 3, :new_status_id => 5)
+
get :edit, :role_id => 2, :tracker_id => 1
assert_response :success
assert_template 'edit'
+
+ # used status only
+ assert_not_nil assigns(:statuses)
+ assert_equal [2, 3, 5], assigns(:statuses).collect(&:id)
+
# allowed transitions
assert_tag :tag => 'input', :attributes => { :type => 'checkbox',
- :name => 'issue_status[2][]',
- :value => '1',
+ :name => 'issue_status[3][]',
+ :value => '5',
:checked => 'checked' }
# not allowed
assert_tag :tag => 'input', :attributes => { :type => 'checkbox',
- :name => 'issue_status[2][]',
- :value => '3',
+ :name => 'issue_status[3][]',
+ :value => '2',
+ :checked => nil }
+ # unused
+ assert_no_tag :tag => 'input', :attributes => { :type => 'checkbox',
+ :name => 'issue_status[4][]' }
+ end
+
+ def test_get_edit_with_role_and_tracker_and_all_statuses
+ Workflow.delete_all
+
+ get :edit, :role_id => 2, :tracker_id => 1, :used_statuses_only => '0'
+ assert_response :success
+ assert_template 'edit'
+
+ assert_not_nil assigns(:statuses)
+ assert_equal IssueStatus.count, assigns(:statuses).size
+
+ assert_tag :tag => 'input', :attributes => { :type => 'checkbox',
+ :name => 'issue_status[1][]',
+ :value => '1',
:checked => nil }
end
diff --git a/test/unit/tracker_test.rb b/test/unit/tracker_test.rb
index efc2aa7ed..f27550aa6 100644
--- a/test/unit/tracker_test.rb
+++ b/test/unit/tracker_test.rb
@@ -18,7 +18,7 @@
require File.dirname(__FILE__) + '/../test_helper'
class TrackerTest < ActiveSupport::TestCase
- fixtures :trackers, :workflows
+ fixtures :trackers, :workflows, :issue_statuses, :roles
def test_copy_workflows
source = Tracker.find(1)
@@ -30,4 +30,20 @@ class TrackerTest < ActiveSupport::TestCase
target.reload
assert_equal 89, target.workflows.size
end
+
+ def test_issue_statuses
+ tracker = Tracker.find(1)
+ Workflow.delete_all
+ Workflow.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 2, :new_status_id => 3)
+ Workflow.create!(:role_id => 2, :tracker_id => 1, :old_status_id => 3, :new_status_id => 5)
+
+ assert_kind_of Array, tracker.issue_statuses
+ assert_kind_of IssueStatus, tracker.issue_statuses.first
+ assert_equal [2, 3, 5], Tracker.find(1).issue_statuses.collect(&:id)
+ end
+
+ def test_issue_statuses_empty
+ Workflow.delete_all("tracker_id = 1")
+ assert_equal [], Tracker.find(1).issue_statuses
+ end
end