From 7a4fc415ac5f4032c30ee7469b6a9eb02135e008 Mon Sep 17 00:00:00 2001 From: radhika Date: Mon, 6 Oct 2014 19:50:19 -0400 Subject: [PATCH] 3990: refactor pipeline instances integration test to reuse logic that creates and runs a pipeline. --- .../pipeline_instances_controller.rb | 2 +- .../integration/pipeline_instances_test.rb | 52 ++++++------------- 2 files changed, 16 insertions(+), 38 deletions(-) diff --git a/apps/workbench/app/controllers/pipeline_instances_controller.rb b/apps/workbench/app/controllers/pipeline_instances_controller.rb index ce3befae06..a618d43517 100644 --- a/apps/workbench/app/controllers/pipeline_instances_controller.rb +++ b/apps/workbench/app/controllers/pipeline_instances_controller.rb @@ -48,7 +48,7 @@ class PipelineInstancesController < ApplicationController end @object.state = 'New' - # set owner_uuid to that of source, provided it is wriable by current user + # set owner_uuid to that of source, provided it is a project and wriable by current user current_project = Group.find(source.owner_uuid) rescue nil if (current_project && current_project.writable_by.andand.include?(current_user.uuid)) @object.owner_uuid = source.owner_uuid diff --git a/apps/workbench/test/integration/pipeline_instances_test.rb b/apps/workbench/test/integration/pipeline_instances_test.rb index 3e8663daa8..386d6b0b64 100644 --- a/apps/workbench/test/integration/pipeline_instances_test.rb +++ b/apps/workbench/test/integration/pipeline_instances_test.rb @@ -113,43 +113,17 @@ class PipelineInstancesTest < ActionDispatch::IntegrationTest wait_for_ajax end - # create a pipeline instance - find('.btn', text: 'Run a pipeline').click - within('.modal-dialog') do - find('.selectable', text: 'Two Part Pipeline Template').click - find('.btn', text: 'Next: choose inputs').click - end - - assert find('p', text: 'Provide a value') - - find('div.form-group', text: 'Foo/bar pair'). - find('.btn', text: 'Choose'). - click - - within('.modal-dialog') do - assert_selector 'button.dropdown-toggle', text: 'A Project' - wait_for_ajax - first('span', text: 'foo_tag').click - find('button', text: 'OK').click - end - wait_for_ajax - - # "Run" button present and enabled - page.assert_no_selector 'a.disabled,button.disabled', text: 'Run' - first('a,button', text: 'Run').click - - # Pipeline is running. We have a "Pause" button instead now. - page.assert_no_selector 'a,button', text: 'Run' - page.assert_selector 'a,button', text: 'Pause' - - # Since it is test env, no jobs are created to run. So, graph not visible - assert_not page.has_text? 'Graph' + create_and_run_pipeline_in_aproject false end # Create a pipeline instance from within a project and run test 'Run a pipeline from dashboard' do visit page_with_token('active_trustedclient') + create_and_run_pipeline_in_aproject true + end + # Create and run a pipeline for 'Two Part Pipeline Template' in 'A Project' + def create_and_run_pipeline_in_aproject choose_project # create a pipeline instance find('.btn', text: 'Run a pipeline').click within('.modal-dialog') do @@ -164,11 +138,16 @@ class PipelineInstancesTest < ActionDispatch::IntegrationTest click within('.modal-dialog') do - assert_selector 'button.dropdown-toggle', text: 'Home' - wait_for_ajax - click_button "Home" - click_link "A Project" - wait_for_ajax + if choose_project + assert_selector 'button.dropdown-toggle', text: 'Home' + wait_for_ajax + click_button "Home" + click_link "A Project" + wait_for_ajax + else + assert_selector 'button.dropdown-toggle', text: 'A Project' + wait_for_ajax + end first('span', text: 'foo_tag').click find('button', text: 'OK').click end @@ -186,7 +165,6 @@ class PipelineInstancesTest < ActionDispatch::IntegrationTest assert_not page.has_text? 'Graph' end - test 'view pipeline with job and see graph' do visit page_with_token('active_trustedclient') -- 2.30.2