summaryrefslogtreecommitdiffstats
path: root/test/functional
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2015-07-26 08:30:19 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2015-07-26 08:30:19 +0000
commit2bc5b60f9de7c533b33348213f6ddac37dc9cdb3 (patch)
tree803c2d2ece43283b231b59ede3636c9fc2d3828a /test/functional
parentfdecb2a17b450c4524856b0286c2ec27ef113ea6 (diff)
downloadredmine-2bc5b60f9de7c533b33348213f6ddac37dc9cdb3.tar.gz
redmine-2bc5b60f9de7c533b33348213f6ddac37dc9cdb3.zip
Makes new issue initial status settable in workflow (#5816).
git-svn-id: http://svn.redmine.org/redmine/trunk@14458 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/functional')
-rw-r--r--test/functional/issues_controller_test.rb37
-rw-r--r--test/functional/workflows_controller_test.rb24
2 files changed, 58 insertions, 3 deletions
diff --git a/test/functional/issues_controller_test.rb b/test/functional/issues_controller_test.rb
index f642d582d..4aa89c64e 100644
--- a/test/functional/issues_controller_test.rb
+++ b/test/functional/issues_controller_test.rb
@@ -1602,6 +1602,37 @@ class IssuesControllerTest < ActionController::TestCase
assert_select 'input[name=was_default_status][value="1"]'
end
+ def test_new_should_propose_allowed_statuses
+ WorkflowTransition.delete_all
+ WorkflowTransition.create!(:tracker_id => 1, :role_id => 1, :old_status_id => 0, :new_status_id => 1)
+ WorkflowTransition.create!(:tracker_id => 1, :role_id => 1, :old_status_id => 0, :new_status_id => 3)
+ @request.session[:user_id] = 2
+
+ get :new, :project_id => 1
+ assert_response :success
+ assert_select 'select[name=?]', 'issue[status_id]' do
+ assert_select 'option[value="1"]'
+ assert_select 'option[value="3"]'
+ assert_select 'option', 2
+ assert_select 'option[value="1"][selected=selected]'
+ end
+ end
+
+ def test_new_should_propose_allowed_statuses_without_default_status_allowed
+ WorkflowTransition.delete_all
+ WorkflowTransition.create!(:tracker_id => 1, :role_id => 1, :old_status_id => 0, :new_status_id => 2)
+ assert_equal 1, Tracker.find(1).default_status_id
+ @request.session[:user_id] = 2
+
+ get :new, :project_id => 1
+ assert_response :success
+ assert_select 'select[name=?]', 'issue[status_id]' do
+ assert_select 'option[value="2"]'
+ assert_select 'option', 1
+ assert_select 'option[value="2"][selected=selected]'
+ end
+ end
+
def test_get_new_with_list_custom_field
@request.session[:user_id] = 2
get :new, :project_id => 1, :tracker_id => 1
@@ -1827,8 +1858,8 @@ class IssuesControllerTest < ActionController::TestCase
def test_update_form_for_new_issue_should_propose_transitions_based_on_initial_status
@request.session[:user_id] = 2
WorkflowTransition.delete_all
- WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 1, :new_status_id => 2)
- WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 1, :new_status_id => 5)
+ WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 0, :new_status_id => 2)
+ WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 0, :new_status_id => 5)
WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 5, :new_status_id => 4)
xhr :post, :new, :project_id => 1,
@@ -1837,7 +1868,7 @@ class IssuesControllerTest < ActionController::TestCase
:subject => 'This is an issue'}
assert_equal 5, assigns(:issue).status_id
- assert_equal [1,2,5], assigns(:allowed_statuses).map(&:id).sort
+ assert_equal [2,5], assigns(:allowed_statuses).map(&:id).sort
end
def test_update_form_with_default_status_should_ignore_submitted_status_id_if_equals
diff --git a/test/functional/workflows_controller_test.rb b/test/functional/workflows_controller_test.rb
index d59614aea..2f455c499 100644
--- a/test/functional/workflows_controller_test.rb
+++ b/test/functional/workflows_controller_test.rb
@@ -61,6 +61,16 @@ class WorkflowsControllerTest < ActionController::TestCase
assert_select 'input[type=checkbox][name=?]', 'transitions[1][1][always]', 0
end
+ def test_get_edit_should_include_allowed_statuses_for_new_issues
+ WorkflowTransition.delete_all
+ WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 0, :new_status_id => 1)
+
+ get :edit, :role_id => 1, :tracker_id => 1
+ assert_response :success
+ assert_select 'td', 'New issue'
+ assert_select 'input[type=checkbox][name=?][value="1"][checked=checked]', 'transitions[0][1][always]'
+ end
+
def test_get_edit_with_all_roles_and_all_trackers
get :edit, :role_id => 'all', :tracker_id => 'all'
assert_response :success
@@ -96,6 +106,20 @@ class WorkflowsControllerTest < ActionController::TestCase
assert_nil WorkflowTransition.where(:role_id => 2, :tracker_id => 1, :old_status_id => 5, :new_status_id => 4).first
end
+ def test_post_edit_with_allowed_statuses_for_new_issues
+ WorkflowTransition.delete_all
+
+ post :edit, :role_id => 2, :tracker_id => 1,
+ :transitions => {
+ '0' => {'1' => {'always' => '1'}, '2' => {'always' => '1'}}
+ }
+ assert_response 302
+
+ assert WorkflowTransition.where(:role_id => 2, :tracker_id => 1, :old_status_id => 0, :new_status_id => 1).any?
+ assert WorkflowTransition.where(:role_id => 2, :tracker_id => 1, :old_status_id => 0, :new_status_id => 2).any?
+ assert_equal 2, WorkflowTransition.where(:tracker_id => 1, :role_id => 2).count
+ end
+
def test_post_edit_with_additional_transitions
WorkflowTransition.delete_all