debian-mirror-gitlab/spec/views/ci/lints/show.html.haml_spec.rb

98 lines
2.3 KiB
Ruby
Raw Normal View History

2016-10-01 15:18:49 +05:30
require 'spec_helper'
describe 'ci/lints/show' do
2017-08-17 22:00:37 +05:30
include Devise::Test::ControllerHelpers
2016-10-01 15:18:49 +05:30
2016-11-03 12:29:30 +05:30
describe 'XSS protection' do
let(:config_processor) { Ci::GitlabCiYamlProcessor.new(YAML.dump(content)) }
before do
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
2016-10-01 15:18:49 +05:30
end
2016-11-03 12:29:30 +05:30
let(:content) do
{
build_template: {
script: './build.sh',
tags: ['dotnet'],
only: ['test@dude/repo'],
except: ['deploy'],
environment: 'testing'
}
}
end
let(:config_processor) { Ci::GitlabCiYamlProcessor.new(YAML.dump(content)) }
context 'when the content is valid' do
before do
assign(:status, true)
assign(:builds, config_processor.builds)
assign(:stages, config_processor.stages)
assign(:jobs, config_processor.jobs)
2016-10-01 15:18:49 +05:30
end
2016-11-03 12:29:30 +05:30
it 'shows the correct values' do
2016-10-01 15:18:49 +05:30
render
2016-11-03 12:29:30 +05:30
expect(rendered).to have_content('Tag list: dotnet')
expect(rendered).to have_content('Refs only: test@dude/repo')
expect(rendered).to have_content('Refs except: deploy')
expect(rendered).to have_content('Environment: testing')
expect(rendered).to have_content('When: on_success')
2016-10-01 15:18:49 +05:30
end
end
2016-11-03 12:29:30 +05:30
context 'when the content is invalid' do
before do
assign(:status, false)
assign(:error, 'Undefined error')
2016-10-01 15:18:49 +05:30
end
2016-11-03 12:29:30 +05:30
it 'shows error message' do
2016-10-01 15:18:49 +05:30
render
2016-11-03 12:29:30 +05:30
expect(rendered).to have_content('Status: syntax is incorrect')
expect(rendered).to have_content('Error: Undefined error')
expect(rendered).not_to have_content('Tag list:')
2016-10-01 15:18:49 +05:30
end
end
end