Skip to content

Rails + Sidekiq will go bezerk after sidekiq-unique-jobs testing check. #128

@antek-drzewiecki

Description

@antek-drzewiecki

When a Testing module is defined in your application namespace or a Testing module in general. Sidekiq-unique-jobs generatesNameErrors, uninitialized constant Sidekiq::Testing in config.rb.

The currently it check if the Testing constant is defined in Sidekiq with .const_defined?. The behaviour of .const_defined? is to check its ancestors if a constant is defined.

Since Sidekiq::Testing is not defined, it will try to look in its ancestors (Module and Object). There Testing is defined so it returns true.

Debug info:

Rails.env
 => "development" 
Object.const_defined? 'Testing'
 => true 
Sidekiq.const_defined? 'Testing'
 => true 
Sidekiq.const_defined? 'Testing', false
 => false 

And in test:

Rails.env
 => "test" 
Object.const_defined? 'Testing'
 => true 
Sidekiq.const_defined? 'Testing'
 => true 
 Sidekiq.const_defined? 'Testing', false
 => true 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions