slack-ruby-client 2.4.0 → 2.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (210) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/update_api.yml +1 -1
  3. data/.rubocop_todo.yml +43 -13
  4. data/CHANGELOG.md +12 -0
  5. data/CONTRIBUTING.md +7 -7
  6. data/Gemfile +1 -0
  7. data/README.md +46 -28
  8. data/bin/commands/admin_conversations.rb +21 -0
  9. data/bin/commands/admin_users_session.rb +1 -1
  10. data/bin/commands/admin_workflows.rb +3 -1
  11. data/bin/commands/admin_workflows_triggers_types_permissions.rb +4 -4
  12. data/bin/commands/assistant_threads.rb +45 -0
  13. data/bin/commands/bookmarks.rb +1 -0
  14. data/bin/commands/canvases.rb +4 -4
  15. data/bin/commands/canvases_access.rb +3 -3
  16. data/bin/commands/chat.rb +7 -3
  17. data/bin/commands/conversations.rb +5 -5
  18. data/bin/commands/conversations_canvases.rb +2 -2
  19. data/bin/commands/conversations_requestSharedInvite.rb +48 -0
  20. data/bin/commands/files.rb +2 -1
  21. data/bin/commands/usergroups.rb +5 -0
  22. data/bin/commands/usergroups_users.rb +2 -0
  23. data/examples/files_upload_v2/.env.example +1 -0
  24. data/examples/files_upload_v2/Gemfile +5 -0
  25. data/examples/files_upload_v2/README.md +13 -0
  26. data/examples/files_upload_v2/files_upload_v2.rb +37 -0
  27. data/examples/oauth_v2/.env.example +4 -0
  28. data/examples/oauth_v2/Gemfile +7 -0
  29. data/examples/oauth_v2/README.md +33 -0
  30. data/examples/oauth_v2/oauth_v2.rb +60 -0
  31. data/lib/slack/messages/formatting.rb +1 -1
  32. data/lib/slack/version.rb +1 -1
  33. data/lib/slack/web/api/endpoints/admin_conversations.rb +35 -0
  34. data/lib/slack/web/api/endpoints/admin_users_session.rb +2 -3
  35. data/lib/slack/web/api/endpoints/admin_workflows.rb +5 -1
  36. data/lib/slack/web/api/endpoints/admin_workflows_triggers_types_permissions.rb +2 -2
  37. data/lib/slack/web/api/endpoints/assistant_threads.rb +68 -0
  38. data/lib/slack/web/api/endpoints/bookmarks.rb +2 -0
  39. data/lib/slack/web/api/endpoints/canvases.rb +2 -2
  40. data/lib/slack/web/api/endpoints/canvases_access.rb +4 -4
  41. data/lib/slack/web/api/endpoints/chat.rb +12 -3
  42. data/lib/slack/web/api/endpoints/conversations.rb +4 -4
  43. data/lib/slack/web/api/endpoints/conversations_canvases.rb +1 -1
  44. data/lib/slack/web/api/endpoints/conversations_requestSharedInvite.rb +73 -0
  45. data/lib/slack/web/api/endpoints/files.rb +3 -1
  46. data/lib/slack/web/api/endpoints/usergroups.rb +10 -0
  47. data/lib/slack/web/api/endpoints/usergroups_users.rb +4 -0
  48. data/lib/slack/web/api/endpoints.rb +4 -0
  49. data/lib/slack/web/api/errors.rb +48 -4
  50. data/lib/slack/web/api/helpers/files.rb +87 -0
  51. data/lib/slack/web/api/helpers.rb +13 -0
  52. data/lib/slack/web/api/templates/method_spec.erb +4 -3
  53. data/lib/slack/web/client.rb +1 -0
  54. data/lib/slack/web/faraday/connection.rb +13 -26
  55. data/lib/slack/web/faraday/options.rb +24 -0
  56. data/lib/slack/web/faraday/request.rb +2 -1
  57. data/lib/slack-ruby-client.rb +2 -0
  58. data/slack-ruby-client.gemspec +2 -1
  59. metadata +32 -154
  60. data/screenshots/create-app.png +0 -0
  61. data/spec/fixtures/slack/web/429_error.yml +0 -81
  62. data/spec/fixtures/slack/web/auth_test_error.yml +0 -81
  63. data/spec/fixtures/slack/web/auth_test_success.yml +0 -81
  64. data/spec/fixtures/slack/web/conversations_info.yml +0 -167
  65. data/spec/fixtures/slack/web/conversations_setTopic.yml +0 -84
  66. data/spec/fixtures/slack/web/conversations_setTopic_one_page.yml +0 -172
  67. data/spec/fixtures/slack/web/conversations_setTopic_paginated.yml +0 -253
  68. data/spec/fixtures/slack/web/paginated_users_list.yml +0 -613
  69. data/spec/fixtures/slack/web/rtm_connect.yml +0 -391
  70. data/spec/fixtures/slack/web/users_info.yml +0 -214
  71. data/spec/fixtures/slack/web/users_list.yml +0 -133
  72. data/spec/fixtures/slack/web/views_open_error.yml +0 -83
  73. data/spec/integration/integration_spec.rb +0 -207
  74. data/spec/slack/config_spec.rb +0 -16
  75. data/spec/slack/events/config_spec.rb +0 -35
  76. data/spec/slack/events/request_spec.rb +0 -199
  77. data/spec/slack/messages/formatting_spec.rb +0 -156
  78. data/spec/slack/real_time/api/message_spec.rb +0 -20
  79. data/spec/slack/real_time/api/ping_spec.rb +0 -17
  80. data/spec/slack/real_time/api/typing_spec.rb +0 -19
  81. data/spec/slack/real_time/client_spec.rb +0 -601
  82. data/spec/slack/real_time/concurrency/clients/async_spec.rb +0 -16
  83. data/spec/slack/real_time/concurrency/it_behaves_like_a_realtime_socket.rb +0 -21
  84. data/spec/slack/real_time/concurrency/with_concurrency_spec.rb +0 -10
  85. data/spec/slack/real_time/concurrency/without_concurrency_spec.rb +0 -10
  86. data/spec/slack/real_time/event_handlers/bot_spec.rb +0 -47
  87. data/spec/slack/real_time/event_handlers/event_handlers_spec.rb +0 -16
  88. data/spec/slack/real_time/event_handlers/im_spec.rb +0 -51
  89. data/spec/slack/real_time/event_handlers/private_channel_spec.rb +0 -99
  90. data/spec/slack/real_time/event_handlers/public_channel_spec.rb +0 -123
  91. data/spec/slack/real_time/event_handlers/team_spec.rb +0 -63
  92. data/spec/slack/real_time/event_handlers/user_spec.rb +0 -65
  93. data/spec/slack/real_time/rtm_connect_spec.rb +0 -14
  94. data/spec/slack/real_time/stores/store_spec.rb +0 -50
  95. data/spec/slack/slack_spec.rb +0 -93
  96. data/spec/slack/version_spec.rb +0 -8
  97. data/spec/slack/web/api/endpoints/admin_analytics_spec.rb +0 -13
  98. data/spec/slack/web/api/endpoints/admin_apps_activities_spec.rb +0 -8
  99. data/spec/slack/web/api/endpoints/admin_apps_approved_spec.rb +0 -8
  100. data/spec/slack/web/api/endpoints/admin_apps_config_spec.rb +0 -18
  101. data/spec/slack/web/api/endpoints/admin_apps_requests_spec.rb +0 -13
  102. data/spec/slack/web/api/endpoints/admin_apps_restricted_spec.rb +0 -8
  103. data/spec/slack/web/api/endpoints/admin_apps_spec.rb +0 -18
  104. data/spec/slack/web/api/endpoints/admin_audit_anomaly_allow_spec.rb +0 -8
  105. data/spec/slack/web/api/endpoints/admin_auth_policy_spec.rb +0 -35
  106. data/spec/slack/web/api/endpoints/admin_barriers_spec.rb +0 -38
  107. data/spec/slack/web/api/endpoints/admin_conversations_ekm_spec.rb +0 -8
  108. data/spec/slack/web/api/endpoints/admin_conversations_restrictAccess_spec.rb +0 -32
  109. data/spec/slack/web/api/endpoints/admin_conversations_spec.rb +0 -133
  110. data/spec/slack/web/api/endpoints/admin_emoji_spec.rb +0 -37
  111. data/spec/slack/web/api/endpoints/admin_functions_permissions_spec.rb +0 -21
  112. data/spec/slack/web/api/endpoints/admin_functions_spec.rb +0 -13
  113. data/spec/slack/web/api/endpoints/admin_inviteRequests_approved_spec.rb +0 -8
  114. data/spec/slack/web/api/endpoints/admin_inviteRequests_denied_spec.rb +0 -8
  115. data/spec/slack/web/api/endpoints/admin_inviteRequests_spec.rb +0 -18
  116. data/spec/slack/web/api/endpoints/admin_roles_spec.rb +0 -30
  117. data/spec/slack/web/api/endpoints/admin_teams_admins_spec.rb +0 -13
  118. data/spec/slack/web/api/endpoints/admin_teams_owners_spec.rb +0 -13
  119. data/spec/slack/web/api/endpoints/admin_teams_settings_spec.rb +0 -53
  120. data/spec/slack/web/api/endpoints/admin_teams_spec.rb +0 -16
  121. data/spec/slack/web/api/endpoints/admin_usergroups_spec.rb +0 -37
  122. data/spec/slack/web/api/endpoints/admin_users_session_spec.rb +0 -41
  123. data/spec/slack/web/api/endpoints/admin_users_spec.rb +0 -67
  124. data/spec/slack/web/api/endpoints/admin_users_unsupportedVersions_spec.rb +0 -8
  125. data/spec/slack/web/api/endpoints/admin_workflows_collaborators_spec.rb +0 -24
  126. data/spec/slack/web/api/endpoints/admin_workflows_permissions_spec.rb +0 -13
  127. data/spec/slack/web/api/endpoints/admin_workflows_spec.rb +0 -13
  128. data/spec/slack/web/api/endpoints/admin_workflows_triggers_types_permissions_spec.rb +0 -21
  129. data/spec/slack/web/api/endpoints/api_spec.rb +0 -8
  130. data/spec/slack/web/api/endpoints/apps_activities_spec.rb +0 -13
  131. data/spec/slack/web/api/endpoints/apps_auth_external_spec.rb +0 -13
  132. data/spec/slack/web/api/endpoints/apps_connections_spec.rb +0 -8
  133. data/spec/slack/web/api/endpoints/apps_datastore_spec.rb +0 -74
  134. data/spec/slack/web/api/endpoints/apps_event_authorizations_spec.rb +0 -13
  135. data/spec/slack/web/api/endpoints/apps_manifest_spec.rb +0 -44
  136. data/spec/slack/web/api/endpoints/apps_spec.rb +0 -16
  137. data/spec/slack/web/api/endpoints/auth_spec.rb +0 -8
  138. data/spec/slack/web/api/endpoints/auth_teams_spec.rb +0 -8
  139. data/spec/slack/web/api/endpoints/bookmarks_spec.rb +0 -40
  140. data/spec/slack/web/api/endpoints/bots_spec.rb +0 -8
  141. data/spec/slack/web/api/endpoints/calls_participants_spec.rb +0 -24
  142. data/spec/slack/web/api/endpoints/calls_spec.rb +0 -31
  143. data/spec/slack/web/api/endpoints/canvases_access_spec.rb +0 -21
  144. data/spec/slack/web/api/endpoints/canvases_sections_spec.rb +0 -16
  145. data/spec/slack/web/api/endpoints/canvases_spec.rb +0 -21
  146. data/spec/slack/web/api/endpoints/chat_scheduledMessages_spec.rb +0 -8
  147. data/spec/slack/web/api/endpoints/chat_spec.rb +0 -134
  148. data/spec/slack/web/api/endpoints/conversations_canvases_spec.rb +0 -13
  149. data/spec/slack/web/api/endpoints/conversations_externalInvitePermissions_spec.rb +0 -19
  150. data/spec/slack/web/api/endpoints/conversations_spec.rb +0 -8
  151. data/spec/slack/web/api/endpoints/custom_specs/auth_spec.rb +0 -27
  152. data/spec/slack/web/api/endpoints/custom_specs/chat_spec.rb +0 -206
  153. data/spec/slack/web/api/endpoints/custom_specs/conversations_spec.rb +0 -13
  154. data/spec/slack/web/api/endpoints/custom_specs/dialog_spec.rb +0 -40
  155. data/spec/slack/web/api/endpoints/custom_specs/users_spec.rb +0 -38
  156. data/spec/slack/web/api/endpoints/custom_specs/views_spec.rb +0 -112
  157. data/spec/slack/web/api/endpoints/dialog_spec.rb +0 -14
  158. data/spec/slack/web/api/endpoints/dnd_spec.rb +0 -18
  159. data/spec/slack/web/api/endpoints/emoji_spec.rb +0 -8
  160. data/spec/slack/web/api/endpoints/files_comments_spec.rb +0 -16
  161. data/spec/slack/web/api/endpoints/files_remote_spec.rb +0 -24
  162. data/spec/slack/web/api/endpoints/files_spec.rb +0 -57
  163. data/spec/slack/web/api/endpoints/functions_distributions_permissions_spec.rb +0 -10
  164. data/spec/slack/web/api/endpoints/functions_spec.rb +0 -28
  165. data/spec/slack/web/api/endpoints/functions_workflows_steps_responses_spec.rb +0 -13
  166. data/spec/slack/web/api/endpoints/functions_workflows_steps_spec.rb +0 -13
  167. data/spec/slack/web/api/endpoints/migration_spec.rb +0 -13
  168. data/spec/slack/web/api/endpoints/oauth_spec.rb +0 -8
  169. data/spec/slack/web/api/endpoints/oauth_v2_spec.rb +0 -16
  170. data/spec/slack/web/api/endpoints/openid_connect_spec.rb +0 -8
  171. data/spec/slack/web/api/endpoints/pins_spec.rb +0 -23
  172. data/spec/slack/web/api/endpoints/reactions_spec.rb +0 -24
  173. data/spec/slack/web/api/endpoints/reminders_spec.rb +0 -31
  174. data/spec/slack/web/api/endpoints/rtm_spec.rb +0 -8
  175. data/spec/slack/web/api/endpoints/search_spec.rb +0 -23
  176. data/spec/slack/web/api/endpoints/stars_spec.rb +0 -8
  177. data/spec/slack/web/api/endpoints/team_billing_spec.rb +0 -8
  178. data/spec/slack/web/api/endpoints/team_externalTeams_spec.rb +0 -13
  179. data/spec/slack/web/api/endpoints/team_preferences_spec.rb +0 -8
  180. data/spec/slack/web/api/endpoints/team_profile_spec.rb +0 -8
  181. data/spec/slack/web/api/endpoints/team_spec.rb +0 -8
  182. data/spec/slack/web/api/endpoints/tooling_tokens_spec.rb +0 -13
  183. data/spec/slack/web/api/endpoints/usergroups_spec.rb +0 -28
  184. data/spec/slack/web/api/endpoints/usergroups_users_spec.rb +0 -21
  185. data/spec/slack/web/api/endpoints/users_admin_spec.rb +0 -18
  186. data/spec/slack/web/api/endpoints/users_discoverableContacts_spec.rb +0 -13
  187. data/spec/slack/web/api/endpoints/users_prefs_spec.rb +0 -8
  188. data/spec/slack/web/api/endpoints/users_profile_spec.rb +0 -14
  189. data/spec/slack/web/api/endpoints/users_spec.rb +0 -8
  190. data/spec/slack/web/api/endpoints/views_spec.rb +0 -65
  191. data/spec/slack/web/api/endpoints/workflows_spec.rb +0 -34
  192. data/spec/slack/web/api/endpoints/workflows_triggers_permissions_spec.rb +0 -31
  193. data/spec/slack/web/api/error_spec.rb +0 -14
  194. data/spec/slack/web/api/errors/slack_error_spec.rb +0 -33
  195. data/spec/slack/web/api/mixins/conversations_list_spec.rb +0 -21
  196. data/spec/slack/web/api/mixins/conversations_spec.rb +0 -45
  197. data/spec/slack/web/api/mixins/users_spec.rb +0 -52
  198. data/spec/slack/web/api/options_spec.rb +0 -69
  199. data/spec/slack/web/api/pagination/cursor_spec.rb +0 -102
  200. data/spec/slack/web/client_spec.rb +0 -359
  201. data/spec/slack/web/faraday/request_spec.rb +0 -80
  202. data/spec/slack/web/faraday/response/raise_error_spec.rb +0 -86
  203. data/spec/spec_helper.rb +0 -30
  204. data/spec/support/queue_with_timeout.rb +0 -35
  205. data/spec/support/real_time/concurrency/mock.rb +0 -31
  206. data/spec/support/real_time/connected_client.rb +0 -21
  207. data/spec/support/real_time/event.rb +0 -12
  208. data/spec/support/real_time/loaded_client.rb +0 -120
  209. data/spec/support/token.rb +0 -11
  210. data/spec/support/vcr.rb +0 -45
@@ -1,16 +0,0 @@
1
- # frozen_string_literal: true
2
- require 'spec_helper'
3
-
4
- RSpec.describe Slack::RealTime::Client, vcr: { cassette_name: 'web/rtm_connect' } do
5
- include_context 'connected client'
6
-
7
- it 'is not fatal' do
8
- event = Slack::RealTime::Event.new(
9
- 'type' => 'pref_change',
10
- 'name' => 'push_sound',
11
- 'value' => 'updated.mp3'
12
- )
13
- expect(client.self).to receive(:prefs) { raise ArgumentError }
14
- expect { client.send(:dispatch, event) }.not_to raise_error
15
- end
16
- end
@@ -1,51 +0,0 @@
1
- # frozen_string_literal: true
2
- require 'spec_helper'
3
-
4
- RSpec.describe Slack::RealTime::Client, vcr: { cassette_name: 'web/rtm_connect' } do
5
- include_context 'connected client'
6
-
7
- context 'im' do
8
- it 'im_created' do
9
- expect(client.ims['CDEADBEEF']).to be_nil
10
- event = Slack::RealTime::Event.new(
11
- 'type' => 'im_created',
12
- 'channel' => {
13
- 'id' => 'CDEADBEEF',
14
- 'name' => 'beef'
15
- }
16
- )
17
- client.send(:dispatch, event)
18
- im = client.ims['CDEADBEEF']
19
- expect(im).not_to be_nil
20
- expect(im.name).to eq 'beef'
21
- end
22
-
23
- context 'with im loaded in the store' do
24
- include_context 'loaded client'
25
-
26
- it 'im_open' do
27
- im = client.ims['D0J1H6QTV']
28
- expect(im).not_to be_nil
29
- im.is_open = false
30
- event = Slack::RealTime::Event.new(
31
- 'type' => 'im_open',
32
- 'channel' => 'D0J1H6QTV'
33
- )
34
- client.send(:dispatch, event)
35
- expect(im.is_open).to be true
36
- end
37
-
38
- it 'im_close' do
39
- im = client.ims['D0J1H6QTV']
40
- expect(im).not_to be_nil
41
- expect(im.is_open).to be true
42
- event = Slack::RealTime::Event.new(
43
- 'type' => 'im_close',
44
- 'channel' => 'D0J1H6QTV'
45
- )
46
- client.send(:dispatch, event)
47
- expect(im.is_open).to be false
48
- end
49
- end
50
- end
51
- end
@@ -1,99 +0,0 @@
1
- # frozen_string_literal: true
2
- require 'spec_helper'
3
-
4
- RSpec.describe Slack::RealTime::Client, vcr: { cassette_name: 'web/rtm_connect' } do
5
- include_context 'connected client'
6
- include_context 'loaded client'
7
-
8
- context 'private channel' do
9
- it 'sets private channel data' do
10
- expect(client.private_channels.count).to eq 1
11
- end
12
-
13
- it 'group_joined' do
14
- expect(client.private_channels['CDEADBEEF']).to be_nil
15
- event = Slack::RealTime::Event.new(
16
- 'type' => 'group_joined',
17
- 'channel' => {
18
- 'id' => 'CDEADBEEF',
19
- 'name' => 'beef'
20
- }
21
- )
22
- client.send(:dispatch, event)
23
- channel = client.private_channels['CDEADBEEF']
24
- expect(channel).not_to be_nil
25
- expect(channel.name).to eq 'beef'
26
- end
27
-
28
- it 'group_left' do
29
- channel = client.private_channels['G0K7EV5A7']
30
- expect(channel.members).to include client.self.id
31
- event = Slack::RealTime::Event.new(
32
- 'type' => 'group_left',
33
- 'channel' => 'G0K7EV5A7'
34
- )
35
- client.send(:dispatch, event)
36
- expect(client.private_channels['G0K7EV5A7']).to be_nil
37
- end
38
-
39
- it 'group_archive' do
40
- channel = client.private_channels['G0K7EV5A7']
41
- expect(channel.is_archived).to be false
42
- event = Slack::RealTime::Event.new(
43
- 'type' => 'group_archive',
44
- 'channel' => 'G0K7EV5A7'
45
- )
46
- client.send(:dispatch, event)
47
- expect(channel.is_archived).to be true
48
- end
49
-
50
- it 'group_unarchive' do
51
- channel = client.private_channels['G0K7EV5A7']
52
- channel.is_archived = true
53
- event = Slack::RealTime::Event.new(
54
- 'type' => 'group_unarchive',
55
- 'channel' => 'G0K7EV5A7'
56
- )
57
- client.send(:dispatch, event)
58
- expect(channel.is_archived).to be false
59
- end
60
-
61
- it 'group_rename' do
62
- channel = client.private_channels['G0K7EV5A7']
63
- expect(channel.name).to eq 'mpdm-dblock--rubybot--player1-1'
64
- event = Slack::RealTime::Event.new(
65
- 'type' => 'group_rename',
66
- 'channel' => {
67
- 'id' => 'G0K7EV5A7',
68
- 'name' => 'updated',
69
- 'created' => 1_360_782_804
70
- }
71
- )
72
- client.send(:dispatch, event)
73
- expect(channel.name).to eq 'updated'
74
- end
75
-
76
- it 'group_open' do
77
- channel = client.private_channels['G0K7EV5A7']
78
- expect(channel).not_to be_nil
79
- event = Slack::RealTime::Event.new(
80
- 'type' => 'group_open',
81
- 'channel' => 'G0K7EV5A7'
82
- )
83
- client.send(:dispatch, event)
84
- expect(channel.is_open).to be true
85
- end
86
-
87
- it 'group_close' do
88
- channel = client.private_channels['G0K7EV5A7']
89
- expect(channel).not_to be_nil
90
- channel.is_open = true
91
- event = Slack::RealTime::Event.new(
92
- 'type' => 'group_close',
93
- 'channel' => 'G0K7EV5A7'
94
- )
95
- client.send(:dispatch, event)
96
- expect(channel.is_open).to be false
97
- end
98
- end
99
- end
@@ -1,123 +0,0 @@
1
- # frozen_string_literal: true
2
- require 'spec_helper'
3
-
4
- RSpec.describe Slack::RealTime::Client, vcr: { cassette_name: 'web/rtm_connect' } do
5
- include_context 'connected client'
6
- include_context 'loaded client'
7
-
8
- context 'public channel' do
9
- it 'channel_archive' do
10
- channel = client.public_channels['C0HNTD0CW']
11
- expect(channel.is_archived).to be false
12
- event = Slack::RealTime::Event.new(
13
- 'type' => 'channel_archive',
14
- 'channel' => 'C0HNTD0CW',
15
- 'user' => 'U04KB5WQR'
16
- )
17
- client.send(:dispatch, event)
18
- expect(channel.is_archived).to be true
19
- end
20
-
21
- it 'channel_created' do
22
- expect(client.public_channels['C024BE91L']).to be_nil
23
- event = Slack::RealTime::Event.new(
24
- 'type' => 'channel_created',
25
- 'channel' => {
26
- 'id' => 'C024BE91L',
27
- 'name' => 'fun',
28
- 'created' => 1360782804,
29
- 'creator' => 'U04KB5WQR'
30
- }
31
- )
32
- client.send(:dispatch, event)
33
- channel = client.public_channels['C024BE91L']
34
- expect(channel).not_to be_nil
35
- expect(channel.name).to eq 'fun'
36
- expect(channel.creator).to eq 'U04KB5WQR'
37
- expect(channel.created).to eq 1360782804
38
- end
39
-
40
- it 'channel_deleted' do
41
- expect(client.public_channels['C0HLE0BBL']).not_to be_nil
42
- event = Slack::RealTime::Event.new(
43
- 'type' => 'channel_deleted',
44
- 'channel' => 'C0HLE0BBL'
45
- )
46
- client.send(:dispatch, event)
47
- expect(client.public_channels['C0HLE0BBL']).to be_nil
48
- end
49
-
50
- context 'channel_joined' do
51
- it 'creates channel' do
52
- expect(client.public_channels['CDEADBEEF']).to be_nil
53
- event = Slack::RealTime::Event.new(
54
- 'type' => 'channel_joined',
55
- 'channel' => {
56
- 'id' => 'CDEADBEEF',
57
- 'name' => 'beef'
58
- }
59
- )
60
- client.send(:dispatch, event)
61
- channel = client.public_channels['CDEADBEEF']
62
- expect(channel).not_to be_nil
63
- expect(channel.name).to eq 'beef'
64
- end
65
-
66
- it 'updates channel' do
67
- expect(client.public_channels['CDEADBEEF']).to be_nil
68
- client.public_channels['CDEADBEEF'] =
69
- Slack::RealTime::Models::Channel.new('id' => 'CDEADBEEF', name: 'beef')
70
- event = Slack::RealTime::Event.new(
71
- 'type' => 'channel_joined',
72
- 'channel' => {
73
- 'id' => 'CDEADBEEF',
74
- 'name' => 'beef',
75
- 'updated' => true
76
- }
77
- )
78
- client.send(:dispatch, event)
79
- channel = client.public_channels['CDEADBEEF']
80
- expect(channel).not_to be_nil
81
- expect(channel.updated).to be true
82
- end
83
- end
84
-
85
- it 'channel_left' do
86
- channel = client.public_channels['C0JHNAB5H']
87
- expect(channel.members).to include client.self.id
88
- event = Slack::RealTime::Event.new(
89
- 'type' => 'channel_left',
90
- 'channel' => 'C0JHNAB5H'
91
- )
92
- client.send(:dispatch, event)
93
- expect(channel.members).not_to include client.self.id
94
- end
95
-
96
- it 'channel_rename' do
97
- channel = client.public_channels['C0HLE0BBL']
98
- expect(channel.name).to eq 'gifs'
99
- event = Slack::RealTime::Event.new(
100
- 'type' => 'channel_rename',
101
- 'channel' => {
102
- 'id' => 'C0HLE0BBL',
103
- 'name' => 'updated',
104
- 'created' => 1_360_782_804
105
- }
106
- )
107
- client.send(:dispatch, event)
108
- expect(channel.name).to eq 'updated'
109
- end
110
-
111
- it 'channel_unarchive' do
112
- channel = client.public_channels['C0HLE0BBL']
113
- expect(channel.is_archived).to be true
114
- event = Slack::RealTime::Event.new(
115
- 'type' => 'channel_unarchive',
116
- 'channel' => 'C0HLE0BBL',
117
- 'user' => 'U04KB5WQR'
118
- )
119
- client.send(:dispatch, event)
120
- expect(channel.is_archived).to be false
121
- end
122
- end
123
- end
@@ -1,63 +0,0 @@
1
- # frozen_string_literal: true
2
- require 'spec_helper'
3
-
4
- [Slack::RealTime::Stores::Store, Slack::RealTime::Stores::Starter].each do |store_class|
5
- RSpec.describe store_class, vcr: { cassette_name: 'web/rtm_connect' } do
6
- include_context 'connected client', store_class: store_class
7
-
8
- context 'team' do
9
- it 'sets team data on rtm.connect' do
10
- expect(client.team.name).to eq 'dblock'
11
- expect(client.team.domain).to eq 'dblockdotorg'
12
- end
13
-
14
- it 'team_domain_change' do
15
- event = Slack::RealTime::Event.new(
16
- 'type' => 'team_domain_change',
17
- 'url' => 'https://my.slack.com',
18
- 'domain' => 'my'
19
- )
20
- client.send(:dispatch, event)
21
- expect(client.team.domain).to eq 'my'
22
- expect(client.team['url']).to eq 'https://my.slack.com'
23
- end
24
-
25
- it 'email_domain_changed' do
26
- event = Slack::RealTime::Event.new(
27
- 'type' => 'email_domain_changed',
28
- 'email_domain' => 'example.com'
29
- )
30
- client.send(:dispatch, event)
31
- expect(client.team.email_domain).to eq 'example.com'
32
- end
33
-
34
- it 'team_pref_change' do
35
- event = Slack::RealTime::Event.new(
36
- 'type' => 'team_pref_change',
37
- 'name' => 'invites_only_admins',
38
- 'value' => false
39
- )
40
- client.send(:dispatch, event)
41
- expect(client.team.prefs.invites_only_admins).to be false
42
- end
43
-
44
- it 'team_rename' do
45
- event = Slack::RealTime::Event.new(
46
- 'type' => 'team_rename',
47
- 'name' => 'New Team Name Inc.'
48
- )
49
- client.send(:dispatch, event)
50
- expect(client.team.name).to eq 'New Team Name Inc.'
51
- end
52
-
53
- it 'team_plan_change' do
54
- event = Slack::RealTime::Event.new(
55
- 'type' => 'team_plan_change',
56
- 'plan' => 'std'
57
- )
58
- client.send(:dispatch, event)
59
- expect(client.team.plan).to eq 'std'
60
- end
61
- end
62
- end
63
- end
@@ -1,65 +0,0 @@
1
- # frozen_string_literal: true
2
- require 'spec_helper'
3
-
4
- RSpec.describe Slack::RealTime::Client, vcr: { cassette_name: 'web/rtm_connect' } do
5
- include_context 'connected client'
6
- include_context 'loaded client'
7
-
8
- context 'user' do
9
- it 'user_change' do
10
- expect(client.users['U07KECJ77'].name).to eq 'aws'
11
- event = Slack::RealTime::Event.new(
12
- 'type' => 'user_change',
13
- 'user' => {
14
- 'id' => 'U07KECJ77', 'name' => 'renamed'
15
- }
16
- )
17
- client.send(:dispatch, event)
18
- expect(client.users['U07KECJ77'].name).to eq 'renamed'
19
- end
20
-
21
- it 'team_join' do
22
- expect do
23
- event = Slack::RealTime::Event.new(
24
- 'type' => 'team_join',
25
- 'user' => {
26
- 'id' => 'DEADBEEF', 'name' => 'added'
27
- }
28
- )
29
- client.send(:dispatch, event)
30
- end.to change(client.users, :count).by(1)
31
- expect(client.users['DEADBEEF'].name).to eq 'added'
32
- end
33
-
34
- it 'pref_change' do
35
- event = Slack::RealTime::Event.new(
36
- 'type' => 'pref_change',
37
- 'name' => 'push_sound',
38
- 'value' => 'updated.mp3'
39
- )
40
- client.send(:dispatch, event)
41
- expect(client.self.prefs['push_sound']).to eq 'updated.mp3'
42
- end
43
-
44
- it 'presence_change' do
45
- expect(client.users['U07KECJ77'].presence).to eq 'away'
46
- event = Slack::RealTime::Event.new(
47
- 'type' => 'presence_change',
48
- 'user' => 'U07KECJ77',
49
- 'presence' => 'updated'
50
- )
51
- client.send(:dispatch, event)
52
- expect(client.users['U07KECJ77'].presence).to eq 'updated'
53
- end
54
-
55
- it 'manual_presence_change' do
56
- expect(client.self['presence']).to eq 'away'
57
- event = Slack::RealTime::Event.new(
58
- 'type' => 'manual_presence_change',
59
- 'presence' => 'updated'
60
- )
61
- client.send(:dispatch, event)
62
- expect(client.self.presence).to eq 'updated'
63
- end
64
- end
65
- end
@@ -1,14 +0,0 @@
1
- # frozen_string_literal: true
2
- # require 'spec_helper'
3
-
4
- #
5
- # to re-record a rtm_connect fixture run with
6
- # SLACK_API_TOKEN=... CONCURRENCY=async-websocket rspec spec/slack/real_time/rtm_connect_spec.rb
7
- # edit rtm_connect.yml and remove the token, fix wss:// path (run specs, fix failures)
8
- #
9
-
10
- # RSpec.describe Slack::RealTime::Client, vcr: { cassette_name: 'web/rtm_connect' } do
11
- # it 'connects' do
12
- # Slack::Web::Client.new.rtm_connect(mpim_aware: true)
13
- # end
14
- # end
@@ -1,50 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- RSpec.describe Slack::RealTime::Stores::Store do
6
- it 'can be initialized with an empty hash' do
7
- store = described_class.new(Hashie::Mash.new)
8
- expect(store.team).to be_nil
9
- expect(store.teams.count).to eq 0
10
- expect(store.self).to be_nil
11
- expect(store.public_channels.count).to eq 0
12
- expect(store.private_channels.count).to eq 0
13
- end
14
-
15
- it 'includes event handlers in subclasses' do
16
- subclass = Class.new(described_class)
17
- expect(subclass.events.key?('channel_created')).to be true
18
- end
19
-
20
- context 'with client started' do
21
- let(:client) { Slack::RealTime::Client.new(store_class: described_class, concurrency: Slack::RealTime::Concurrency::Mock) }
22
-
23
- before do
24
- client.store = described_class.new(Hashie::Mash.new, { caches: :all })
25
- end
26
-
27
- it 'initializes itself with data' do
28
- team_info = Hashie::Mash.new(team: {})
29
- allow(client.web_client).to receive(:team_info).and_return(team_info)
30
- expect(client.web_client).to receive(:team_info)
31
- expect(client.web_client).to receive(:users_list)
32
- expect(client.web_client).to receive(:conversations_list).with(types: 'public_channel,private_channel,im,mpim')
33
- event = Slack::RealTime::Event.new('type' => 'hello', 'start' => true)
34
- client.send(:dispatch, event)
35
- end
36
-
37
- context 'when configured to only cache some types' do
38
- before do
39
- client.store = described_class.new(Hashie::Mash.new, { caches: %i[users public_channels] })
40
- end
41
-
42
- it 'initializes specified caches with data' do
43
- expect(client.web_client).to receive(:users_list)
44
- expect(client.web_client).to receive(:conversations_list).with(types: 'public_channel')
45
- event = Slack::RealTime::Event.new('type' => 'hello', 'start' => true)
46
- client.send(:dispatch, event)
47
- end
48
- end
49
- end
50
- end
@@ -1,93 +0,0 @@
1
- # frozen_string_literal: true
2
- require 'spec_helper'
3
-
4
- describe Slack do
5
- let(:slack) { File.expand_path(File.join(__FILE__, '../../../bin/slack')) }
6
-
7
- before do
8
- @token = ENV.delete('SLACK_API_TOKEN')
9
- end
10
-
11
- after do
12
- ENV['SLACK_API_TOKEN'] = @token if @token
13
- end
14
-
15
- describe '#help' do
16
- it 'displays help' do
17
- help = `"#{slack}" help`
18
- expect(help).to include 'slack - Slack client.'
19
- end
20
- end
21
-
22
- context 'globals' do
23
- let(:command) do
24
- "\"#{slack}\" --vcr-cassette-name=web/auth_test_success " \
25
- '--slack-api-token=token -d auth test 2>&1'
26
- end
27
-
28
- it 'enables request and response logging with -d' do
29
- output = `#{command}`
30
- expect(output).to include 'POST https://slack.com/api/auth.test'
31
- expect(output).to include 'Status 200'
32
- end
33
-
34
- it 'requires --slack-api-token' do
35
- err = `"#{slack}" auth test 2>&1`
36
- expect(err).to(
37
- start_with(
38
- 'error: parse error: Set Slack API token via --slack-api-token or SLACK_API_TOKEN.'
39
- )
40
- )
41
- end
42
- end
43
-
44
- describe '#auth' do
45
- context 'bad auth' do
46
- let(:command) do
47
- "\"#{slack}\" --vcr-cassette-name=web/auth_test_error " \
48
- '--slack-api-token=token auth test 2>&1'
49
- end
50
-
51
- it 'fails with an exception' do
52
- err = `#{command}`
53
- expect(err).to eq "error: not_authed\n"
54
- end
55
- end
56
-
57
- context 'good auth' do
58
- let(:command) do
59
- "\"#{slack}\" --vcr-cassette-name=web/auth_test_success " \
60
- '--slack-api-token=token auth test 2>&1'
61
- end
62
-
63
- it 'succeeds' do
64
- json = Slack::Messages::Message.new(JSON[`#{command}`])
65
- expect(json).to eq(
66
- 'bot_id' => 'B0J1L75DY',
67
- 'is_enterprise_install' => false,
68
- 'ok' => true,
69
- 'url' => 'https://rubybot.slack.com/',
70
- 'team' => 'team_name',
71
- 'user' => 'user_name',
72
- 'team_id' => 'TDEADBEEF',
73
- 'user_id' => 'UBAADFOOD'
74
- )
75
- expect(json.ok).to be true
76
- end
77
- end
78
- end
79
-
80
- describe '#users' do
81
- let(:command) do
82
- "\"#{slack}\" --vcr-cassette-name=web/users_list " \
83
- '--slack-api-token=token users list --presence=true 2>&1'
84
- end
85
-
86
- it 'list' do
87
- json = Slack::Messages::Message.new(JSON[`#{command}`])
88
- expect(json.ok).to be true
89
- expect(json.members.size).to eq 35
90
- expect(json.members.first['presence']).to eq 'away'
91
- end
92
- end
93
- end
@@ -1,8 +0,0 @@
1
- # frozen_string_literal: true
2
- require 'spec_helper'
3
-
4
- describe Slack do
5
- it 'has a version' do
6
- expect(Slack::VERSION).not_to be_nil
7
- end
8
- end
@@ -1,13 +0,0 @@
1
- # frozen_string_literal: true
2
- # This file was auto-generated by lib/tasks/web.rake
3
-
4
- require 'spec_helper'
5
-
6
- RSpec.describe Slack::Web::Api::Endpoints::AdminAnalytics do
7
- let(:client) { Slack::Web::Client.new }
8
- context 'admin.analytics_getFile' do
9
- it 'requires type' do
10
- expect { client.admin_analytics_getFile }.to raise_error ArgumentError, /Required arguments :type missing/
11
- end
12
- end
13
- end
@@ -1,8 +0,0 @@
1
- # frozen_string_literal: true
2
- # This file was auto-generated by lib/tasks/web.rake
3
-
4
- require 'spec_helper'
5
-
6
- RSpec.describe Slack::Web::Api::Endpoints::AdminAppsActivities do
7
- let(:client) { Slack::Web::Client.new }
8
- end
@@ -1,8 +0,0 @@
1
- # frozen_string_literal: true
2
- # This file was auto-generated by lib/tasks/web.rake
3
-
4
- require 'spec_helper'
5
-
6
- RSpec.describe Slack::Web::Api::Endpoints::AdminAppsApproved do
7
- let(:client) { Slack::Web::Client.new }
8
- end
@@ -1,18 +0,0 @@
1
- # frozen_string_literal: true
2
- # This file was auto-generated by lib/tasks/web.rake
3
-
4
- require 'spec_helper'
5
-
6
- RSpec.describe Slack::Web::Api::Endpoints::AdminAppsConfig do
7
- let(:client) { Slack::Web::Client.new }
8
- context 'admin.apps.config_lookup' do
9
- it 'requires app_ids' do
10
- expect { client.admin_apps_config_lookup }.to raise_error ArgumentError, /Required arguments :app_ids missing/
11
- end
12
- end
13
- context 'admin.apps.config_set' do
14
- it 'requires app_id' do
15
- expect { client.admin_apps_config_set }.to raise_error ArgumentError, /Required arguments :app_id missing/
16
- end
17
- end
18
- end
@@ -1,13 +0,0 @@
1
- # frozen_string_literal: true
2
- # This file was auto-generated by lib/tasks/web.rake
3
-
4
- require 'spec_helper'
5
-
6
- RSpec.describe Slack::Web::Api::Endpoints::AdminAppsRequests do
7
- let(:client) { Slack::Web::Client.new }
8
- context 'admin.apps.requests_cancel' do
9
- it 'requires request_id' do
10
- expect { client.admin_apps_requests_cancel }.to raise_error ArgumentError, /Required arguments :request_id missing/
11
- end
12
- end
13
- end
@@ -1,8 +0,0 @@
1
- # frozen_string_literal: true
2
- # This file was auto-generated by lib/tasks/web.rake
3
-
4
- require 'spec_helper'
5
-
6
- RSpec.describe Slack::Web::Api::Endpoints::AdminAppsRestricted do
7
- let(:client) { Slack::Web::Client.new }
8
- end