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/lib
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-09-30 18:09:46 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-09-30 18:09:46 +0300
commitdd240e5cc4e0abc4eef8b97962c247dab43e3777 (patch)
treebc0752959bc0713afb555e358bb43d65cf04f48e /spec/lib
parent6aa5c04c74d2d70ee7d19ef3a155b2def9dd46de (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib')
-rw-r--r--spec/lib/gitlab/ci/runner/backoff_spec.rb30
-rw-r--r--spec/lib/gitlab/pagination/offset_pagination_spec.rb30
-rw-r--r--spec/lib/gitlab/prometheus/query_variables_spec.rb4
-rw-r--r--spec/lib/gitlab/webpack/manifest_spec.rb4
4 files changed, 64 insertions, 4 deletions
diff --git a/spec/lib/gitlab/ci/runner/backoff_spec.rb b/spec/lib/gitlab/ci/runner/backoff_spec.rb
index 13455ccd692..f147d69f7cd 100644
--- a/spec/lib/gitlab/ci/runner/backoff_spec.rb
+++ b/spec/lib/gitlab/ci/runner/backoff_spec.rb
@@ -15,14 +15,36 @@ RSpec.describe Gitlab::Ci::Runner::Backoff do
end
end
end
+
+ it 'returns an integer value' do
+ freeze_time do
+ described_class.new(5.seconds.ago).then do |backoff|
+ expect(backoff.duration).to be 5
+ end
+ end
+ end
+
+ it 'returns the smallest number greater than or equal to duration' do
+ freeze_time do
+ described_class.new(0.5.seconds.ago).then do |backoff|
+ expect(backoff.duration).to be 1
+ end
+ end
+ end
end
describe '#slot' do
using RSpec::Parameterized::TableSyntax
where(:started, :slot) do
+ 0 | 0
+ 0.1 | 0
+ 0.9 | 0
1 | 0
+ 1.1 | 0
+ 1.9 | 0
2 | 0
+ 2.9 | 0
3 | 0
4 | 1
5 | 1
@@ -30,6 +52,7 @@ RSpec.describe Gitlab::Ci::Runner::Backoff do
7 | 1
8 | 2
9 | 2
+ 9.9 | 2
10 | 2
15 | 2
16 | 3
@@ -59,15 +82,22 @@ RSpec.describe Gitlab::Ci::Runner::Backoff do
using RSpec::Parameterized::TableSyntax
where(:started, :backoff) do
+ 0 | 1
+ 0.1 | 1
+ 0.9 | 1
1 | 1
+ 1.1 | 1
+ 1.9 | 1
2 | 1
3 | 1
4 | 2
5 | 2
6 | 2
+ 6.5 | 2
7 | 2
8 | 4
9 | 4
+ 9.9 | 4
10 | 4
15 | 4
16 | 8
diff --git a/spec/lib/gitlab/pagination/offset_pagination_spec.rb b/spec/lib/gitlab/pagination/offset_pagination_spec.rb
index be20f0194f7..c9a23170137 100644
--- a/spec/lib/gitlab/pagination/offset_pagination_spec.rb
+++ b/spec/lib/gitlab/pagination/offset_pagination_spec.rb
@@ -13,7 +13,7 @@ RSpec.describe Gitlab::Pagination::OffsetPagination do
let(:request_context) { double("request_context") }
- subject do
+ subject(:paginator) do
described_class.new(request_context)
end
@@ -119,6 +119,34 @@ RSpec.describe Gitlab::Pagination::OffsetPagination do
subject.paginate(resource)
end
end
+
+ it 'does not return the total headers when excluding them' do
+ expect_no_header('X-Total')
+ expect_no_header('X-Total-Pages')
+ expect_header('X-Per-Page', '2')
+ expect_header('X-Page', '1')
+
+ paginator.paginate(resource, exclude_total_headers: true)
+ end
+ end
+
+ context 'when resource is a paginatable array' do
+ let(:resource) { Kaminari.paginate_array(Project.all.to_a) }
+
+ it_behaves_like 'response with pagination headers'
+
+ it 'only returns the requested resources' do
+ expect(paginator.paginate(resource).count).to eq(2)
+ end
+
+ it 'does not return total headers when excluding them' do
+ expect_no_header('X-Total')
+ expect_no_header('X-Total-Pages')
+ expect_header('X-Per-Page', '2')
+ expect_header('X-Page', '1')
+
+ paginator.paginate(resource, exclude_total_headers: true)
+ end
end
end
diff --git a/spec/lib/gitlab/prometheus/query_variables_spec.rb b/spec/lib/gitlab/prometheus/query_variables_spec.rb
index 1422d48152a..1dbdb892a5d 100644
--- a/spec/lib/gitlab/prometheus/query_variables_spec.rb
+++ b/spec/lib/gitlab/prometheus/query_variables_spec.rb
@@ -4,12 +4,12 @@ require 'spec_helper'
RSpec.describe Gitlab::Prometheus::QueryVariables do
describe '.call' do
+ let_it_be_with_refind(:environment) { create(:environment) }
let(:project) { environment.project }
- let(:environment) { create(:environment) }
let(:slug) { environment.slug }
let(:params) { {} }
- subject { described_class.call(environment, params) }
+ subject { described_class.call(environment, **params) }
it { is_expected.to include(ci_environment_slug: slug) }
it { is_expected.to include(ci_project_name: project.name) }
diff --git a/spec/lib/gitlab/webpack/manifest_spec.rb b/spec/lib/gitlab/webpack/manifest_spec.rb
index 606a94ace8d..e3aeceda148 100644
--- a/spec/lib/gitlab/webpack/manifest_spec.rb
+++ b/spec/lib/gitlab/webpack/manifest_spec.rb
@@ -41,7 +41,9 @@ RSpec.describe Gitlab::Webpack::Manifest do
before do
# Test that config variables work while we're here
::Rails.configuration.webpack.dev_server.host = 'hostname'
- ::Rails.configuration.webpack.dev_server.port = 2000
+ ::Rails.configuration.webpack.dev_server.port = 1999
+ ::Rails.configuration.webpack.dev_server.manifest_host = 'hostname'
+ ::Rails.configuration.webpack.dev_server.manifest_port = 2000
::Rails.configuration.webpack.manifest_filename = "my_manifest.json"
::Rails.configuration.webpack.public_path = "public_path"
::Rails.configuration.webpack.output_dir = "manifest_output"