gitlab-org--gitlab-foss/spec/views/projects/ci/lints/show.html.haml_spec.rb

100 lines
2.4 KiB
Ruby
Raw Normal View History

2016-09-09 08:43:43 -04:00
require 'spec_helper'
describe 'projects/ci/lints/show' do
include Devise::Test::ControllerHelpers
let(:project) { create(:project, :repository) }
let(:config_processor) { Gitlab::Ci::YamlProcessor.new(YAML.dump(content)) }
describe 'XSS protection' do
before do
assign(:project, project)
assign(:status, true)
assign(:builds, config_processor.builds)
assign(:stages, config_processor.stages)
assign(:jobs, config_processor.jobs)
end
context 'when builds attrbiutes contain HTML nodes' do
let(:content) do
{
rspec: {
script: '<h1>rspec</h1>',
stage: 'test'
}
}
end
it 'does not render HTML elements' do
render
expect(rendered).not_to have_css('h1', text: 'rspec')
end
end
context 'when builds attributes do not contain HTML nodes' do
let(:content) do
{
rspec: {
script: 'rspec',
stage: 'test'
}
}
end
it 'shows configuration in the table' do
render
expect(rendered).to have_css('td pre', text: 'rspec')
end
end
end
context 'when the content is valid' do
let(:content) do
{
build_template: {
script: './build.sh',
tags: ['dotnet'],
only: ['test@dude/repo'],
except: ['deploy'],
environment: 'testing'
}
2016-09-09 08:43:43 -04:00
}
end
2016-09-09 08:43:43 -04:00
before do
assign(:project, project)
2016-09-09 08:43:43 -04:00
assign(:status, true)
assign(:builds, config_processor.builds)
assign(:stages, config_processor.stages)
2016-09-20 09:19:55 -04:00
assign(:jobs, config_processor.jobs)
2016-09-09 08:43:43 -04:00
end
2016-09-12 02:47:35 -04:00
it 'shows the correct values' do
2016-09-09 08:43:43 -04:00
render
expect(rendered).to have_content('Tag list: dotnet')
2017-08-31 09:30:48 -04:00
expect(rendered).to have_content('Only policy: refs, test@dude/repo')
expect(rendered).to have_content('Except policy: refs, deploy')
2016-09-09 08:43:43 -04:00
expect(rendered).to have_content('Environment: testing')
expect(rendered).to have_content('When: on_success')
end
end
2016-09-20 09:19:55 -04:00
context 'when the content is invalid' do
before do
assign(:project, project)
2016-09-20 09:19:55 -04:00
assign(:status, false)
assign(:error, 'Undefined error')
end
it 'shows error message' do
render
2016-09-20 11:28:54 -04:00
expect(rendered).to have_content('Status: syntax is incorrect')
2016-09-20 09:19:55 -04:00
expect(rendered).to have_content('Error: Undefined error')
expect(rendered).not_to have_content('Tag list:')
end
end
2016-09-09 08:43:43 -04:00
end