summaryrefslogtreecommitdiffstats
path: root/test/functional
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2014-11-02 19:45:14 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2014-11-02 19:45:14 +0000
commitdfc594c33702a123674dcae1d6b4bfe3a2f32fd3 (patch)
tree42f8653451b35f54db68bf914e1d963bfaf13418 /test/functional
parent32b79b6fd4e3a523ee393d7a3e2bb60dbeed77c3 (diff)
downloadredmine-dfc594c33702a123674dcae1d6b4bfe3a2f32fd3.tar.gz
redmine-dfc594c33702a123674dcae1d6b4bfe3a2f32fd3.zip
Default status per tracker (#5991).
git-svn-id: http://svn.redmine.org/redmine/trunk@13535 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/functional')
-rw-r--r--test/functional/issue_statuses_controller_test.rb17
-rw-r--r--test/functional/issues_controller_test.rb54
-rw-r--r--test/functional/trackers_controller_test.rb12
3 files changed, 70 insertions, 13 deletions
diff --git a/test/functional/issue_statuses_controller_test.rb b/test/functional/issue_statuses_controller_test.rb
index 59fff8141..b8e0ea5b5 100644
--- a/test/functional/issue_statuses_controller_test.rb
+++ b/test/functional/issue_statuses_controller_test.rb
@@ -86,7 +86,8 @@ class IssueStatusesControllerTest < ActionController::TestCase
end
def test_destroy
- Issue.delete_all("status_id = 1")
+ Issue.where(:status_id => 1).delete_all
+ Tracker.where(:default_status_id => 1).delete_all
assert_difference 'IssueStatus.count', -1 do
delete :destroy, :id => '1'
@@ -96,7 +97,19 @@ class IssueStatusesControllerTest < ActionController::TestCase
end
def test_destroy_should_block_if_status_in_use
- assert_not_nil Issue.find_by_status_id(1)
+ assert Issue.where(:status_id => 1).any?
+ Tracker.where(:default_status_id => 1).delete_all
+
+ assert_no_difference 'IssueStatus.count' do
+ delete :destroy, :id => '1'
+ end
+ assert_redirected_to :action => 'index'
+ assert_not_nil IssueStatus.find_by_id(1)
+ end
+
+ def test_destroy_should_block_if_status_in_use
+ Issue.where(:status_id => 1).delete_all
+ assert Tracker.where(:default_status_id => 1).any?
assert_no_difference 'IssueStatus.count' do
delete :destroy, :id => '1'
diff --git a/test/functional/issues_controller_test.rb b/test/functional/issues_controller_test.rb
index 6b2dd7110..8ffb9c848 100644
--- a/test/functional/issues_controller_test.rb
+++ b/test/functional/issues_controller_test.rb
@@ -1511,6 +1511,30 @@ class IssuesControllerTest < ActionController::TestCase
end
end
+ def test_new_should_select_default_status
+ @request.session[:user_id] = 2
+
+ get :new, :project_id => 1
+ assert_response :success
+ assert_template 'new'
+ assert_select 'select[name=?]', 'issue[status_id]' do
+ assert_select 'option[value=1][selected=selected]'
+ end
+ assert_select 'input[name=was_default_status][value=1]'
+ end
+
+ def test_new_should_select_default_status
+ @request.session[:user_id] = 2
+
+ get :new, :project_id => 1
+ assert_response :success
+ assert_template 'new'
+ assert_select 'select[name=?]', 'issue[status_id]' do
+ assert_select 'option[value=1][selected=selected]'
+ end
+ assert_select 'input[name=was_default_status][value=1]'
+ end
+
def test_get_new_with_list_custom_field
@request.session[:user_id] = 2
get :new, :project_id => 1, :tracker_id => 1
@@ -1731,6 +1755,20 @@ class IssuesControllerTest < ActionController::TestCase
assert_equal [1,2,5], assigns(:allowed_statuses).map(&:id).sort
end
+ def test_update_form_with_default_status_should_ignore_submitted_status_id_if_equals
+ @request.session[:user_id] = 2
+ tracker = Tracker.find(2)
+ tracker.update! :default_status_id => 2
+ tracker.generate_transitions! 2, 1, :clear => true
+
+ xhr :post, :update_form, :project_id => 1,
+ :issue => {:tracker_id => 2,
+ :status_id => 1},
+ :was_default_status => 1
+
+ assert_equal 2, assigns(:issue).status_id
+ end
+
def test_post_create
@request.session[:user_id] = 2
assert_difference 'Issue.count' do
@@ -2266,13 +2304,17 @@ class IssuesControllerTest < ActionController::TestCase
get :new, :project_id => 1
assert_response :success
assert_template 'new'
+
+ issue = assigns(:issue)
+ assert_not_nil issue.default_status
+
assert_select 'select[name=?]', 'issue[status_id]' do
assert_select 'option', 1
- assert_select 'option[value=?]', IssueStatus.default.id.to_s
+ assert_select 'option[value=?]', issue.default_status.id.to_s
end
end
- test "without workflow privilege #new should accept default status" do
+ test "without workflow privilege #create should accept default status" do
setup_without_workflow_privilege
assert_difference 'Issue.count' do
post :create, :project_id => 1,
@@ -2281,10 +2323,11 @@ class IssuesControllerTest < ActionController::TestCase
:status_id => 1}
end
issue = Issue.order('id').last
- assert_equal IssueStatus.default, issue.status
+ assert_not_nil issue.default_status
+ assert_equal issue.default_status, issue.status
end
- test "without workflow privilege #new should ignore unauthorized status" do
+ test "without workflow privilege #create should ignore unauthorized status" do
setup_without_workflow_privilege
assert_difference 'Issue.count' do
post :create, :project_id => 1,
@@ -2293,7 +2336,8 @@ class IssuesControllerTest < ActionController::TestCase
:status_id => 3}
end
issue = Issue.order('id').last
- assert_equal IssueStatus.default, issue.status
+ assert_not_nil issue.default_status
+ assert_equal issue.default_status, issue.status
end
test "without workflow privilege #update should ignore status change" do
diff --git a/test/functional/trackers_controller_test.rb b/test/functional/trackers_controller_test.rb
index e5246ce59..4e872926c 100644
--- a/test/functional/trackers_controller_test.rb
+++ b/test/functional/trackers_controller_test.rb
@@ -18,7 +18,7 @@
require File.expand_path('../../test_helper', __FILE__)
class TrackersControllerTest < ActionController::TestCase
- fixtures :trackers, :projects, :projects_trackers, :users, :issues, :custom_fields
+ fixtures :trackers, :projects, :projects_trackers, :users, :issues, :custom_fields, :issue_statuses
def setup
User.current = nil
@@ -51,7 +51,7 @@ class TrackersControllerTest < ActionController::TestCase
def test_create
assert_difference 'Tracker.count' do
- post :create, :tracker => { :name => 'New tracker', :project_ids => ['1', '', ''], :custom_field_ids => ['1', '6', ''] }
+ post :create, :tracker => { :name => 'New tracker', :default_status_id => 1, :project_ids => ['1', '', ''], :custom_field_ids => ['1', '6', ''] }
end
assert_redirected_to :action => 'index'
tracker = Tracker.order('id DESC').first
@@ -62,9 +62,9 @@ class TrackersControllerTest < ActionController::TestCase
assert_equal 0, tracker.workflow_rules.count
end
- def create_with_disabled_core_fields
+ def test_create_with_disabled_core_fields
assert_difference 'Tracker.count' do
- post :create, :tracker => { :name => 'New tracker', :core_fields => ['assigned_to_id', 'fixed_version_id', ''] }
+ post :create, :tracker => { :name => 'New tracker', :default_status_id => 1, :core_fields => ['assigned_to_id', 'fixed_version_id', ''] }
end
assert_redirected_to :action => 'index'
tracker = Tracker.order('id DESC').first
@@ -74,7 +74,7 @@ class TrackersControllerTest < ActionController::TestCase
def test_create_new_with_workflow_copy
assert_difference 'Tracker.count' do
- post :create, :tracker => { :name => 'New tracker' }, :copy_workflow_from => 1
+ post :create, :tracker => { :name => 'New tracker', :default_status_id => 1 }, :copy_workflow_from => 1
end
assert_redirected_to :action => 'index'
tracker = Tracker.find_by_name('New tracker')
@@ -164,7 +164,7 @@ class TrackersControllerTest < ActionController::TestCase
end
def test_destroy
- tracker = Tracker.create!(:name => 'Destroyable')
+ tracker = Tracker.generate!(:name => 'Destroyable')
assert_difference 'Tracker.count', -1 do
delete :destroy, :id => tracker.id
end