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:
Diffstat (limited to 'spec/rubocop/cop/sidekiq_redis_call_spec.rb')
-rw-r--r--spec/rubocop/cop/sidekiq_redis_call_spec.rb30
1 files changed, 30 insertions, 0 deletions
diff --git a/spec/rubocop/cop/sidekiq_redis_call_spec.rb b/spec/rubocop/cop/sidekiq_redis_call_spec.rb
new file mode 100644
index 00000000000..7d1c68bfabe
--- /dev/null
+++ b/spec/rubocop/cop/sidekiq_redis_call_spec.rb
@@ -0,0 +1,30 @@
+# frozen_string_literal: true
+
+require 'rubocop_spec_helper'
+
+require_relative '../../../rubocop/cop/sidekiq_redis_call'
+
+RSpec.describe RuboCop::Cop::SidekiqRedisCall do
+ it 'flags any use of Sidekiq.redis even without blocks' do
+ expect_offense(<<~PATTERN)
+ Sidekiq.redis
+ ^^^^^^^^^^^^^ Refrain from directly using Sidekiq.redis unless for migration. For admin operations, use Sidekiq APIs.
+ PATTERN
+ end
+
+ it 'flags the use of Sidekiq.redis in single-line blocks' do
+ expect_offense(<<~PATTERN)
+ Sidekiq.redis { |redis| yield redis }
+ ^^^^^^^^^^^^^ Refrain from directly using Sidekiq.redis unless for migration. For admin operations, use Sidekiq APIs.
+ PATTERN
+ end
+
+ it 'flags the use of Sidekiq.redis in multi-line blocks' do
+ expect_offense(<<~PATTERN)
+ Sidekiq.redis do |conn|
+ ^^^^^^^^^^^^^ Refrain from directly using Sidekiq.redis unless for migration. For admin operations, use Sidekiq APIs.
+ conn.sadd('queues', queues)
+ end
+ PATTERN
+ end
+end