@@ -22,8 +22,6 class TrackersController < ApplicationController | |||
|
22 | 22 | before_filter :require_admin_or_api_request, :only => :index |
|
23 | 23 | accept_api_auth :index |
|
24 | 24 | |
|
25 | verify :method => :post, :only => :destroy, :redirect_to => { :action => :index } | |
|
26 | ||
|
27 | 25 | def index |
|
28 | 26 | respond_to do |format| |
|
29 | 27 | format.html { |
@@ -37,6 +35,12 class TrackersController < ApplicationController | |||
|
37 | 35 | end |
|
38 | 36 | |
|
39 | 37 | def new |
|
38 | @tracker ||= Tracker.new(params[:tracker]) | |
|
39 | @trackers = Tracker.find :all, :order => 'position' | |
|
40 | @projects = Project.find(:all) | |
|
41 | end | |
|
42 | ||
|
43 | def create | |
|
40 | 44 | @tracker = Tracker.new(params[:tracker]) |
|
41 | 45 | if request.post? and @tracker.save |
|
42 | 46 | # workflow copy |
@@ -47,20 +51,27 class TrackersController < ApplicationController | |||
|
47 | 51 | redirect_to :action => 'index' |
|
48 | 52 | return |
|
49 | 53 | end |
|
50 | @trackers = Tracker.find :all, :order => 'position' | |
|
51 | @projects = Project.find(:all) | |
|
54 | new | |
|
55 | render :action => 'new' | |
|
52 | 56 | end |
|
53 | 57 | |
|
54 | 58 | def edit |
|
59 | @tracker ||= Tracker.find(params[:id]) | |
|
60 | @projects = Project.find(:all) | |
|
61 | end | |
|
62 | ||
|
63 | def update | |
|
55 | 64 | @tracker = Tracker.find(params[:id]) |
|
56 |
if request.p |
|
|
65 | if request.put? and @tracker.update_attributes(params[:tracker]) | |
|
57 | 66 | flash[:notice] = l(:notice_successful_update) |
|
58 | 67 | redirect_to :action => 'index' |
|
59 | 68 | return |
|
60 | 69 | end |
|
61 | @projects = Project.find(:all) | |
|
70 | edit | |
|
71 | render :action => 'edit' | |
|
62 | 72 | end |
|
63 | 73 | |
|
74 | verify :method => :delete, :only => :destroy, :redirect_to => { :action => :index } | |
|
64 | 75 | def destroy |
|
65 | 76 | @tracker = Tracker.find(params[:id]) |
|
66 | 77 | unless @tracker.issues.empty? |
@@ -391,19 +391,19 module ApplicationHelper | |||
|
391 | 391 | links.size > 1 ? l(:label_display_per_page, links.join(', ')) : nil |
|
392 | 392 | end |
|
393 | 393 | |
|
394 | def reorder_links(name, url) | |
|
394 | def reorder_links(name, url, method = :post) | |
|
395 | 395 | link_to(image_tag('2uparrow.png', :alt => l(:label_sort_highest)), |
|
396 | 396 | url.merge({"#{name}[move_to]" => 'highest'}), |
|
397 |
:method => |
|
|
397 | :method => method, :title => l(:label_sort_highest)) + | |
|
398 | 398 | link_to(image_tag('1uparrow.png', :alt => l(:label_sort_higher)), |
|
399 | 399 | url.merge({"#{name}[move_to]" => 'higher'}), |
|
400 |
:method => |
|
|
400 | :method => method, :title => l(:label_sort_higher)) + | |
|
401 | 401 | link_to(image_tag('1downarrow.png', :alt => l(:label_sort_lower)), |
|
402 | 402 | url.merge({"#{name}[move_to]" => 'lower'}), |
|
403 |
:method => |
|
|
403 | :method => method, :title => l(:label_sort_lower)) + | |
|
404 | 404 | link_to(image_tag('2downarrow.png', :alt => l(:label_sort_lowest)), |
|
405 | 405 | url.merge({"#{name}[move_to]" => 'lowest'}), |
|
406 |
:method => |
|
|
406 | :method => method, :title => l(:label_sort_lowest)) | |
|
407 | 407 | end |
|
408 | 408 | |
|
409 | 409 | def breadcrumb(*args) |
@@ -1,5 +1,5 | |||
|
1 |
<h2><%= link_to l(:label_tracker_plural), |
|
|
1 | <h2><%= link_to l(:label_tracker_plural), trackers_path %> » <%=h @tracker %></h2> | |
|
2 | 2 | |
|
3 |
<% form_for |
|
|
3 | <% form_for @tracker, :builder => TabularFormBuilder do |f| %> | |
|
4 | 4 | <%= render :partial => 'form', :locals => { :f => f } %> |
|
5 | 5 | <% end %> |
@@ -1,5 +1,5 | |||
|
1 | 1 | <div class="contextual"> |
|
2 |
<%= link_to l(:label_tracker_new), |
|
|
2 | <%= link_to l(:label_tracker_new), new_tracker_path, :class => 'icon icon-add' %> | |
|
3 | 3 | </div> |
|
4 | 4 | |
|
5 | 5 | <h2><%=l(:label_tracker_plural)%></h2> |
@@ -14,12 +14,12 | |||
|
14 | 14 | <tbody> |
|
15 | 15 | <% for tracker in @trackers %> |
|
16 | 16 | <tr class="<%= cycle("odd", "even") %>"> |
|
17 |
<td><%= link_to h(tracker.name), |
|
|
17 | <td><%= link_to h(tracker.name), edit_tracker_path(tracker) %></td> | |
|
18 | 18 | <td align="center"><% unless tracker.workflows.count > 0 %><span class="icon icon-warning"><%= l(:text_tracker_no_workflow) %> (<%= link_to l(:button_edit), {:controller => 'workflows', :action => 'edit', :tracker_id => tracker} %>)</span><% end %></td> |
|
19 |
<td align="center" style="width:15%;"><%= reorder_links('tracker', {:action => ' |
|
|
19 | <td align="center" style="width:15%;"><%= reorder_links('tracker', {:action => 'update', :id => tracker}, :put) %></td> | |
|
20 | 20 | <td class="buttons"> |
|
21 |
<%= link_to(l(:button_delete), |
|
|
22 |
:method => : |
|
|
21 | <%= link_to(l(:button_delete), tracker_path(tracker), | |
|
22 | :method => :delete, | |
|
23 | 23 | :confirm => l(:text_are_you_sure), |
|
24 | 24 | :class => 'icon icon-del') %> |
|
25 | 25 | </td> |
@@ -1,5 +1,5 | |||
|
1 |
<h2><%= link_to l(:label_tracker_plural), |
|
|
1 | <h2><%= link_to l(:label_tracker_plural), trackers_path %> » <%=l(:label_tracker_new)%></h2> | |
|
2 | 2 | |
|
3 |
<% form_for |
|
|
3 | <% form_for @tracker, :builder => TabularFormBuilder do |f| %> | |
|
4 | 4 | <%= render :partial => 'form', :locals => { :f => f } %> |
|
5 | 5 | <% end %> |
@@ -222,9 +222,9 ActionController::Routing::Routes.draw do |map| | |||
|
222 | 222 | map.connect 'attachments/download/:id/:filename', :controller => 'attachments', :action => 'download', :id => /\d+/, :filename => /.*/ |
|
223 | 223 | |
|
224 | 224 | map.resources :groups |
|
225 | map.resources :trackers, :except => :show | |
|
225 | 226 | |
|
226 | 227 | #left old routes at the bottom for backwards compat |
|
227 | map.connect 'trackers.:format', :controller => 'trackers', :action => 'index' | |
|
228 | 228 | map.connect 'issue_statuses.:format', :controller => 'issue_statuses', :action => 'index' |
|
229 | 229 | map.connect 'projects/:project_id/issues/:action', :controller => 'issues' |
|
230 | 230 | map.connect 'projects/:project_id/documents/:action', :controller => 'documents' |
@@ -50,30 +50,43 class TrackersControllerTest < ActionController::TestCase | |||
|
50 | 50 | assert_response 406 |
|
51 | 51 | end |
|
52 | 52 | |
|
53 |
def test_ |
|
|
53 | def test_new | |
|
54 | 54 | get :new |
|
55 | 55 | assert_response :success |
|
56 | 56 | assert_template 'new' |
|
57 | 57 | end |
|
58 | 58 | |
|
59 |
def test_ |
|
|
60 | post :new, :tracker => { :name => 'New tracker', :project_ids => ['1', '', ''], :custom_field_ids => ['1', '6', ''] } | |
|
59 | def test_create | |
|
60 | assert_difference 'Tracker.count' do | |
|
61 | post :create, :tracker => { :name => 'New tracker', :project_ids => ['1', '', ''], :custom_field_ids => ['1', '6', ''] } | |
|
62 | end | |
|
61 | 63 | assert_redirected_to :action => 'index' |
|
62 | tracker = Tracker.find_by_name('New tracker') | |
|
64 | tracker = Tracker.first(:order => 'id DESC') | |
|
65 | assert_equal 'New tracker', tracker.name | |
|
63 | 66 | assert_equal [1], tracker.project_ids.sort |
|
64 | 67 | assert_equal [1, 6], tracker.custom_field_ids |
|
65 | 68 | assert_equal 0, tracker.workflows.count |
|
66 | 69 | end |
|
67 | 70 | |
|
68 |
def test_ |
|
|
69 | post :new, :tracker => { :name => 'New tracker' }, :copy_workflow_from => 1 | |
|
71 | def test_create_new_with_workflow_copy | |
|
72 | assert_difference 'Tracker.count' do | |
|
73 | post :create, :tracker => { :name => 'New tracker' }, :copy_workflow_from => 1 | |
|
74 | end | |
|
70 | 75 | assert_redirected_to :action => 'index' |
|
71 | 76 | tracker = Tracker.find_by_name('New tracker') |
|
72 | 77 | assert_equal 0, tracker.projects.count |
|
73 | 78 | assert_equal Tracker.find(1).workflows.count, tracker.workflows.count |
|
74 | 79 | end |
|
75 | 80 | |
|
76 |
def test_ |
|
|
81 | def test_create_new_failure | |
|
82 | assert_no_difference 'Tracker.count' do | |
|
83 | post :create, :tracker => { :name => '', :project_ids => ['1', '', ''], :custom_field_ids => ['1', '6', ''] } | |
|
84 | end | |
|
85 | assert_response :success | |
|
86 | assert_template 'new' | |
|
87 | end | |
|
88 | ||
|
89 | def test_edit | |
|
77 | 90 | Tracker.find(1).project_ids = [1, 3] |
|
78 | 91 | |
|
79 | 92 | get :edit, :id => 1 |
@@ -93,15 +106,15 class TrackersControllerTest < ActionController::TestCase | |||
|
93 | 106 | :type => 'hidden'} |
|
94 | 107 | end |
|
95 | 108 | |
|
96 |
def test_ |
|
|
97 |
p |
|
|
109 | def test_update | |
|
110 | put :update, :id => 1, :tracker => { :name => 'Renamed', | |
|
98 | 111 | :project_ids => ['1', '2', ''] } |
|
99 | 112 | assert_redirected_to :action => 'index' |
|
100 | 113 | assert_equal [1, 2], Tracker.find(1).project_ids.sort |
|
101 | 114 | end |
|
102 | 115 | |
|
103 |
def test_ |
|
|
104 |
p |
|
|
116 | def test_update_without_projects | |
|
117 | put :update, :id => 1, :tracker => { :name => 'Renamed', | |
|
105 | 118 | :project_ids => [''] } |
|
106 | 119 | assert_redirected_to :action => 'index' |
|
107 | 120 | assert Tracker.find(1).project_ids.empty? |
@@ -109,14 +122,14 class TrackersControllerTest < ActionController::TestCase | |||
|
109 | 122 | |
|
110 | 123 | def test_move_lower |
|
111 | 124 | tracker = Tracker.find_by_position(1) |
|
112 |
p |
|
|
125 | put :update, :id => 1, :tracker => { :move_to => 'lower' } | |
|
113 | 126 | assert_equal 2, tracker.reload.position |
|
114 | 127 | end |
|
115 | 128 | |
|
116 | 129 | def test_destroy |
|
117 | 130 | tracker = Tracker.create!(:name => 'Destroyable') |
|
118 | 131 | assert_difference 'Tracker.count', -1 do |
|
119 |
|
|
|
132 | delete :destroy, :id => tracker.id | |
|
120 | 133 | end |
|
121 | 134 | assert_redirected_to :action => 'index' |
|
122 | 135 | assert_nil flash[:error] |
@@ -124,7 +137,7 class TrackersControllerTest < ActionController::TestCase | |||
|
124 | 137 | |
|
125 | 138 | def test_destroy_tracker_in_use |
|
126 | 139 | assert_no_difference 'Tracker.count' do |
|
127 |
|
|
|
140 | delete :destroy, :id => 1 | |
|
128 | 141 | end |
|
129 | 142 | assert_redirected_to :action => 'index' |
|
130 | 143 | assert_not_nil flash[:error] |
General Comments 0
You need to be logged in to leave comments.
Login now