##// END OF EJS Templates
Merged r3937 from trunk....
Eric Davis -
r3873:7af610631f47
parent child
Show More
@@ -1,99 +1,99
1 require 'test_helper'
1 require File.dirname(__FILE__) + '/../test_helper'
2 2
3 3 class IssueMovesControllerTest < ActionController::TestCase
4 4 fixtures :all
5 5
6 6 def setup
7 7 User.current = nil
8 8 end
9 9
10 10 def test_create_one_issue_to_another_project
11 11 @request.session[:user_id] = 2
12 12 post :create, :id => 1, :new_project_id => 2, :tracker_id => '', :assigned_to_id => '', :status_id => '', :start_date => '', :due_date => ''
13 13 assert_redirected_to :controller => 'issues', :action => 'index', :project_id => 'ecookbook'
14 14 assert_equal 2, Issue.find(1).project_id
15 15 end
16 16
17 17 def test_create_one_issue_to_another_project_should_follow_when_needed
18 18 @request.session[:user_id] = 2
19 19 post :create, :id => 1, :new_project_id => 2, :follow => '1'
20 20 assert_redirected_to '/issues/1'
21 21 end
22 22
23 23 def test_bulk_create_to_another_project
24 24 @request.session[:user_id] = 2
25 25 post :create, :ids => [1, 2], :new_project_id => 2
26 26 assert_redirected_to :controller => 'issues', :action => 'index', :project_id => 'ecookbook'
27 27 # Issues moved to project 2
28 28 assert_equal 2, Issue.find(1).project_id
29 29 assert_equal 2, Issue.find(2).project_id
30 30 # No tracker change
31 31 assert_equal 1, Issue.find(1).tracker_id
32 32 assert_equal 2, Issue.find(2).tracker_id
33 33 end
34 34
35 35 def test_bulk_create_to_another_tracker
36 36 @request.session[:user_id] = 2
37 37 post :create, :ids => [1, 2], :new_tracker_id => 2
38 38 assert_redirected_to :controller => 'issues', :action => 'index', :project_id => 'ecookbook'
39 39 assert_equal 2, Issue.find(1).tracker_id
40 40 assert_equal 2, Issue.find(2).tracker_id
41 41 end
42 42
43 43 def test_bulk_copy_to_another_project
44 44 @request.session[:user_id] = 2
45 45 assert_difference 'Issue.count', 2 do
46 46 assert_no_difference 'Project.find(1).issues.count' do
47 47 post :create, :ids => [1, 2], :new_project_id => 2, :copy_options => {:copy => '1'}
48 48 end
49 49 end
50 50 assert_redirected_to 'projects/ecookbook/issues'
51 51 end
52 52
53 53 context "#create via bulk copy" do
54 54 should "allow not changing the issue's attributes" do
55 55 @request.session[:user_id] = 2
56 56 issue_before_move = Issue.find(1)
57 57 assert_difference 'Issue.count', 1 do
58 58 assert_no_difference 'Project.find(1).issues.count' do
59 59 post :create, :ids => [1], :new_project_id => 2, :copy_options => {:copy => '1'}, :new_tracker_id => '', :assigned_to_id => '', :status_id => '', :start_date => '', :due_date => ''
60 60 end
61 61 end
62 62 issue_after_move = Issue.first(:order => 'id desc', :conditions => {:project_id => 2})
63 63 assert_equal issue_before_move.tracker_id, issue_after_move.tracker_id
64 64 assert_equal issue_before_move.status_id, issue_after_move.status_id
65 65 assert_equal issue_before_move.assigned_to_id, issue_after_move.assigned_to_id
66 66 end
67 67
68 68 should "allow changing the issue's attributes" do
69 69 # Fixes random test failure with Mysql
70 70 # where Issue.all(:limit => 2, :order => 'id desc', :conditions => {:project_id => 2}) doesn't return the expected results
71 71 Issue.delete_all("project_id=2")
72 72
73 73 @request.session[:user_id] = 2
74 74 assert_difference 'Issue.count', 2 do
75 75 assert_no_difference 'Project.find(1).issues.count' do
76 76 post :create, :ids => [1, 2], :new_project_id => 2, :copy_options => {:copy => '1'}, :new_tracker_id => '', :assigned_to_id => 4, :status_id => 3, :start_date => '2009-12-01', :due_date => '2009-12-31'
77 77 end
78 78 end
79 79
80 80 copied_issues = Issue.all(:limit => 2, :order => 'id desc', :conditions => {:project_id => 2})
81 81 assert_equal 2, copied_issues.size
82 82 copied_issues.each do |issue|
83 83 assert_equal 2, issue.project_id, "Project is incorrect"
84 84 assert_equal 4, issue.assigned_to_id, "Assigned to is incorrect"
85 85 assert_equal 3, issue.status_id, "Status is incorrect"
86 86 assert_equal '2009-12-01', issue.start_date.to_s, "Start date is incorrect"
87 87 assert_equal '2009-12-31', issue.due_date.to_s, "Due date is incorrect"
88 88 end
89 89 end
90 90 end
91 91
92 92 def test_copy_to_another_project_should_follow_when_needed
93 93 @request.session[:user_id] = 2
94 94 post :create, :ids => [1], :new_project_id => 2, :copy_options => {:copy => '1'}, :follow => '1'
95 95 issue = Issue.first(:order => 'id DESC')
96 96 assert_redirected_to :controller => 'issues', :action => 'show', :id => issue
97 97 end
98 98
99 99 end
General Comments 0
You need to be logged in to leave comments. Login now