diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-01-20 12:16:11 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-01-20 12:16:11 +0300 |
commit | edaa33dee2ff2f7ea3fac488d41558eb5f86d68c (patch) | |
tree | 11f143effbfeba52329fb7afbd05e6e2a3790241 /spec/rubocop/cop/database/establish_connection_spec.rb | |
parent | d8a5691316400a0f7ec4f83832698f1988eb27c1 (diff) |
Add latest changes from gitlab-org/gitlab@14-7-stable-eev14.7.0-rc42
Diffstat (limited to 'spec/rubocop/cop/database/establish_connection_spec.rb')
-rw-r--r-- | spec/rubocop/cop/database/establish_connection_spec.rb | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/spec/rubocop/cop/database/establish_connection_spec.rb b/spec/rubocop/cop/database/establish_connection_spec.rb new file mode 100644 index 00000000000..a3c27d33cb0 --- /dev/null +++ b/spec/rubocop/cop/database/establish_connection_spec.rb @@ -0,0 +1,29 @@ +# frozen_string_literal: true + +require 'spec_helper' +require_relative '../../../../rubocop/cop/database/establish_connection' + +RSpec.describe RuboCop::Cop::Database::EstablishConnection do + subject(:cop) { described_class.new } + + it 'flags the use of ActiveRecord::Base.establish_connection' do + expect_offense(<<~CODE) + ActiveRecord::Base.establish_connection + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Don't establish new database [...] + CODE + end + + it 'flags the use of ActiveRecord::Base.establish_connection with arguments' do + expect_offense(<<~CODE) + ActiveRecord::Base.establish_connection(:foo) + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Don't establish new database [...] + CODE + end + + it 'flags the use of SomeModel.establish_connection' do + expect_offense(<<~CODE) + SomeModel.establish_connection + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Don't establish new database [...] + CODE + end +end |