##// END OF EJS Templates
Merged r15955 and r15956 (#24297)....
Jean-Philippe Lang -
r15617:6ebb700db2f5
parent child
Show More
@@ -19,6 +19,7 class TimelogController < ApplicationController
19 menu_item :issues
19 menu_item :issues
20
20
21 before_filter :find_time_entry, :only => [:show, :edit, :update]
21 before_filter :find_time_entry, :only => [:show, :edit, :update]
22 before_filter :check_editability, :only => [:edit, :update]
22 before_filter :find_time_entries, :only => [:bulk_edit, :bulk_update, :destroy]
23 before_filter :find_time_entries, :only => [:bulk_edit, :bulk_update, :destroy]
23 before_filter :authorize, :only => [:show, :edit, :update, :bulk_edit, :bulk_update, :destroy]
24 before_filter :authorize, :only => [:show, :edit, :update, :bulk_edit, :bulk_update, :destroy]
24
25
@@ -222,13 +223,16 class TimelogController < ApplicationController
222 private
223 private
223 def find_time_entry
224 def find_time_entry
224 @time_entry = TimeEntry.find(params[:id])
225 @time_entry = TimeEntry.find(params[:id])
226 @project = @time_entry.project
227 rescue ActiveRecord::RecordNotFound
228 render_404
229 end
230
231 def check_editability
225 unless @time_entry.editable_by?(User.current)
232 unless @time_entry.editable_by?(User.current)
226 render_403
233 render_403
227 return false
234 return false
228 end
235 end
229 @project = @time_entry.project
230 rescue ActiveRecord::RecordNotFound
231 render_404
232 end
236 end
233
237
234 def find_time_entries
238 def find_time_entries
@@ -48,6 +48,17 class Redmine::ApiTest::TimeEntriesTest < Redmine::ApiTest::Base
48 assert_select 'time_entry id', :text => '2'
48 assert_select 'time_entry id', :text => '2'
49 end
49 end
50
50
51 test "GET /time_entries/:id.xml on closed project should return the time entry" do
52 project = TimeEntry.find(2).project
53 project.close
54 project.save!
55
56 get '/time_entries/2.xml', {}, credentials('jsmith')
57 assert_response :success
58 assert_equal 'application/xml', @response.content_type
59 assert_select 'time_entry id', :text => '2'
60 end
61
51 test "POST /time_entries.xml with issue_id should create time entry" do
62 test "POST /time_entries.xml with issue_id should create time entry" do
52 assert_difference 'TimeEntry.count' do
63 assert_difference 'TimeEntry.count' do
53 post '/time_entries.xml', {:time_entry => {:issue_id => '1', :spent_on => '2010-12-02', :hours => '3.5', :activity_id => '11'}}, credentials('jsmith')
64 post '/time_entries.xml', {:time_entry => {:issue_id => '1', :spent_on => '2010-12-02', :hours => '3.5', :activity_id => '11'}}, credentials('jsmith')
General Comments 0
You need to be logged in to leave comments. Login now