2016-11-03 12:29:30 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
feature 'Widget Deployments Header', js: true do
|
2016-11-03 12:29:30 +05:30
|
|
|
describe 'when deployed to an environment' do
|
|
|
|
given(:user) { create(:user) }
|
|
|
|
given(:project) { merge_request.target_project }
|
|
|
|
given(:merge_request) { create(:merge_request, :merged) }
|
|
|
|
given(:environment) { create(:environment, project: project) }
|
|
|
|
given(:role) { :developer }
|
|
|
|
given(:sha) { project.commit('master').id }
|
|
|
|
given!(:deployment) { create(:deployment, environment: environment, sha: sha) }
|
|
|
|
given!(:manual) { }
|
|
|
|
|
|
|
|
background do
|
2017-09-10 17:25:29 +05:30
|
|
|
sign_in(user)
|
2016-11-03 12:29:30 +05:30
|
|
|
project.team << [user, role]
|
2017-09-10 17:25:29 +05:30
|
|
|
visit project_merge_request_path(project, merge_request)
|
2016-11-03 12:29:30 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
scenario 'displays that the environment is deployed' do
|
2017-09-10 17:25:29 +05:30
|
|
|
wait_for_requests
|
2016-11-03 12:29:30 +05:30
|
|
|
|
|
|
|
expect(page).to have_content("Deployed to #{environment.name}")
|
2017-08-17 22:00:37 +05:30
|
|
|
expect(find('.js-deploy-time')['data-title']).to eq(deployment.created_at.to_time.in_time_zone.to_s(:medium))
|
2016-11-03 12:29:30 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
context 'with stop action' do
|
|
|
|
given(:pipeline) { create(:ci_pipeline, project: project) }
|
|
|
|
given(:build) { create(:ci_build, pipeline: pipeline) }
|
|
|
|
given(:manual) { create(:ci_build, :manual, pipeline: pipeline, name: 'close_app') }
|
|
|
|
given(:deployment) do
|
|
|
|
create(:deployment, environment: environment, ref: merge_request.target_branch,
|
|
|
|
sha: sha, deployable: build, on_stop: 'close_app')
|
|
|
|
end
|
|
|
|
|
|
|
|
background do
|
2017-09-10 17:25:29 +05:30
|
|
|
wait_for_requests
|
2016-11-03 12:29:30 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
scenario 'does show stop button' do
|
2017-08-17 22:00:37 +05:30
|
|
|
expect(page).to have_button('Stop environment')
|
2016-11-03 12:29:30 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
scenario 'does start build when stop button clicked' do
|
2017-08-17 22:00:37 +05:30
|
|
|
click_button('Stop environment')
|
2016-11-03 12:29:30 +05:30
|
|
|
|
|
|
|
expect(page).to have_content('close_app')
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'for reporter' do
|
|
|
|
given(:role) { :reporter }
|
|
|
|
|
|
|
|
scenario 'does not show stop button' do
|
2017-08-17 22:00:37 +05:30
|
|
|
expect(page).not_to have_button('Stop environment')
|
2016-11-03 12:29:30 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|