@@ -18,9 +18,9 | |||
|
18 | 18 | class TimelogController < ApplicationController |
|
19 | 19 | menu_item :issues |
|
20 | 20 | before_filter :find_project, :authorize, :only => [:edit, :destroy] |
|
21 |
before_filter :find_optional_project, :only => [: |
|
|
21 | before_filter :find_optional_project, :only => [:index] | |
|
22 | 22 | |
|
23 |
verify :method => :post, :only => :destroy, :redirect_to => { :action => : |
|
|
23 | verify :method => :post, :only => :destroy, :redirect_to => { :action => :index } | |
|
24 | 24 | |
|
25 | 25 | helper :sort |
|
26 | 26 | include SortHelper |
@@ -29,7 +29,7 class TimelogController < ApplicationController | |||
|
29 | 29 | helper :custom_fields |
|
30 | 30 | include CustomFieldsHelper |
|
31 | 31 | |
|
32 |
def |
|
|
32 | def index | |
|
33 | 33 | sort_init 'spent_on', 'desc' |
|
34 | 34 | sort_update 'spent_on' => 'spent_on', |
|
35 | 35 | 'user' => 'user_id', |
@@ -95,7 +95,7 class TimelogController < ApplicationController | |||
|
95 | 95 | |
|
96 | 96 | if request.post? and @time_entry.save |
|
97 | 97 | flash[:notice] = l(:notice_successful_update) |
|
98 |
redirect_back_or_default :action => ' |
|
|
98 | redirect_back_or_default :action => 'index', :project_id => @time_entry.project | |
|
99 | 99 | return |
|
100 | 100 | end |
|
101 | 101 | end |
@@ -110,7 +110,7 class TimelogController < ApplicationController | |||
|
110 | 110 | end |
|
111 | 111 | redirect_to :back |
|
112 | 112 | rescue ::ActionController::RedirectBackError |
|
113 |
redirect_to :action => ' |
|
|
113 | redirect_to :action => 'index', :project_id => @time_entry.project | |
|
114 | 114 | end |
|
115 | 115 | |
|
116 | 116 | private |
@@ -32,7 +32,7 | |||
|
32 | 32 | <th class="category"><%=l(:field_category)%>:</th><td class="category"><%=h @issue.category ? @issue.category.name : "-" %></td> |
|
33 | 33 | <% if User.current.allowed_to?(:view_time_entries, @project) %> |
|
34 | 34 | <th class="spent-time"><%=l(:label_spent_time)%>:</th> |
|
35 |
<td class="spent-time"><%= @issue.spent_hours > 0 ? (link_to l_hours(@issue.spent_hours), {:controller => 'timelog', :action => ' |
|
|
35 | <td class="spent-time"><%= @issue.spent_hours > 0 ? (link_to l_hours(@issue.spent_hours), {:controller => 'timelog', :action => 'index', :project_id => @project, :issue_id => @issue}) : "-" %></td> | |
|
36 | 36 | <% end %> |
|
37 | 37 | </tr> |
|
38 | 38 | <tr> |
@@ -67,7 +67,7 | |||
|
67 | 67 | <% if @total_hours && User.current.allowed_to?(:view_time_entries, @project) %> |
|
68 | 68 | <h3><%= l(:label_spent_time) %></h3> |
|
69 | 69 | <p><span class="icon icon-time"><%= l_hours(@total_hours) %></span></p> |
|
70 |
<p><%= link_to(l(:label_details), {:controller => 'timelog', :action => ' |
|
|
70 | <p><%= link_to(l(:label_details), {:controller => 'timelog', :action => 'index', :project_id => @project}) %> | | |
|
71 | 71 | <%= link_to(l(:label_report), {:controller => 'time_entry_reports', :action => 'report', :project_id => @project}) %></p> |
|
72 | 72 | <% end %> |
|
73 | 73 | <%= call_hook(:view_projects_show_sidebar_bottom, :project => @project) %> |
@@ -28,8 +28,8 | |||
|
28 | 28 | <div class="tabs"> |
|
29 | 29 | <% url_params = @free_period ? { :from => @from, :to => @to } : { :period => params[:period] } %> |
|
30 | 30 | <ul> |
|
31 |
<li><%= link_to(l(:label_details), url_params.merge({:controller => 'timelog', :action => ' |
|
|
32 |
:class => (@controller.action_name == ' |
|
|
31 | <li><%= link_to(l(:label_details), url_params.merge({:controller => 'timelog', :action => 'index', :project_id => @project, :issue_id => @issue }), | |
|
32 | :class => (@controller.action_name == 'index' ? 'selected' : nil)) %></li> | |
|
33 | 33 | <li><%= link_to(l(:label_report), url_params.merge({:controller => 'time_entry_reports', :action => 'report', :project_id => @project, :issue_id => @issue}), |
|
34 | 34 | :class => (@controller.action_name == 'report' ? 'selected' : nil)) %></li> |
|
35 | 35 | </ul> |
|
1 | NO CONTENT: file renamed from app/views/timelog/details.rhtml to app/views/timelog/index.html.erb |
@@ -19,9 +19,9 ActionController::Routing::Routes.draw do |map| | |||
|
19 | 19 | map.connect 'projects/:project_id/issues/:issue_id/time_entries/new', :action => 'edit', :controller => 'timelog' |
|
20 | 20 | |
|
21 | 21 | map.with_options :controller => 'timelog' do |timelog| |
|
22 |
timelog.connect 'projects/:project_id/time_entries', :action => ' |
|
|
22 | timelog.connect 'projects/:project_id/time_entries', :action => 'index' | |
|
23 | 23 | |
|
24 |
timelog.with_options :action => ' |
|
|
24 | timelog.with_options :action => 'index', :conditions => {:method => :get} do |time_details| | |
|
25 | 25 | time_details.connect 'time_entries' |
|
26 | 26 | time_details.connect 'time_entries.:format' |
|
27 | 27 | time_details.connect 'issues/:issue_id/time_entries' |
@@ -85,7 +85,7 Redmine::AccessControl.map do |map| | |||
|
85 | 85 | |
|
86 | 86 | map.project_module :time_tracking do |map| |
|
87 | 87 | map.permission :log_time, {:timelog => :edit}, :require => :loggedin |
|
88 |
map.permission :view_time_entries, :timelog => [: |
|
|
88 | map.permission :view_time_entries, :timelog => [:index], :time_entry_reports => [:report] | |
|
89 | 89 | map.permission :edit_time_entries, {:timelog => [:edit, :destroy]}, :require => :member |
|
90 | 90 | map.permission :edit_own_time_entries, {:timelog => [:edit, :destroy]}, :require => :loggedin |
|
91 | 91 | map.permission :manage_project_activities, {:project_enumerations => [:update, :destroy]}, :require => :member |
@@ -83,7 +83,7 class TimelogControllerTest < ActionController::TestCase | |||
|
83 | 83 | :spent_on => '2008-03-14', |
|
84 | 84 | :issue_id => '1', |
|
85 | 85 | :hours => '7.3'} |
|
86 |
assert_redirected_to :action => ' |
|
|
86 | assert_redirected_to :action => 'index', :project_id => 'ecookbook' | |
|
87 | 87 | |
|
88 | 88 | i = Issue.find(1) |
|
89 | 89 | t = TimeEntry.find_by_comments('Some work on TimelogControllerTest') |
@@ -104,7 +104,7 class TimelogControllerTest < ActionController::TestCase | |||
|
104 | 104 | post :edit, :id => 1, |
|
105 | 105 | :time_entry => {:issue_id => '2', |
|
106 | 106 | :hours => '8'} |
|
107 |
assert_redirected_to :action => ' |
|
|
107 | assert_redirected_to :action => 'index', :project_id => 'ecookbook' | |
|
108 | 108 | entry.reload |
|
109 | 109 | |
|
110 | 110 | assert_equal 8, entry.hours |
@@ -115,7 +115,7 class TimelogControllerTest < ActionController::TestCase | |||
|
115 | 115 | def test_destroy |
|
116 | 116 | @request.session[:user_id] = 2 |
|
117 | 117 | post :destroy, :id => 1 |
|
118 |
assert_redirected_to :action => ' |
|
|
118 | assert_redirected_to :action => 'index', :project_id => 'ecookbook' | |
|
119 | 119 | assert_equal I18n.t(:notice_successful_delete), flash[:notice] |
|
120 | 120 | assert_nil TimeEntry.find_by_id(1) |
|
121 | 121 | end |
@@ -129,7 +129,7 class TimelogControllerTest < ActionController::TestCase | |||
|
129 | 129 | |
|
130 | 130 | @request.session[:user_id] = 2 |
|
131 | 131 | post :destroy, :id => 1 |
|
132 |
assert_redirected_to :action => ' |
|
|
132 | assert_redirected_to :action => 'index', :project_id => 'ecookbook' | |
|
133 | 133 | assert_equal I18n.t(:notice_unable_delete_time_entry), flash[:error] |
|
134 | 134 | assert_not_nil TimeEntry.find_by_id(1) |
|
135 | 135 | |
@@ -137,18 +137,18 class TimelogControllerTest < ActionController::TestCase | |||
|
137 | 137 | TimeEntry.before_destroy.reject! {|callback| callback.method == :stop_callback_chain } |
|
138 | 138 | end |
|
139 | 139 | |
|
140 |
def test_ |
|
|
141 |
get : |
|
|
140 | def test_index_all_projects | |
|
141 | get :index | |
|
142 | 142 | assert_response :success |
|
143 |
assert_template ' |
|
|
143 | assert_template 'index' | |
|
144 | 144 | assert_not_nil assigns(:total_hours) |
|
145 | 145 | assert_equal "162.90", "%.2f" % assigns(:total_hours) |
|
146 | 146 | end |
|
147 | 147 | |
|
148 |
def test_ |
|
|
149 |
get : |
|
|
148 | def test_index_at_project_level | |
|
149 | get :index, :project_id => 1 | |
|
150 | 150 | assert_response :success |
|
151 |
assert_template ' |
|
|
151 | assert_template 'index' | |
|
152 | 152 | assert_not_nil assigns(:entries) |
|
153 | 153 | assert_equal 4, assigns(:entries).size |
|
154 | 154 | # project and subproject |
@@ -160,10 +160,10 class TimelogControllerTest < ActionController::TestCase | |||
|
160 | 160 | assert_equal '2007-04-22'.to_date, assigns(:to) |
|
161 | 161 | end |
|
162 | 162 | |
|
163 |
def test_ |
|
|
164 |
get : |
|
|
163 | def test_index_at_project_level_with_date_range | |
|
164 | get :index, :project_id => 1, :from => '2007-03-20', :to => '2007-04-30' | |
|
165 | 165 | assert_response :success |
|
166 |
assert_template ' |
|
|
166 | assert_template 'index' | |
|
167 | 167 | assert_not_nil assigns(:entries) |
|
168 | 168 | assert_equal 3, assigns(:entries).size |
|
169 | 169 | assert_not_nil assigns(:total_hours) |
@@ -172,28 +172,28 class TimelogControllerTest < ActionController::TestCase | |||
|
172 | 172 | assert_equal '2007-04-30'.to_date, assigns(:to) |
|
173 | 173 | end |
|
174 | 174 | |
|
175 |
def test_ |
|
|
176 |
get : |
|
|
175 | def test_index_at_project_level_with_period | |
|
176 | get :index, :project_id => 1, :period => '7_days' | |
|
177 | 177 | assert_response :success |
|
178 |
assert_template ' |
|
|
178 | assert_template 'index' | |
|
179 | 179 | assert_not_nil assigns(:entries) |
|
180 | 180 | assert_not_nil assigns(:total_hours) |
|
181 | 181 | assert_equal Date.today - 7, assigns(:from) |
|
182 | 182 | assert_equal Date.today, assigns(:to) |
|
183 | 183 | end |
|
184 | 184 | |
|
185 |
def test_ |
|
|
186 |
get : |
|
|
185 | def test_index_one_day | |
|
186 | get :index, :project_id => 1, :from => "2007-03-23", :to => "2007-03-23" | |
|
187 | 187 | assert_response :success |
|
188 |
assert_template ' |
|
|
188 | assert_template 'index' | |
|
189 | 189 | assert_not_nil assigns(:total_hours) |
|
190 | 190 | assert_equal "4.25", "%.2f" % assigns(:total_hours) |
|
191 | 191 | end |
|
192 | 192 | |
|
193 |
def test_ |
|
|
194 |
get : |
|
|
193 | def test_index_at_issue_level | |
|
194 | get :index, :issue_id => 1 | |
|
195 | 195 | assert_response :success |
|
196 |
assert_template ' |
|
|
196 | assert_template 'index' | |
|
197 | 197 | assert_not_nil assigns(:entries) |
|
198 | 198 | assert_equal 2, assigns(:entries).size |
|
199 | 199 | assert_not_nil assigns(:total_hours) |
@@ -203,26 +203,26 class TimelogControllerTest < ActionController::TestCase | |||
|
203 | 203 | assert_equal '2007-04-22'.to_date, assigns(:to) |
|
204 | 204 | end |
|
205 | 205 | |
|
206 |
def test_ |
|
|
207 |
get : |
|
|
206 | def test_index_atom_feed | |
|
207 | get :index, :project_id => 1, :format => 'atom' | |
|
208 | 208 | assert_response :success |
|
209 | 209 | assert_equal 'application/atom+xml', @response.content_type |
|
210 | 210 | assert_not_nil assigns(:items) |
|
211 | 211 | assert assigns(:items).first.is_a?(TimeEntry) |
|
212 | 212 | end |
|
213 | 213 | |
|
214 |
def test_ |
|
|
214 | def test_index_all_projects_csv_export | |
|
215 | 215 | Setting.date_format = '%m/%d/%Y' |
|
216 |
get : |
|
|
216 | get :index, :format => 'csv' | |
|
217 | 217 | assert_response :success |
|
218 | 218 | assert_equal 'text/csv', @response.content_type |
|
219 | 219 | assert @response.body.include?("Date,User,Activity,Project,Issue,Tracker,Subject,Hours,Comment\n") |
|
220 | 220 | assert @response.body.include?("\n04/21/2007,redMine Admin,Design,eCookbook,3,Bug,Error 281 when updating a recipe,1.0,\"\"\n") |
|
221 | 221 | end |
|
222 | 222 | |
|
223 |
def test_ |
|
|
223 | def test_index_csv_export | |
|
224 | 224 | Setting.date_format = '%m/%d/%Y' |
|
225 |
get : |
|
|
225 | get :index, :project_id => 1, :format => 'csv' | |
|
226 | 226 | assert_response :success |
|
227 | 227 | assert_equal 'text/csv', @response.content_type |
|
228 | 228 | assert @response.body.include?("Date,User,Activity,Project,Issue,Tracker,Subject,Hours,Comment\n") |
@@ -222,6 +222,17 class RoutingTest < ActionController::IntegrationTest | |||
|
222 | 222 | end |
|
223 | 223 | |
|
224 | 224 | context "timelogs" do |
|
225 | should_route :get, "/time_entries", :controller => 'timelog', :action => 'index' | |
|
226 | should_route :get, "/time_entries.csv", :controller => 'timelog', :action => 'index', :format => 'csv' | |
|
227 | should_route :get, "/time_entries.atom", :controller => 'timelog', :action => 'index', :format => 'atom' | |
|
228 | should_route :get, "/projects/567/time_entries", :controller => 'timelog', :action => 'index', :project_id => '567' | |
|
229 | should_route :get, "/projects/567/time_entries.csv", :controller => 'timelog', :action => 'index', :project_id => '567', :format => 'csv' | |
|
230 | should_route :get, "/projects/567/time_entries.atom", :controller => 'timelog', :action => 'index', :project_id => '567', :format => 'atom' | |
|
231 | should_route :get, "/issues/234/time_entries", :controller => 'timelog', :action => 'index', :issue_id => '234' | |
|
232 | should_route :get, "/issues/234/time_entries.csv", :controller => 'timelog', :action => 'index', :issue_id => '234', :format => 'csv' | |
|
233 | should_route :get, "/issues/234/time_entries.atom", :controller => 'timelog', :action => 'index', :issue_id => '234', :format => 'atom' | |
|
234 | should_route :get, "/projects/ecookbook/issues/123/time_entries", :controller => 'timelog', :action => 'index', :project_id => 'ecookbook', :issue_id => '123' | |
|
235 | ||
|
225 | 236 | should_route :get, "/issues/567/time_entries/new", :controller => 'timelog', :action => 'edit', :issue_id => '567' |
|
226 | 237 | should_route :get, "/projects/ecookbook/time_entries/new", :controller => 'timelog', :action => 'edit', :project_id => 'ecookbook' |
|
227 | 238 | should_route :get, "/projects/ecookbook/issues/567/time_entries/new", :controller => 'timelog', :action => 'edit', :project_id => 'ecookbook', :issue_id => '567' |
@@ -234,18 +245,6 class RoutingTest < ActionController::IntegrationTest | |||
|
234 | 245 | should_route :get, "/time_entries/report", :controller => 'time_entry_reports', :action => 'report' |
|
235 | 246 | should_route :get, "/projects/567/time_entries/report", :controller => 'time_entry_reports', :action => 'report', :project_id => '567' |
|
236 | 247 | should_route :get, "/projects/567/time_entries/report.csv", :controller => 'time_entry_reports', :action => 'report', :project_id => '567', :format => 'csv' |
|
237 | ||
|
238 | should_route :get, "/time_entries", :controller => 'timelog', :action => 'details' | |
|
239 | should_route :get, "/time_entries.csv", :controller => 'timelog', :action => 'details', :format => 'csv' | |
|
240 | should_route :get, "/time_entries.atom", :controller => 'timelog', :action => 'details', :format => 'atom' | |
|
241 | should_route :get, "/projects/567/time_entries", :controller => 'timelog', :action => 'details', :project_id => '567' | |
|
242 | should_route :get, "/projects/567/time_entries.csv", :controller => 'timelog', :action => 'details', :project_id => '567', :format => 'csv' | |
|
243 | should_route :get, "/projects/567/time_entries.atom", :controller => 'timelog', :action => 'details', :project_id => '567', :format => 'atom' | |
|
244 | should_route :get, "/issues/234/time_entries", :controller => 'timelog', :action => 'details', :issue_id => '234' | |
|
245 | should_route :get, "/issues/234/time_entries.csv", :controller => 'timelog', :action => 'details', :issue_id => '234', :format => 'csv' | |
|
246 | should_route :get, "/issues/234/time_entries.atom", :controller => 'timelog', :action => 'details', :issue_id => '234', :format => 'atom' | |
|
247 | should_route :get, "/projects/ecookbook/issues/123/time_entries", :controller => 'timelog', :action => 'details', :project_id => 'ecookbook', :issue_id => '123' | |
|
248 | ||
|
249 | 248 | end |
|
250 | 249 | |
|
251 | 250 | context "users" do |
General Comments 0
You need to be logged in to leave comments.
Login now