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