Skip to content

Commit 0756b95

Browse files
committed
improve test that users.all.count uses api response total_count rather than paging all and counting
1 parent cca51e8 commit 0756b95

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

spec/unit/intercom/user_collection_proxy_spec.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@
1818
Intercom::User.all.collect { |user| user.email }.must_equal %W(user1@example.com user2@example.com user3@example.com)
1919
end
2020

21-
it "yields each user to the block" do
22-
Intercom.expects(:get).with("users", {:per_page => 1}).returns(page_of_users(1,1))
21+
it "counts users based on total_count in paged_response" do
22+
paged_response = page_of_users(1, 1)
23+
Intercom.expects(:get).with("users", {:per_page => 1}).returns(paged_response)
24+
paged_response.expects(:[]).with("total_count").returns(3)
2325
Intercom::User.all.count.must_equal 3
2426
end
2527

0 commit comments

Comments
 (0)