9372: name and description can be edited on containers and container_requests despite...
authorradhika <radhika@curoverse.com>
Tue, 14 Jun 2016 22:11:29 +0000 (18:11 -0400)
committerradhika <radhika@curoverse.com>
Tue, 14 Jun 2016 22:11:29 +0000 (18:11 -0400)
apps/workbench/app/models/container.rb
apps/workbench/app/models/container_request.rb
apps/workbench/app/models/container_work_unit.rb
apps/workbench/app/models/job_work_unit.rb
apps/workbench/app/models/pipeline_instance_work_unit.rb
apps/workbench/app/models/proxy_work_unit.rb
apps/workbench/test/integration/application_layout_test.rb
services/api/app/models/container_request.rb
services/api/test/unit/container_request_test.rb

index b52313280a3611577e325145c76a8ee2ae2e2b0f..0a7c288718f581f89235cb9a9fed9fdcd76d1d8e 100644 (file)
@@ -1,4 +1,8 @@
 class Container < ArvadosBase
+  def self.creatable?
+    false
+  end
+
   def work_unit(label=nil)
     ContainerWorkUnit.new(self, label)
   end
index 765300b192cb06fbf57d0b2d6dcedec875a69b50..62d8bff042c16dec335f746ff6f0991e5e37250e 100644 (file)
@@ -1,4 +1,12 @@
 class ContainerRequest < ArvadosBase
+  def self.creatable?
+    false
+  end
+
+  def textile_attributes
+    [ 'description' ]
+  end
+
   def work_unit(label=nil)
     ContainerWorkUnit.new(self, label)
   end
index 2fe1ff06698c452aee44c0e7df143e6a185af36d..d90299531f7ec1f8053e74a763e41dcc9a41b034 100644 (file)
@@ -44,6 +44,12 @@ class ContainerWorkUnit < ProxyWorkUnit
     "container"
   end
 
+  def uri
+    uuid = get(:uuid)
+    "/#{@proxied.class.table_name}/#{uuid}" rescue nil
+  end
+
+
   def can_cancel?
     @proxied.is_a?(ContainerRequest) && state_label.in?(["Queued", "Locked", "Running"]) && priority > 0
   end
index 42a39fcdfd4747323f59915295d6fcbcb03a892f..a3f13f388c9bff38d8f5450633b1e41d1fad338a 100644 (file)
@@ -81,6 +81,11 @@ class JobWorkUnit < ProxyWorkUnit
     state_label.in? ["Queued", "Running"]
   end
 
+  def uri
+    uuid = get(:uuid)
+    "/jobs/#{uuid}"
+  end
+
   def title
     "job"
   end
index 7c623935d4853343e949c5ed2fc007a8474f6893..889fa1a7f3cccecf86c53f5cd837ad4f34cb7ca2 100644 (file)
@@ -43,6 +43,11 @@ class PipelineInstanceWorkUnit < ProxyWorkUnit
     items
   end
 
+  def uri
+    uuid = get(:uuid)
+    "/pipeline_instances/#{uuid}"
+  end
+
   def title
     "pipeline"
   end
index 91673371fe4a3e87f3ebb4c24ba74697c81978a5..f672c8c64cea79c46e7dc99b8f1e37a3ce09c3a6 100644 (file)
@@ -322,11 +322,6 @@ class ProxyWorkUnit < WorkUnit
     resp
   end
 
-  def uri
-    uuid = get(:uuid)
-    "/#{@proxied.class.table_name}/#{uuid}"
-  end
-
   protected
 
   def get key, obj=@proxied
index 02dc06cc0dcceb7ceb2c625cb81fccb012ce6193..8e81c7c0d887179d6868cb1f8c58fd9ea6255f4f 100644 (file)
@@ -303,4 +303,27 @@ class ApplicationLayoutTest < ActionDispatch::IntegrationTest
       end
     end
   end
+
+  [
+    ['jobs', 'running_job_with_components'],
+    ['pipeline_instances', 'has_component_with_completed_jobs'],
+    ['container_requests', 'running'],
+    ['container_requests', 'completed'],
+  ].each do |type, fixture|
+    test "edit description for #{type}/#{fixture}" do
+      obj = api_fixture(type)[fixture]
+      visit page_with_token "active", "/#{type}/#{obj['uuid']}"
+
+      within('.arv-description-as-subtitle') do
+        find('.fa-pencil').click
+        find('.editable-input textarea').set('*Textile description for object*')
+        find('.editable-submit').click
+      end
+      wait_for_ajax
+
+      # verify description
+      assert page.has_no_text? '*Textile description for object*'
+      assert page.has_text? 'Textile description for object'
+    end
+  end
 end
index 83ca3346deed2f907ffabd666317c79293257596..496a6b141db2d4f95536430b31edad1f90fba82f 100644 (file)
@@ -129,8 +129,8 @@ class ContainerRequest < ArvadosModel
         errors.add :priority, "cannot be nil"
       end
 
-      # Can update priority, container count.
-      permitted.push :priority, :container_count_max, :container_uuid
+      # Can update priority, container count, name and description
+      permitted.push :priority, :container_count_max, :container_uuid, :name, :description
 
       if self.state_changed?
         # Allow create-and-commit in a single operation.
@@ -141,12 +141,12 @@ class ContainerRequest < ArvadosModel
       end
 
     when Final
-      if not current_user.andand.is_admin
+      if not current_user.andand.is_admin and not (self.name_changed? || self.description_changed?)
         errors.add :state, "of container request can only be set to Final by system."
       end
 
-      if self.state_changed?
-          permitted.push :state
+      if self.state_changed? || self.name_changed? || self.description_changed?
+          permitted.push :state, :name, :description
       else
         errors.add :state, "does not allow updates"
       end
index 2c7eb76b2cb90d9284185b227905f8ee4499d909..df89b93bf4bba59b90bd11e0cff3afd41b921739 100644 (file)
@@ -369,7 +369,7 @@ class ContainerRequestTest < ActiveSupport::TestCase
   end
 
   [
-    ['active', 'zzzzz-dz642-requestercntnr1'],
+    ['active', 'zzzzz-dz642-runningcontainr'],
     ['active_no_prefs', nil],
   ].each do |token, expected|
     test "create as #{token} and expect requesting_container_uuid to be #{expected}" do