3 class PipelineInstancesControllerTest < ActionController::TestCase
4 def create_instance_long_enough_to(instance_attrs={})
5 # create 'two_part' pipeline with the given instance attributes
6 pt_fixture = api_fixture('pipeline_templates')['two_part']
8 pipeline_instance: instance_attrs.merge({
9 pipeline_template_uuid: pt_fixture['uuid']
12 }, session_for(:active)
13 assert_response :success
14 pi_uuid = assigns(:object).uuid
15 assert_not_nil assigns(:object)
18 yield pi_uuid, pt_fixture
20 # delete the pipeline instance
22 PipelineInstance.where(uuid: pi_uuid).first.destroy
25 test "pipeline instance components populated after create" do
26 create_instance_long_enough_to do |new_instance_uuid, template_fixture|
27 assert_equal(template_fixture['components'].to_json,
28 assigns(:object).components.to_json)
32 test "can render pipeline instance with tagged collections" do
33 # Make sure to pass in a tagged collection to test that part of the rendering behavior.
35 {id: api_fixture("pipeline_instances")["pipeline_with_tagged_collection_input"]["uuid"]},
37 assert_response :success
40 test "update script_parameters one at a time using merge param" do
41 template_fixture = api_fixture('pipeline_templates')['two_part']
43 id: api_fixture("pipeline_instances")["pipeline_to_merge_params"]["uuid"],
60 }, session_for(:active)
61 assert_response :success
62 assert_not_nil assigns(:object)
63 orig_params = template_fixture['components']['part-two']['script_parameters']
64 new_params = assigns(:object).components[:'part-two'][:script_parameters]
65 orig_params.keys.each do |k|
66 unless %w(integer_with_value plain_string).index(k)
67 assert_equal orig_params[k].to_json, new_params[k.to_sym].to_json
72 test "component rendering copes with unexpeceted components format" do
74 {id: api_fixture("pipeline_instances")["components_is_jobspec"]["uuid"]},
76 assert_response :success
79 test "dates in JSON components are parsed" do
81 {id: api_fixture('pipeline_instances')['has_component_with_completed_jobs']['uuid']},
83 assert_response :success
84 assert_not_nil assigns(:object)
85 assert_not_nil assigns(:object).components[:foo][:job]
86 assert assigns(:object).components[:foo][:job][:started_at].is_a? Time
87 assert assigns(:object).components[:foo][:job][:finished_at].is_a? Time