##// END OF EJS Templates
Fixed: time entries created with the default activity even if a different one is specified (#1302)....
Jean-Philippe Lang -
r1519:846045fd0590
parent child
Show More
@@ -30,8 +30,10 class TimeEntry < ActiveRecord::Base
30 validates_length_of :comments, :maximum => 255
30 validates_length_of :comments, :maximum => 255
31
31
32 def after_initialize
32 def after_initialize
33 if new_record?
33 if new_record? && self.activity.nil?
34 self.activity ||= Enumeration.default('ACTI')
34 if default_activity = Enumeration.default('ACTI')
35 self.activity_id = default_activity.id
36 end
35 end
37 end
36 end
38 end
37
39
@@ -44,7 +44,8 class TimelogControllerTest < Test::Unit::TestCase
44 @request.session[:user_id] = 3
44 @request.session[:user_id] = 3
45 post :edit, :project_id => 1,
45 post :edit, :project_id => 1,
46 :time_entry => {:comments => 'Some work on TimelogControllerTest',
46 :time_entry => {:comments => 'Some work on TimelogControllerTest',
47 :activity_id => '10',
47 # Not the default activity
48 :activity_id => '11',
48 :spent_on => '2008-03-14',
49 :spent_on => '2008-03-14',
49 :issue_id => '1',
50 :issue_id => '1',
50 :hours => '7.3'}
51 :hours => '7.3'}
@@ -53,6 +54,7 class TimelogControllerTest < Test::Unit::TestCase
53 i = Issue.find(1)
54 i = Issue.find(1)
54 t = TimeEntry.find_by_comments('Some work on TimelogControllerTest')
55 t = TimeEntry.find_by_comments('Some work on TimelogControllerTest')
55 assert_not_nil t
56 assert_not_nil t
57 assert_equal 11, t.activity_id
56 assert_equal 7.3, t.hours
58 assert_equal 7.3, t.hours
57 assert_equal 3, t.user_id
59 assert_equal 3, t.user_id
58 assert_equal i, t.issue
60 assert_equal i, t.issue
General Comments 0
You need to be logged in to leave comments. Login now