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