@@ -0,0 +1,45 | |||||
|
1 | # encoding: utf-8 | |||
|
2 | # | |||
|
3 | # Redmine - project management software | |||
|
4 | # Copyright (C) 2006-2014 Jean-Philippe Lang | |||
|
5 | # | |||
|
6 | # This program is free software; you can redistribute it and/or | |||
|
7 | # modify it under the terms of the GNU General Public License | |||
|
8 | # as published by the Free Software Foundation; either version 2 | |||
|
9 | # of the License, or (at your option) any later version. | |||
|
10 | # | |||
|
11 | # This program is distributed in the hope that it will be useful, | |||
|
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
|
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
|
14 | # GNU General Public License for more details. | |||
|
15 | # | |||
|
16 | # You should have received a copy of the GNU General Public License | |||
|
17 | # along with this program; if not, write to the Free Software | |||
|
18 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
|
19 | ||||
|
20 | require File.expand_path('../../../test_helper', __FILE__) | |||
|
21 | ||||
|
22 | class RoutesHelperTest < ActionView::TestCase | |||
|
23 | include Rails.application.routes.url_helpers | |||
|
24 | ||||
|
25 | def test_time_entries_path | |||
|
26 | assert_equal '/projects/ecookbook/time_entries', _time_entries_path(Project.find(1), nil) | |||
|
27 | assert_equal '/issues/1/time_entries', _time_entries_path(Project.find(1), Issue.find(1)) | |||
|
28 | assert_equal '/issues/1/time_entries', _time_entries_path(nil, Issue.find(1)) | |||
|
29 | assert_equal '/time_entries', _time_entries_path(nil, nil) | |||
|
30 | end | |||
|
31 | ||||
|
32 | def test_report_time_entries_path | |||
|
33 | assert_equal '/projects/ecookbook/time_entries/report', _report_time_entries_path(Project.find(1), nil) | |||
|
34 | assert_equal '/issues/1/time_entries/report', _report_time_entries_path(Project.find(1), Issue.find(1)) | |||
|
35 | assert_equal '/issues/1/time_entries/report', _report_time_entries_path(nil, Issue.find(1)) | |||
|
36 | assert_equal '/time_entries/report', _report_time_entries_path(nil, nil) | |||
|
37 | end | |||
|
38 | ||||
|
39 | def test_new_time_entry_path | |||
|
40 | assert_equal '/projects/ecookbook/time_entries/new', _new_time_entry_path(Project.find(1), nil) | |||
|
41 | assert_equal '/issues/1/time_entries/new', _new_time_entry_path(Project.find(1), Issue.find(1)) | |||
|
42 | assert_equal '/issues/1/time_entries/new', _new_time_entry_path(nil, Issue.find(1)) | |||
|
43 | assert_equal '/time_entries/new', _new_time_entry_path(nil, nil) | |||
|
44 | end | |||
|
45 | end |
@@ -36,4 +36,34 module RoutesHelper | |||||
36 | def _project_gantt_path(project, *args) |
|
36 | def _project_gantt_path(project, *args) | |
37 | project ? project_gantt_path(project, *args) : issues_gantt_path(*args) |
|
37 | project ? project_gantt_path(project, *args) : issues_gantt_path(*args) | |
38 | end |
|
38 | end | |
|
39 | ||||
|
40 | def _time_entries_path(project, issue, *args) | |||
|
41 | if issue | |||
|
42 | issue_time_entries_path(issue, *args) | |||
|
43 | elsif project | |||
|
44 | project_time_entries_path(project, *args) | |||
|
45 | else | |||
|
46 | time_entries_path(*args) | |||
|
47 | end | |||
|
48 | end | |||
|
49 | ||||
|
50 | def _report_time_entries_path(project, issue, *args) | |||
|
51 | if issue | |||
|
52 | report_issue_time_entries_path(issue, *args) | |||
|
53 | elsif project | |||
|
54 | report_project_time_entries_path(project, *args) | |||
|
55 | else | |||
|
56 | report_time_entries_path(*args) | |||
|
57 | end | |||
|
58 | end | |||
|
59 | ||||
|
60 | def _new_time_entry_path(project, issue, *args) | |||
|
61 | if issue | |||
|
62 | new_issue_time_entry_path(issue, *args) | |||
|
63 | elsif project | |||
|
64 | new_project_time_entry_path(project, *args) | |||
|
65 | else | |||
|
66 | new_time_entry_path(*args) | |||
|
67 | end | |||
|
68 | end | |||
39 | end |
|
69 | end |
@@ -28,9 +28,9 | |||||
28 | <div class="tabs hide-when-print"> |
|
28 | <div class="tabs hide-when-print"> | |
29 | <% query_params = params.slice(:f, :op, :v, :sort) %> |
|
29 | <% query_params = params.slice(:f, :op, :v, :sort) %> | |
30 | <ul> |
|
30 | <ul> | |
31 | <li><%= link_to(l(:label_details), query_params.merge({:controller => 'timelog', :action => 'index', :project_id => @project, :issue_id => @issue }), |
|
31 | <li><%= link_to(l(:label_details), _time_entries_path(@project, @issue, query_params), | |
32 | :class => (action_name == 'index' ? 'selected' : nil)) %></li> |
|
32 | :class => (action_name == 'index' ? 'selected' : nil)) %></li> | |
33 | <li><%= link_to(l(:label_report), query_params.merge({:controller => 'timelog', :action => 'report', :project_id => @project, :issue_id => @issue}), |
|
33 | <li><%= link_to(l(:label_report), _report_time_entries_path(@project, @issue, query_params), | |
34 | :class => (action_name == 'report' ? 'selected' : nil)) %></li> |
|
34 | :class => (action_name == 'report' ? 'selected' : nil)) %></li> | |
35 | </ul> |
|
35 | </ul> | |
36 | </div> |
|
36 | </div> |
@@ -1,6 +1,6 | |||||
1 | <div class="contextual"> |
|
1 | <div class="contextual"> | |
2 | <%= link_to l(:button_log_time), |
|
2 | <%= link_to l(:button_log_time), | |
3 | {:controller => 'timelog', :action => 'new', :project_id => @project, :issue_id => @issue}, |
|
3 | _new_time_entry_path(@project, @issue), | |
4 | :class => 'icon icon-time-add' if User.current.allowed_to?(:log_time, @project, :global => true) %> |
|
4 | :class => 'icon icon-time-add' if User.current.allowed_to?(:log_time, @project, :global => true) %> | |
5 | </div> |
|
5 | </div> | |
6 |
|
6 | |||
@@ -8,7 +8,7 | |||||
8 |
|
8 | |||
9 | <h2><%= l(:label_spent_time) %></h2> |
|
9 | <h2><%= l(:label_spent_time) %></h2> | |
10 |
|
10 | |||
11 |
<%= form_tag( |
|
11 | <%= form_tag(params.slice(:project_id, :issue_id), :method => :get, :id => 'query_form') do %> | |
12 | <%= render :partial => 'date_range' %> |
|
12 | <%= render :partial => 'date_range' %> | |
13 | <% end %> |
|
13 | <% end %> | |
14 |
|
14 |
@@ -1,14 +1,14 | |||||
1 | <div class="contextual"> |
|
1 | <div class="contextual"> | |
2 | <%= link_to_if_authorized l(:button_log_time), {:controller => 'timelog', :action => 'new', :project_id => @project, :issue_id => @issue}, :class => 'icon icon-time-add' %> |
|
2 | <%= link_to l(:button_log_time), | |
|
3 | _new_time_entry_path(@project, @issue), | |||
|
4 | :class => 'icon icon-time-add' if User.current.allowed_to?(:log_time, @project, :global => true) %> | |||
3 | </div> |
|
5 | </div> | |
4 |
|
6 | |||
5 | <%= render_timelog_breadcrumb %> |
|
7 | <%= render_timelog_breadcrumb %> | |
6 |
|
8 | |||
7 | <h2><%= l(:label_spent_time) %></h2> |
|
9 | <h2><%= l(:label_spent_time) %></h2> | |
8 |
|
10 | |||
9 | <%= form_tag({:controller => 'timelog', :action => 'report', |
|
11 | <%= form_tag(params.slice(:project_id, :issue_id), :method => :get, :id => 'query_form') do %> | |
10 | :project_id => @project, :issue_id => @issue}, |
|
|||
11 | :method => :get, :id => 'query_form') do %> |
|
|||
12 | <% @report.criteria.each do |criterion| %> |
|
12 | <% @report.criteria.each do |criterion| %> | |
13 | <%= hidden_field_tag 'criteria[]', criterion, :id => nil %> |
|
13 | <%= hidden_field_tag 'criteria[]', criterion, :id => nil %> | |
14 | <% end %> |
|
14 | <% end %> |
@@ -111,13 +111,7 RedmineApp::Application.routes.draw do | |||||
111 | resource :enumerations, :controller => 'project_enumerations', :only => [:update, :destroy] |
|
111 | resource :enumerations, :controller => 'project_enumerations', :only => [:update, :destroy] | |
112 |
|
112 | |||
113 | get 'issues/:copy_from/copy', :to => 'issues#new', :as => 'copy_issue' |
|
113 | get 'issues/:copy_from/copy', :to => 'issues#new', :as => 'copy_issue' | |
114 |
resources :issues, :only => [:index, :new, :create] |
|
114 | resources :issues, :only => [:index, :new, :create] | |
115 | resources :time_entries, :controller => 'timelog' do |
|
|||
116 | collection do |
|
|||
117 | get 'report' |
|
|||
118 | end |
|
|||
119 | end |
|
|||
120 | end |
|
|||
121 | # issue form update |
|
115 | # issue form update | |
122 | match 'issues/update_form', :controller => 'issues', :action => 'update_form', :via => [:put, :post], :as => 'issue_form' |
|
116 | match 'issues/update_form', :controller => 'issues', :action => 'update_form', :via => [:put, :post], :as => 'issue_form' | |
123 |
|
117 |
@@ -130,13 +130,13 class TimeEntryReportsControllerTest < ActionController::TestCase | |||||
130 | end |
|
130 | end | |
131 |
|
131 | |||
132 | def test_report_at_issue_level |
|
132 | def test_report_at_issue_level | |
133 |
get :report |
|
133 | get :report, :issue_id => 1, :columns => 'month', :from => "2007-01-01", :to => "2007-12-31", :criteria => ["user", "activity"] | |
134 | assert_response :success |
|
134 | assert_response :success | |
135 | assert_template 'report' |
|
135 | assert_template 'report' | |
136 | assert_not_nil assigns(:report) |
|
136 | assert_not_nil assigns(:report) | |
137 | assert_equal "154.25", "%.2f" % assigns(:report).total_hours |
|
137 | assert_equal "154.25", "%.2f" % assigns(:report).total_hours | |
138 | assert_tag :form, |
|
138 | assert_tag :form, | |
139 |
:attributes => {:action => " |
|
139 | :attributes => {:action => "/issues/1/time_entries/report", :id => 'query_form'} | |
140 | end |
|
140 | end | |
141 |
|
141 | |||
142 | def test_report_by_week_should_use_commercial_year |
|
142 | def test_report_by_week_should_use_commercial_year |
@@ -581,7 +581,7 class TimelogControllerTest < ActionController::TestCase | |||||
581 | assert_nil assigns(:from) |
|
581 | assert_nil assigns(:from) | |
582 | assert_nil assigns(:to) |
|
582 | assert_nil assigns(:to) | |
583 | assert_tag :form, |
|
583 | assert_tag :form, | |
584 |
:attributes => {:action => " |
|
584 | :attributes => {:action => "/issues/1/time_entries", :id => 'query_form'} | |
585 | end |
|
585 | end | |
586 |
|
586 | |||
587 | def test_index_should_sort_by_spent_on_and_created_on |
|
587 | def test_index_should_sort_by_spent_on_and_created_on | |
@@ -693,11 +693,11 class TimelogControllerTest < ActionController::TestCase | |||||
693 | end |
|
693 | end | |
694 |
|
694 | |||
695 | def test_index_at_issue_level_should_include_csv_export_dialog |
|
695 | def test_index_at_issue_level_should_include_csv_export_dialog | |
696 |
get :index |
|
696 | get :index, :issue_id => 3 | |
697 | assert_response :success |
|
697 | assert_response :success | |
698 |
|
698 | |||
699 | assert_select '#csv-export-options' do |
|
699 | assert_select '#csv-export-options' do | |
700 |
assert_select 'form[action=?][method=get]', '/ |
|
700 | assert_select 'form[action=?][method=get]', '/issues/3/time_entries.csv' | |
701 | end |
|
701 | end | |
702 | end |
|
702 | end | |
703 |
|
703 |
@@ -134,57 +134,6 class RoutingTimelogsTest < ActionController::IntegrationTest | |||||
134 | ) |
|
134 | ) | |
135 | end |
|
135 | end | |
136 |
|
136 | |||
137 | def test_timelogs_scoped_under_project_and_issues |
|
|||
138 | assert_routing( |
|
|||
139 | { :method => 'get', |
|
|||
140 | :path => "/projects/ecookbook/issues/234/time_entries" }, |
|
|||
141 | { :controller => 'timelog', :action => 'index', |
|
|||
142 | :issue_id => '234', :project_id => 'ecookbook' } |
|
|||
143 | ) |
|
|||
144 | assert_routing( |
|
|||
145 | { :method => 'get', |
|
|||
146 | :path => "/projects/ecookbook/issues/234/time_entries.csv" }, |
|
|||
147 | { :controller => 'timelog', :action => 'index', |
|
|||
148 | :issue_id => '234', :project_id => 'ecookbook', :format => 'csv' } |
|
|||
149 | ) |
|
|||
150 | assert_routing( |
|
|||
151 | { :method => 'get', |
|
|||
152 | :path => "/projects/ecookbook/issues/234/time_entries.atom" }, |
|
|||
153 | { :controller => 'timelog', :action => 'index', |
|
|||
154 | :issue_id => '234', :project_id => 'ecookbook', :format => 'atom' } |
|
|||
155 | ) |
|
|||
156 | assert_routing( |
|
|||
157 | { :method => 'get', |
|
|||
158 | :path => "/projects/ecookbook/issues/234/time_entries/new" }, |
|
|||
159 | { :controller => 'timelog', :action => 'new', |
|
|||
160 | :issue_id => '234', :project_id => 'ecookbook' } |
|
|||
161 | ) |
|
|||
162 | assert_routing( |
|
|||
163 | { :method => 'get', |
|
|||
164 | :path => "/projects/ecookbook/issues/234/time_entries/22/edit" }, |
|
|||
165 | { :controller => 'timelog', :action => 'edit', :id => '22', |
|
|||
166 | :issue_id => '234', :project_id => 'ecookbook' } |
|
|||
167 | ) |
|
|||
168 | assert_routing( |
|
|||
169 | { :method => 'post', |
|
|||
170 | :path => "/projects/ecookbook/issues/234/time_entries" }, |
|
|||
171 | { :controller => 'timelog', :action => 'create', |
|
|||
172 | :issue_id => '234', :project_id => 'ecookbook' } |
|
|||
173 | ) |
|
|||
174 | assert_routing( |
|
|||
175 | { :method => 'put', |
|
|||
176 | :path => "/projects/ecookbook/issues/234/time_entries/22" }, |
|
|||
177 | { :controller => 'timelog', :action => 'update', :id => '22', |
|
|||
178 | :issue_id => '234', :project_id => 'ecookbook' } |
|
|||
179 | ) |
|
|||
180 | assert_routing( |
|
|||
181 | { :method => 'delete', |
|
|||
182 | :path => "/projects/ecookbook/issues/234/time_entries/55" }, |
|
|||
183 | { :controller => 'timelog', :action => 'destroy', :id => '55', |
|
|||
184 | :issue_id => '234', :project_id => 'ecookbook' } |
|
|||
185 | ) |
|
|||
186 | end |
|
|||
187 |
|
||||
188 | def test_timelogs_report |
|
137 | def test_timelogs_report | |
189 | assert_routing( |
|
138 | assert_routing( | |
190 | { :method => 'get', |
|
139 | { :method => 'get', |
General Comments 0
You need to be logged in to leave comments.
Login now