diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-27 15:08:16 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-27 15:08:16 +0000 |
commit | fb73ca3398c2ac49a616ab553e117b0586089702 (patch) | |
tree | c2f787ac97df38569c59cd0e967331ec1ead6d7e /spec/lib | |
parent | b6b8f7dc871e73f29af55f06a773136a7242df57 (diff) | |
download | gitlab-ce-fb73ca3398c2ac49a616ab553e117b0586089702.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib')
-rw-r--r-- | spec/lib/gitlab/backtrace_cleaner_spec.rb | 50 | ||||
-rw-r--r-- | spec/lib/gitlab/grape_logging/loggers/exception_logger_spec.rb | 2 | ||||
-rw-r--r-- | spec/lib/gitlab/profiler_spec.rb | 45 | ||||
-rw-r--r-- | spec/lib/gitlab/repository_cache_spec.rb | 2 | ||||
-rw-r--r-- | spec/lib/gitlab/repository_set_cache_spec.rb | 2 | ||||
-rw-r--r-- | spec/lib/gitlab/sidekiq_logging/exception_handler_spec.rb | 2 |
6 files changed, 54 insertions, 49 deletions
diff --git a/spec/lib/gitlab/backtrace_cleaner_spec.rb b/spec/lib/gitlab/backtrace_cleaner_spec.rb new file mode 100644 index 00000000000..f3aded9faad --- /dev/null +++ b/spec/lib/gitlab/backtrace_cleaner_spec.rb @@ -0,0 +1,50 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe Gitlab::BacktraceCleaner do + describe '.clean_backtrace' do + it 'uses the Rails backtrace cleaner' do + backtrace = [] + + expect(Rails.backtrace_cleaner).to receive(:clean).with(backtrace) + + described_class.clean_backtrace(backtrace) + end + + it 'removes lines from IGNORE_BACKTRACES' do + backtrace = [ + "lib/gitlab/gitaly_client.rb:294:in `block (2 levels) in migrate'", + "lib/gitlab/gitaly_client.rb:331:in `allow_n_plus_1_calls'", + "lib/gitlab/gitaly_client.rb:280:in `block in migrate'", + "lib/gitlab/metrics/influx_db.rb:103:in `measure'", + "lib/gitlab/gitaly_client.rb:278:in `migrate'", + "lib/gitlab/git/repository.rb:1451:in `gitaly_migrate'", + "lib/gitlab/git/commit.rb:66:in `find'", + "app/models/repository.rb:1047:in `find_commit'", + "lib/gitlab/metrics/instrumentation.rb:159:in `block in find_commit'", + "lib/gitlab/metrics/method_call.rb:36:in `measure'", + "lib/gitlab/metrics/instrumentation.rb:159:in `find_commit'", + "app/models/repository.rb:113:in `commit'", + "lib/gitlab/i18n.rb:50:in `with_locale'", + "lib/gitlab/middleware/multipart.rb:95:in `call'", + "lib/gitlab/request_profiler/middleware.rb:14:in `call'", + "ee/lib/gitlab/database/load_balancing/rack_middleware.rb:37:in `call'", + "ee/lib/gitlab/jira/middleware.rb:15:in `call'" + ] + + expect(described_class.clean_backtrace(backtrace)) + .to eq([ + "lib/gitlab/gitaly_client.rb:294:in `block (2 levels) in migrate'", + "lib/gitlab/gitaly_client.rb:331:in `allow_n_plus_1_calls'", + "lib/gitlab/gitaly_client.rb:280:in `block in migrate'", + "lib/gitlab/gitaly_client.rb:278:in `migrate'", + "lib/gitlab/git/repository.rb:1451:in `gitaly_migrate'", + "lib/gitlab/git/commit.rb:66:in `find'", + "app/models/repository.rb:1047:in `find_commit'", + "app/models/repository.rb:113:in `commit'", + "ee/lib/gitlab/jira/middleware.rb:15:in `call'" + ]) + end + end +end diff --git a/spec/lib/gitlab/grape_logging/loggers/exception_logger_spec.rb b/spec/lib/gitlab/grape_logging/loggers/exception_logger_spec.rb index 0cfda80b854..c9021e2f436 100644 --- a/spec/lib/gitlab/grape_logging/loggers/exception_logger_spec.rb +++ b/spec/lib/gitlab/grape_logging/loggers/exception_logger_spec.rb @@ -39,7 +39,7 @@ describe Gitlab::GrapeLogging::Loggers::ExceptionLogger do before do current_backtrace = caller allow(exception).to receive(:backtrace).and_return(current_backtrace) - expected['exception.backtrace'] = Gitlab::Profiler.clean_backtrace(current_backtrace) + expected['exception.backtrace'] = Gitlab::BacktraceCleaner.clean_backtrace(current_backtrace) end it 'includes the backtrace' do diff --git a/spec/lib/gitlab/profiler_spec.rb b/spec/lib/gitlab/profiler_spec.rb index a19392f4bcb..c27e3ca7ace 100644 --- a/spec/lib/gitlab/profiler_spec.rb +++ b/spec/lib/gitlab/profiler_spec.rb @@ -120,51 +120,6 @@ describe Gitlab::Profiler do end end - describe '.clean_backtrace' do - it 'uses the Rails backtrace cleaner' do - backtrace = [] - - expect(Rails.backtrace_cleaner).to receive(:clean).with(backtrace) - - described_class.clean_backtrace(backtrace) - end - - it 'removes lines from IGNORE_BACKTRACES' do - backtrace = [ - "lib/gitlab/gitaly_client.rb:294:in `block (2 levels) in migrate'", - "lib/gitlab/gitaly_client.rb:331:in `allow_n_plus_1_calls'", - "lib/gitlab/gitaly_client.rb:280:in `block in migrate'", - "lib/gitlab/metrics/influx_db.rb:103:in `measure'", - "lib/gitlab/gitaly_client.rb:278:in `migrate'", - "lib/gitlab/git/repository.rb:1451:in `gitaly_migrate'", - "lib/gitlab/git/commit.rb:66:in `find'", - "app/models/repository.rb:1047:in `find_commit'", - "lib/gitlab/metrics/instrumentation.rb:159:in `block in find_commit'", - "lib/gitlab/metrics/method_call.rb:36:in `measure'", - "lib/gitlab/metrics/instrumentation.rb:159:in `find_commit'", - "app/models/repository.rb:113:in `commit'", - "lib/gitlab/i18n.rb:50:in `with_locale'", - "lib/gitlab/middleware/multipart.rb:95:in `call'", - "lib/gitlab/request_profiler/middleware.rb:14:in `call'", - "ee/lib/gitlab/database/load_balancing/rack_middleware.rb:37:in `call'", - "ee/lib/gitlab/jira/middleware.rb:15:in `call'" - ] - - expect(described_class.clean_backtrace(backtrace)) - .to eq([ - "lib/gitlab/gitaly_client.rb:294:in `block (2 levels) in migrate'", - "lib/gitlab/gitaly_client.rb:331:in `allow_n_plus_1_calls'", - "lib/gitlab/gitaly_client.rb:280:in `block in migrate'", - "lib/gitlab/gitaly_client.rb:278:in `migrate'", - "lib/gitlab/git/repository.rb:1451:in `gitaly_migrate'", - "lib/gitlab/git/commit.rb:66:in `find'", - "app/models/repository.rb:1047:in `find_commit'", - "app/models/repository.rb:113:in `commit'", - "ee/lib/gitlab/jira/middleware.rb:15:in `call'" - ]) - end - end - describe '.with_custom_logger' do context 'when the logger is set' do it 'uses the replacement logger for the duration of the block' do diff --git a/spec/lib/gitlab/repository_cache_spec.rb b/spec/lib/gitlab/repository_cache_spec.rb index 6a684595eb8..1b7dd1766da 100644 --- a/spec/lib/gitlab/repository_cache_spec.rb +++ b/spec/lib/gitlab/repository_cache_spec.rb @@ -3,8 +3,8 @@ require 'spec_helper' describe Gitlab::RepositoryCache do + let_it_be(:project) { create(:project) } let(:backend) { double('backend').as_null_object } - let(:project) { create(:project) } let(:repository) { project.repository } let(:namespace) { "#{repository.full_path}:#{project.id}" } let(:cache) { described_class.new(repository, backend: backend) } diff --git a/spec/lib/gitlab/repository_set_cache_spec.rb b/spec/lib/gitlab/repository_set_cache_spec.rb index 87e51f801e5..de0f3602346 100644 --- a/spec/lib/gitlab/repository_set_cache_spec.rb +++ b/spec/lib/gitlab/repository_set_cache_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' describe Gitlab::RepositorySetCache, :clean_gitlab_redis_cache do - let(:project) { create(:project) } + let_it_be(:project) { create(:project) } let(:repository) { project.repository } let(:namespace) { "#{repository.full_path}:#{project.id}" } let(:cache) { described_class.new(repository) } diff --git a/spec/lib/gitlab/sidekiq_logging/exception_handler_spec.rb b/spec/lib/gitlab/sidekiq_logging/exception_handler_spec.rb index 24b6090cb19..a79a0678e2b 100644 --- a/spec/lib/gitlab/sidekiq_logging/exception_handler_spec.rb +++ b/spec/lib/gitlab/sidekiq_logging/exception_handler_spec.rb @@ -33,7 +33,7 @@ describe Gitlab::SidekiqLogging::ExceptionHandler do error_class: 'RuntimeError', error_message: exception_message, context: 'Test', - error_backtrace: Gitlab::Profiler.clean_backtrace(backtrace) + error_backtrace: Gitlab::BacktraceCleaner.clean_backtrace(backtrace) ) expect(logger).to receive(:warn).with(expected_data) |