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