Commit 17faa8a2 authored by Grzegorz Bizon's avatar Grzegorz Bizon

Fix specs for environments with manual actions

parent 9b27f49d
...@@ -57,7 +57,7 @@ FactoryGirl.define do ...@@ -57,7 +57,7 @@ FactoryGirl.define do
end end
trait :manual do trait :manual do
status 'skipped' status 'manual'
self.when 'manual' self.when 'manual'
end end
......
...@@ -13,7 +13,7 @@ feature 'Environment', :feature do ...@@ -13,7 +13,7 @@ feature 'Environment', :feature do
feature 'environment details page' do feature 'environment details page' do
given!(:environment) { create(:environment, project: project) } given!(:environment) { create(:environment, project: project) }
given!(:deployment) { } given!(:deployment) { }
given!(:manual) { } given!(:action) { }
before do before do
visit_environment(environment) visit_environment(environment)
...@@ -69,17 +69,23 @@ feature 'Environment', :feature do ...@@ -69,17 +69,23 @@ feature 'Environment', :feature do
end end
context 'with manual action' do context 'with manual action' do
given(:manual) { create(:ci_build, :manual, pipeline: pipeline, name: 'deploy to production') } given(:action) do
create(:ci_build, :manual, pipeline: pipeline,
name: 'deploy to production')
end
scenario 'does show a play button' do scenario 'does show a play button' do
expect(page).to have_link(manual.name.humanize) expect(page).to have_link(action.name.humanize)
end end
scenario 'does allow to play manual action' do scenario 'does allow to play manual action' do
expect(manual).to be_skipped expect(action).to be_manual
expect{ click_link(manual.name.humanize) }.not_to change { Ci::Pipeline.count }
expect(page).to have_content(manual.name) expect { click_link(action.name.humanize) }
expect(manual.reload).to be_pending .not_to change { Ci::Pipeline.count }
expect(page).to have_content(action.name)
expect(action.reload).to be_pending
end end
context 'with external_url' do context 'with external_url' do
...@@ -130,8 +136,16 @@ feature 'Environment', :feature do ...@@ -130,8 +136,16 @@ feature 'Environment', :feature do
context 'when environment is available' do context 'when environment is available' do
context 'with stop action' do context 'with stop action' do
given(:manual) { create(:ci_build, :manual, pipeline: pipeline, name: 'close_app') } given(:action) do
given(:deployment) { create(:deployment, environment: environment, deployable: build, on_stop: 'close_app') } create(:ci_build, :manual, pipeline: pipeline,
name: 'close_app')
end
given(:deployment) do
create(:deployment, environment: environment,
deployable: build,
on_stop: 'close_app')
end
scenario 'does show stop button' do scenario 'does show stop button' do
expect(page).to have_link('Stop') expect(page).to have_link('Stop')
......
...@@ -12,7 +12,7 @@ feature 'Environments page', :feature, :js do ...@@ -12,7 +12,7 @@ feature 'Environments page', :feature, :js do
given!(:environment) { } given!(:environment) { }
given!(:deployment) { } given!(:deployment) { }
given!(:manual) { } given!(:action) { }
before do before do
visit_environments(project) visit_environments(project)
...@@ -90,7 +90,7 @@ feature 'Environments page', :feature, :js do ...@@ -90,7 +90,7 @@ feature 'Environments page', :feature, :js do
given(:pipeline) { create(:ci_pipeline, project: project) } given(:pipeline) { create(:ci_pipeline, project: project) }
given(:build) { create(:ci_build, pipeline: pipeline) } given(:build) { create(:ci_build, pipeline: pipeline) }
given(:manual) do given(:action) do
create(:ci_build, :manual, pipeline: pipeline, name: 'deploy to production') create(:ci_build, :manual, pipeline: pipeline, name: 'deploy to production')
end end
...@@ -102,19 +102,19 @@ feature 'Environments page', :feature, :js do ...@@ -102,19 +102,19 @@ feature 'Environments page', :feature, :js do
scenario 'does show a play button' do scenario 'does show a play button' do
find('.js-dropdown-play-icon-container').click find('.js-dropdown-play-icon-container').click
expect(page).to have_content(manual.name.humanize) expect(page).to have_content(action.name.humanize)
end end
scenario 'does allow to play manual action', js: true do scenario 'does allow to play manual action', js: true do
expect(manual).to be_skipped expect(action).to be_manual
find('.js-dropdown-play-icon-container').click find('.js-dropdown-play-icon-container').click
expect(page).to have_content(manual.name.humanize) expect(page).to have_content(action.name.humanize)
expect { click_link(manual.name.humanize) } expect { click_link(action.name.humanize) }
.not_to change { Ci::Pipeline.count } .not_to change { Ci::Pipeline.count }
expect(manual.reload).to be_pending expect(action.reload).to be_pending
end end
scenario 'does show build name and id' do scenario 'does show build name and id' do
...@@ -144,8 +144,15 @@ feature 'Environments page', :feature, :js do ...@@ -144,8 +144,15 @@ feature 'Environments page', :feature, :js do
end end
context 'with stop action' do context 'with stop action' do
given(:manual) { create(:ci_build, :manual, pipeline: pipeline, name: 'close_app') } given(:action) do
given(:deployment) { create(:deployment, environment: environment, deployable: build, on_stop: 'close_app') } create(:ci_build, :manual, pipeline: pipeline, name: 'close_app')
end
given(:deployment) do
create(:deployment, environment: environment,
deployable: build,
on_stop: 'close_app')
end
scenario 'does show stop button' do scenario 'does show stop button' do
expect(page).to have_selector('.stop-env-link') expect(page).to have_selector('.stop-env-link')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment