[ARVADOS] updated: 884856a326b06d4c17d52d7371f2270c7925caf6

git at public.curoverse.com git at public.curoverse.com
Tue Oct 7 13:57:59 EDT 2014


Summary of changes:
 services/api/app/models/job.rb                                  | 3 ++-
 services/api/test/functional/arvados/v1/jobs_controller_test.rb | 2 ++
 2 files changed, 4 insertions(+), 1 deletion(-)

       via  884856a326b06d4c17d52d7371f2270c7925caf6 (commit)
      from  a1def9bcfa954a7442f95e965f300a3e73e4f83f (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit 884856a326b06d4c17d52d7371f2270c7925caf6
Author: radhika <radhika at curoverse.com>
Date:   Tue Oct 7 13:55:32 2014 -0400

    3882: update "after_validation :update_timestamps_when_state_changes" to "before_save :update_timestamps_when_state_changes",
    and also add comple more test combinations around cancelled state.

diff --git a/services/api/app/models/job.rb b/services/api/app/models/job.rb
index e6a4125..864e608 100644
--- a/services/api/app/models/job.rb
+++ b/services/api/app/models/job.rb
@@ -14,7 +14,7 @@ class Job < ArvadosModel
   validate :find_docker_image_locator
   validate :validate_status
   validate :validate_state_change
-  after_validation :update_timestamps_when_state_changes
+  before_save :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)
@@ -261,6 +261,7 @@ class Job < ArvadosModel
 
   def update_timestamps_when_state_changes
     return if not (state_changed? or new_record?)
+
     case state
     when Running
       self.started_at ||= Time.now
diff --git a/services/api/test/functional/arvados/v1/jobs_controller_test.rb b/services/api/test/functional/arvados/v1/jobs_controller_test.rb
index 7f4b9d5..07e7f84 100644
--- a/services/api/test/functional/arvados/v1/jobs_controller_test.rb
+++ b/services/api/test/functional/arvados/v1/jobs_controller_test.rb
@@ -103,7 +103,9 @@ class Arvados::V1::JobsControllerTest < ActionController::TestCase
 
   [
    [:put, :update, {job:{cancelled_at: Time.now}}, :success],
+   [:put, :update, {job:{cancelled_at: nil}}, :unprocessable_entity],
    [:put, :update, {job:{state: 'Cancelled'}}, :success],
+   [:put, :update, {job:{state: 'Queued'}}, :unprocessable_entity],
    [:put, :update, {job:{state: 'Running'}}, :unprocessable_entity],
    [:put, :update, {job:{state: 'Failed'}}, :unprocessable_entity],
    [:put, :update, {job:{state: 'Complete'}}, :unprocessable_entity],

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list