9799: Remove bogus bootstrap classes and fix html syntax.
[arvados.git] / apps / workbench / test / unit / work_unit_test.rb
index c737982fc664db1e9dc5a9408383584c23bad251..68bc2fdaddc59c5e0ef0c67e06815684bb4fb344 100644 (file)
@@ -35,6 +35,19 @@ class WorkUnitTest < ActiveSupport::TestCase
     end
   end
 
+  [
+    ['cr_for_failed', 'Failed', 33],
+    ['completed', 'Complete', 0],
+  ].each do |cr_fixture, state, exit_code|
+    test "Completed ContainerRequest state = #{state} with exit_code = #{exit_code}" do
+      use_token 'active'
+      obj = find_fixture(ContainerRequest, cr_fixture)
+      wu = obj.work_unit
+      assert_equal state, wu.state_label
+      assert_equal exit_code, wu.exit_code
+    end
+  end
+
   [
     [Job, 'running_job_with_components', 1, 1, nil],
     [Job, 'queued', nil, nil, 1],
@@ -91,4 +104,18 @@ class WorkUnitTest < ActiveSupport::TestCase
       end
     end
   end
+
+  test 'can_cancel?' do
+    use_token 'active' do
+      assert find_fixture(Job, 'running').work_unit.can_cancel?
+      refute find_fixture(Container, 'running').work_unit.can_cancel?
+      assert find_fixture(ContainerRequest, 'running').work_unit.can_cancel?
+    end
+    use_token 'spectator' do
+      refute find_fixture(ContainerRequest, 'running_anonymous_accessible').work_unit.can_cancel?
+    end
+    use_token 'admin' do
+      assert find_fixture(ContainerRequest, 'running_anonymous_accessible').work_unit.can_cancel?
+    end
+  end
 end