File tree Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -68,8 +68,6 @@ def self.create(params)
68
68
69
69
# Retrieve all the users
70
70
# Examples:
71
- # Intercom::User.all.count
72
- # > 5346
73
71
# Intercom::User.all.each do |user|
74
72
# puts user.inspect
75
73
# end
@@ -82,6 +80,14 @@ def self.all
82
80
UserCollectionProxy . new
83
81
end
84
82
83
+ # Fetches a count of all Users tracked on Intercom.
84
+ #
85
+ # @return [Integer]
86
+ def self . count
87
+ response = Intercom . get ( "/v1/users" , { :per_page => 1 } )
88
+ response [ "total_count" ]
89
+ end
90
+
85
91
# Deletes a user record on your application.
86
92
#
87
93
# Calls DELETE https://api.intercom.io/v1/users
Original file line number Diff line number Diff line change 185
185
all . must_be_instance_of ( Intercom ::UserCollectionProxy )
186
186
end
187
187
188
+ it "returns the total number of users" do
189
+ Intercom . expects ( :get ) . with ( "/v1/users" , { :per_page => 1 } ) . returns ( page_of_users )
190
+ Intercom ::User . count . must_be_kind_of ( Integer )
191
+ end
192
+
188
193
it "can find_by_email" do
189
194
Intercom ::User . expects ( :find ) . with ( :email => "bob@example.com" )
190
195
Intercom ::User . find_by_email ( "bob@example.com" )
You can’t perform that action at this time.
0 commit comments