Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-02-18 13:34:06 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-02-18 13:34:06 +0300
commit859a6fb938bb9ee2a317c46dfa4fcc1af49608f0 (patch)
treed7f2700abe6b4ffcb2dcfc80631b2d87d0609239 /spec/presenters
parent446d496a6d000c73a304be52587cd9bbc7493136 (diff)
Add latest changes from gitlab-org/gitlab@13-9-stable-eev13.9.0-rc42
Diffstat (limited to 'spec/presenters')
-rw-r--r--spec/presenters/ci/build_runner_presenter_spec.rb14
-rw-r--r--spec/presenters/ci/pipeline_artifacts/code_quality_mr_diff_presenter_spec.rb66
-rw-r--r--spec/presenters/gitlab/whats_new/item_presenter_spec.rb29
-rw-r--r--spec/presenters/project_presenter_spec.rb2
4 files changed, 69 insertions, 42 deletions
diff --git a/spec/presenters/ci/build_runner_presenter_spec.rb b/spec/presenters/ci/build_runner_presenter_spec.rb
index f78ad38f4e8..43b677483ce 100644
--- a/spec/presenters/ci/build_runner_presenter_spec.rb
+++ b/spec/presenters/ci/build_runner_presenter_spec.rb
@@ -17,7 +17,7 @@ RSpec.describe Ci::BuildRunnerPresenter do
describe '#artifacts' do
context "when option contains archive-type artifacts" do
- let(:build) { create(:ci_build, options: { artifacts: archive } ) }
+ let(:build) { create(:ci_build, options: { artifacts: archive }) }
it 'presents correct hash' do
expect(presenter.artifacts.first).to include(archive_expectation)
@@ -196,16 +196,6 @@ RSpec.describe Ci::BuildRunnerPresenter do
expect(subject[0]).to match(/^\+[0-9a-f]{40}:refs\/pipelines\/[0-9]+$/)
end
- context 'when the scalability_ci_fetch_sha feature flag is disabled' do
- before do
- stub_feature_flags(scalability_ci_fetch_sha: false)
- end
-
- it 'fetches the ref by name' do
- expect(subject[0]).to eq("+refs/pipelines/#{pipeline.id}:refs/pipelines/#{pipeline.id}")
- end
- end
-
context 'when ref is tag' do
let(:build) { create(:ci_build, :tag) }
@@ -259,7 +249,7 @@ RSpec.describe Ci::BuildRunnerPresenter do
it 'returns the correct refspecs' do
is_expected.to contain_exactly("+#{pipeline.sha}:refs/pipelines/#{pipeline.id}",
- "+refs/heads/#{build.ref}:refs/remotes/origin/#{build.ref}")
+ "+refs/heads/#{build.ref}:refs/remotes/origin/#{build.ref}")
end
end
end
diff --git a/spec/presenters/ci/pipeline_artifacts/code_quality_mr_diff_presenter_spec.rb b/spec/presenters/ci/pipeline_artifacts/code_quality_mr_diff_presenter_spec.rb
new file mode 100644
index 00000000000..06d5422eed3
--- /dev/null
+++ b/spec/presenters/ci/pipeline_artifacts/code_quality_mr_diff_presenter_spec.rb
@@ -0,0 +1,66 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe Ci::PipelineArtifacts::CodeQualityMrDiffPresenter do
+ let(:pipeline_artifact) { create(:ci_pipeline_artifact, :with_codequality_mr_diff_report) }
+
+ subject(:presenter) { described_class.new(pipeline_artifact) }
+
+ describe '#for_files' do
+ subject(:quality_data) { presenter.for_files(filenames) }
+
+ context 'when code quality has data' do
+ context 'when filenames is empty' do
+ let(:filenames) { %w() }
+
+ it 'returns hash without quality' do
+ expect(quality_data).to match(files: {})
+ end
+ end
+
+ context 'when filenames do not match code quality data' do
+ let(:filenames) { %w(demo.rb) }
+
+ it 'returns hash without quality' do
+ expect(quality_data).to match(files: {})
+ end
+ end
+
+ context 'when filenames matches code quality data' do
+ context 'when asking for one filename' do
+ let(:filenames) { %w(file_a.rb) }
+
+ it 'returns quality for the given filename' do
+ expect(quality_data).to match(
+ files: {
+ "file_a.rb" => [
+ { line: 10, description: "Avoid parameter lists longer than 5 parameters. [12/5]", severity: "major" },
+ { line: 10, description: "Method `new_array` has 12 arguments (exceeds 4 allowed). Consider refactoring.", severity: "minor" }
+ ]
+ }
+ )
+ end
+ end
+
+ context 'when asking for multiple filenames' do
+ let(:filenames) { %w(file_a.rb file_b.rb) }
+
+ it 'returns quality for the given filenames' do
+ expect(quality_data).to match(
+ files: {
+ "file_a.rb" => [
+ { line: 10, description: "Avoid parameter lists longer than 5 parameters. [12/5]", severity: "major" },
+ { line: 10, description: "Method `new_array` has 12 arguments (exceeds 4 allowed). Consider refactoring.", severity: "minor" }
+ ],
+ "file_b.rb" => [
+ { line: 10, description: "This cop checks for methods with too many parameters.\nThe maximum number of parameters is configurable.\nKeyword arguments can optionally be excluded from the total count.", severity: "minor" }
+ ]
+ }
+ )
+ end
+ end
+ end
+ end
+ end
+end
diff --git a/spec/presenters/gitlab/whats_new/item_presenter_spec.rb b/spec/presenters/gitlab/whats_new/item_presenter_spec.rb
deleted file mode 100644
index 9b04741aa60..00000000000
--- a/spec/presenters/gitlab/whats_new/item_presenter_spec.rb
+++ /dev/null
@@ -1,29 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-
-RSpec.describe Gitlab::WhatsNew::ItemPresenter do
- let(:present) { Gitlab::WhatsNew::ItemPresenter.present(item) }
- let(:item) { { "packages" => %w(Core Starter Premium Ultimate) } }
- let(:gitlab_com) { true }
-
- before do
- allow(Gitlab).to receive(:com?).and_return(gitlab_com)
- end
-
- describe '.present' do
- context 'when on Gitlab.com' do
- it 'transforms package names to gitlab.com friendly package names' do
- expect(present).to eq({ "packages" => %w(Free Bronze Silver Gold) })
- end
- end
-
- context 'when not on Gitlab.com' do
- let(:gitlab_com) { false }
-
- it 'does not transform package names' do
- expect(present).to eq({ "packages" => %w(Core Starter Premium Ultimate) })
- end
- end
- end
-end
diff --git a/spec/presenters/project_presenter_spec.rb b/spec/presenters/project_presenter_spec.rb
index a9050c233af..98bcbd8384b 100644
--- a/spec/presenters/project_presenter_spec.rb
+++ b/spec/presenters/project_presenter_spec.rb
@@ -350,7 +350,7 @@ RSpec.describe ProjectPresenter do
is_link: false,
label: a_string_including("New file"),
link: presenter.project_new_blob_path(project, 'master'),
- class_modifier: 'missing'
+ class_modifier: 'dashed'
)
end