File tree Expand file tree Collapse file tree 2 files changed +5
-5
lines changed Expand file tree Collapse file tree 2 files changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ module Rails
14
14
# # good
15
15
# has_many :accounts, class_name: 'Account'
16
16
class ReflectionClassName < Cop
17
- MSG = 'Use a string has value for a class_name.' . freeze
17
+ MSG = 'Use a string value for ` class_name` .' . freeze
18
18
19
19
def_node_matcher :association_with_options? , <<-PATTERN
20
20
(send nil? {:has_many :has_one :belongs_to} _ (hash $...))
Original file line number Diff line number Diff line change 9
9
it 'has_many' do
10
10
expect_offense ( <<-RUBY . strip_indent )
11
11
has_many :accounts, class_name: Account, foreign_key: :account_id
12
- ^^^^^^^^^^^^^^^^^^^ Use a string has value for a class_name.
12
+ ^^^^^^^^^^^^^^^^^^^ Use a string value for ` class_name` .
13
13
RUBY
14
14
end
15
15
16
16
it '.name' do
17
17
expect_offense ( <<-RUBY . strip_indent )
18
18
has_many :accounts, class_name: Account.name
19
- ^^^^^^^^^^^^^^^^^^^^^^^^ Use a string has value for a class_name.
19
+ ^^^^^^^^^^^^^^^^^^^^^^^^ Use a string value for ` class_name` .
20
20
RUBY
21
21
end
22
22
23
23
it 'has_one' do
24
24
expect_offense ( <<-RUBY . strip_indent )
25
25
has_one :account, class_name: Account
26
- ^^^^^^^^^^^^^^^^^^^ Use a string has value for a class_name.
26
+ ^^^^^^^^^^^^^^^^^^^ Use a string value for ` class_name` .
27
27
RUBY
28
28
end
29
29
30
30
it 'belongs_to' do
31
31
expect_offense ( <<-RUBY . strip_indent )
32
32
belongs_to :account, class_name: Account
33
- ^^^^^^^^^^^^^^^^^^^ Use a string has value for a class_name.
33
+ ^^^^^^^^^^^^^^^^^^^ Use a string value for ` class_name` .
34
34
RUBY
35
35
end
36
36
end
You can’t perform that action at this time.
0 commit comments