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
path: root/spec
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-07-23 21:10:06 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-07-23 21:10:06 +0300
commit4a6e6c740b131b6291d553fcdab5a0612f8c099b (patch)
treec9b31140b4161e25f5395447272187e344ea9ca1 /spec
parent228eb2ee910e2fb7f9bedf713c43a30c55cf3314 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r--spec/deprecation_toolkit_env.rb1
-rw-r--r--spec/experiments/application_experiment_spec.rb29
-rw-r--r--spec/experiments/new_project_readme_content_experiment_spec.rb4
-rw-r--r--spec/lib/gitlab/ci/ansi2html_spec.rb4
-rw-r--r--spec/lib/gitlab/encoding_helper_spec.rb18
-rw-r--r--spec/lib/gitlab/graphql/markdown_field_spec.rb2
-rw-r--r--spec/rubocop/cop/graphql/id_type_spec.rb8
7 files changed, 60 insertions, 6 deletions
diff --git a/spec/deprecation_toolkit_env.rb b/spec/deprecation_toolkit_env.rb
index 8e06dcb8c75..37ff7bafc54 100644
--- a/spec/deprecation_toolkit_env.rb
+++ b/spec/deprecation_toolkit_env.rb
@@ -57,6 +57,7 @@ module DeprecationToolkitEnv
%w[
asciidoctor-2.0.12/lib/asciidoctor/extensions.rb
gitlab-labkit-0.20.0/lib/labkit/correlation/grpc/client_interceptor.rb
+ actionpack-6.1.3.2/lib/action_dispatch/routing/route_set.rb
]
end
diff --git a/spec/experiments/application_experiment_spec.rb b/spec/experiments/application_experiment_spec.rb
index 9c03910cf66..4966e508f7e 100644
--- a/spec/experiments/application_experiment_spec.rb
+++ b/spec/experiments/application_experiment_spec.rb
@@ -209,6 +209,35 @@ RSpec.describe ApplicationExperiment, :experiment do
end
end
+ describe "#process_redirect_url" do
+ using RSpec::Parameterized::TableSyntax
+
+ where(:url, :processed_url) do
+ 'https://about.gitlab.com/' | 'https://about.gitlab.com/'
+ 'https://gitlab.com/' | 'https://gitlab.com/'
+ 'http://docs.gitlab.com' | 'http://docs.gitlab.com'
+ 'https://docs.gitlab.com/some/path?foo=bar' | 'https://docs.gitlab.com/some/path?foo=bar'
+ 'http://badgitlab.com' | nil
+ 'https://gitlab.com.nefarious.net' | nil
+ 'https://unknown.gitlab.com' | nil
+ "https://badplace.com\nhttps://gitlab.com" | nil
+ 'https://gitlabbcom' | nil
+ 'https://gitlabbcom/' | nil
+ end
+
+ with_them do
+ it "returns the url or nil if invalid" do
+ allow(Gitlab).to receive(:dev_env_or_com?).and_return(true)
+ expect(subject.process_redirect_url(url)).to eq(processed_url)
+ end
+
+ it "considers all urls invalid when not on dev or com" do
+ allow(Gitlab).to receive(:dev_env_or_com?).and_return(false)
+ expect(subject.process_redirect_url(url)).to be_nil
+ end
+ end
+ end
+
context "when resolving variants" do
it "uses the default value as specified in the yaml" do
expect(Feature).to receive(:enabled?).with('namespaced_stub', subject, type: :experiment, default_enabled: :yaml)
diff --git a/spec/experiments/new_project_readme_content_experiment_spec.rb b/spec/experiments/new_project_readme_content_experiment_spec.rb
index 92a883078df..f76b8a1ded1 100644
--- a/spec/experiments/new_project_readme_content_experiment_spec.rb
+++ b/spec/experiments/new_project_readme_content_experiment_spec.rb
@@ -30,7 +30,9 @@ RSpec.describe NewProjectReadmeContentExperiment, :experiment do
end
it "renders redirect URLs" do
- expect(markdown).to include(Rails.application.routes.url_helpers.experiment_redirect_url(subject, initial_url))
+ expect(markdown).to include(
+ Rails.application.routes.url_helpers.experiment_redirect_url(subject, url: initial_url)
+ )
end
end
end
diff --git a/spec/lib/gitlab/ci/ansi2html_spec.rb b/spec/lib/gitlab/ci/ansi2html_spec.rb
index bf1f2bae7da..27c2b005a93 100644
--- a/spec/lib/gitlab/ci/ansi2html_spec.rb
+++ b/spec/lib/gitlab/ci/ansi2html_spec.rb
@@ -150,6 +150,10 @@ RSpec.describe Gitlab::Ci::Ansi2html do
expect(convert_html("\r\n")).to eq('<span><br/></span>')
end
+ it 'replaces invalid UTF-8 data' do
+ expect(convert_html("UTF-8 dashes here: ā”€ā”€ā”€\nšŸ¤šŸ¤šŸ¤šŸ¤\xF0\x9F\x90\n")).to eq("<span>UTF-8 dashes here: ā”€ā”€ā”€<br/>šŸ¤šŸ¤šŸ¤šŸ¤ļæ½<br/></span>")
+ end
+
describe "incremental update" do
shared_examples 'stateable converter' do
let(:pass1_stream) { StringIO.new(pre_text) }
diff --git a/spec/lib/gitlab/encoding_helper_spec.rb b/spec/lib/gitlab/encoding_helper_spec.rb
index cf0d1577314..268ac5dcc21 100644
--- a/spec/lib/gitlab/encoding_helper_spec.rb
+++ b/spec/lib/gitlab/encoding_helper_spec.rb
@@ -3,6 +3,8 @@
require "spec_helper"
RSpec.describe Gitlab::EncodingHelper do
+ using RSpec::Parameterized::TableSyntax
+
let(:ext_class) { Class.new { extend Gitlab::EncodingHelper } }
let(:binary_string) { File.read(Rails.root + "spec/fixtures/dk.png") }
@@ -90,6 +92,22 @@ RSpec.describe Gitlab::EncodingHelper do
end
end
+ describe '#encode_utf8_no_detect' do
+ where(:input, :expected) do
+ "abcd" | "abcd"
+ "Ē²Ē²Ē²" | "Ē²Ē²Ē²"
+ "\xC7\xB2\xC7Ē²Ē²Ē²" | "Ē²ļæ½Ē²Ē²Ē²"
+ "šŸ¤šŸ¤šŸ¤šŸ¤\xF0\x9F\x90" | "šŸ¤šŸ¤šŸ¤šŸ¤ļæ½"
+ end
+
+ with_them do
+ it 'drops invalid UTF-8' do
+ expect(ext_class.encode_utf8_no_detect(input.dup.force_encoding(Encoding::ASCII_8BIT))).to eq(expected)
+ expect(ext_class.encode_utf8_no_detect(input)).to eq(expected)
+ end
+ end
+ end
+
describe '#encode_utf8' do
[
["nil", nil, nil],
diff --git a/spec/lib/gitlab/graphql/markdown_field_spec.rb b/spec/lib/gitlab/graphql/markdown_field_spec.rb
index 44ca23f547c..a3fb0bbbed8 100644
--- a/spec/lib/gitlab/graphql/markdown_field_spec.rb
+++ b/spec/lib/gitlab/graphql/markdown_field_spec.rb
@@ -10,7 +10,7 @@ RSpec.describe Gitlab::Graphql::MarkdownField do
expect(field.name).to eq('testHtml')
expect(field.description).to eq('The GitLab Flavored Markdown rendering of `hello`')
- expect(field.type).to eq(GraphQL::STRING_TYPE)
+ expect(field.type).to eq(GraphQL::Types::String)
expect(field.to_graphql.complexity).to eq(5)
end
diff --git a/spec/rubocop/cop/graphql/id_type_spec.rb b/spec/rubocop/cop/graphql/id_type_spec.rb
index a566488b118..771e4e32dd2 100644
--- a/spec/rubocop/cop/graphql/id_type_spec.rb
+++ b/spec/rubocop/cop/graphql/id_type_spec.rb
@@ -7,10 +7,10 @@ require_relative '../../../../rubocop/cop/graphql/id_type'
RSpec.describe RuboCop::Cop::Graphql::IDType do
subject(:cop) { described_class.new }
- it 'adds an offense when GraphQL::ID_TYPE is used as a param to #argument' do
+ it 'adds an offense when GraphQL::Types::ID is used as a param to #argument' do
expect_offense(<<~TYPE)
- argument :some_arg, GraphQL::ID_TYPE, some: other, params: do_not_matter
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Do not use GraphQL::ID_TYPE, use a specific GlobalIDType instead
+ argument :some_arg, GraphQL::Types::ID, some: other, params: do_not_matter
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Do not use GraphQL::Types::ID, use a specific GlobalIDType instead
TYPE
end
@@ -18,7 +18,7 @@ RSpec.describe RuboCop::Cop::Graphql::IDType do
RuboCop::Cop::Graphql::IDType::WHITELISTED_ARGUMENTS.each do |arg|
it "does not add an offense for calls to #argument with #{arg} as argument name" do
expect_no_offenses(<<~TYPE.strip)
- argument #{arg}, GraphQL::ID_TYPE, some: other, params: do_not_matter
+ argument #{arg}, GraphQL::Types::ID, some: other, params: do_not_matter
TYPE
end
end