summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2008-05-26 17:12:11 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2008-05-26 17:12:11 +0000
commitd6daeca40ad2aa180ac807875861b987b11ba3eb (patch)
treeb250a606ef4128bdbff8bf500ca123168c12a835
parentb3e5f1a1c39822923160e376e99c05d370429cfd (diff)
downloadredmine-d6daeca40ad2aa180ac807875861b987b11ba3eb.tar.gz
redmine-d6daeca40ad2aa180ac807875861b987b11ba3eb.zip
Fixed: IssueController#edit doesn't set default Activity as default (#1302).
git-svn-id: http://redmine.rubyforge.org/svn/trunk@1461 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r--app/controllers/issues_controller.rb1
-rw-r--r--app/models/time_entry.rb6
-rw-r--r--test/fixtures/enumerations.yml5
-rw-r--r--test/functional/timelog_controller_test.rb12
4 files changed, 23 insertions, 1 deletions
diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb
index 84b95741e..ca3309c46 100644
--- a/app/controllers/issues_controller.rb
+++ b/app/controllers/issues_controller.rb
@@ -102,6 +102,7 @@ class IssuesController < ApplicationController
@edit_allowed = User.current.allowed_to?(:edit_issues, @project)
@activities = Enumeration::get_values('ACTI')
@priorities = Enumeration::get_values('IPRI')
+ @time_entry = TimeEntry.new
respond_to do |format|
format.html { render :template => 'issues/show.rhtml' }
format.atom { render :action => 'changes', :layout => false, :content_type => 'application/atom+xml' }
diff --git a/app/models/time_entry.rb b/app/models/time_entry.rb
index ddaff2b60..4bd2d33b8 100644
--- a/app/models/time_entry.rb
+++ b/app/models/time_entry.rb
@@ -29,6 +29,12 @@ class TimeEntry < ActiveRecord::Base
validates_numericality_of :hours, :allow_nil => true
validates_length_of :comments, :maximum => 255
+ def after_initialize
+ if new_record?
+ self.activity ||= Enumeration.default('ACTI')
+ end
+ end
+
def before_validation
self.project = issue.project if issue && project.nil?
end
diff --git a/test/fixtures/enumerations.yml b/test/fixtures/enumerations.yml
index c90a997ee..5e2615476 100644
--- a/test/fixtures/enumerations.yml
+++ b/test/fixtures/enumerations.yml
@@ -39,4 +39,9 @@ enumerations_010:
name: Development
id: 10
opt: ACTI
+ is_default: true
+enumerations_011:
+ name: QA
+ id: 11
+ opt: ACTI
\ No newline at end of file
diff --git a/test/functional/timelog_controller_test.rb b/test/functional/timelog_controller_test.rb
index e80a67728..479f4f44f 100644
--- a/test/functional/timelog_controller_test.rb
+++ b/test/functional/timelog_controller_test.rb
@@ -30,7 +30,17 @@ class TimelogControllerTest < Test::Unit::TestCase
@response = ActionController::TestResponse.new
end
- def test_create
+ def test_get_edit
+ @request.session[:user_id] = 3
+ get :edit, :project_id => 1
+ assert_response :success
+ assert_template 'edit'
+ # Default activity selected
+ assert_tag :tag => 'option', :attributes => { :selected => 'selected' },
+ :content => 'Development'
+ end
+
+ def test_post_edit
@request.session[:user_id] = 3
post :edit, :project_id => 1,
:time_entry => {:comments => 'Some work on TimelogControllerTest',