[PATCH aeolus-conductor 1/2] RM #3448 - Fixes instance.feature:66 test

Matt Wagner matt.wagner at redhat.com
Thu Jul 5 20:45:36 UTC 2012


This cleans up task.rb to fix a strange failure that was being
encountered when using newer versions of Rails (via Bundler).

Resolves https://www.aeolusproject.org/redmine/issues/3448
---
 src/app/models/task.rb |   11 ++++++-----
 1 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/src/app/models/task.rb b/src/app/models/task.rb
index 86d966c..6d65fcc 100644
--- a/src/app/models/task.rb
+++ b/src/app/models/task.rb
@@ -76,6 +76,8 @@ class Task < ActiveRecord::Base
   validates_inclusion_of :state,
     :in => COMPLETED_STATES + WORKING_STATES
 
+  after_initialize :initialize_state
+
   # FIXME validate action depending on type / subclass
   # validate task_target_id, task_type_id, arg, message
   #   depending on subclass, action, state
@@ -89,11 +91,6 @@ class Task < ActiveRecord::Base
                          ["Canceled", Task::STATE_CANCELED, "break"],
                          ["All States", ""]]
 
-  def initialize(params)
-    super
-    self.state = STATE_QUEUED unless self.state
-  end
-
   def cancel
     self[:state] = STATE_CANCELED
     save!
@@ -143,4 +140,8 @@ class Task < ActiveRecord::Base
     errors.add("time_ended", "Tasks ends before it's started") unless time_ended.nil? or time_started.nil? or time_ended >= time_started
     errors.add("time_started", "Tasks starts before it's created") unless time_started.nil? or created_at.nil? or time_started >= created_at
   end
+
+  def initialize_state
+    self.state = STATE_QUEUED unless self.state
+  end
 end
-- 
1.7.7.6




More information about the aeolus-devel mailing list