Skip to content

Commit b116415

Browse files
committed
Allow overriding conversations_id limit with an argument
1 parent 4a87569 commit b116415

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

lib/slack/web/api/mixins/conversations.id.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,12 @@ module Conversations
1212
#
1313
# @option options [channel] :channel
1414
# Channel to get ID for, prefixed with #.
15+
# @option options [integer] :limit
16+
# The page size used for conversations_list calls required to find the channel's ID
1517
def conversations_id(options = {})
1618
name = options[:channel]
19+
limit = options.fetch(:limit, conversations_id_page_size)
20+
1721
raise ArgumentError, 'Required arguments :channel missing' if name.nil?
1822

1923
id_for(
@@ -23,7 +27,7 @@ def conversations_id(options = {})
2327
:conversations_list,
2428
:channels,
2529
'channel_not_found',
26-
enum_method_options: { limit: conversations_id_page_size }
30+
enum_method_options: { limit: limit }
2731
)
2832
end
2933
end

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@
3737
)
3838
end
3939

40+
it 'forwards a provided limit to the underlying conversations_list calls' do
41+
expect(conversations).to receive(:conversations_list).with(limit: 1234)
42+
conversations.conversations_id(channel: '#general', limit: 1234)
43+
end
44+
4045
it 'fails with an exception' do
4146
expect { conversations.conversations_id(channel: '#invalid') }.to(
4247
raise_error(Slack::Web::Api::Errors::SlackError, 'channel_not_found')

0 commit comments

Comments
 (0)