##// END OF EJS Templates
Adds a few functional tests....
Jean-Philippe Lang -
r2899:3b9d8c2a72f6
parent child
Show More
@@ -0,0 +1,73
1 require File.dirname(__FILE__) + '/../test_helper'
2 require 'issue_statuses_controller'
3
4 # Re-raise errors caught by the controller.
5 class IssueStatusesController; def rescue_action(e) raise e end; end
6
7
8 class IssueStatusesControllerTest < ActionController::TestCase
9 fixtures :issue_statuses, :issues
10
11 def setup
12 @controller = IssueStatusesController.new
13 @request = ActionController::TestRequest.new
14 @response = ActionController::TestResponse.new
15 User.current = nil
16 @request.session[:user_id] = 1 # admin
17 end
18
19 def test_index
20 # TODO: unify with #list
21 get :index
22 assert_response :success
23 assert_template 'list'
24 end
25
26 def test_new
27 get :new
28 assert_response :success
29 assert_template 'new'
30 end
31
32 def test_create
33 assert_difference 'IssueStatus.count' do
34 post :create, :issue_status => {:name => 'New status'}
35 end
36 assert_redirected_to 'issue_statuses/list'
37 status = IssueStatus.find(:first, :order => 'id DESC')
38 assert_equal 'New status', status.name
39 end
40
41 def test_edit
42 get :edit, :id => '3'
43 assert_response :success
44 assert_template 'edit'
45 end
46
47 def test_update
48 post :update, :id => '3', :issue_status => {:name => 'Renamed status'}
49 assert_redirected_to 'issue_statuses/list'
50 status = IssueStatus.find(3)
51 assert_equal 'Renamed status', status.name
52 end
53
54 def test_destroy
55 Issue.delete_all("status_id = 1")
56
57 assert_difference 'IssueStatus.count', -1 do
58 post :destroy, :id => '1'
59 end
60 assert_redirected_to 'issue_statuses/list'
61 assert_nil IssueStatus.find_by_id(1)
62 end
63
64 def test_destroy_should_block_if_status_in_use
65 assert_not_nil Issue.find_by_status_id(1)
66
67 assert_no_difference 'IssueStatus.count' do
68 post :destroy, :id => '1'
69 end
70 assert_redirected_to 'issue_statuses/list'
71 assert_not_nil IssueStatus.find_by_id(1)
72 end
73 end
@@ -1,7 +1,13
1 issue_relation_001:
1 issue_relation_001:
2 id: 1
2 id: 1
3 issue_from_id: 10
3 issue_from_id: 10
4 issue_to_id: 9
4 issue_to_id: 9
5 relation_type: blocks
5 relation_type: blocks
6 delay:
6 delay:
7 issue_relation_002:
8 id: 2
9 issue_from_id: 2
10 issue_to_id: 3
11 relation_type: relates
12 delay:
7
13
@@ -1,59 +1,67
1 require File.dirname(__FILE__) + '/../test_helper'
1 require File.dirname(__FILE__) + '/../test_helper'
2 require 'issue_relations_controller'
2 require 'issue_relations_controller'
3
3
4 # Re-raise errors caught by the controller.
4 # Re-raise errors caught by the controller.
5 class IssueRelationsController; def rescue_action(e) raise e end; end
5 class IssueRelationsController; def rescue_action(e) raise e end; end
6
6
7
7
8 class IssueRelationsControllerTest < ActionController::TestCase
8 class IssueRelationsControllerTest < ActionController::TestCase
9 fixtures :projects,
9 fixtures :projects,
10 :users,
10 :users,
11 :roles,
11 :roles,
12 :members,
12 :members,
13 :member_roles,
13 :member_roles,
14 :issues,
14 :issues,
15 :issue_statuses,
15 :issue_statuses,
16 :issue_relations,
16 :enabled_modules,
17 :enabled_modules,
17 :enumerations,
18 :enumerations,
18 :trackers
19 :trackers
19
20
20 def setup
21 def setup
21 @controller = IssueRelationsController.new
22 @controller = IssueRelationsController.new
22 @request = ActionController::TestRequest.new
23 @request = ActionController::TestRequest.new
23 @response = ActionController::TestResponse.new
24 @response = ActionController::TestResponse.new
24 User.current = nil
25 User.current = nil
25 end
26 end
26
27
27 def test_new_routing
28 def test_new_routing
28 assert_routing(
29 assert_routing(
29 {:method => :post, :path => '/issues/1/relations'},
30 {:method => :post, :path => '/issues/1/relations'},
30 {:controller => 'issue_relations', :action => 'new', :issue_id => '1'}
31 {:controller => 'issue_relations', :action => 'new', :issue_id => '1'}
31 )
32 )
32 end
33 end
33
34
34 def test_destroy_routing
35 assert_recognizes( #TODO: use DELETE on issue URI
36 {:controller => 'issue_relations', :action => 'destroy', :issue_id => '1', :id => '23'},
37 {:method => :post, :path => '/issues/1/relations/23/destroy'}
38 )
39 end
40
41 def test_new
35 def test_new
42 assert_difference 'IssueRelation.count' do
36 assert_difference 'IssueRelation.count' do
43 @request.session[:user_id] = 3
37 @request.session[:user_id] = 3
44 post :new, :issue_id => 1,
38 post :new, :issue_id => 1,
45 :relation => {:issue_to_id => '2', :relation_type => 'relates', :delay => ''}
39 :relation => {:issue_to_id => '2', :relation_type => 'relates', :delay => ''}
46 end
40 end
47 end
41 end
48
42
49 def test_should_create_relations_with_visible_issues_only
43 def test_should_create_relations_with_visible_issues_only
50 Setting.cross_project_issue_relations = '1'
44 Setting.cross_project_issue_relations = '1'
51 assert_nil Issue.visible(User.find(3)).find_by_id(4)
45 assert_nil Issue.visible(User.find(3)).find_by_id(4)
52
46
53 assert_no_difference 'IssueRelation.count' do
47 assert_no_difference 'IssueRelation.count' do
54 @request.session[:user_id] = 3
48 @request.session[:user_id] = 3
55 post :new, :issue_id => 1,
49 post :new, :issue_id => 1,
56 :relation => {:issue_to_id => '4', :relation_type => 'relates', :delay => ''}
50 :relation => {:issue_to_id => '4', :relation_type => 'relates', :delay => ''}
57 end
51 end
58 end
52 end
53
54 def test_destroy_routing
55 assert_recognizes( #TODO: use DELETE on issue URI
56 {:controller => 'issue_relations', :action => 'destroy', :issue_id => '1', :id => '23'},
57 {:method => :post, :path => '/issues/1/relations/23/destroy'}
58 )
59 end
60
61 def test_destroy
62 assert_difference 'IssueRelation.count', -1 do
63 @request.session[:user_id] = 3
64 post :destroy, :id => '2', :issue_id => '3'
65 end
66 end
59 end
67 end
@@ -1,53 +1,59
1 # redMine - project management software
1 # redMine - project management software
2 # Copyright (C) 2006-2007 Jean-Philippe Lang
2 # Copyright (C) 2006-2007 Jean-Philippe Lang
3 #
3 #
4 # This program is free software; you can redistribute it and/or
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
7 # of the License, or (at your option) any later version.
8 #
8 #
9 # This program is distributed in the hope that it will be useful,
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
12 # GNU General Public License for more details.
13 #
13 #
14 # You should have received a copy of the GNU General Public License
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
17
18 require File.dirname(__FILE__) + '/../test_helper'
18 require File.dirname(__FILE__) + '/../test_helper'
19 require 'settings_controller'
19 require 'settings_controller'
20
20
21 # Re-raise errors caught by the controller.
21 # Re-raise errors caught by the controller.
22 class SettingsController; def rescue_action(e) raise e end; end
22 class SettingsController; def rescue_action(e) raise e end; end
23
23
24 class SettingsControllerTest < ActionController::TestCase
24 class SettingsControllerTest < ActionController::TestCase
25 fixtures :users
25 fixtures :users
26
26
27 def setup
27 def setup
28 @controller = SettingsController.new
28 @controller = SettingsController.new
29 @request = ActionController::TestRequest.new
29 @request = ActionController::TestRequest.new
30 @response = ActionController::TestResponse.new
30 @response = ActionController::TestResponse.new
31 User.current = nil
31 User.current = nil
32 @request.session[:user_id] = 1 # admin
32 @request.session[:user_id] = 1 # admin
33 end
33 end
34
34
35 def test_index
36 get :index
37 assert_response :success
38 assert_template 'edit'
39 end
40
35 def test_get_edit
41 def test_get_edit
36 get :edit
42 get :edit
37 assert_response :success
43 assert_response :success
38 assert_template 'edit'
44 assert_template 'edit'
39 end
45 end
40
46
41 def test_post_edit_notifications
47 def test_post_edit_notifications
42 post :edit, :settings => {:mail_from => 'functional@test.foo',
48 post :edit, :settings => {:mail_from => 'functional@test.foo',
43 :bcc_recipients => '0',
49 :bcc_recipients => '0',
44 :notified_events => %w(issue_added issue_updated news_added),
50 :notified_events => %w(issue_added issue_updated news_added),
45 :emails_footer => 'Test footer'
51 :emails_footer => 'Test footer'
46 }
52 }
47 assert_redirected_to 'settings/edit'
53 assert_redirected_to 'settings/edit'
48 assert_equal 'functional@test.foo', Setting.mail_from
54 assert_equal 'functional@test.foo', Setting.mail_from
49 assert !Setting.bcc_recipients?
55 assert !Setting.bcc_recipients?
50 assert_equal %w(issue_added issue_updated news_added), Setting.notified_events
56 assert_equal %w(issue_added issue_updated news_added), Setting.notified_events
51 assert_equal 'Test footer', Setting.emails_footer
57 assert_equal 'Test footer', Setting.emails_footer
52 end
58 end
53 end
59 end
General Comments 0
You need to be logged in to leave comments. Login now