@@ -1,69 +1,64 | |||
|
1 | 1 | # Redmine - project management software |
|
2 | 2 | # Copyright (C) 2006-2009 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 | class TrackersController < ApplicationController |
|
19 | 19 | layout 'admin' |
|
20 | 20 | |
|
21 | 21 | before_filter :require_admin |
|
22 | 22 | |
|
23 | def index | |
|
24 | list | |
|
25 | render :action => 'list' unless request.xhr? | |
|
26 | end | |
|
27 | ||
|
28 | verify :method => :post, :only => :destroy, :redirect_to => { :action => :list } | |
|
23 | verify :method => :post, :only => :destroy, :redirect_to => { :action => :index } | |
|
29 | 24 | |
|
30 |
def |
|
|
25 | def index | |
|
31 | 26 | @tracker_pages, @trackers = paginate :trackers, :per_page => 10, :order => 'position' |
|
32 |
render :action => " |
|
|
27 | render :action => "index", :layout => false if request.xhr? | |
|
33 | 28 | end |
|
34 | 29 | |
|
35 | 30 | def new |
|
36 | 31 | @tracker = Tracker.new(params[:tracker]) |
|
37 | 32 | if request.post? and @tracker.save |
|
38 | 33 | # workflow copy |
|
39 | 34 | if !params[:copy_workflow_from].blank? && (copy_from = Tracker.find_by_id(params[:copy_workflow_from])) |
|
40 | 35 | @tracker.workflows.copy(copy_from) |
|
41 | 36 | end |
|
42 | 37 | flash[:notice] = l(:notice_successful_create) |
|
43 |
redirect_to :action => ' |
|
|
38 | redirect_to :action => 'index' | |
|
44 | 39 | return |
|
45 | 40 | end |
|
46 | 41 | @trackers = Tracker.find :all, :order => 'position' |
|
47 | 42 | @projects = Project.find(:all) |
|
48 | 43 | end |
|
49 | 44 | |
|
50 | 45 | def edit |
|
51 | 46 | @tracker = Tracker.find(params[:id]) |
|
52 | 47 | if request.post? and @tracker.update_attributes(params[:tracker]) |
|
53 | 48 | flash[:notice] = l(:notice_successful_update) |
|
54 |
redirect_to :action => ' |
|
|
49 | redirect_to :action => 'index' | |
|
55 | 50 | return |
|
56 | 51 | end |
|
57 | 52 | @projects = Project.find(:all) |
|
58 | 53 | end |
|
59 | 54 | |
|
60 | 55 | def destroy |
|
61 | 56 | @tracker = Tracker.find(params[:id]) |
|
62 | 57 | unless @tracker.issues.empty? |
|
63 | 58 | flash[:error] = "This tracker contains issues and can\'t be deleted." |
|
64 | 59 | else |
|
65 | 60 | @tracker.destroy |
|
66 | 61 | end |
|
67 |
redirect_to :action => ' |
|
|
62 | redirect_to :action => 'index' | |
|
68 | 63 | end |
|
69 | 64 | end |
|
1 | NO CONTENT: file renamed from app/views/trackers/list.rhtml to app/views/trackers/index.html.erb |
@@ -1,120 +1,120 | |||
|
1 | 1 | # Redmine - project management software |
|
2 | 2 | # Copyright (C) 2006-2009 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 'trackers_controller' |
|
20 | 20 | |
|
21 | 21 | # Re-raise errors caught by the controller. |
|
22 | 22 | class TrackersController; def rescue_action(e) raise e end; end |
|
23 | 23 | |
|
24 | 24 | class TrackersControllerTest < ActionController::TestCase |
|
25 | 25 | fixtures :trackers, :projects, :projects_trackers, :users, :issues, :custom_fields |
|
26 | 26 | |
|
27 | 27 | def setup |
|
28 | 28 | @controller = TrackersController.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 | 35 | def test_index |
|
36 | 36 | get :index |
|
37 | 37 | assert_response :success |
|
38 |
assert_template ' |
|
|
38 | assert_template 'index' | |
|
39 | 39 | end |
|
40 | 40 | |
|
41 | 41 | def test_get_new |
|
42 | 42 | get :new |
|
43 | 43 | assert_response :success |
|
44 | 44 | assert_template 'new' |
|
45 | 45 | end |
|
46 | 46 | |
|
47 | 47 | def test_post_new |
|
48 | 48 | post :new, :tracker => { :name => 'New tracker', :project_ids => ['1', '', ''], :custom_field_ids => ['1', '6', ''] } |
|
49 |
assert_redirected_to |
|
|
49 | assert_redirected_to :action => 'index' | |
|
50 | 50 | tracker = Tracker.find_by_name('New tracker') |
|
51 | 51 | assert_equal [1], tracker.project_ids.sort |
|
52 | 52 | assert_equal [1, 6], tracker.custom_field_ids |
|
53 | 53 | assert_equal 0, tracker.workflows.count |
|
54 | 54 | end |
|
55 | 55 | |
|
56 | 56 | def test_post_new_with_workflow_copy |
|
57 | 57 | post :new, :tracker => { :name => 'New tracker' }, :copy_workflow_from => 1 |
|
58 |
assert_redirected_to |
|
|
58 | assert_redirected_to :action => 'index' | |
|
59 | 59 | tracker = Tracker.find_by_name('New tracker') |
|
60 | 60 | assert_equal 0, tracker.projects.count |
|
61 | 61 | assert_equal Tracker.find(1).workflows.count, tracker.workflows.count |
|
62 | 62 | end |
|
63 | 63 | |
|
64 | 64 | def test_get_edit |
|
65 | 65 | Tracker.find(1).project_ids = [1, 3] |
|
66 | 66 | |
|
67 | 67 | get :edit, :id => 1 |
|
68 | 68 | assert_response :success |
|
69 | 69 | assert_template 'edit' |
|
70 | 70 | |
|
71 | 71 | assert_tag :input, :attributes => { :name => 'tracker[project_ids][]', |
|
72 | 72 | :value => '1', |
|
73 | 73 | :checked => 'checked' } |
|
74 | 74 | |
|
75 | 75 | assert_tag :input, :attributes => { :name => 'tracker[project_ids][]', |
|
76 | 76 | :value => '2', |
|
77 | 77 | :checked => nil } |
|
78 | 78 | |
|
79 | 79 | assert_tag :input, :attributes => { :name => 'tracker[project_ids][]', |
|
80 | 80 | :value => '', |
|
81 | 81 | :type => 'hidden'} |
|
82 | 82 | end |
|
83 | 83 | |
|
84 | 84 | def test_post_edit |
|
85 | 85 | post :edit, :id => 1, :tracker => { :name => 'Renamed', |
|
86 | 86 | :project_ids => ['1', '2', ''] } |
|
87 |
assert_redirected_to |
|
|
87 | assert_redirected_to :action => 'index' | |
|
88 | 88 | assert_equal [1, 2], Tracker.find(1).project_ids.sort |
|
89 | 89 | end |
|
90 | 90 | |
|
91 | 91 | def test_post_edit_without_projects |
|
92 | 92 | post :edit, :id => 1, :tracker => { :name => 'Renamed', |
|
93 | 93 | :project_ids => [''] } |
|
94 |
assert_redirected_to |
|
|
94 | assert_redirected_to :action => 'index' | |
|
95 | 95 | assert Tracker.find(1).project_ids.empty? |
|
96 | 96 | end |
|
97 | 97 | |
|
98 | 98 | def test_move_lower |
|
99 | 99 | tracker = Tracker.find_by_position(1) |
|
100 | 100 | post :edit, :id => 1, :tracker => { :move_to => 'lower' } |
|
101 | 101 | assert_equal 2, tracker.reload.position |
|
102 | 102 | end |
|
103 | 103 | |
|
104 | 104 | def test_destroy |
|
105 | 105 | tracker = Tracker.create!(:name => 'Destroyable') |
|
106 | 106 | assert_difference 'Tracker.count', -1 do |
|
107 | 107 | post :destroy, :id => tracker.id |
|
108 | 108 | end |
|
109 |
assert_redirected_to |
|
|
109 | assert_redirected_to :action => 'index' | |
|
110 | 110 | assert_nil flash[:error] |
|
111 | 111 | end |
|
112 | 112 | |
|
113 | 113 | def test_destroy_tracker_in_use |
|
114 | 114 | assert_no_difference 'Tracker.count' do |
|
115 | 115 | post :destroy, :id => 1 |
|
116 | 116 | end |
|
117 |
assert_redirected_to |
|
|
117 | assert_redirected_to :action => 'index' | |
|
118 | 118 | assert_not_nil flash[:error] |
|
119 | 119 | end |
|
120 | 120 | end |
General Comments 0
You need to be logged in to leave comments.
Login now