summaryrefslogtreecommitdiff
path: root/spec/views/projects/ci/lints/show.html.haml_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/views/projects/ci/lints/show.html.haml_spec.rb')
-rw-r--r--spec/views/projects/ci/lints/show.html.haml_spec.rb34
1 files changed, 18 insertions, 16 deletions
diff --git a/spec/views/projects/ci/lints/show.html.haml_spec.rb b/spec/views/projects/ci/lints/show.html.haml_spec.rb
index a71cea6d3c8..f59ad3f5f84 100644
--- a/spec/views/projects/ci/lints/show.html.haml_spec.rb
+++ b/spec/views/projects/ci/lints/show.html.haml_spec.rb
@@ -4,16 +4,16 @@ require 'spec_helper'
RSpec.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)) }
+ let_it_be(:user) { create(:user) }
+ let_it_be(:project) { create(:project, :repository) }
+ let(:lint) { Gitlab::Ci::Lint.new(project: project, current_user: user) }
+ let(:result) { lint.validate(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)
+ assign(:result, result)
+ stub_feature_flags(ci_lint_vue: false)
end
context 'when builds attrbiutes contain HTML nodes' do
@@ -66,10 +66,8 @@ RSpec.describe 'projects/ci/lints/show' do
before do
assign(:project, project)
- assign(:status, true)
- assign(:builds, config_processor.builds)
- assign(:stages, config_processor.stages)
- assign(:jobs, config_processor.jobs)
+ assign(:result, result)
+ stub_feature_flags(ci_lint_vue: false)
end
it 'shows the correct values' do
@@ -85,13 +83,13 @@ RSpec.describe 'projects/ci/lints/show' do
context 'when content has warnings' do
before do
- assign(:warnings, ['Warning 1', 'Warning 2'])
+ allow(result).to receive(:warnings).and_return(['Warning 1', 'Warning 2'])
end
it 'shows warning messages' do
render
- expect(rendered).to have_content('Warning:')
+ expect(rendered).to have_content('2 warning(s) found:')
expect(rendered).to have_content('Warning 1')
expect(rendered).to have_content('Warning 2')
end
@@ -99,11 +97,15 @@ RSpec.describe 'projects/ci/lints/show' do
end
context 'when the content is invalid' do
+ let(:content) { double(:content) }
+
before do
+ allow(result).to receive(:warnings).and_return(['Warning 1', 'Warning 2'])
+ allow(result).to receive(:errors).and_return(['Undefined error'])
+
assign(:project, project)
- assign(:status, false)
- assign(:errors, ['Undefined error'])
- assign(:warnings, ['Warning 1', 'Warning 2'])
+ assign(:result, result)
+ stub_feature_flags(ci_lint_vue: false)
end
it 'shows error message' do
@@ -117,7 +119,7 @@ RSpec.describe 'projects/ci/lints/show' do
it 'shows warning messages' do
render
- expect(rendered).to have_content('Warning:')
+ expect(rendered).to have_content('2 warning(s) found:')
expect(rendered).to have_content('Warning 1')
expect(rendered).to have_content('Warning 2')
end