]> source.dussan.org Git - redmine.git/commitdiff
Fixed: IssueController#edit doesn't set default Activity as default (#1302).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Mon, 26 May 2008 17:12:11 +0000 (17:12 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Mon, 26 May 2008 17:12:11 +0000 (17:12 +0000)
git-svn-id: http://redmine.rubyforge.org/svn/trunk@1461 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/controllers/issues_controller.rb
app/models/time_entry.rb
test/fixtures/enumerations.yml
test/functional/timelog_controller_test.rb

index 84b95741e6233e5bdfa661606debc3f0315245b8..ca3309c4694273c77c9dc0c6296156b64b419025 100644 (file)
@@ -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' }
index ddaff2b6061f4b5390775597221e4bfd041394fe..4bd2d33b886a5edeeef6599ab88a566a203f0e88 100644 (file)
@@ -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
index c90a997ee15b88c12366e1f376ea6359f6b1f1da..5e2615476970ca1b14a36b7c5d51313b6249b8ea 100644 (file)
@@ -39,4 +39,9 @@ enumerations_010:
   name: Development\r
   id: 10\r
   opt: ACTI\r
+  is_default: true\r
+enumerations_011: \r
+  name: QA\r
+  id: 11\r
+  opt: ACTI\r
   
\ No newline at end of file
index e80a677283bb5c2dd9575ecc85d08f49d45a57fc..479f4f44f22b2df4a784ed7c76548e631f0ede78 100644 (file)
@@ -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',