From 80f9aff34b07fd8dc490a06cd6281b5af4310438 Mon Sep 17 00:00:00 2001 From: Mayra Cabrera Date: Tue, 13 Mar 2018 11:57:16 -0600 Subject: Make ci/lint page context aware: - Create ci/lints controller inside project/ - Move js pages to be inside projects/ - Copy view ci/lint view to be inside project folder - Remove ci/lint view and js files Closes #43603 --- spec/views/ci/lints/show.html.haml_spec.rb | 98 -------------------- .../views/projects/ci/lints/show.html.haml_spec.rb | 102 +++++++++++++++++++++ 2 files changed, 102 insertions(+), 98 deletions(-) delete mode 100644 spec/views/ci/lints/show.html.haml_spec.rb create mode 100644 spec/views/projects/ci/lints/show.html.haml_spec.rb (limited to 'spec/views') diff --git a/spec/views/ci/lints/show.html.haml_spec.rb b/spec/views/ci/lints/show.html.haml_spec.rb deleted file mode 100644 index ded320793ea..00000000000 --- a/spec/views/ci/lints/show.html.haml_spec.rb +++ /dev/null @@ -1,98 +0,0 @@ -require 'spec_helper' - -describe 'ci/lints/show' do - include Devise::Test::ControllerHelpers - - describe 'XSS protection' do - let(:config_processor) { Gitlab::Ci::YamlProcessor.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: '

rspec

', - 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 - - let(:content) do - { - build_template: { - script: './build.sh', - tags: ['dotnet'], - only: ['test@dude/repo'], - except: ['deploy'], - environment: 'testing' - } - } - end - - let(:config_processor) { Gitlab::Ci::YamlProcessor.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) - end - - it 'shows the correct values' do - render - - expect(rendered).to have_content('Tag list: dotnet') - expect(rendered).to have_content('Only policy: refs, test@dude/repo') - expect(rendered).to have_content('Except policy: refs, deploy') - expect(rendered).to have_content('Environment: testing') - expect(rendered).to have_content('When: on_success') - end - end - - context 'when the content is invalid' do - before do - assign(:status, false) - assign(:error, 'Undefined error') - end - - it 'shows error message' do - render - - 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:') - end - end -end diff --git a/spec/views/projects/ci/lints/show.html.haml_spec.rb b/spec/views/projects/ci/lints/show.html.haml_spec.rb new file mode 100644 index 00000000000..b50acc54276 --- /dev/null +++ b/spec/views/projects/ci/lints/show.html.haml_spec.rb @@ -0,0 +1,102 @@ +require 'spec_helper' + +describe 'projects/ci/lints/show' do + include Devise::Test::ControllerHelpers + let(:project) { create(:project, :repository) } + + describe 'XSS protection' do + let(:config_processor) { Gitlab::Ci::YamlProcessor.new(YAML.dump(content)) } + + 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: '

rspec

', + 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 + + let(:content) do + { + build_template: { + script: './build.sh', + tags: ['dotnet'], + only: ['test@dude/repo'], + except: ['deploy'], + environment: 'testing' + } + } + end + + let(:config_processor) { Gitlab::Ci::YamlProcessor.new(YAML.dump(content)) } + + context 'when the content is valid' 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 + + it 'shows the correct values' do + render + + expect(rendered).to have_content('Tag list: dotnet') + expect(rendered).to have_content('Only policy: refs, test@dude/repo') + expect(rendered).to have_content('Except policy: refs, deploy') + expect(rendered).to have_content('Environment: testing') + expect(rendered).to have_content('When: on_success') + end + end + + context 'when the content is invalid' do + before do + assign(:project, project) + assign(:status, false) + assign(:error, 'Undefined error') + end + + it 'shows error message' do + render + + 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:') + end + end +end -- cgit v1.2.3