@@ -17,7 +17,7 | |||
|
17 | 17 | |
|
18 | 18 | class TimelogController < ApplicationController |
|
19 | 19 | menu_item :issues |
|
20 | before_filter :find_project, :authorize, :only => [:edit, :destroy] | |
|
20 | before_filter :find_project, :authorize, :only => [:new, :edit, :destroy] | |
|
21 | 21 | before_filter :find_optional_project, :only => [:index] |
|
22 | 22 | |
|
23 | 23 | verify :method => :post, :only => :destroy, :redirect_to => { :action => :index } |
@@ -85,6 +85,14 class TimelogController < ApplicationController | |||
|
85 | 85 | end |
|
86 | 86 | end |
|
87 | 87 | end |
|
88 | ||
|
89 | def new | |
|
90 | @time_entry ||= TimeEntry.new(:project => @project, :issue => @issue, :user => User.current, :spent_on => User.current.today) | |
|
91 | @time_entry.attributes = params[:time_entry] | |
|
92 | ||
|
93 | call_hook(:controller_timelog_edit_before_save, { :params => params, :time_entry => @time_entry }) | |
|
94 | render :action => 'edit' | |
|
95 | end | |
|
88 | 96 | |
|
89 | 97 | def edit |
|
90 | 98 | (render_403; return) if @time_entry && !@time_entry.editable_by?(User.current) |
@@ -1,5 +1,5 | |||
|
1 | 1 | <div class="contextual"> |
|
2 |
<%= link_to_if_authorized l(:button_log_time), {:controller => 'timelog', :action => ' |
|
|
2 | <%= link_to_if_authorized l(:button_log_time), {:controller => 'timelog', :action => 'new', :project_id => @project, :issue_id => @issue}, :class => 'icon icon-time-add' %> | |
|
3 | 3 | </div> |
|
4 | 4 | |
|
5 | 5 | <%= render_timelog_breadcrumb %> |
@@ -1,5 +1,5 | |||
|
1 | 1 | <div class="contextual"> |
|
2 |
<%= link_to_if_authorized l(:button_log_time), {:controller => 'timelog', :action => ' |
|
|
2 | <%= link_to_if_authorized l(:button_log_time), {:controller => 'timelog', :action => 'new', :project_id => @project, :issue_id => @issue}, :class => 'icon icon-time-add' %> | |
|
3 | 3 | </div> |
|
4 | 4 | |
|
5 | 5 | <%= render_timelog_breadcrumb %> |
@@ -15,8 +15,8 ActionController::Routing::Routes.draw do |map| | |||
|
15 | 15 | map.connect 'help/:ctrl/:page', :controller => 'help' |
|
16 | 16 | |
|
17 | 17 | map.connect 'time_entries/:id/edit', :action => 'edit', :controller => 'timelog' |
|
18 |
map.connect 'projects/:project_id/time_entries/new', :action => ' |
|
|
19 |
map.connect 'projects/:project_id/issues/:issue_id/time_entries/new', :action => ' |
|
|
18 | map.connect 'projects/:project_id/time_entries/new', :action => 'new', :controller => 'timelog' | |
|
19 | map.connect 'projects/:project_id/issues/:issue_id/time_entries/new', :action => 'new', :controller => 'timelog' | |
|
20 | 20 | |
|
21 | 21 | map.with_options :controller => 'timelog' do |timelog| |
|
22 | 22 | timelog.connect 'projects/:project_id/time_entries', :action => 'index' |
@@ -37,7 +37,7 ActionController::Routing::Routes.draw do |map| | |||
|
37 | 37 | time_report.connect 'projects/:project_id/time_entries/report.:format' |
|
38 | 38 | end |
|
39 | 39 | |
|
40 |
timelog.with_options :action => ' |
|
|
40 | timelog.with_options :action => 'new', :conditions => {:method => :get} do |time_edit| | |
|
41 | 41 | time_edit.connect 'issues/:issue_id/time_entries/new' |
|
42 | 42 | end |
|
43 | 43 |
@@ -86,8 +86,8 Redmine::AccessControl.map do |map| | |||
|
86 | 86 | map.project_module :time_tracking do |map| |
|
87 | 87 | map.permission :log_time, {:timelog => :edit}, :require => :loggedin |
|
88 | 88 | map.permission :view_time_entries, :timelog => [:index], :time_entry_reports => [:report] |
|
89 | map.permission :edit_time_entries, {:timelog => [:edit, :destroy]}, :require => :member | |
|
90 | map.permission :edit_own_time_entries, {:timelog => [:edit, :destroy]}, :require => :loggedin | |
|
89 | map.permission :edit_time_entries, {:timelog => [:new, :edit, :destroy]}, :require => :member | |
|
90 | map.permission :edit_own_time_entries, {:timelog => [:new, :edit, :destroy]}, :require => :loggedin | |
|
91 | 91 | map.permission :manage_project_activities, {:project_enumerations => [:update, :destroy]}, :require => :member |
|
92 | 92 | end |
|
93 | 93 |
@@ -31,9 +31,9 class TimelogControllerTest < ActionController::TestCase | |||
|
31 | 31 | @response = ActionController::TestResponse.new |
|
32 | 32 | end |
|
33 | 33 | |
|
34 |
def test_get_ |
|
|
34 | def test_get_new | |
|
35 | 35 | @request.session[:user_id] = 3 |
|
36 |
get : |
|
|
36 | get :new, :project_id => 1 | |
|
37 | 37 | assert_response :success |
|
38 | 38 | assert_template 'edit' |
|
39 | 39 | # Default activity selected |
@@ -41,6 +41,15 class TimelogControllerTest < ActionController::TestCase | |||
|
41 | 41 | :content => 'Development' |
|
42 | 42 | end |
|
43 | 43 | |
|
44 | def test_get_new_should_only_show_active_time_entry_activities | |
|
45 | @request.session[:user_id] = 3 | |
|
46 | get :new, :project_id => 1 | |
|
47 | assert_response :success | |
|
48 | assert_template 'edit' | |
|
49 | assert_no_tag :tag => 'option', :content => 'Inactive Activity' | |
|
50 | ||
|
51 | end | |
|
52 | ||
|
44 | 53 | def test_get_edit_existing_time |
|
45 | 54 | @request.session[:user_id] = 2 |
|
46 | 55 | get :edit, :id => 2, :project_id => nil |
@@ -50,15 +59,6 class TimelogControllerTest < ActionController::TestCase | |||
|
50 | 59 | assert_tag :tag => 'form', :attributes => { :action => '/projects/ecookbook/timelog/edit/2' } |
|
51 | 60 | end |
|
52 | 61 | |
|
53 | def test_get_edit_should_only_show_active_time_entry_activities | |
|
54 | @request.session[:user_id] = 3 | |
|
55 | get :edit, :project_id => 1 | |
|
56 | assert_response :success | |
|
57 | assert_template 'edit' | |
|
58 | assert_no_tag :tag => 'option', :content => 'Inactive Activity' | |
|
59 | ||
|
60 | end | |
|
61 | ||
|
62 | 62 | def test_get_edit_with_an_existing_time_entry_with_inactive_activity |
|
63 | 63 | te = TimeEntry.find(1) |
|
64 | 64 | te.activity = TimeEntryActivity.find_by_name("Inactive Activity") |
@@ -233,11 +233,12 class RoutingTest < ActionController::IntegrationTest | |||
|
233 | 233 | should_route :get, "/issues/234/time_entries.atom", :controller => 'timelog', :action => 'index', :issue_id => '234', :format => 'atom' |
|
234 | 234 | should_route :get, "/projects/ecookbook/issues/123/time_entries", :controller => 'timelog', :action => 'index', :project_id => 'ecookbook', :issue_id => '123' |
|
235 | 235 | |
|
236 |
should_route :get, "/issues/567/time_entries/new", :controller => 'timelog', :action => ' |
|
|
237 |
should_route :get, "/projects/ecookbook/time_entries/new", :controller => 'timelog', :action => ' |
|
|
238 |
should_route :get, "/projects/ecookbook/issues/567/time_entries/new", :controller => 'timelog', :action => ' |
|
|
236 | should_route :get, "/issues/567/time_entries/new", :controller => 'timelog', :action => 'new', :issue_id => '567' | |
|
237 | should_route :get, "/projects/ecookbook/time_entries/new", :controller => 'timelog', :action => 'new', :project_id => 'ecookbook' | |
|
238 | should_route :get, "/projects/ecookbook/issues/567/time_entries/new", :controller => 'timelog', :action => 'new', :project_id => 'ecookbook', :issue_id => '567' | |
|
239 | 239 | should_route :get, "/time_entries/22/edit", :controller => 'timelog', :action => 'edit', :id => '22' |
|
240 | 240 | |
|
241 | should_route :post, "/time_entries/22/edit", :controller => 'timelog', :action => 'edit', :id => '22' | |
|
241 | 242 | should_route :post, "/time_entries/55/destroy", :controller => 'timelog', :action => 'destroy', :id => '55' |
|
242 | 243 | end |
|
243 | 244 |
General Comments 0
You need to be logged in to leave comments.
Login now