validate :validate_state_change
validate :validate_change
after_save :update_priority
+ before_create :set_requesting_container_uuid
api_accessible :user, extend: :common do |t|
t.add :command
end
end
+ def set_requesting_container_uuid
+ return true if self.requesting_container_uuid # already set
+
+ token_uuid = current_api_client_authorization.andand.uuid
+ container = Container.where('auth_uuid=?', token_uuid).order('created_at desc').first
+ self.requesting_container_uuid = container.uuid if container
+ true
+ end
end
assert_equal 0, c2.priority
end
+ [
+ ['active', 'zzzzz-dz642-requestercntnr1'],
+ ['active_no_prefs', nil],
+ ].each do |token, expected|
+ test "create as #{token} and expect requesting_container_uuid to be #{expected}" do
+ set_user_from_auth token
+ cr = ContainerRequest.create(container_image: "img", output_path: "/tmp", command: ["echo", "foo"])
+ assert_not_nil cr.uuid, 'uuid should be set for newly created container_request'
+ assert_equal expected, cr.requesting_container_uuid
+ end
+ end
end