slack-ruby-client 0.14.5 → 0.17.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/FUNDING.yml +1 -0
- data/.rubocop.yml +11 -3
- data/.rubocop_todo.yml +61 -23
- data/.travis.yml +1 -5
- data/CHANGELOG.md +43 -4
- data/CONTRIBUTING.md +17 -6
- data/Dangerfile +1 -1
- data/Gemfile +1 -2
- data/LICENSE.md +1 -1
- data/README.md +86 -52
- data/UPGRADING.md +20 -2
- data/bin/commands.rb +23 -0
- data/bin/commands/admin_analytics.rb +16 -0
- data/bin/commands/admin_apps.rb +15 -2
- data/bin/commands/admin_apps_approved.rb +17 -0
- data/bin/commands/admin_apps_restricted.rb +17 -0
- data/bin/commands/admin_barriers.rb +47 -0
- data/bin/commands/admin_conversations.rb +159 -0
- data/bin/commands/admin_conversations_ekm.rb +17 -0
- data/bin/commands/admin_conversations_restrictAccess.rb +37 -0
- data/bin/commands/admin_conversations_whitelist.rb +37 -0
- data/bin/commands/admin_emoji.rb +54 -0
- data/bin/commands/admin_inviteRequests.rb +36 -0
- data/bin/commands/admin_inviteRequests_approved.rb +16 -0
- data/bin/commands/admin_inviteRequests_denied.rb +16 -0
- data/bin/commands/admin_teams.rb +27 -0
- data/bin/commands/admin_teams_admins.rb +16 -0
- data/bin/commands/admin_teams_owners.rb +16 -0
- data/bin/commands/admin_teams_settings.rb +64 -0
- data/bin/commands/admin_usergroups.rb +48 -0
- data/bin/commands/admin_users.rb +97 -0
- data/bin/commands/admin_users_session.rb +22 -0
- data/bin/commands/api.rb +0 -1
- data/bin/commands/apps_connections.rb +13 -0
- data/bin/commands/apps_event_authorizations.rb +16 -0
- data/bin/commands/auth_teams.rb +16 -0
- data/bin/commands/bots.rb +1 -0
- data/bin/commands/calls.rb +52 -0
- data/bin/commands/calls_participants.rb +25 -0
- data/bin/commands/channels.rb +1 -155
- data/bin/commands/chat.rb +14 -12
- data/bin/commands/chat_scheduledMessages.rb +1 -0
- data/bin/commands/conversations.rb +15 -4
- data/bin/commands/dnd.rb +3 -1
- data/bin/commands/files.rb +7 -5
- data/bin/commands/files_remote.rb +3 -3
- data/bin/commands/groups.rb +1 -162
- data/bin/commands/im.rb +1 -63
- data/bin/commands/migration.rb +1 -0
- data/bin/commands/mpim.rb +1 -61
- data/bin/commands/oauth.rb +1 -1
- data/bin/commands/pins.rb +0 -2
- data/bin/commands/reactions.rb +1 -0
- data/bin/commands/search.rb +4 -1
- data/bin/commands/team.rb +3 -0
- data/bin/commands/usergroups.rb +6 -1
- data/bin/commands/usergroups_users.rb +2 -0
- data/bin/commands/users.rb +5 -3
- data/bin/commands/users_profile.rb +5 -5
- data/bin/commands/views.rb +1 -1
- data/bin/commands/workflows.rb +38 -0
- data/lib/slack-ruby-client.rb +5 -4
- data/lib/slack/events/request.rb +7 -3
- data/lib/slack/messages/message.rb +0 -4
- data/lib/slack/real_time/client.rb +2 -1
- data/lib/slack/real_time/concurrency.rb +0 -2
- data/lib/slack/real_time/concurrency/async.rb +1 -3
- data/lib/slack/real_time/config.rb +5 -14
- data/lib/slack/real_time/models/base.rb +0 -4
- data/lib/slack/real_time/socket.rb +2 -2
- data/lib/slack/real_time/stores/base.rb +3 -1
- data/lib/slack/version.rb +1 -1
- data/lib/slack/web/api/endpoints.rb +47 -0
- data/lib/slack/web/api/endpoints/admin_analytics.rb +28 -0
- data/lib/slack/web/api/endpoints/admin_apps.rb +22 -2
- data/lib/slack/web/api/endpoints/admin_apps_approved.rb +35 -0
- data/lib/slack/web/api/endpoints/admin_apps_restricted.rb +35 -0
- data/lib/slack/web/api/endpoints/admin_barriers.rb +82 -0
- data/lib/slack/web/api/endpoints/admin_conversations.rb +246 -0
- data/lib/slack/web/api/endpoints/admin_conversations_ekm.rb +35 -0
- data/lib/slack/web/api/endpoints/admin_conversations_restrictAccess.rb +61 -0
- data/lib/slack/web/api/endpoints/admin_conversations_whitelist.rb +64 -0
- data/lib/slack/web/api/endpoints/admin_emoji.rb +88 -0
- data/lib/slack/web/api/endpoints/admin_inviteRequests.rb +61 -0
- data/lib/slack/web/api/endpoints/admin_inviteRequests_approved.rb +33 -0
- data/lib/slack/web/api/endpoints/admin_inviteRequests_denied.rb +33 -0
- data/lib/slack/web/api/endpoints/admin_teams.rb +50 -0
- data/lib/slack/web/api/endpoints/admin_teams_admins.rb +34 -0
- data/lib/slack/web/api/endpoints/admin_teams_owners.rb +34 -0
- data/lib/slack/web/api/endpoints/admin_teams_settings.rb +99 -0
- data/lib/slack/web/api/endpoints/admin_usergroups.rb +77 -0
- data/lib/slack/web/api/endpoints/admin_users.rb +161 -0
- data/lib/slack/web/api/endpoints/admin_users_session.rb +38 -0
- data/lib/slack/web/api/endpoints/api.rb +0 -2
- data/lib/slack/web/api/endpoints/apps_connections.rb +21 -0
- data/lib/slack/web/api/endpoints/apps_event_authorizations.rb +34 -0
- data/lib/slack/web/api/endpoints/auth_teams.rb +33 -0
- data/lib/slack/web/api/endpoints/bots.rb +2 -0
- data/lib/slack/web/api/endpoints/calls.rb +83 -0
- data/lib/slack/web/api/endpoints/calls_participants.rb +42 -0
- data/lib/slack/web/api/endpoints/channels.rb +1 -245
- data/lib/slack/web/api/endpoints/chat.rb +23 -19
- data/lib/slack/web/api/endpoints/chat_scheduledMessages.rb +3 -1
- data/lib/slack/web/api/endpoints/conversations.rb +37 -19
- data/lib/slack/web/api/endpoints/dnd.rb +4 -0
- data/lib/slack/web/api/endpoints/files.rb +8 -4
- data/lib/slack/web/api/endpoints/files_remote.rb +4 -4
- data/lib/slack/web/api/endpoints/groups.rb +0 -253
- data/lib/slack/web/api/endpoints/im.rb +0 -101
- data/lib/slack/web/api/endpoints/migration.rb +2 -0
- data/lib/slack/web/api/endpoints/mpim.rb +0 -96
- data/lib/slack/web/api/endpoints/oauth.rb +1 -4
- data/lib/slack/web/api/endpoints/pins.rb +3 -8
- data/lib/slack/web/api/endpoints/reactions.rb +5 -3
- data/lib/slack/web/api/endpoints/search.rb +6 -0
- data/lib/slack/web/api/endpoints/stars.rb +2 -2
- data/lib/slack/web/api/endpoints/team.rb +6 -0
- data/lib/slack/web/api/endpoints/usergroups.rb +10 -0
- data/lib/slack/web/api/endpoints/usergroups_users.rb +4 -0
- data/lib/slack/web/api/endpoints/users.rb +7 -5
- data/lib/slack/web/api/endpoints/users_profile.rb +3 -3
- data/lib/slack/web/api/endpoints/views.rb +1 -1
- data/lib/slack/web/api/endpoints/workflows.rb +61 -0
- data/lib/slack/web/api/errors.rb +848 -0
- data/lib/slack/web/api/errors/internal_error.rb +14 -0
- data/lib/slack/web/api/errors/slack_error.rb +12 -0
- data/lib/slack/web/api/mixins.rb +1 -0
- data/lib/slack/web/api/mixins/channels.id.rb +1 -3
- data/lib/slack/web/api/mixins/conversations.id.rb +25 -0
- data/lib/slack/web/api/mixins/groups.id.rb +1 -3
- data/lib/slack/web/api/mixins/ids.id.rb +3 -5
- data/lib/slack/web/api/mixins/users.id.rb +1 -3
- data/lib/slack/web/api/patches/{chat.6.block-kit-support.patch → chat.1.patch} +26 -24
- data/lib/slack/web/api/templates/endpoints.erb +1 -0
- data/lib/slack/web/api/templates/errors.erb +20 -0
- data/lib/slack/web/api/templates/method.erb +4 -1
- data/lib/slack/web/api/templates/method_spec.erb +1 -1
- data/lib/slack/web/client.rb +1 -1
- data/lib/slack/web/config.rb +2 -0
- data/lib/slack/web/faraday/connection.rb +23 -20
- data/lib/slack/web/faraday/response/raise_error.rb +16 -2
- data/lib/slack/web/faraday/response/wrap_error.rb +24 -0
- data/lib/slack/web/pagination/cursor.rb +2 -2
- data/lib/tasks/real_time.rake +1 -1
- data/lib/tasks/web.rake +21 -4
- data/slack-ruby-client.gemspec +5 -5
- data/spec/fixtures/slack/web/channels_info.yml +108 -15
- data/spec/fixtures/slack/web/{groups_info.yml → conversations_info.yml} +4 -4
- data/spec/fixtures/slack/web/conversations_setTopic.yml +69 -0
- data/spec/fixtures/slack/web/conversations_setTopic_one_page.yml +142 -0
- data/spec/fixtures/slack/web/conversations_setTopic_paginated.yml +208 -0
- data/spec/fixtures/slack/web/views_open_error.yml +76 -0
- data/spec/slack/events/request_spec.rb +13 -8
- data/spec/slack/real_time/client_spec.rb +18 -1
- data/spec/slack/real_time/concurrency/with_concurrency_spec.rb +10 -0
- data/spec/slack/real_time/concurrency/without_concurrency_spec.rb +10 -0
- data/spec/slack/real_time/rtm_connect_spec.rb +1 -1
- data/spec/slack/real_time/rtm_start_spec.rb +1 -1
- data/spec/slack/web/api/endpoints/admin_analytics_spec.rb +13 -0
- data/spec/slack/web/api/endpoints/admin_apps_approved_spec.rb +8 -0
- data/spec/slack/web/api/endpoints/admin_apps_restricted_spec.rb +8 -0
- data/spec/slack/web/api/endpoints/admin_apps_spec.rb +5 -0
- data/spec/slack/web/api/endpoints/admin_barriers_spec.rb +38 -0
- data/spec/slack/web/api/endpoints/admin_conversations_ekm_spec.rb +8 -0
- data/spec/slack/web/api/endpoints/admin_conversations_restrictAccess_spec.rb +32 -0
- data/spec/slack/web/api/endpoints/admin_conversations_spec.rb +93 -0
- data/spec/slack/web/api/endpoints/admin_emoji_spec.rb +37 -0
- data/spec/slack/web/api/endpoints/admin_inviteRequests_approved_spec.rb +8 -0
- data/spec/slack/web/api/endpoints/admin_inviteRequests_denied_spec.rb +8 -0
- data/spec/slack/web/api/endpoints/admin_inviteRequests_spec.rb +18 -0
- data/spec/slack/web/api/endpoints/admin_teams_admins_spec.rb +13 -0
- data/spec/slack/web/api/endpoints/admin_teams_owners_spec.rb +13 -0
- data/spec/slack/web/api/endpoints/admin_teams_settings_spec.rb +53 -0
- data/spec/slack/web/api/endpoints/admin_teams_spec.rb +16 -0
- data/spec/slack/web/api/endpoints/admin_usergroups_spec.rb +37 -0
- data/spec/slack/web/api/endpoints/admin_users_session_spec.rb +8 -0
- data/spec/slack/web/api/endpoints/admin_users_spec.rb +67 -0
- data/spec/slack/web/api/endpoints/apps_connections_spec.rb +8 -0
- data/spec/slack/web/api/endpoints/apps_event_authorizations_spec.rb +13 -0
- data/spec/slack/web/api/endpoints/apps_permissions_spec.rb +2 -2
- data/spec/slack/web/api/endpoints/apps_permissions_users_spec.rb +3 -3
- data/spec/slack/web/api/endpoints/apps_spec.rb +2 -2
- data/spec/slack/web/api/endpoints/auth_teams_spec.rb +8 -0
- data/spec/slack/web/api/endpoints/calls_participants_spec.rb +24 -0
- data/spec/slack/web/api/endpoints/calls_spec.rb +31 -0
- data/spec/slack/web/api/endpoints/conversations_spec.rb +20 -12
- data/spec/slack/web/api/endpoints/custom_specs/conversations_spec.rb +13 -0
- data/spec/slack/web/api/endpoints/files_comments_spec.rb +2 -2
- data/spec/slack/web/api/endpoints/files_remote_spec.rb +3 -3
- data/spec/slack/web/api/endpoints/files_spec.rb +4 -4
- data/spec/slack/web/api/endpoints/im_spec.rb +0 -31
- data/spec/slack/web/api/endpoints/mpim_spec.rb +0 -31
- data/spec/slack/web/api/endpoints/oauth_spec.rb +3 -14
- data/spec/slack/web/api/endpoints/pins_spec.rb +1 -4
- data/spec/slack/web/api/endpoints/reactions_spec.rb +3 -3
- data/spec/slack/web/api/endpoints/reminders_spec.rb +2 -2
- data/spec/slack/web/api/endpoints/usergroups_users_spec.rb +2 -2
- data/spec/slack/web/api/endpoints/workflows_spec.rb +26 -0
- data/spec/slack/web/api/errors/slack_error_spec.rb +22 -0
- data/spec/slack/web/api/mixins/channels_spec.rb +1 -1
- data/spec/slack/web/api/mixins/conversations_list_spec.rb +21 -0
- data/spec/slack/web/api/mixins/conversations_spec.rb +43 -0
- data/spec/slack/web/api/mixins/groups_spec.rb +1 -1
- data/spec/slack/web/api/mixins/users_spec.rb +1 -1
- data/spec/slack/web/client_spec.rb +121 -0
- data/spec/slack/web/faraday/response/raise_error_spec.rb +33 -9
- data/spec/support/vcr.rb +4 -0
- metadata +145 -55
- data/examples/hi_real_time/Gemfile +0 -6
- data/examples/hi_real_time/hi.gif +0 -0
- data/examples/hi_real_time/hi.rb +0 -41
- data/examples/hi_real_time_async_celluloid/Gemfile +0 -7
- data/examples/hi_real_time_async_celluloid/Procfile +0 -2
- data/examples/hi_real_time_async_celluloid/hi.rb +0 -39
- data/examples/hi_real_time_async_eventmachine/Gemfile +0 -7
- data/examples/hi_real_time_async_eventmachine/Procfile +0 -2
- data/examples/hi_real_time_async_eventmachine/hi.rb +0 -39
- data/lib/slack/real_time/concurrency/celluloid.rb +0 -142
- data/lib/slack/real_time/concurrency/eventmachine.rb +0 -85
- data/lib/slack/web/api/patches/chat.1.text-attachments-required.patch +0 -13
- data/lib/slack/web/api/patches/chat.2.attachments-json.patch +0 -17
- data/lib/slack/web/api/patches/chat.3.update-attachments-support.patch +0 -21
- data/lib/slack/web/api/patches/chat.4.postEphemeral-attachments-support.patch +0 -17
- data/lib/slack/web/api/patches/chat.5.postEphemeral-text-or-attachments.patch +0 -15
- data/spec/slack/real_time/concurrency/celluloid_spec.rb +0 -116
- data/spec/slack/real_time/concurrency/eventmachine_spec.rb +0 -57
- data/spec/slack/web/api/endpoints/custom_specs/channels_spec.rb +0 -13
- data/spec/slack/web/api/endpoints/custom_specs/groups_spec.rb +0 -13
- data/spec/slack/web/api/endpoints/views_spec.rb +0 -29
- data/spec/slack/web/api/errors/service_unavailable_spec.rb +0 -17
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
RSpec.describe Slack::Web::Api::Endpoints::Groups do
|
5
|
+
let(:client) { Slack::Web::Client.new }
|
6
|
+
|
7
|
+
context 'groups' do
|
8
|
+
it 'info', vcr: { cassette_name: 'web/conversations_info' } do
|
9
|
+
json = client.conversations_info(channel: '#mpdm-dblock--rubybot--player1-1')
|
10
|
+
expect(json.channel.name).to eq 'mpdm-dblock--rubybot--player1-1'
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -7,10 +7,10 @@ RSpec.describe Slack::Web::Api::Endpoints::FilesComments do
|
|
7
7
|
let(:client) { Slack::Web::Client.new }
|
8
8
|
context 'files.comments_delete' do
|
9
9
|
it 'requires file' do
|
10
|
-
expect { client.files_comments_delete(id:
|
10
|
+
expect { client.files_comments_delete(id: %q[Fc1234567890]) }.to raise_error ArgumentError, /Required arguments :file missing/
|
11
11
|
end
|
12
12
|
it 'requires id' do
|
13
|
-
expect { client.files_comments_delete(file:
|
13
|
+
expect { client.files_comments_delete(file: %q[F1234567890]) }.to raise_error ArgumentError, /Required arguments :id missing/
|
14
14
|
end
|
15
15
|
end
|
16
16
|
end
|
@@ -7,13 +7,13 @@ RSpec.describe Slack::Web::Api::Endpoints::FilesRemote do
|
|
7
7
|
let(:client) { Slack::Web::Client.new }
|
8
8
|
context 'files.remote_add' do
|
9
9
|
it 'requires external_id' do
|
10
|
-
expect { client.files_remote_add(external_url:
|
10
|
+
expect { client.files_remote_add(external_url: %q[http://example.com/my_cloud_service_file/abc123], title: %q[Danger, High Voltage!]) }.to raise_error ArgumentError, /Required arguments :external_id missing/
|
11
11
|
end
|
12
12
|
it 'requires external_url' do
|
13
|
-
expect { client.files_remote_add(external_id:
|
13
|
+
expect { client.files_remote_add(external_id: %q[123456], title: %q[Danger, High Voltage!]) }.to raise_error ArgumentError, /Required arguments :external_url missing/
|
14
14
|
end
|
15
15
|
it 'requires title' do
|
16
|
-
expect { client.files_remote_add(external_id:
|
16
|
+
expect { client.files_remote_add(external_id: %q[123456], external_url: %q[http://example.com/my_cloud_service_file/abc123]) }.to raise_error ArgumentError, /Required arguments :title missing/
|
17
17
|
end
|
18
18
|
end
|
19
19
|
context 'files.remote_share' do
|
@@ -12,10 +12,10 @@ RSpec.describe Slack::Web::Api::Endpoints::Files do
|
|
12
12
|
end
|
13
13
|
context 'files_edit' do
|
14
14
|
it 'requires file' do
|
15
|
-
expect { client.files_edit(title:
|
15
|
+
expect { client.files_edit(title: %q[Brand new title]) }.to raise_error ArgumentError, /Required arguments :file missing/
|
16
16
|
end
|
17
17
|
it 'requires title' do
|
18
|
-
expect { client.files_edit(file:
|
18
|
+
expect { client.files_edit(file: %q[F2147483862]) }.to raise_error ArgumentError, /Required arguments :title missing/
|
19
19
|
end
|
20
20
|
end
|
21
21
|
context 'files_info' do
|
@@ -30,10 +30,10 @@ RSpec.describe Slack::Web::Api::Endpoints::Files do
|
|
30
30
|
end
|
31
31
|
context 'files_share' do
|
32
32
|
it 'requires file' do
|
33
|
-
expect { client.files_share(channel:
|
33
|
+
expect { client.files_share(channel: %q[C1234567890]) }.to raise_error ArgumentError, /Required arguments :file missing/
|
34
34
|
end
|
35
35
|
it 'requires channel' do
|
36
|
-
expect { client.files_share(file:
|
36
|
+
expect { client.files_share(file: %q[F2147483862]) }.to raise_error ArgumentError, /Required arguments :channel missing/
|
37
37
|
end
|
38
38
|
end
|
39
39
|
context 'files_sharedPublicURL' do
|
@@ -5,35 +5,4 @@ require 'spec_helper'
|
|
5
5
|
|
6
6
|
RSpec.describe Slack::Web::Api::Endpoints::Im do
|
7
7
|
let(:client) { Slack::Web::Client.new }
|
8
|
-
context 'im_close' do
|
9
|
-
it 'requires channel' do
|
10
|
-
expect { client.im_close }.to raise_error ArgumentError, /Required arguments :channel missing/
|
11
|
-
end
|
12
|
-
end
|
13
|
-
context 'im_history' do
|
14
|
-
it 'requires channel' do
|
15
|
-
expect { client.im_history }.to raise_error ArgumentError, /Required arguments :channel missing/
|
16
|
-
end
|
17
|
-
end
|
18
|
-
context 'im_mark' do
|
19
|
-
it 'requires channel' do
|
20
|
-
expect { client.im_mark(ts: '1234567890.123456') }.to raise_error ArgumentError, /Required arguments :channel missing/
|
21
|
-
end
|
22
|
-
it 'requires ts' do
|
23
|
-
expect { client.im_mark(channel: 'D1234567890') }.to raise_error ArgumentError, /Required arguments :ts missing/
|
24
|
-
end
|
25
|
-
end
|
26
|
-
context 'im_open' do
|
27
|
-
it 'requires user' do
|
28
|
-
expect { client.im_open }.to raise_error ArgumentError, /Required arguments :user missing/
|
29
|
-
end
|
30
|
-
end
|
31
|
-
context 'im_replies' do
|
32
|
-
it 'requires channel' do
|
33
|
-
expect { client.im_replies(thread_ts: '1234567890.123456') }.to raise_error ArgumentError, /Required arguments :channel missing/
|
34
|
-
end
|
35
|
-
it 'requires thread_ts' do
|
36
|
-
expect { client.im_replies(channel: 'C1234567890') }.to raise_error ArgumentError, /Required arguments :thread_ts missing/
|
37
|
-
end
|
38
|
-
end
|
39
8
|
end
|
@@ -5,35 +5,4 @@ require 'spec_helper'
|
|
5
5
|
|
6
6
|
RSpec.describe Slack::Web::Api::Endpoints::Mpim do
|
7
7
|
let(:client) { Slack::Web::Client.new }
|
8
|
-
context 'mpim_close' do
|
9
|
-
it 'requires channel' do
|
10
|
-
expect { client.mpim_close }.to raise_error ArgumentError, /Required arguments :channel missing/
|
11
|
-
end
|
12
|
-
end
|
13
|
-
context 'mpim_history' do
|
14
|
-
it 'requires channel' do
|
15
|
-
expect { client.mpim_history }.to raise_error ArgumentError, /Required arguments :channel missing/
|
16
|
-
end
|
17
|
-
end
|
18
|
-
context 'mpim_mark' do
|
19
|
-
it 'requires channel' do
|
20
|
-
expect { client.mpim_mark(ts: '1234567890.123456') }.to raise_error ArgumentError, /Required arguments :channel missing/
|
21
|
-
end
|
22
|
-
it 'requires ts' do
|
23
|
-
expect { client.mpim_mark(channel: 'G1234567890') }.to raise_error ArgumentError, /Required arguments :ts missing/
|
24
|
-
end
|
25
|
-
end
|
26
|
-
context 'mpim_open' do
|
27
|
-
it 'requires users' do
|
28
|
-
expect { client.mpim_open }.to raise_error ArgumentError, /Required arguments :users missing/
|
29
|
-
end
|
30
|
-
end
|
31
|
-
context 'mpim_replies' do
|
32
|
-
it 'requires channel' do
|
33
|
-
expect { client.mpim_replies(thread_ts: '1234567890.123456') }.to raise_error ArgumentError, /Required arguments :channel missing/
|
34
|
-
end
|
35
|
-
it 'requires thread_ts' do
|
36
|
-
expect { client.mpim_replies(channel: 'C1234567890') }.to raise_error ArgumentError, /Required arguments :thread_ts missing/
|
37
|
-
end
|
38
|
-
end
|
39
8
|
end
|
@@ -5,26 +5,15 @@ require 'spec_helper'
|
|
5
5
|
|
6
6
|
RSpec.describe Slack::Web::Api::Endpoints::Oauth do
|
7
7
|
let(:client) { Slack::Web::Client.new }
|
8
|
-
context 'oauth_access' do
|
9
|
-
it 'requires client_id' do
|
10
|
-
expect { client.oauth_access(client_secret: '33fea0113f5b1', code: 'ccdaa72ad') }.to raise_error ArgumentError, /Required arguments :client_id missing/
|
11
|
-
end
|
12
|
-
it 'requires client_secret' do
|
13
|
-
expect { client.oauth_access(client_id: '4b39e9-752c4', code: 'ccdaa72ad') }.to raise_error ArgumentError, /Required arguments :client_secret missing/
|
14
|
-
end
|
15
|
-
it 'requires code' do
|
16
|
-
expect { client.oauth_access(client_id: '4b39e9-752c4', client_secret: '33fea0113f5b1') }.to raise_error ArgumentError, /Required arguments :code missing/
|
17
|
-
end
|
18
|
-
end
|
19
8
|
context 'oauth_token' do
|
20
9
|
it 'requires client_id' do
|
21
|
-
expect { client.oauth_token(client_secret:
|
10
|
+
expect { client.oauth_token(client_secret: %q[33fea0113f5b1], code: %q[ccdaa72ad]) }.to raise_error ArgumentError, /Required arguments :client_id missing/
|
22
11
|
end
|
23
12
|
it 'requires client_secret' do
|
24
|
-
expect { client.oauth_token(client_id:
|
13
|
+
expect { client.oauth_token(client_id: %q[4b39e9-752c4], code: %q[ccdaa72ad]) }.to raise_error ArgumentError, /Required arguments :client_secret missing/
|
25
14
|
end
|
26
15
|
it 'requires code' do
|
27
|
-
expect { client.oauth_token(client_id:
|
16
|
+
expect { client.oauth_token(client_id: %q[4b39e9-752c4], client_secret: %q[33fea0113f5b1]) }.to raise_error ArgumentError, /Required arguments :code missing/
|
28
17
|
end
|
29
18
|
end
|
30
19
|
end
|
@@ -7,10 +7,7 @@ RSpec.describe Slack::Web::Api::Endpoints::Pins do
|
|
7
7
|
let(:client) { Slack::Web::Client.new }
|
8
8
|
context 'pins_add' do
|
9
9
|
it 'requires channel' do
|
10
|
-
expect { client.pins_add
|
11
|
-
end
|
12
|
-
it 'requires timestamp' do
|
13
|
-
expect { client.pins_add(channel: 'C1234567890') }.to raise_error ArgumentError, /Required arguments :timestamp missing/
|
10
|
+
expect { client.pins_add }.to raise_error ArgumentError, /Required arguments :channel missing/
|
14
11
|
end
|
15
12
|
end
|
16
13
|
context 'pins_list' do
|
@@ -7,13 +7,13 @@ RSpec.describe Slack::Web::Api::Endpoints::Reactions do
|
|
7
7
|
let(:client) { Slack::Web::Client.new }
|
8
8
|
context 'reactions_add' do
|
9
9
|
it 'requires channel' do
|
10
|
-
expect { client.reactions_add(name:
|
10
|
+
expect { client.reactions_add(name: %q[thumbsup], timestamp: %q[1234567890.123456]) }.to raise_error ArgumentError, /Required arguments :channel missing/
|
11
11
|
end
|
12
12
|
it 'requires name' do
|
13
|
-
expect { client.reactions_add(channel:
|
13
|
+
expect { client.reactions_add(channel: %q[C1234567890], timestamp: %q[1234567890.123456]) }.to raise_error ArgumentError, /Required arguments :name missing/
|
14
14
|
end
|
15
15
|
it 'requires timestamp' do
|
16
|
-
expect { client.reactions_add(channel:
|
16
|
+
expect { client.reactions_add(channel: %q[C1234567890], name: %q[thumbsup]) }.to raise_error ArgumentError, /Required arguments :timestamp missing/
|
17
17
|
end
|
18
18
|
end
|
19
19
|
context 'reactions_remove' do
|
@@ -7,10 +7,10 @@ RSpec.describe Slack::Web::Api::Endpoints::Reminders do
|
|
7
7
|
let(:client) { Slack::Web::Client.new }
|
8
8
|
context 'reminders_add' do
|
9
9
|
it 'requires text' do
|
10
|
-
expect { client.reminders_add(time:
|
10
|
+
expect { client.reminders_add(time: %q[1602288000]) }.to raise_error ArgumentError, /Required arguments :text missing/
|
11
11
|
end
|
12
12
|
it 'requires time' do
|
13
|
-
expect { client.reminders_add(text:
|
13
|
+
expect { client.reminders_add(text: %q[eat a banana]) }.to raise_error ArgumentError, /Required arguments :time missing/
|
14
14
|
end
|
15
15
|
end
|
16
16
|
context 'reminders_complete' do
|
@@ -12,10 +12,10 @@ RSpec.describe Slack::Web::Api::Endpoints::UsergroupsUsers do
|
|
12
12
|
end
|
13
13
|
context 'usergroups.users_update' do
|
14
14
|
it 'requires usergroup' do
|
15
|
-
expect { client.usergroups_users_update(users:
|
15
|
+
expect { client.usergroups_users_update(users: %q[U060R4BJ4,U060RNRCZ]) }.to raise_error ArgumentError, /Required arguments :usergroup missing/
|
16
16
|
end
|
17
17
|
it 'requires users' do
|
18
|
-
expect { client.usergroups_users_update(usergroup:
|
18
|
+
expect { client.usergroups_users_update(usergroup: %q[S0604QSJC]) }.to raise_error ArgumentError, /Required arguments :users missing/
|
19
19
|
end
|
20
20
|
end
|
21
21
|
end
|
@@ -0,0 +1,26 @@
|
|
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::Workflows do
|
7
|
+
let(:client) { Slack::Web::Client.new }
|
8
|
+
context 'workflows_stepCompleted' do
|
9
|
+
it 'requires workflow_step_execute_id' do
|
10
|
+
expect { client.workflows_stepCompleted }.to raise_error ArgumentError, /Required arguments :workflow_step_execute_id missing/
|
11
|
+
end
|
12
|
+
end
|
13
|
+
context 'workflows_stepFailed' do
|
14
|
+
it 'requires error' do
|
15
|
+
expect { client.workflows_stepFailed(workflow_step_execute_id: %q[]) }.to raise_error ArgumentError, /Required arguments :error missing/
|
16
|
+
end
|
17
|
+
it 'requires workflow_step_execute_id' do
|
18
|
+
expect { client.workflows_stepFailed(error: %q[]) }.to raise_error ArgumentError, /Required arguments :workflow_step_execute_id missing/
|
19
|
+
end
|
20
|
+
end
|
21
|
+
context 'workflows_updateStep' do
|
22
|
+
it 'requires workflow_step_edit_id' do
|
23
|
+
expect { client.workflows_updateStep }.to raise_error ArgumentError, /Required arguments :workflow_step_edit_id missing/
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -11,6 +11,28 @@ RSpec.describe Slack::Web::Api::Errors::SlackError do
|
|
11
11
|
rescue described_class => e
|
12
12
|
expect(e.response).not_to be_nil
|
13
13
|
expect(e.response.status).to eq 200
|
14
|
+
expect(e.message).to eql 'not_authed'
|
15
|
+
expect(e.error).to eql 'not_authed'
|
16
|
+
expect(e.response_metadata).to be_nil
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'provides access to any response_metadata', vcr: { cassette_name: 'web/views_open_error' } do
|
21
|
+
begin
|
22
|
+
client.views_open(trigger_id: 'trigger_id', view: {})
|
23
|
+
raise 'Expected to receive Slack::Web::Api::Errors::SlackError.'
|
24
|
+
rescue described_class => e
|
25
|
+
expect(e.response).not_to be_nil
|
26
|
+
expect(e.response.status).to eq 200
|
27
|
+
expect(e.message).to eql 'invalid_arguments'
|
28
|
+
expect(e.error).to eql 'invalid_arguments'
|
29
|
+
expect(e.response_metadata).to eq(
|
30
|
+
'messages' => [
|
31
|
+
"[ERROR] missing required field: title [json-pointer:\/view]",
|
32
|
+
"[ERROR] missing required field: blocks [json-pointer:\/view]",
|
33
|
+
"[ERROR] missing required field: type [json-pointer:\/view]"
|
34
|
+
]
|
35
|
+
)
|
14
36
|
end
|
15
37
|
end
|
16
38
|
end
|
@@ -13,7 +13,7 @@ RSpec.describe Slack::Web::Api::Mixins::Channels do
|
|
13
13
|
end
|
14
14
|
|
15
15
|
before do
|
16
|
-
allow(channels).to receive(:channels_list).
|
16
|
+
allow(channels).to receive(:channels_list).and_yield(
|
17
17
|
Slack::Messages::Message.new(
|
18
18
|
'channels' => [{
|
19
19
|
'id' => 'CDEADBEEF',
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
RSpec.describe Slack::Web::Client do
|
5
|
+
context 'conversations_setTopic' do
|
6
|
+
it 'does not invoke conversations_list', vcr: { cassette_name: 'web/conversations_setTopic' } do
|
7
|
+
rc = subject.conversations_setTopic({ channel: 'C018Y6VH39D', topic: 'new topic' })
|
8
|
+
expect(rc.channel.topic.value).to eq 'new topic'
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'resolves IDs via conversations_list', vcr: { cassette_name: 'web/conversations_setTopic_one_page' } do
|
12
|
+
rc = subject.conversations_setTopic({ channel: '#1', topic: 'new topic' })
|
13
|
+
expect(rc.channel.topic.value).to eq 'new topic'
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'paginates to resolve IDs', vcr: { cassette_name: 'web/conversations_setTopic_paginated' } do
|
17
|
+
rc = subject.conversations_setTopic({ channel: '#topic', topic: 'new topic' })
|
18
|
+
expect(rc.channel.topic.value).to eq 'new topic'
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
RSpec.describe Slack::Web::Api::Mixins::Conversations do
|
5
|
+
subject(:conversations) do
|
6
|
+
klass.new
|
7
|
+
end
|
8
|
+
|
9
|
+
let(:klass) do
|
10
|
+
Class.new do
|
11
|
+
include Slack::Web::Api::Mixins::Conversations
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
before do
|
16
|
+
allow(conversations).to receive(:conversations_list).and_yield(
|
17
|
+
Slack::Messages::Message.new(
|
18
|
+
'channels' => [{
|
19
|
+
'id' => 'CDEADBEEF',
|
20
|
+
'name' => 'general'
|
21
|
+
}]
|
22
|
+
)
|
23
|
+
)
|
24
|
+
end
|
25
|
+
|
26
|
+
describe '#conversations_id' do
|
27
|
+
it 'leaves channels specified by ID alone' do
|
28
|
+
expect(conversations.conversations_id(channel: 'C123456')).to(
|
29
|
+
eq('ok' => true, 'channel' => { 'id' => 'C123456' })
|
30
|
+
)
|
31
|
+
end
|
32
|
+
it 'translates a channel that starts with a #' do
|
33
|
+
expect(conversations.conversations_id(channel: '#general')).to(
|
34
|
+
eq('ok' => true, 'channel' => { 'id' => 'CDEADBEEF' })
|
35
|
+
)
|
36
|
+
end
|
37
|
+
it 'fails with an exception' do
|
38
|
+
expect { conversations.conversations_id(channel: '#invalid') }.to(
|
39
|
+
raise_error(Slack::Web::Api::Errors::SlackError, 'channel_not_found')
|
40
|
+
)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -150,6 +150,50 @@ RSpec.describe Slack::Web::Client do
|
|
150
150
|
end
|
151
151
|
end
|
152
152
|
|
153
|
+
context 'adapter option' do
|
154
|
+
let(:adapter) { Faraday.default_adapter }
|
155
|
+
let(:adapter_class) { Faraday::Adapter::NetHttp }
|
156
|
+
|
157
|
+
around do |ex|
|
158
|
+
previous_adapter = Faraday.default_adapter
|
159
|
+
# ensure default adapter is set for this spec
|
160
|
+
Faraday.default_adapter = :net_http
|
161
|
+
ex.run
|
162
|
+
Faraday.default_adapter = previous_adapter
|
163
|
+
end
|
164
|
+
|
165
|
+
context 'default adapter' do
|
166
|
+
describe '#initialize' do
|
167
|
+
it 'sets adapter' do
|
168
|
+
expect(client.adapter).to eq adapter
|
169
|
+
end
|
170
|
+
it 'creates a connection with an adapter' do
|
171
|
+
expect(client.send(:connection).adapter).to eq adapter_class
|
172
|
+
end
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
context 'non default adapter' do
|
177
|
+
let(:adapter) { :typhoeus }
|
178
|
+
let(:adapter_class) { Faraday::Adapter::Typhoeus }
|
179
|
+
|
180
|
+
before do
|
181
|
+
described_class.configure do |config|
|
182
|
+
config.adapter = adapter
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
186
|
+
describe '#initialize' do
|
187
|
+
it 'sets adapter' do
|
188
|
+
expect(client.adapter).to eq adapter
|
189
|
+
end
|
190
|
+
it 'creates a connection with an adapter' do
|
191
|
+
expect(client.send(:connection).adapter).to eq adapter_class
|
192
|
+
end
|
193
|
+
end
|
194
|
+
end
|
195
|
+
end
|
196
|
+
|
153
197
|
context 'timeout options' do
|
154
198
|
before do
|
155
199
|
described_class.configure do |config|
|
@@ -205,5 +249,82 @@ RSpec.describe Slack::Web::Client do
|
|
205
249
|
client.users_admin_setInactive(user: 'U092BDCLV')
|
206
250
|
end
|
207
251
|
end
|
252
|
+
|
253
|
+
context 'persistent capability' do
|
254
|
+
describe '#initialize' do
|
255
|
+
it 'caches the Faraday connection to allow persistent adapters' do
|
256
|
+
first = client.send(:connection)
|
257
|
+
second = client.send(:connection)
|
258
|
+
|
259
|
+
expect(first).to equal second
|
260
|
+
end
|
261
|
+
end
|
262
|
+
end
|
263
|
+
|
264
|
+
context 'server failures' do
|
265
|
+
subject(:request) { client.api_test }
|
266
|
+
|
267
|
+
let(:stub_slack_request) { stub_request(:post, 'https://slack.com/api/api.test') }
|
268
|
+
let(:exception) do
|
269
|
+
begin
|
270
|
+
request
|
271
|
+
rescue Slack::Web::Api::Errors::ServerError => e
|
272
|
+
return e
|
273
|
+
end
|
274
|
+
end
|
275
|
+
|
276
|
+
context 'parsing error' do
|
277
|
+
before { stub_slack_request.to_return(body: '<html></html>') }
|
278
|
+
|
279
|
+
it 'raises ParsingError' do
|
280
|
+
expect { request }.to raise_error(Slack::Web::Api::Errors::ParsingError).with_message('parsing_error')
|
281
|
+
expect(exception.response.body).to eq('<html></html>')
|
282
|
+
expect(exception.cause).to be_a(Faraday::ParsingError)
|
283
|
+
expect(exception.cause.cause.cause).to be_a(JSON::ParserError)
|
284
|
+
end
|
285
|
+
end
|
286
|
+
|
287
|
+
context 'timeout' do
|
288
|
+
context 'open timeout' do
|
289
|
+
before { stub_slack_request.to_timeout }
|
290
|
+
|
291
|
+
it 'raises TimoutError' do
|
292
|
+
expect { request }.to raise_error(Slack::Web::Api::Errors::TimeoutError).with_message('timeout_error')
|
293
|
+
expect(exception.cause).to be_a(Faraday::ConnectionFailed)
|
294
|
+
expect(exception.cause.cause).to be_a(Net::OpenTimeout)
|
295
|
+
end
|
296
|
+
end
|
297
|
+
|
298
|
+
context 'read timeout' do
|
299
|
+
before { stub_slack_request.to_raise(Net::ReadTimeout) }
|
300
|
+
|
301
|
+
it 'raises TimeoutError' do
|
302
|
+
expect { request }.to raise_error(Slack::Web::Api::Errors::TimeoutError).with_message('timeout_error')
|
303
|
+
expect(exception.cause).to be_a(Faraday::TimeoutError)
|
304
|
+
expect(exception.cause.cause).to be_a(Net::ReadTimeout)
|
305
|
+
end
|
306
|
+
end
|
307
|
+
end
|
308
|
+
|
309
|
+
context '5xx response' do
|
310
|
+
context 'with a JSON body' do
|
311
|
+
before { stub_slack_request.to_return(status: 500, body: '{}') }
|
312
|
+
|
313
|
+
it 'raises UnavailableError' do
|
314
|
+
expect { request }.to raise_error(Slack::Web::Api::Errors::UnavailableError).with_message('unavailable_error')
|
315
|
+
expect(exception.response.status).to eq(500)
|
316
|
+
end
|
317
|
+
end
|
318
|
+
|
319
|
+
context 'with a HTML response' do
|
320
|
+
before { stub_slack_request.to_return(status: 500, body: '<html></html>') }
|
321
|
+
|
322
|
+
it 'raises UnavailableError' do
|
323
|
+
expect { request }.to raise_error(Slack::Web::Api::Errors::UnavailableError).with_message('unavailable_error')
|
324
|
+
expect(exception.response.status).to eq(500)
|
325
|
+
end
|
326
|
+
end
|
327
|
+
end
|
328
|
+
end
|
208
329
|
end
|
209
330
|
end
|