blob: 987f68def75857764d424ec1c1c1616d8f1e63d2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# frozen_string_literal: true
require 'rubocop_spec_helper'
require_relative '../../../../rubocop/cop/database/establish_connection'
RSpec.describe RuboCop::Cop::Database::EstablishConnection do
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
|