diff options
Diffstat (limited to 'spec/workers/every_sidekiq_worker_spec.rb')
-rw-r--r-- | spec/workers/every_sidekiq_worker_spec.rb | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/spec/workers/every_sidekiq_worker_spec.rb b/spec/workers/every_sidekiq_worker_spec.rb index 8fddd8540ef..b7ba4d61723 100644 --- a/spec/workers/every_sidekiq_worker_spec.rb +++ b/spec/workers/every_sidekiq_worker_spec.rb @@ -35,4 +35,32 @@ describe 'Every Sidekiq worker' do expect(config_queues).to include(queue).or(include(queue_namespace)) end end + + describe "feature category declarations" do + let(:feature_categories) do + YAML.load_file(Rails.root.join('config', 'feature_categories.yml')).map(&:to_sym).to_set + end + + # All Sidekiq worker classes should declare a valid `feature_category` + # or explicitely be excluded with the `feature_category_not_owned!` annotation. + # Please see doc/development/sidekiq_style_guide.md#Feature-Categorization for more details. + it 'has a feature_category or feature_category_not_owned! attribute', :aggregate_failures do + Gitlab::SidekiqConfig.workers.each do |worker| + expect(worker.get_feature_category).to be_a(Symbol), "expected #{worker.inspect} to declare a feature_category or feature_category_not_owned!" + end + end + + # All Sidekiq worker classes should declare a valid `feature_category`. + # The category should match a value in `config/feature_categories.yml`. + # Please see doc/development/sidekiq_style_guide.md#Feature-Categorization for more details. + it 'has a feature_category that maps to a value in feature_categories.yml', :aggregate_failures do + workers_with_feature_categories = Gitlab::SidekiqConfig.workers + .select(&:get_feature_category) + .reject(&:feature_category_not_owned?) + + workers_with_feature_categories.each do |worker| + expect(feature_categories).to include(worker.get_feature_category), "expected #{worker.inspect} to declare a valid feature_category, but got #{worker.get_feature_category}" + end + end + end end |