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