- test "copy pipeline instance with components=use_latest" do
- post(:copy,
- params: {
- id: api_fixture('pipeline_instances')['pipeline_with_newer_template']['uuid'],
- components: 'use_latest',
- script: 'use_latest',
- pipeline_instance: {
- state: 'RunningOnServer'
- }
- },
- session: session_for(:active))
- assert_response 302
- assert_not_nil assigns(:object)
-
- # Component 'foo' has script parameters only in the pipeline instance.
- # Component 'bar' is present only in the pipeline_template.
- # Test that the copied pipeline instance includes parameters for
- # component 'foo' from the source instance, and parameters for
- # component 'bar' from the source template.
- #
- assert_not_nil assigns(:object).components[:foo]
- foo = assigns(:object).components[:foo]
- assert_not_nil foo[:script_parameters]
- assert_not_nil foo[:script_parameters][:input]
- assert_equal 'foo instance input', foo[:script_parameters][:input][:title]
-
- assert_not_nil assigns(:object).components[:bar]
- bar = assigns(:object).components[:bar]
- assert_not_nil bar[:script_parameters]
- assert_not_nil bar[:script_parameters][:input]
- assert_equal 'bar template input', bar[:script_parameters][:input][:title]
- end
-
- test "copy pipeline instance on newer template works with script=use_same" do
- post(:copy,
- params: {
- id: api_fixture('pipeline_instances')['pipeline_with_newer_template']['uuid'],
- components: 'use_latest',
- script: 'use_same',
- pipeline_instance: {
- state: 'RunningOnServer'
- }
- },
- session: session_for(:active))
- assert_response 302
- assert_not_nil assigns(:object)
-
- # Test that relevant component parameters were copied from both
- # the source instance and source template, respectively (see
- # previous test)
- #
- assert_not_nil assigns(:object).components[:foo]
- foo = assigns(:object).components[:foo]
- assert_not_nil foo[:script_parameters]
- assert_not_nil foo[:script_parameters][:input]
- assert_equal 'foo instance input', foo[:script_parameters][:input][:title]
-
- assert_not_nil assigns(:object).components[:bar]
- bar = assigns(:object).components[:bar]
- assert_not_nil bar[:script_parameters]
- assert_not_nil bar[:script_parameters][:input]
- assert_equal 'bar template input', bar[:script_parameters][:input][:title]
- end
-