Skip to content

Commit d6dfce9

Browse files
authored
Merge pull request #339 from dblock/paginated-ids
Fix #337: channel_not_found error resolving channel IDs with 100+ channels
2 parents a9ada02 + 5703385 commit d6dfce9

16 files changed

+485
-34
lines changed

.rubocop_todo.yml

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This configuration was generated by
22
# `rubocop --auto-gen-config`
3-
# on 2020-06-29 08:44:31 -0400 using RuboCop version 0.82.0.
3+
# on 2020-08-24 10:08:11 -0400 using RuboCop version 0.82.0.
44
# The point is for the user to remove these configuration records
55
# one by one as the offenses are removed from the code base.
66
# Note that changes in the inspected code, or installation of new
@@ -40,6 +40,11 @@ Metrics/CyclomaticComplexity:
4040
Metrics/MethodLength:
4141
Max: 32
4242

43+
# Offense count: 1
44+
# Configuration parameters: CountKeywordArgs.
45+
Metrics/ParameterLists:
46+
Max: 6
47+
4348
# Offense count: 1
4449
# Configuration parameters: IgnoredMethods.
4550
Metrics/PerceivedComplexity:
@@ -65,13 +70,13 @@ RSpec/ContextMethod:
6570
- 'spec/slack/web/api/mixins/groups_spec.rb'
6671
- 'spec/slack/web/api/mixins/users_spec.rb'
6772

68-
# Offense count: 71
73+
# Offense count: 72
6974
# Configuration parameters: Prefixes.
7075
# Prefixes: when, with, without
7176
RSpec/ContextWording:
7277
Enabled: false
7378

74-
# Offense count: 129
79+
# Offense count: 131
7580
# Cop supports --auto-correct.
7681
# Configuration parameters: AllowConsecutiveOneLiners.
7782
RSpec/EmptyLineAfterExample:
@@ -82,12 +87,12 @@ RSpec/EmptyLineAfterExample:
8287
RSpec/ExampleLength:
8388
Enabled: false
8489

85-
# Offense count: 17
90+
# Offense count: 18
8691
# Configuration parameters: CustomTransform, IgnoreMethods.
8792
RSpec/FilePath:
8893
Enabled: false
8994

90-
# Offense count: 13
95+
# Offense count: 14
9196
# Configuration parameters: AssignmentOnly.
9297
RSpec/InstanceVariable:
9398
Exclude:
@@ -105,14 +110,21 @@ RSpec/MessageSpies:
105110
RSpec/MultipleExpectations:
106111
Max: 5
107112

108-
# Offense count: 35
113+
# Offense count: 2
114+
# Configuration parameters: IgnoreSharedExamples.
115+
RSpec/NamedSubject:
116+
Exclude:
117+
- 'spec/slack/web/api/mixins/conversations_list_spec.rb'
118+
119+
# Offense count: 37
109120
RSpec/NestedGroups:
110121
Max: 6
111122

112-
# Offense count: 3
123+
# Offense count: 4
113124
RSpec/SubjectStub:
114125
Exclude:
115126
- 'spec/slack/web/api/mixins/channels_spec.rb'
127+
- 'spec/slack/web/api/mixins/conversations_spec.rb'
116128
- 'spec/slack/web/api/mixins/groups_spec.rb'
117129
- 'spec/slack/web/api/mixins/users_spec.rb'
118130

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
### 0.15.1 (Next)
22

3-
* Your contribution here.
43
* [#336](https://github.com/slack-ruby/slack-ruby-client/pull/336): Fix: handle nil events - [@pyama86](https://github.com/pyama86).
4+
* [#339](https://github.com/slack-ruby/slack-ruby-client/pull/339): Fix: `channel_not_found` resolving channel IDs with 100+ channels - [@dblock](https://github.com/dblock).
5+
* Your contribution here.
56

67
### 0.15.0 (2020/7/26)
78

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@ def channels_id(options = {})
1616
name = options[:channel]
1717
throw ArgumentError.new('Required arguments :channel missing') if name.nil?
1818

19-
id_for(:channel, name, '#', :channels, 'channel_not_found') do
20-
channels_list
21-
end
19+
id_for :channel, name, '#', :channels_list, :channels, 'channel_not_found'
2220
end
2321
end
2422
end

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@ def conversations_id(options = {})
1616
name = options[:channel]
1717
throw ArgumentError.new('Required arguments :channel missing') if name.nil?
1818

19-
id_for(:channel, name, '#', :channels, 'channel_not_found') do
20-
conversations_list
21-
end
19+
id_for :channel, name, '#', :conversations_list, :channels, 'channel_not_found'
2220
end
2321
end
2422
end

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@ def groups_id(options = {})
1616
name = options[:channel]
1717
throw ArgumentError.new('Required arguments :channel missing') if name.nil?
1818

19-
id_for(:group, name, '#', :groups, 'channel_not_found') do
20-
groups_list
21-
end
19+
id_for :group, name, '#', :groups_list, :groups, 'channel_not_found'
2220
end
2321
end
2422
end

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ module Mixins
66
module Ids
77
private
88

9-
def id_for(key, name, prefix, list_method, not_found_error)
9+
def id_for(key, name, prefix, enum_method, list_method, not_found_error)
1010
return { 'ok' => true, key.to_s => { 'id' => name } } unless name[0] == prefix
1111

12-
yield.tap do |list|
12+
public_send enum_method do |list|
1313
list.public_send(list_method).each do |li|
1414
return Slack::Messages::Message.new('ok' => true, key.to_s => { 'id' => li.id }) if li.name == name[1..-1]
1515
end

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@ def users_id(options = {})
1616
name = options[:user]
1717
throw ArgumentError.new('Required arguments :user missing') if name.nil?
1818

19-
id_for(:user, name, '@', :members, 'user_not_found') do
20-
users_list
21-
end
19+
id_for :user, name, '@', :users_list, :members, 'user_not_found'
2220
end
2321
end
2422
end

spec/fixtures/slack/web/conversations_setTopic.yml

Lines changed: 69 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

spec/fixtures/slack/web/conversations_setTopic_one_page.yml

Lines changed: 142 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

spec/fixtures/slack/web/conversations_setTopic_paginated.yml

Lines changed: 208 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)