Fix autoloading issues when invoking rails
What does this MR do?
Fixes the redefining warning on rails console by checking if Rails is defined. If it is, we'll let Rails smartly handle it as it is likely already loaded.
If not, then we'll require as usual.
This resolves these warning messages when launching rails:
15:05 $ be rails c
--------------------------------------------------------------------------------
Ruby: ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x86_64-darwin19]
GitLab: 13.8.0-pre (cf4abe87663) EE
GitLab Shell: 13.15.0
PostgreSQL: 11.9
--------------------------------------------------------------------------------
/Users/dstull/projects/gdk/gitlab/lib/gitlab/danger/title_linting.rb:6: warning: already initialized constant Gitlab::Danger::TitleLinting::DRAFT_REGEX
/Users/dstull/projects/gdk/gitlab/lib/gitlab/danger/title_linting.rb:6: warning: previous definition of DRAFT_REGEX was here
/Users/dstull/projects/gdk/gitlab/lib/gitlab/danger/weightage.rb:6: warning: already initialized constant Gitlab::Danger::Weightage::CAPACITY_MULTIPLIER
/Users/dstull/projects/gdk/gitlab/lib/gitlab/danger/weightage.rb:6: warning: previous definition of CAPACITY_MULTIPLIER was here
/Users/dstull/projects/gdk/gitlab/lib/gitlab/danger/weightage.rb:7: warning: already initialized constant Gitlab::Danger::Weightage::BASE_REVIEWER_WEIGHT
/Users/dstull/projects/gdk/gitlab/lib/gitlab/danger/weightage.rb:7: warning: previous definition of BASE_REVIEWER_WEIGHT was here
/Users/dstull/projects/gdk/gitlab/lib/gitlab/danger/weightage/reviewers.rb:22: warning: already initialized constant Gitlab::Danger::Weightage::Reviewers::DEFAULT_REVIEWER_WEIGHT
/Users/dstull/projects/gdk/gitlab/lib/gitlab/danger/weightage/reviewers.rb:22: warning: previous definition of DEFAULT_REVIEWER_WEIGHT was here
/Users/dstull/projects/gdk/gitlab/lib/gitlab/danger/weightage/reviewers.rb:23: warning: already initialized constant Gitlab::Danger::Weightage::Reviewers::TRAINTAINER_WEIGHT
/Users/dstull/projects/gdk/gitlab/lib/gitlab/danger/weightage/reviewers.rb:23: warning: previous definition of TRAINTAINER_WEIGHT was here
Loading development environment (Rails 6.0.3.4)
[1] pry(main)> quit
Now...
15:30 $ be rails c
--------------------------------------------------------------------------------
Ruby: ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x86_64-darwin19]
GitLab: 13.8.0-pre (cf4abe87663) EE
GitLab Shell: 13.15.0
PostgreSQL: 11.9
--------------------------------------------------------------------------------
Loading development environment (Rails 6.0.3.4)
[1] pry(main)> quit
Does this MR meet the acceptance criteria?
Conformity
-
Changelog entry -
Documentation (if required) -
Code review guidelines -
Merge request performance guidelines -
Style guides -
Database guides -
Separation of EE specific content
Availability and Testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. -
Tested in all supported browsers -
Informed Infrastructure department of a default or new setting change, if applicable per definition of done
Security
If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:
-
Label as security and @ mention @gitlab-com/gl-security/appsec
-
The MR includes necessary changes to maintain consistency between UI, API, email, or other methods -
Security reports checked/validated by a reviewer from the AppSec team