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