Skip to content

Commit 88713a1

Browse files
committed
Tests for default id_for page sizes
1 parent a6a86d1 commit 88713a1

File tree

2 files changed

+36
-2
lines changed

2 files changed

+36
-2
lines changed

spec/slack/web/api/mixins/conversations_spec.rb

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
end
1414

1515
before do
16-
allow(conversations).to receive(:conversations_id_page_size).and_return(100)
16+
allow(conversations).to receive(:conversations_id_page_size) { Slack::Web.config.conversations_id_page_size }
1717
allow(conversations).to receive(:conversations_list).and_yield(
1818
Slack::Messages::Message.new(
1919
'channels' => [{
@@ -32,6 +32,7 @@
3232
end
3333

3434
it 'translates a channel that starts with a #' do
35+
expect(conversations).to receive(:conversations_list).with(limit: 100)
3536
expect(conversations.conversations_id(channel: '#general')).to(
3637
eq('ok' => true, 'channel' => { 'id' => 'CDEADBEEF' })
3738
)
@@ -47,5 +48,22 @@
4748
raise_error(Slack::Web::Api::Errors::SlackError, 'channel_not_found')
4849
)
4950
end
51+
52+
context "when a non-default conversations_id page size has been configured" do
53+
before { Slack::Web.config.conversations_id_page_size = 500 }
54+
after { Slack::Web.config.reset }
55+
56+
it 'translates a channel that starts with a #' do
57+
expect(conversations).to receive(:conversations_list).with(limit: 500)
58+
expect(conversations.conversations_id(channel: '#general')).to(
59+
eq('ok' => true, 'channel' => { 'id' => 'CDEADBEEF' })
60+
)
61+
end
62+
63+
it 'forwards a provided limit to the underlying conversations_list calls' do
64+
expect(conversations).to receive(:conversations_list).with(limit: 1234)
65+
conversations.conversations_id(channel: '#general', limit: 1234)
66+
end
67+
end
5068
end
5169
end

spec/slack/web/api/mixins/users_spec.rb

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
end
1414

1515
before do
16-
allow(users).to receive(:users_id_page_size).and_return(100)
16+
allow(users).to receive(:users_id_page_size) { Slack::Web.config.users_id_page_size }
1717
allow(users).to receive(:users_list).and_yield(
1818
Slack::Messages::Message.new(
1919
'members' => [{
@@ -31,6 +31,7 @@
3131
end
3232

3333
it 'translates a user that starts with a @' do
34+
expect(users).to receive(:users_list).with(limit: 100)
3435
expect(users.users_id(user: '@aws')).to eq('ok' => true, 'user' => { 'id' => 'UDEADBEEF' })
3536
end
3637

@@ -44,6 +45,21 @@
4445
raise_error(Slack::Web::Api::Errors::SlackError, 'user_not_found')
4546
)
4647
end
48+
49+
context "when a non-default conversations_id page size has been configured" do
50+
before { Slack::Web.config.users_id_page_size = 500 }
51+
after { Slack::Web.config.reset }
52+
53+
it 'translates a user that starts with a @' do
54+
expect(users).to receive(:users_list).with(limit: 500)
55+
expect(users.users_id(user: '@aws')).to eq('ok' => true, 'user' => { 'id' => 'UDEADBEEF' })
56+
end
57+
58+
it 'forwards a provided limit to the underlying users_list calls' do
59+
expect(users).to receive(:users_list).with(limit: 1234)
60+
users.users_id(user: '@aws', limit: 1234)
61+
end
62+
end
4763
end
4864

4965
if defined?(Picky)

0 commit comments

Comments
 (0)