To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.
root / .svn / pristine / de / de71f387d0c606eebf684b499bd4901c9d91a85f.svn-base @ 1297:0a574315af3e
History | View | Annotate | Download (6.91 KB)
| 1 |
require File.expand_path('../../test_helper', __FILE__)
|
|---|---|
| 2 |
|
| 3 |
class IssueMovesControllerTest < ActionController::TestCase |
| 4 |
fixtures :projects, :trackers, :issue_statuses, :issues, |
| 5 |
:enumerations, :users, :issue_categories, |
| 6 |
:projects_trackers, |
| 7 |
:roles, |
| 8 |
:member_roles, |
| 9 |
:members, |
| 10 |
:enabled_modules, |
| 11 |
:workflows, |
| 12 |
:journals, :journal_details |
| 13 |
|
| 14 |
def setup |
| 15 |
User.current = nil |
| 16 |
end |
| 17 |
|
| 18 |
def test_get_issue_moves_new |
| 19 |
@request.session[:user_id] = 2 |
| 20 |
get :new, :id => 1 |
| 21 |
|
| 22 |
assert_tag :tag => 'option', :content => 'eCookbook', |
| 23 |
:attributes => { :value => '1', :selected => 'selected' }
|
| 24 |
%w(new_tracker_id status_id priority_id assigned_to_id).each do |field| |
| 25 |
assert_tag :tag => 'option', :content => '(No change)', :attributes => { :value => '' },
|
| 26 |
:parent => {:tag => 'select', :attributes => {:id => field}}
|
| 27 |
assert_no_tag :tag => 'option', :attributes => {:selected => 'selected'},
|
| 28 |
:parent => {:tag => 'select', :attributes => {:id => field}}
|
| 29 |
end |
| 30 |
|
| 31 |
# Be sure we don't include inactive enumerations |
| 32 |
assert ! IssuePriority.find(15).active? |
| 33 |
assert_no_tag :option, :attributes => {:value => '15'},
|
| 34 |
:parent => {:tag => 'select', :attributes => {:id => 'priority_id'} }
|
| 35 |
end |
| 36 |
|
| 37 |
def test_create_one_issue_to_another_project |
| 38 |
@request.session[:user_id] = 2 |
| 39 |
post :create, :id => 1, :new_project_id => 2, :tracker_id => '', :assigned_to_id => '', :status_id => '', :start_date => '', :due_date => '' |
| 40 |
assert_redirected_to :controller => 'issues', :action => 'index', :project_id => 'ecookbook' |
| 41 |
assert_equal 2, Issue.find(1).project_id |
| 42 |
end |
| 43 |
|
| 44 |
def test_create_one_issue_to_another_project_should_follow_when_needed |
| 45 |
@request.session[:user_id] = 2 |
| 46 |
post :create, :id => 1, :new_project_id => 2, :follow => '1' |
| 47 |
assert_redirected_to '/issues/1' |
| 48 |
end |
| 49 |
|
| 50 |
def test_bulk_create_to_another_project |
| 51 |
@request.session[:user_id] = 2 |
| 52 |
post :create, :ids => [1, 2], :new_project_id => 2 |
| 53 |
assert_redirected_to :controller => 'issues', :action => 'index', :project_id => 'ecookbook' |
| 54 |
# Issues moved to project 2 |
| 55 |
assert_equal 2, Issue.find(1).project_id |
| 56 |
assert_equal 2, Issue.find(2).project_id |
| 57 |
# No tracker change |
| 58 |
assert_equal 1, Issue.find(1).tracker_id |
| 59 |
assert_equal 2, Issue.find(2).tracker_id |
| 60 |
end |
| 61 |
|
| 62 |
def test_bulk_create_to_another_tracker |
| 63 |
@request.session[:user_id] = 2 |
| 64 |
post :create, :ids => [1, 2], :new_tracker_id => 2 |
| 65 |
assert_redirected_to :controller => 'issues', :action => 'index', :project_id => 'ecookbook' |
| 66 |
assert_equal 2, Issue.find(1).tracker_id |
| 67 |
assert_equal 2, Issue.find(2).tracker_id |
| 68 |
end |
| 69 |
|
| 70 |
context "#create via bulk move" do |
| 71 |
setup do |
| 72 |
@request.session[:user_id] = 2 |
| 73 |
end |
| 74 |
|
| 75 |
should "allow changing the issue priority" do |
| 76 |
post :create, :ids => [1, 2], :priority_id => 6 |
| 77 |
|
| 78 |
assert_redirected_to :controller => 'issues', :action => 'index', :project_id => 'ecookbook' |
| 79 |
assert_equal 6, Issue.find(1).priority_id |
| 80 |
assert_equal 6, Issue.find(2).priority_id |
| 81 |
|
| 82 |
end |
| 83 |
|
| 84 |
should "allow adding a note when moving" do |
| 85 |
post :create, :ids => [1, 2], :notes => 'Moving two issues' |
| 86 |
|
| 87 |
assert_redirected_to :controller => 'issues', :action => 'index', :project_id => 'ecookbook' |
| 88 |
assert_equal 'Moving two issues', Issue.find(1).journals.sort_by(&:id).last.notes |
| 89 |
assert_equal 'Moving two issues', Issue.find(2).journals.sort_by(&:id).last.notes |
| 90 |
|
| 91 |
end |
| 92 |
|
| 93 |
end |
| 94 |
|
| 95 |
def test_bulk_copy_to_another_project |
| 96 |
@request.session[:user_id] = 2 |
| 97 |
assert_difference 'Issue.count', 2 do |
| 98 |
assert_no_difference 'Project.find(1).issues.count' do |
| 99 |
post :create, :ids => [1, 2], :new_project_id => 2, :copy_options => {:copy => '1'}
|
| 100 |
end |
| 101 |
end |
| 102 |
assert_redirected_to '/projects/ecookbook/issues' |
| 103 |
end |
| 104 |
|
| 105 |
context "#create via bulk copy" do |
| 106 |
should "allow not changing the issue's attributes" do |
| 107 |
@request.session[:user_id] = 2 |
| 108 |
issue_before_move = Issue.find(1) |
| 109 |
assert_difference 'Issue.count', 1 do |
| 110 |
assert_no_difference 'Project.find(1).issues.count' do |
| 111 |
post :create, :ids => [1], :new_project_id => 2, |
| 112 |
:copy_options => {:copy => '1'}, :new_tracker_id => '',
|
| 113 |
:assigned_to_id => '', :status_id => '', |
| 114 |
:start_date => '', :due_date => '' |
| 115 |
end |
| 116 |
end |
| 117 |
issue_after_move = Issue.first(:order => 'id desc', :conditions => {:project_id => 2})
|
| 118 |
assert_equal issue_before_move.tracker_id, issue_after_move.tracker_id |
| 119 |
assert_equal issue_before_move.status_id, issue_after_move.status_id |
| 120 |
assert_equal issue_before_move.assigned_to_id, issue_after_move.assigned_to_id |
| 121 |
end |
| 122 |
|
| 123 |
should "allow changing the issue's attributes" do |
| 124 |
# Fixes random test failure with Mysql |
| 125 |
# where Issue.all(:limit => 2, :order => 'id desc', :conditions => {:project_id => 2})
|
| 126 |
# doesn't return the expected results |
| 127 |
Issue.delete_all("project_id=2")
|
| 128 |
|
| 129 |
@request.session[:user_id] = 2 |
| 130 |
assert_difference 'Issue.count', 2 do |
| 131 |
assert_no_difference 'Project.find(1).issues.count' do |
| 132 |
post :create, :ids => [1, 2], :new_project_id => 2, |
| 133 |
:copy_options => {:copy => '1'}, :new_tracker_id => '',
|
| 134 |
:assigned_to_id => 4, :status_id => 3, |
| 135 |
:start_date => '2009-12-01', :due_date => '2009-12-31' |
| 136 |
end |
| 137 |
end |
| 138 |
|
| 139 |
copied_issues = Issue.all(:limit => 2, :order => 'id desc', :conditions => {:project_id => 2})
|
| 140 |
assert_equal 2, copied_issues.size |
| 141 |
copied_issues.each do |issue| |
| 142 |
assert_equal 2, issue.project_id, "Project is incorrect" |
| 143 |
assert_equal 4, issue.assigned_to_id, "Assigned to is incorrect" |
| 144 |
assert_equal 3, issue.status_id, "Status is incorrect" |
| 145 |
assert_equal '2009-12-01', issue.start_date.to_s, "Start date is incorrect" |
| 146 |
assert_equal '2009-12-31', issue.due_date.to_s, "Due date is incorrect" |
| 147 |
end |
| 148 |
end |
| 149 |
|
| 150 |
should "allow adding a note when copying" do |
| 151 |
@request.session[:user_id] = 2 |
| 152 |
assert_difference 'Issue.count', 1 do |
| 153 |
post :create, :ids => [1], :copy_options => {:copy => '1'},
|
| 154 |
:notes => 'Copying one issue', :new_tracker_id => '', |
| 155 |
:assigned_to_id => 4, :status_id => 3, |
| 156 |
:start_date => '2009-12-01', :due_date => '2009-12-31' |
| 157 |
end |
| 158 |
|
| 159 |
issue = Issue.first(:order => 'id DESC') |
| 160 |
assert_equal 1, issue.journals.size |
| 161 |
journal = issue.journals.first |
| 162 |
assert_equal 0, journal.details.size |
| 163 |
assert_equal 'Copying one issue', journal.notes |
| 164 |
end |
| 165 |
end |
| 166 |
|
| 167 |
def test_copy_to_another_project_should_follow_when_needed |
| 168 |
@request.session[:user_id] = 2 |
| 169 |
post :create, :ids => [1], :new_project_id => 2, :copy_options => {:copy => '1'}, :follow => '1'
|
| 170 |
issue = Issue.first(:order => 'id DESC') |
| 171 |
assert_redirected_to :controller => 'issues', :action => 'show', :id => issue |
| 172 |
end |
| 173 |
|
| 174 |
end |