def _project_gantt_path(project, *args)
project ? project_gantt_path(project, *args) : issues_gantt_path(*args)
end
+
+ def _time_entries_path(project, issue, *args)
+ if issue
+ issue_time_entries_path(issue, *args)
+ elsif project
+ project_time_entries_path(project, *args)
+ else
+ time_entries_path(*args)
+ end
+ end
+
+ def _report_time_entries_path(project, issue, *args)
+ if issue
+ report_issue_time_entries_path(issue, *args)
+ elsif project
+ report_project_time_entries_path(project, *args)
+ else
+ report_time_entries_path(*args)
+ end
+ end
+
+ def _new_time_entry_path(project, issue, *args)
+ if issue
+ new_issue_time_entry_path(issue, *args)
+ elsif project
+ new_project_time_entry_path(project, *args)
+ else
+ new_time_entry_path(*args)
+ end
+ end
end
<div class="tabs hide-when-print">
<% query_params = params.slice(:f, :op, :v, :sort) %>
<ul>
- <li><%= link_to(l(:label_details), query_params.merge({:controller => 'timelog', :action => 'index', :project_id => @project, :issue_id => @issue }),
+ <li><%= link_to(l(:label_details), _time_entries_path(@project, @issue, query_params),
:class => (action_name == 'index' ? 'selected' : nil)) %></li>
- <li><%= link_to(l(:label_report), query_params.merge({:controller => 'timelog', :action => 'report', :project_id => @project, :issue_id => @issue}),
+ <li><%= link_to(l(:label_report), _report_time_entries_path(@project, @issue, query_params),
:class => (action_name == 'report' ? 'selected' : nil)) %></li>
</ul>
</div>
<div class="contextual">
<%= link_to l(:button_log_time),
- {:controller => 'timelog', :action => 'new', :project_id => @project, :issue_id => @issue},
+ _new_time_entry_path(@project, @issue),
:class => 'icon icon-time-add' if User.current.allowed_to?(:log_time, @project, :global => true) %>
</div>
<h2><%= l(:label_spent_time) %></h2>
-<%= form_tag({:controller => 'timelog', :action => 'index', :project_id => @project, :issue_id => @issue}, :method => :get, :id => 'query_form') do %>
+<%= form_tag(params.slice(:project_id, :issue_id), :method => :get, :id => 'query_form') do %>
<%= render :partial => 'date_range' %>
<% end %>
<div class="contextual">
-<%= link_to_if_authorized l(:button_log_time), {:controller => 'timelog', :action => 'new', :project_id => @project, :issue_id => @issue}, :class => 'icon icon-time-add' %>
+<%= link_to l(:button_log_time),
+ _new_time_entry_path(@project, @issue),
+ :class => 'icon icon-time-add' if User.current.allowed_to?(:log_time, @project, :global => true) %>
</div>
<%= render_timelog_breadcrumb %>
<h2><%= l(:label_spent_time) %></h2>
-<%= form_tag({:controller => 'timelog', :action => 'report',
- :project_id => @project, :issue_id => @issue},
- :method => :get, :id => 'query_form') do %>
+<%= form_tag(params.slice(:project_id, :issue_id), :method => :get, :id => 'query_form') do %>
<% @report.criteria.each do |criterion| %>
<%= hidden_field_tag 'criteria[]', criterion, :id => nil %>
<% end %>
resource :enumerations, :controller => 'project_enumerations', :only => [:update, :destroy]
get 'issues/:copy_from/copy', :to => 'issues#new', :as => 'copy_issue'
- resources :issues, :only => [:index, :new, :create] do
- resources :time_entries, :controller => 'timelog' do
- collection do
- get 'report'
- end
- end
- end
+ resources :issues, :only => [:index, :new, :create]
# issue form update
match 'issues/update_form', :controller => 'issues', :action => 'update_form', :via => [:put, :post], :as => 'issue_form'
end
def test_report_at_issue_level
- get :report, :project_id => 1, :issue_id => 1, :columns => 'month', :from => "2007-01-01", :to => "2007-12-31", :criteria => ["user", "activity"]
+ get :report, :issue_id => 1, :columns => 'month', :from => "2007-01-01", :to => "2007-12-31", :criteria => ["user", "activity"]
assert_response :success
assert_template 'report'
assert_not_nil assigns(:report)
assert_equal "154.25", "%.2f" % assigns(:report).total_hours
assert_tag :form,
- :attributes => {:action => "/projects/ecookbook/issues/1/time_entries/report", :id => 'query_form'}
+ :attributes => {:action => "/issues/1/time_entries/report", :id => 'query_form'}
end
def test_report_by_week_should_use_commercial_year
assert_nil assigns(:from)
assert_nil assigns(:to)
assert_tag :form,
- :attributes => {:action => "/projects/ecookbook/issues/1/time_entries", :id => 'query_form'}
+ :attributes => {:action => "/issues/1/time_entries", :id => 'query_form'}
end
def test_index_should_sort_by_spent_on_and_created_on
end
def test_index_at_issue_level_should_include_csv_export_dialog
- get :index, :project_id => 'ecookbook', :issue_id => 3
+ get :index, :issue_id => 3
assert_response :success
assert_select '#csv-export-options' do
- assert_select 'form[action=?][method=get]', '/projects/ecookbook/issues/3/time_entries.csv'
+ assert_select 'form[action=?][method=get]', '/issues/3/time_entries.csv'
end
end
)
end
- def test_timelogs_scoped_under_project_and_issues
- assert_routing(
- { :method => 'get',
- :path => "/projects/ecookbook/issues/234/time_entries" },
- { :controller => 'timelog', :action => 'index',
- :issue_id => '234', :project_id => 'ecookbook' }
- )
- assert_routing(
- { :method => 'get',
- :path => "/projects/ecookbook/issues/234/time_entries.csv" },
- { :controller => 'timelog', :action => 'index',
- :issue_id => '234', :project_id => 'ecookbook', :format => 'csv' }
- )
- assert_routing(
- { :method => 'get',
- :path => "/projects/ecookbook/issues/234/time_entries.atom" },
- { :controller => 'timelog', :action => 'index',
- :issue_id => '234', :project_id => 'ecookbook', :format => 'atom' }
- )
- assert_routing(
- { :method => 'get',
- :path => "/projects/ecookbook/issues/234/time_entries/new" },
- { :controller => 'timelog', :action => 'new',
- :issue_id => '234', :project_id => 'ecookbook' }
- )
- assert_routing(
- { :method => 'get',
- :path => "/projects/ecookbook/issues/234/time_entries/22/edit" },
- { :controller => 'timelog', :action => 'edit', :id => '22',
- :issue_id => '234', :project_id => 'ecookbook' }
- )
- assert_routing(
- { :method => 'post',
- :path => "/projects/ecookbook/issues/234/time_entries" },
- { :controller => 'timelog', :action => 'create',
- :issue_id => '234', :project_id => 'ecookbook' }
- )
- assert_routing(
- { :method => 'put',
- :path => "/projects/ecookbook/issues/234/time_entries/22" },
- { :controller => 'timelog', :action => 'update', :id => '22',
- :issue_id => '234', :project_id => 'ecookbook' }
- )
- assert_routing(
- { :method => 'delete',
- :path => "/projects/ecookbook/issues/234/time_entries/55" },
- { :controller => 'timelog', :action => 'destroy', :id => '55',
- :issue_id => '234', :project_id => 'ecookbook' }
- )
- end
-
def test_timelogs_report
assert_routing(
{ :method => 'get',
--- /dev/null
+# encoding: utf-8
+#
+# Redmine - project management software
+# Copyright (C) 2006-2014 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+require File.expand_path('../../../test_helper', __FILE__)
+
+class RoutesHelperTest < ActionView::TestCase
+ include Rails.application.routes.url_helpers
+
+ def test_time_entries_path
+ assert_equal '/projects/ecookbook/time_entries', _time_entries_path(Project.find(1), nil)
+ assert_equal '/issues/1/time_entries', _time_entries_path(Project.find(1), Issue.find(1))
+ assert_equal '/issues/1/time_entries', _time_entries_path(nil, Issue.find(1))
+ assert_equal '/time_entries', _time_entries_path(nil, nil)
+ end
+
+ def test_report_time_entries_path
+ assert_equal '/projects/ecookbook/time_entries/report', _report_time_entries_path(Project.find(1), nil)
+ assert_equal '/issues/1/time_entries/report', _report_time_entries_path(Project.find(1), Issue.find(1))
+ assert_equal '/issues/1/time_entries/report', _report_time_entries_path(nil, Issue.find(1))
+ assert_equal '/time_entries/report', _report_time_entries_path(nil, nil)
+ end
+
+ def test_new_time_entry_path
+ assert_equal '/projects/ecookbook/time_entries/new', _new_time_entry_path(Project.find(1), nil)
+ assert_equal '/issues/1/time_entries/new', _new_time_entry_path(Project.find(1), Issue.find(1))
+ assert_equal '/issues/1/time_entries/new', _new_time_entry_path(nil, Issue.find(1))
+ assert_equal '/time_entries/new', _new_time_entry_path(nil, nil)
+ end
+end