Skip to content

Commit

Permalink
fix to catch error when it retrieves polymorphic association
Browse files Browse the repository at this point in the history
closes #113
  • Loading branch information
eitoball committed Apr 30, 2019
1 parent 8db2aa5 commit 85b70e1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
3 changes: 2 additions & 1 deletion lib/comma/header_extractor.rb
Expand Up @@ -45,7 +45,8 @@ def get_association_class(model_class, association)

begin
model_class.reflect_on_association(association)&.klass
rescue NameError
rescue ArgumentError, NameError
# Since Rails 5.2, ArgumentError is raised.
nil
end
end
Expand Down
3 changes: 1 addition & 2 deletions spec/comma/rails/active_record_spec.rb
Expand Up @@ -144,8 +144,7 @@ def name

describe 'github pull-request 83' do
it 'should not raise NameError' do
expect { Picture.all.to_comma(:pr_83) }
.not_to raise_exception(NameError)
expect { Picture.all.to_comma(:pr_83) }.not_to raise_error
end
end
end
Expand Down

0 comments on commit 85b70e1

Please sign in to comment.