Skip to content

Commit 85b70e1

Browse files
committed
fix to catch error when it retrieves polymorphic association
closes #113
1 parent 8db2aa5 commit 85b70e1

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

lib/comma/header_extractor.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ def get_association_class(model_class, association)
4545

4646
begin
4747
model_class.reflect_on_association(association)&.klass
48-
rescue NameError
48+
rescue ArgumentError, NameError
49+
# Since Rails 5.2, ArgumentError is raised.
4950
nil
5051
end
5152
end

spec/comma/rails/active_record_spec.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,7 @@ def name
144144

145145
describe 'github pull-request 83' do
146146
it 'should not raise NameError' do
147-
expect { Picture.all.to_comma(:pr_83) }
148-
.not_to raise_exception(NameError)
147+
expect { Picture.all.to_comma(:pr_83) }.not_to raise_error
149148
end
150149
end
151150
end

0 commit comments

Comments
 (0)