diff --git a/app/controllers/timelog_controller.rb b/app/controllers/timelog_controller.rb index c03ea6891..bf571aa59 100644 --- a/app/controllers/timelog_controller.rb +++ b/app/controllers/timelog_controller.rb @@ -18,9 +18,9 @@ class TimelogController < ApplicationController menu_item :issues before_filter :find_project, :authorize, :only => [:edit, :destroy] - before_filter :find_optional_project, :only => [:details] + before_filter :find_optional_project, :only => [:index] - verify :method => :post, :only => :destroy, :redirect_to => { :action => :details } + verify :method => :post, :only => :destroy, :redirect_to => { :action => :index } helper :sort include SortHelper @@ -29,7 +29,7 @@ class TimelogController < ApplicationController helper :custom_fields include CustomFieldsHelper - def details + def index sort_init 'spent_on', 'desc' sort_update 'spent_on' => 'spent_on', 'user' => 'user_id', @@ -95,7 +95,7 @@ class TimelogController < ApplicationController if request.post? and @time_entry.save flash[:notice] = l(:notice_successful_update) - redirect_back_or_default :action => 'details', :project_id => @time_entry.project + redirect_back_or_default :action => 'index', :project_id => @time_entry.project return end end @@ -110,7 +110,7 @@ class TimelogController < ApplicationController end redirect_to :back rescue ::ActionController::RedirectBackError - redirect_to :action => 'details', :project_id => @time_entry.project + redirect_to :action => 'index', :project_id => @time_entry.project end private diff --git a/app/views/issues/show.rhtml b/app/views/issues/show.rhtml index b3493cf7c..d1d93da9a 100644 --- a/app/views/issues/show.rhtml +++ b/app/views/issues/show.rhtml @@ -32,7 +32,7 @@ <%=l(:field_category)%>:<%=h @issue.category ? @issue.category.name : "-" %> <% if User.current.allowed_to?(:view_time_entries, @project) %> <%=l(:label_spent_time)%>: - <%= @issue.spent_hours > 0 ? (link_to l_hours(@issue.spent_hours), {:controller => 'timelog', :action => 'details', :project_id => @project, :issue_id => @issue}) : "-" %> + <%= @issue.spent_hours > 0 ? (link_to l_hours(@issue.spent_hours), {:controller => 'timelog', :action => 'index', :project_id => @project, :issue_id => @issue}) : "-" %> <% end %> diff --git a/app/views/projects/show.rhtml b/app/views/projects/show.rhtml index 80e45adf0..9651651ac 100644 --- a/app/views/projects/show.rhtml +++ b/app/views/projects/show.rhtml @@ -67,7 +67,7 @@ <% if @total_hours && User.current.allowed_to?(:view_time_entries, @project) %>

<%= l(:label_spent_time) %>

<%= l_hours(@total_hours) %>

-

<%= link_to(l(:label_details), {:controller => 'timelog', :action => 'details', :project_id => @project}) %> | +

<%= link_to(l(:label_details), {:controller => 'timelog', :action => 'index', :project_id => @project}) %> | <%= link_to(l(:label_report), {:controller => 'time_entry_reports', :action => 'report', :project_id => @project}) %>

<% end %> <%= call_hook(:view_projects_show_sidebar_bottom, :project => @project) %> diff --git a/app/views/timelog/_date_range.rhtml b/app/views/timelog/_date_range.rhtml index 041e5587f..727de25ed 100644 --- a/app/views/timelog/_date_range.rhtml +++ b/app/views/timelog/_date_range.rhtml @@ -28,8 +28,8 @@
<% url_params = @free_period ? { :from => @from, :to => @to } : { :period => params[:period] } %> diff --git a/app/views/timelog/details.rhtml b/app/views/timelog/index.html.erb similarity index 100% rename from app/views/timelog/details.rhtml rename to app/views/timelog/index.html.erb diff --git a/config/routes.rb b/config/routes.rb index 32ab0ca37..87aefa806 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -19,9 +19,9 @@ ActionController::Routing::Routes.draw do |map| map.connect 'projects/:project_id/issues/:issue_id/time_entries/new', :action => 'edit', :controller => 'timelog' map.with_options :controller => 'timelog' do |timelog| - timelog.connect 'projects/:project_id/time_entries', :action => 'details' + timelog.connect 'projects/:project_id/time_entries', :action => 'index' - timelog.with_options :action => 'details', :conditions => {:method => :get} do |time_details| + timelog.with_options :action => 'index', :conditions => {:method => :get} do |time_details| time_details.connect 'time_entries' time_details.connect 'time_entries.:format' time_details.connect 'issues/:issue_id/time_entries' diff --git a/lib/redmine.rb b/lib/redmine.rb index 9bff8e19a..42f3c47f2 100644 --- a/lib/redmine.rb +++ b/lib/redmine.rb @@ -85,7 +85,7 @@ Redmine::AccessControl.map do |map| map.project_module :time_tracking do |map| map.permission :log_time, {:timelog => :edit}, :require => :loggedin - map.permission :view_time_entries, :timelog => [:details], :time_entry_reports => [:report] + map.permission :view_time_entries, :timelog => [:index], :time_entry_reports => [:report] map.permission :edit_time_entries, {:timelog => [:edit, :destroy]}, :require => :member map.permission :edit_own_time_entries, {:timelog => [:edit, :destroy]}, :require => :loggedin map.permission :manage_project_activities, {:project_enumerations => [:update, :destroy]}, :require => :member diff --git a/test/functional/timelog_controller_test.rb b/test/functional/timelog_controller_test.rb index 00178dcb9..22d14e32e 100644 --- a/test/functional/timelog_controller_test.rb +++ b/test/functional/timelog_controller_test.rb @@ -83,7 +83,7 @@ class TimelogControllerTest < ActionController::TestCase :spent_on => '2008-03-14', :issue_id => '1', :hours => '7.3'} - assert_redirected_to :action => 'details', :project_id => 'ecookbook' + assert_redirected_to :action => 'index', :project_id => 'ecookbook' i = Issue.find(1) t = TimeEntry.find_by_comments('Some work on TimelogControllerTest') @@ -104,7 +104,7 @@ class TimelogControllerTest < ActionController::TestCase post :edit, :id => 1, :time_entry => {:issue_id => '2', :hours => '8'} - assert_redirected_to :action => 'details', :project_id => 'ecookbook' + assert_redirected_to :action => 'index', :project_id => 'ecookbook' entry.reload assert_equal 8, entry.hours @@ -115,7 +115,7 @@ class TimelogControllerTest < ActionController::TestCase def test_destroy @request.session[:user_id] = 2 post :destroy, :id => 1 - assert_redirected_to :action => 'details', :project_id => 'ecookbook' + assert_redirected_to :action => 'index', :project_id => 'ecookbook' assert_equal I18n.t(:notice_successful_delete), flash[:notice] assert_nil TimeEntry.find_by_id(1) end @@ -129,7 +129,7 @@ class TimelogControllerTest < ActionController::TestCase @request.session[:user_id] = 2 post :destroy, :id => 1 - assert_redirected_to :action => 'details', :project_id => 'ecookbook' + assert_redirected_to :action => 'index', :project_id => 'ecookbook' assert_equal I18n.t(:notice_unable_delete_time_entry), flash[:error] assert_not_nil TimeEntry.find_by_id(1) @@ -137,18 +137,18 @@ class TimelogControllerTest < ActionController::TestCase TimeEntry.before_destroy.reject! {|callback| callback.method == :stop_callback_chain } end - def test_details_all_projects - get :details + def test_index_all_projects + get :index assert_response :success - assert_template 'details' + assert_template 'index' assert_not_nil assigns(:total_hours) assert_equal "162.90", "%.2f" % assigns(:total_hours) end - def test_details_at_project_level - get :details, :project_id => 1 + def test_index_at_project_level + get :index, :project_id => 1 assert_response :success - assert_template 'details' + assert_template 'index' assert_not_nil assigns(:entries) assert_equal 4, assigns(:entries).size # project and subproject @@ -160,10 +160,10 @@ class TimelogControllerTest < ActionController::TestCase assert_equal '2007-04-22'.to_date, assigns(:to) end - def test_details_at_project_level_with_date_range - get :details, :project_id => 1, :from => '2007-03-20', :to => '2007-04-30' + def test_index_at_project_level_with_date_range + get :index, :project_id => 1, :from => '2007-03-20', :to => '2007-04-30' assert_response :success - assert_template 'details' + assert_template 'index' assert_not_nil assigns(:entries) assert_equal 3, assigns(:entries).size assert_not_nil assigns(:total_hours) @@ -172,28 +172,28 @@ class TimelogControllerTest < ActionController::TestCase assert_equal '2007-04-30'.to_date, assigns(:to) end - def test_details_at_project_level_with_period - get :details, :project_id => 1, :period => '7_days' + def test_index_at_project_level_with_period + get :index, :project_id => 1, :period => '7_days' assert_response :success - assert_template 'details' + assert_template 'index' assert_not_nil assigns(:entries) assert_not_nil assigns(:total_hours) assert_equal Date.today - 7, assigns(:from) assert_equal Date.today, assigns(:to) end - def test_details_one_day - get :details, :project_id => 1, :from => "2007-03-23", :to => "2007-03-23" + def test_index_one_day + get :index, :project_id => 1, :from => "2007-03-23", :to => "2007-03-23" assert_response :success - assert_template 'details' + assert_template 'index' assert_not_nil assigns(:total_hours) assert_equal "4.25", "%.2f" % assigns(:total_hours) end - def test_details_at_issue_level - get :details, :issue_id => 1 + def test_index_at_issue_level + get :index, :issue_id => 1 assert_response :success - assert_template 'details' + assert_template 'index' assert_not_nil assigns(:entries) assert_equal 2, assigns(:entries).size assert_not_nil assigns(:total_hours) @@ -203,26 +203,26 @@ class TimelogControllerTest < ActionController::TestCase assert_equal '2007-04-22'.to_date, assigns(:to) end - def test_details_atom_feed - get :details, :project_id => 1, :format => 'atom' + def test_index_atom_feed + get :index, :project_id => 1, :format => 'atom' assert_response :success assert_equal 'application/atom+xml', @response.content_type assert_not_nil assigns(:items) assert assigns(:items).first.is_a?(TimeEntry) end - def test_details_all_projects_csv_export + def test_index_all_projects_csv_export Setting.date_format = '%m/%d/%Y' - get :details, :format => 'csv' + get :index, :format => 'csv' assert_response :success assert_equal 'text/csv', @response.content_type assert @response.body.include?("Date,User,Activity,Project,Issue,Tracker,Subject,Hours,Comment\n") assert @response.body.include?("\n04/21/2007,redMine Admin,Design,eCookbook,3,Bug,Error 281 when updating a recipe,1.0,\"\"\n") end - def test_details_csv_export + def test_index_csv_export Setting.date_format = '%m/%d/%Y' - get :details, :project_id => 1, :format => 'csv' + get :index, :project_id => 1, :format => 'csv' assert_response :success assert_equal 'text/csv', @response.content_type assert @response.body.include?("Date,User,Activity,Project,Issue,Tracker,Subject,Hours,Comment\n") diff --git a/test/integration/routing_test.rb b/test/integration/routing_test.rb index d1a2aa390..d8d036853 100644 --- a/test/integration/routing_test.rb +++ b/test/integration/routing_test.rb @@ -222,6 +222,17 @@ class RoutingTest < ActionController::IntegrationTest end context "timelogs" do + should_route :get, "/time_entries", :controller => 'timelog', :action => 'index' + should_route :get, "/time_entries.csv", :controller => 'timelog', :action => 'index', :format => 'csv' + should_route :get, "/time_entries.atom", :controller => 'timelog', :action => 'index', :format => 'atom' + should_route :get, "/projects/567/time_entries", :controller => 'timelog', :action => 'index', :project_id => '567' + should_route :get, "/projects/567/time_entries.csv", :controller => 'timelog', :action => 'index', :project_id => '567', :format => 'csv' + should_route :get, "/projects/567/time_entries.atom", :controller => 'timelog', :action => 'index', :project_id => '567', :format => 'atom' + should_route :get, "/issues/234/time_entries", :controller => 'timelog', :action => 'index', :issue_id => '234' + should_route :get, "/issues/234/time_entries.csv", :controller => 'timelog', :action => 'index', :issue_id => '234', :format => 'csv' + should_route :get, "/issues/234/time_entries.atom", :controller => 'timelog', :action => 'index', :issue_id => '234', :format => 'atom' + should_route :get, "/projects/ecookbook/issues/123/time_entries", :controller => 'timelog', :action => 'index', :project_id => 'ecookbook', :issue_id => '123' + should_route :get, "/issues/567/time_entries/new", :controller => 'timelog', :action => 'edit', :issue_id => '567' should_route :get, "/projects/ecookbook/time_entries/new", :controller => 'timelog', :action => 'edit', :project_id => 'ecookbook' 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 should_route :get, "/time_entries/report", :controller => 'time_entry_reports', :action => 'report' should_route :get, "/projects/567/time_entries/report", :controller => 'time_entry_reports', :action => 'report', :project_id => '567' should_route :get, "/projects/567/time_entries/report.csv", :controller => 'time_entry_reports', :action => 'report', :project_id => '567', :format => 'csv' - - should_route :get, "/time_entries", :controller => 'timelog', :action => 'details' - should_route :get, "/time_entries.csv", :controller => 'timelog', :action => 'details', :format => 'csv' - should_route :get, "/time_entries.atom", :controller => 'timelog', :action => 'details', :format => 'atom' - should_route :get, "/projects/567/time_entries", :controller => 'timelog', :action => 'details', :project_id => '567' - should_route :get, "/projects/567/time_entries.csv", :controller => 'timelog', :action => 'details', :project_id => '567', :format => 'csv' - should_route :get, "/projects/567/time_entries.atom", :controller => 'timelog', :action => 'details', :project_id => '567', :format => 'atom' - should_route :get, "/issues/234/time_entries", :controller => 'timelog', :action => 'details', :issue_id => '234' - should_route :get, "/issues/234/time_entries.csv", :controller => 'timelog', :action => 'details', :issue_id => '234', :format => 'csv' - should_route :get, "/issues/234/time_entries.atom", :controller => 'timelog', :action => 'details', :issue_id => '234', :format => 'atom' - should_route :get, "/projects/ecookbook/issues/123/time_entries", :controller => 'timelog', :action => 'details', :project_id => 'ecookbook', :issue_id => '123' - end context "users" do