gitlab-org--gitlab-foss/spec/features/merge_requests/widget_deployments_spec.rb

62 lines
2 KiB
Ruby
Raw Normal View History

2016-10-04 10:03:13 -04:00
require 'spec_helper'
feature 'Widget Deployments Header', feature: true, js: true do
include WaitForAjax
describe 'when deployed to an environment' do
2016-10-17 16:01:56 -04:00
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 }
2016-10-18 05:22:22 -04:00
given(:sha) { project.commit('master').id }
given!(:deployment) { create(:deployment, environment: environment, sha: sha) }
2016-10-17 16:01:56 -04:00
given!(:manual) { }
2016-10-04 10:03:13 -04:00
2016-10-17 16:01:56 -04:00
background do
login_as(user)
project.team << [user, role]
2016-10-04 10:03:13 -04:00
visit namespace_project_merge_request_path(project.namespace, project, merge_request)
end
2016-10-17 16:01:56 -04:00
scenario 'displays that the environment is deployed' do
2016-10-04 10:03:13 -04:00
wait_for_ajax
expect(page).to have_content("Deployed to #{environment.name}")
expect(find('.ci_widget > span > span')['data-title']).to eq(deployment.created_at.to_time.in_time_zone.to_s(:medium))
end
2016-10-17 16:01:56 -04:00
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') }
2016-10-18 05:22:22 -04:00
given(:deployment) do
create(:deployment, environment: environment, ref: merge_request.target_branch,
2016-10-18 07:51:12 -04:00
sha: sha, deployable: build, on_stop: 'close_app')
2016-10-18 05:22:22 -04:00
end
2016-10-17 16:01:56 -04:00
background do
wait_for_ajax
end
scenario 'does show stop button' do
expect(page).to have_link('Stop environment')
end
scenario 'does start build when stop button clicked' do
click_link('Stop environment')
expect(page).to have_content('close_app')
end
context 'for reporter' do
given(:role) { :reporter }
scenario 'does not show stop button' do
expect(page).not_to have_link('Stop environment')
end
end
end
2016-10-04 10:03:13 -04:00
end
end