summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-10-23 12:06:18 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2019-10-23 12:06:18 +0000
commit09ffaae1328da918056512ddc674913f0bb7b134 (patch)
tree5d53f44823cbc132d9f61c60f9781ca9dc9f2e44 /spec
parentb3e4ec8e8adf4fe96c982124e91b6a05021a9cda (diff)
downloadgitlab-ce-09ffaae1328da918056512ddc674913f0bb7b134.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r--spec/controllers/application_controller_spec.rb20
-rw-r--r--spec/lib/gitlab/sidekiq_middleware/metrics_spec.rb20
-rw-r--r--spec/lib/gitlab/sql/recursive_cte_spec.rb2
-rw-r--r--spec/lib/gitlab/sql/union_spec.rb4
-rw-r--r--spec/migrations/schedule_fix_gitlab_com_pages_access_level_spec.rb2
-rw-r--r--spec/models/concerns/from_union_spec.rb6
6 files changed, 25 insertions, 29 deletions
diff --git a/spec/controllers/application_controller_spec.rb b/spec/controllers/application_controller_spec.rb
index ed91b5973b8..f4ac539136c 100644
--- a/spec/controllers/application_controller_spec.rb
+++ b/spec/controllers/application_controller_spec.rb
@@ -96,30 +96,14 @@ describe ApplicationController do
request.path = '/-/peek'
end
- # TODO:
- # remove line below once `privacy_policy_update_callout`
- # feature flag is removed and `gon` reverts back to
- # to not setting any variables.
- if Gitlab.ee?
- it_behaves_like 'setting gon variables'
- else
- it_behaves_like 'not setting gon variables'
- end
+ it_behaves_like 'not setting gon variables'
end
end
context 'with json format' do
let(:format) { :json }
- # TODO:
- # remove line below once `privacy_policy_update_callout`
- # feature flag is removed and `gon` reverts back to
- # to not setting any variables.
- if Gitlab.ee?
- it_behaves_like 'setting gon variables'
- else
- it_behaves_like 'not setting gon variables'
- end
+ it_behaves_like 'not setting gon variables'
end
end
diff --git a/spec/lib/gitlab/sidekiq_middleware/metrics_spec.rb b/spec/lib/gitlab/sidekiq_middleware/metrics_spec.rb
index ec4c8560f22..df16b9d073c 100644
--- a/spec/lib/gitlab/sidekiq_middleware/metrics_spec.rb
+++ b/spec/lib/gitlab/sidekiq_middleware/metrics_spec.rb
@@ -44,12 +44,14 @@ describe Gitlab::SidekiqMiddleware::Metrics do
it 'sets queue specific metrics' do
labels = { queue: :test }
+ labels_with_job_status = { queue: :test, job_status: :done }
allow(middleware).to receive(:get_thread_cputime).and_return(1, 3)
+ allow(Gitlab::Metrics::System).to receive(:monotonic_time).and_return(2, 3)
- expect(user_execution_seconds_metric).to receive(:observe).with(labels, 2)
expect(running_jobs_metric).to receive(:increment).with(labels, 1)
expect(running_jobs_metric).to receive(:increment).with(labels, -1)
- expect(completion_seconds_metric).to receive(:observe).with(labels, kind_of(Numeric))
+ expect(user_execution_seconds_metric).to receive(:observe).with(labels_with_job_status, 2)
+ expect(completion_seconds_metric).to receive(:observe).with(labels_with_job_status, 1)
middleware.call(worker, {}, :test) { nil }
end
@@ -74,8 +76,18 @@ describe Gitlab::SidekiqMiddleware::Metrics do
context 'when error is raised' do
it 'sets sidekiq_jobs_failed_total and reraises' do
- expect(failed_total_metric).to receive(:increment)
- expect { middleware.call(worker, {}, :test) { raise } }.to raise_error
+ labels = { queue: :test }
+ labels_with_job_status = { queue: :test, job_status: :fail }
+ allow(middleware).to receive(:get_thread_cputime).and_return(1, 4)
+ allow(Gitlab::Metrics::System).to receive(:monotonic_time).and_return(2, 6)
+
+ expect(running_jobs_metric).to receive(:increment).with(labels, 1)
+ expect(running_jobs_metric).to receive(:increment).with(labels, -1)
+ expect(failed_total_metric).to receive(:increment).with(labels, 1)
+ expect(user_execution_seconds_metric).to receive(:observe).with(labels_with_job_status, 3)
+ expect(completion_seconds_metric).to receive(:observe).with(labels_with_job_status, 4)
+
+ expect { middleware.call(worker, {}, :test) { raise StandardError, "Failed" } }.to raise_error(StandardError, "Failed")
end
end
end
diff --git a/spec/lib/gitlab/sql/recursive_cte_spec.rb b/spec/lib/gitlab/sql/recursive_cte_spec.rb
index 20e36c224b0..b15be56dd6d 100644
--- a/spec/lib/gitlab/sql/recursive_cte_spec.rb
+++ b/spec/lib/gitlab/sql/recursive_cte_spec.rb
@@ -20,7 +20,7 @@ describe Gitlab::SQL::RecursiveCTE do
[rel1.except(:order).to_sql, rel2.except(:order).to_sql]
end
- expect(sql).to eq("#{name} AS (#{sql1}\nUNION\n#{sql2})")
+ expect(sql).to eq("#{name} AS ((#{sql1})\nUNION\n(#{sql2}))")
end
end
diff --git a/spec/lib/gitlab/sql/union_spec.rb b/spec/lib/gitlab/sql/union_spec.rb
index f8f6da19fa5..f736614ae53 100644
--- a/spec/lib/gitlab/sql/union_spec.rb
+++ b/spec/lib/gitlab/sql/union_spec.rb
@@ -14,7 +14,7 @@ describe Gitlab::SQL::Union do
it 'returns a String joining relations together using a UNION' do
union = described_class.new([relation_1, relation_2])
- expect(union.to_sql).to eq("#{to_sql(relation_1)}\nUNION\n#{to_sql(relation_2)}")
+ expect(union.to_sql).to eq("(#{to_sql(relation_1)})\nUNION\n(#{to_sql(relation_2)})")
end
it 'skips Model.none segements' do
@@ -22,7 +22,7 @@ describe Gitlab::SQL::Union do
union = described_class.new([empty_relation, relation_1, relation_2])
expect {User.where("users.id IN (#{union.to_sql})").to_a}.not_to raise_error
- expect(union.to_sql).to eq("#{to_sql(relation_1)}\nUNION\n#{to_sql(relation_2)}")
+ expect(union.to_sql).to eq("(#{to_sql(relation_1)})\nUNION\n(#{to_sql(relation_2)})")
end
it 'uses UNION ALL when removing duplicates is disabled' do
diff --git a/spec/migrations/schedule_fix_gitlab_com_pages_access_level_spec.rb b/spec/migrations/schedule_fix_gitlab_com_pages_access_level_spec.rb
index db312242bea..88e5c101d32 100644
--- a/spec/migrations/schedule_fix_gitlab_com_pages_access_level_spec.rb
+++ b/spec/migrations/schedule_fix_gitlab_com_pages_access_level_spec.rb
@@ -1,7 +1,7 @@
require 'spec_helper'
require Rails.root.join('db', 'post_migrate', '20191017045817_schedule_fix_gitlab_com_pages_access_level.rb')
-describe ScheduleFixGitlabComPagesAccessLevel, :migration, :sidekiq, schema: 2019_10_16_072826 do
+describe ScheduleFixGitlabComPagesAccessLevel, :migration, :sidekiq_might_not_need_inline, schema: 2019_10_16_072826 do
using RSpec::Parameterized::TableSyntax
let(:migration_name) { 'FixGitlabComPagesAccessLevel' }
diff --git a/spec/models/concerns/from_union_spec.rb b/spec/models/concerns/from_union_spec.rb
index ee427a667c6..735e14b47ec 100644
--- a/spec/models/concerns/from_union_spec.rb
+++ b/spec/models/concerns/from_union_spec.rb
@@ -15,7 +15,7 @@ describe FromUnion do
it 'selects from the results of the UNION' do
query = model.from_union([model.where(id: 1), model.where(id: 2)])
- expect(query.to_sql).to match(/FROM \(SELECT.+UNION.+SELECT.+\) users/m)
+ expect(query.to_sql).to match(/FROM \(\(SELECT.+\)\nUNION\n\(SELECT.+\)\) users/m)
end
it 'supports the use of a custom alias for the sub query' do
@@ -24,7 +24,7 @@ describe FromUnion do
alias_as: 'kittens'
)
- expect(query.to_sql).to match(/FROM \(SELECT.+UNION.+SELECT.+\) kittens/m)
+ expect(query.to_sql).to match(/FROM \(\(SELECT.+\)\nUNION\n\(SELECT.+\)\) kittens/m)
end
it 'supports keeping duplicate rows' do
@@ -34,7 +34,7 @@ describe FromUnion do
)
expect(query.to_sql)
- .to match(/FROM \(SELECT.+UNION ALL.+SELECT.+\) users/m)
+ .to match(/FROM \(\(SELECT.+\)\nUNION ALL\n\(SELECT.+\)\) users/m)
end
end
end