Skip to content

Commit

Permalink
Merge pull request #6760 from tagliala/fix-reflection-class-name-typo
Browse files Browse the repository at this point in the history
Fix typo in ReflectionClassName Cop
  • Loading branch information
Drenmi authored Feb 12, 2019
2 parents ad0cf42 + a72a193 commit 7c6e3cd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/rubocop/cop/rails/reflection_class_name.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ module Rails
# # good
# has_many :accounts, class_name: 'Account'
class ReflectionClassName < Cop
MSG = 'Use a string has value for a class_name.'.freeze
MSG = 'Use a string value for `class_name`.'.freeze

def_node_matcher :association_with_options?, <<-PATTERN
(send nil? {:has_many :has_one :belongs_to} _ (hash $...))
Expand Down
8 changes: 4 additions & 4 deletions spec/rubocop/cop/rails/reflection_class_name_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,28 @@
it 'has_many' do
expect_offense(<<-RUBY.strip_indent)
has_many :accounts, class_name: Account, foreign_key: :account_id
^^^^^^^^^^^^^^^^^^^ Use a string has value for a class_name.
^^^^^^^^^^^^^^^^^^^ Use a string value for `class_name`.
RUBY
end

it '.name' do
expect_offense(<<-RUBY.strip_indent)
has_many :accounts, class_name: Account.name
^^^^^^^^^^^^^^^^^^^^^^^^ Use a string has value for a class_name.
^^^^^^^^^^^^^^^^^^^^^^^^ Use a string value for `class_name`.
RUBY
end

it 'has_one' do
expect_offense(<<-RUBY.strip_indent)
has_one :account, class_name: Account
^^^^^^^^^^^^^^^^^^^ Use a string has value for a class_name.
^^^^^^^^^^^^^^^^^^^ Use a string value for `class_name`.
RUBY
end

it 'belongs_to' do
expect_offense(<<-RUBY.strip_indent)
belongs_to :account, class_name: Account
^^^^^^^^^^^^^^^^^^^ Use a string has value for a class_name.
^^^^^^^^^^^^^^^^^^^ Use a string value for `class_name`.
RUBY
end
end
Expand Down

0 comments on commit 7c6e3cd

Please sign in to comment.