2015-08-25 21:42:46 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2017-10-03 04:35:01 -04:00
|
|
|
describe 'CI Lint', :js do
|
2015-08-25 21:42:46 -04:00
|
|
|
before do
|
2017-06-21 19:44:10 -04:00
|
|
|
sign_in(create(:user))
|
2015-08-25 21:42:46 -04:00
|
|
|
end
|
|
|
|
|
2015-12-22 03:40:32 -05:00
|
|
|
describe 'YAML parsing' do
|
2015-12-22 02:47:23 -05:00
|
|
|
before do
|
|
|
|
visit ci_lint_path
|
2017-01-04 16:44:16 -05:00
|
|
|
# Ace editor updates a hidden textarea and it happens asynchronously
|
|
|
|
# `sleep 0.1` is actually needed here because of this
|
2017-10-16 13:37:52 -04:00
|
|
|
find('#ci-editor')
|
2017-01-04 16:44:16 -05:00
|
|
|
execute_script("ace.edit('ci-editor').setValue(" + yaml_content.to_json + ");")
|
|
|
|
sleep 0.1
|
2015-12-22 02:47:23 -05:00
|
|
|
click_on 'Validate'
|
2015-08-25 21:42:46 -04:00
|
|
|
end
|
|
|
|
|
2015-12-22 02:47:23 -05:00
|
|
|
context 'YAML is correct' do
|
|
|
|
let(:yaml_content) do
|
|
|
|
File.read(Rails.root.join('spec/support/gitlab_stubs/gitlab_ci.yml'))
|
|
|
|
end
|
|
|
|
|
2016-07-25 14:16:19 -04:00
|
|
|
it 'parses Yaml' do
|
2015-12-22 02:47:23 -05:00
|
|
|
within "table" do
|
|
|
|
expect(page).to have_content('Job - rspec')
|
|
|
|
expect(page).to have_content('Job - spinach')
|
|
|
|
expect(page).to have_content('Deploy Job - staging')
|
|
|
|
expect(page).to have_content('Deploy Job - production')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'YAML is incorrect' do
|
|
|
|
let(:yaml_content) { '' }
|
|
|
|
|
|
|
|
it 'displays information about an error' do
|
|
|
|
expect(page).to have_content('Status: syntax is incorrect')
|
|
|
|
expect(page).to have_content('Error: Please provide content of .gitlab-ci.yml')
|
|
|
|
end
|
|
|
|
end
|
2016-01-11 07:34:12 -05:00
|
|
|
|
|
|
|
describe 'YAML revalidate' do
|
|
|
|
let(:yaml_content) { 'my yaml content' }
|
|
|
|
|
|
|
|
it 'loads previous YAML content after validation' do
|
2017-01-04 16:44:16 -05:00
|
|
|
expect(page).to have_field('content', with: 'my yaml content', visible: false, type: 'textarea')
|
2016-01-11 07:34:12 -05:00
|
|
|
end
|
|
|
|
end
|
2015-08-25 21:42:46 -04:00
|
|
|
end
|
|
|
|
end
|