Add 'apps/arv-web/' from commit 'f9732ad8460d013c2f28363655d0d1b91894dca5'
[arvados.git] / apps / workbench / test / unit / pipeline_instance_test.rb
1 require 'test_helper'
2
3 class PipelineInstanceTest < ActiveSupport::TestCase
4   def attribute_editable_for?(token_name, pi_name, attr_name, ever=nil)
5     use_token token_name
6     find_fixture(PipelineInstance, pi_name).attribute_editable?(attr_name, ever)
7   end
8
9   test "admin can edit name" do
10     assert(attribute_editable_for?(:admin, "new_pipeline_in_subproject",
11                                    "name"),
12            "admin not allowed to edit pipeline instance name")
13   end
14
15   test "project owner can edit name" do
16     assert(attribute_editable_for?(:active, "new_pipeline_in_subproject",
17                                    "name"),
18            "project owner not allowed to edit pipeline instance name")
19   end
20
21   test "project admin can edit name" do
22     assert(attribute_editable_for?(:subproject_admin,
23                                    "new_pipeline_in_subproject", "name"),
24            "project admin not allowed to edit pipeline instance name")
25   end
26
27   test "project viewer cannot edit name" do
28     refute(attribute_editable_for?(:project_viewer,
29                                    "new_pipeline_in_subproject", "name"),
30            "project viewer allowed to edit pipeline instance name")
31   end
32
33   test "name editable on completed pipeline" do
34     assert(attribute_editable_for?(:active, "has_component_with_completed_jobs",
35                                    "name"),
36            "name not editable on complete pipeline")
37   end
38
39   test "components editable on new pipeline" do
40     assert(attribute_editable_for?(:active, "new_pipeline", "components"),
41            "components not editable on new pipeline")
42   end
43
44   test "components not editable on completed pipeline" do
45     refute(attribute_editable_for?(:active, "has_component_with_completed_jobs",
46                                    "components"),
47            "components not editable on new pipeline")
48   end
49 end