File tree Expand file tree Collapse file tree 2 files changed +5
-1
lines changed
spec/unit/views/components Expand file tree Collapse file tree 2 files changed +5
-1
lines changed Original file line number Diff line number Diff line change 1
1
# frozen_string_literal: true
2
2
module ActiveAdmin
3
3
class AsyncCount
4
+ class NotSupportedError < RuntimeError ; end
5
+
4
6
def initialize ( collection )
7
+ raise NotSupportedError , "#{ collection . inspect } does not support :async_count" unless collection . respond_to? ( :async_count )
8
+
5
9
@collection = collection . except ( :select , :order )
6
10
@promise = @collection . async_count
7
11
end
Original file line number Diff line number Diff line change 69
69
end
70
70
71
71
it "raises an error when ActiveRecord async_count is unavailable" , unless : Post . respond_to? ( :async_count ) do
72
- expect { scopes } . to raise_error ( NoMethodError , %r{async_count} )
72
+ expect { scopes } . to raise_error ( ActiveAdmin :: AsyncCount :: NotSupportedError , %r{does not support : async_count} )
73
73
end
74
74
75
75
context "when async_count is available in Rails" , if : Post . respond_to? ( :async_count ) do
You can’t perform that action at this time.
0 commit comments