3882: Change "update_timestamps_when_state_changes" from before_validation to after_v...
authorradhika <radhika@curoverse.com>
Mon, 6 Oct 2014 16:24:29 +0000 (12:24 -0400)
committerradhika <radhika@curoverse.com>
Mon, 6 Oct 2014 16:24:29 +0000 (12:24 -0400)
so that update of success and running flags is done AFTER ensuring the state change is valid.
Otherwise, the update to success and running flags is resulting in overriding the actual state update.

services/api/app/models/job.rb

index 4b86be79699e6cf678975934e40f35c3e35d62c7..56c070cb6c28773d1c388a97e17698127022f4ae 100644 (file)
@@ -9,12 +9,12 @@ class Job < ArvadosModel
   before_create :ensure_unique_submit_id
   after_commit :trigger_crunch_dispatch_if_cancelled, :on => :update
   before_validation :set_priority
-  before_validation :update_timestamps_when_state_changes
   before_validation :update_state_from_old_state_attrs
   validate :ensure_script_version_is_commit
   validate :find_docker_image_locator
   validate :validate_status
   validate :validate_state_change
+  after_validation :update_timestamps_when_state_changes
 
   has_many :commit_ancestors, :foreign_key => :descendant, :primary_key => :script_version
   has_many(:nodes, foreign_key: :job_uuid, primary_key: :uuid)