slack-ruby-client 0.13.1 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/FUNDING.yml +1 -0
- data/.github/workflows/integration_test.yml +26 -0
- data/.github/workflows/lint.yml +14 -0
- data/.github/workflows/pr_lint.yml +21 -0
- data/.github/workflows/test.yml +36 -0
- data/.gitignore +5 -3
- data/.rubocop.yml +34 -5
- data/.rubocop_todo.yml +180 -46
- data/.ruby-version +1 -0
- data/CHANGELOG.md +119 -2
- data/CONTRIBUTING.md +23 -11
- data/Dangerfile +2 -0
- data/Gemfile +22 -5
- data/Gemfile.danger +6 -0
- data/LICENSE.md +1 -1
- data/README.md +236 -101
- data/RELEASING.md +2 -2
- data/Rakefile +2 -1
- data/UPGRADING.md +100 -2
- data/bin/commands/admin_analytics.rb +16 -0
- data/bin/commands/admin_apps.rb +51 -0
- data/bin/commands/admin_apps_approved.rb +17 -0
- data/bin/commands/admin_apps_requests.rb +28 -0
- data/bin/commands/admin_apps_restricted.rb +17 -0
- data/bin/commands/admin_audit_anomaly_allow.rb +23 -0
- data/bin/commands/admin_auth_policy.rb +39 -0
- data/bin/commands/admin_barriers.rb +47 -0
- data/bin/commands/admin_conversations.rb +171 -0
- data/bin/commands/admin_conversations_ekm.rb +17 -0
- data/bin/commands/admin_conversations_restrictAccess.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 +98 -0
- data/bin/commands/admin_users_session.rb +78 -0
- data/bin/commands/admin_users_unsupportedVersions.rb +15 -0
- data/bin/commands/api.rb +1 -1
- data/bin/commands/apps.rb +15 -0
- data/bin/commands/apps_connections.rb +13 -0
- data/bin/commands/apps_event_authorizations.rb +16 -0
- data/bin/commands/apps_manifest.rb +52 -0
- data/bin/commands/auth.rb +1 -0
- data/bin/commands/auth_teams.rb +16 -0
- data/bin/commands/bookmarks.rb +53 -0
- data/bin/commands/bots.rb +2 -0
- data/bin/commands/calls.rb +52 -0
- data/bin/commands/calls_participants.rb +25 -0
- data/bin/commands/chat.rb +61 -14
- data/bin/commands/chat_scheduledMessages.rb +19 -0
- data/bin/commands/conversations.rb +82 -10
- data/bin/commands/dialog.rb +1 -0
- data/bin/commands/dnd.rb +6 -3
- data/bin/commands/emoji.rb +1 -0
- data/bin/commands/files.rb +34 -18
- data/bin/commands/files_comments.rb +1 -21
- data/bin/commands/files_remote.rb +78 -0
- data/bin/commands/migration.rb +2 -0
- data/bin/commands/oauth.rb +2 -14
- data/bin/commands/oauth_v2.rb +29 -0
- data/bin/commands/openid_connect.rb +27 -0
- data/bin/commands/pins.rb +3 -6
- data/bin/commands/reactions.rb +3 -3
- data/bin/commands/reminders.rb +7 -0
- data/bin/commands/rtm.rb +1 -15
- data/bin/commands/search.rb +6 -1
- data/bin/commands/stars.rb +8 -6
- data/bin/commands/team.rb +6 -0
- data/bin/commands/team_billing.rb +13 -0
- data/bin/commands/team_preferences.rb +13 -0
- data/bin/commands/team_profile.rb +1 -0
- data/bin/commands/tooling_tokens.rb +14 -0
- data/bin/commands/usergroups.rb +7 -1
- data/bin/commands/usergroups_users.rb +3 -0
- data/bin/commands/users.rb +6 -4
- data/bin/commands/users_admin.rb +1 -0
- data/bin/commands/users_prefs.rb +1 -0
- data/bin/commands/users_profile.rb +6 -5
- data/bin/commands/views.rb +50 -0
- data/bin/commands/workflows.rb +38 -0
- data/bin/commands.rb +41 -8
- data/bin/slack +3 -4
- data/examples/hi_real_time_and_web/Gemfile +1 -0
- data/examples/hi_real_time_and_web/hi.rb +7 -3
- data/examples/hi_real_time_async_async/Gemfile +1 -0
- data/examples/hi_real_time_async_async/hi.rb +6 -2
- data/examples/hi_web/Gemfile +1 -0
- data/examples/hi_web/hi.rb +1 -0
- data/examples/new_ticket/Gemfile +1 -0
- data/examples/new_ticket/new_ticket.rb +1 -0
- data/lib/slack/config.rb +2 -2
- data/lib/slack/events/config.rb +32 -0
- data/lib/slack/events/request.rb +72 -0
- data/lib/slack/logger.rb +6 -5
- data/lib/slack/messages/formatting.rb +1 -0
- data/lib/slack/messages/message.rb +1 -4
- data/lib/slack/real_time/api/message.rb +6 -3
- data/lib/slack/real_time/api/message_id.rb +1 -0
- data/lib/slack/real_time/api/ping.rb +5 -2
- data/lib/slack/real_time/api/templates/event_handler.erb +5 -1
- data/lib/slack/real_time/api/typing.rb +5 -2
- data/lib/slack/real_time/client.rb +105 -54
- data/lib/slack/real_time/concurrency/async.rb +77 -6
- data/lib/slack/real_time/concurrency.rb +1 -2
- data/lib/slack/real_time/config.rb +9 -13
- data/lib/slack/real_time/models/base.rb +1 -4
- data/lib/slack/real_time/models/bot.rb +1 -0
- data/lib/slack/real_time/models/channel.rb +5 -0
- data/lib/slack/real_time/models/im.rb +1 -0
- data/lib/slack/real_time/models/{group.rb → mpim.rb} +2 -1
- data/lib/slack/real_time/models/team.rb +1 -0
- data/lib/slack/real_time/models/user.rb +1 -0
- data/lib/slack/real_time/models.rb +3 -1
- data/lib/slack/real_time/socket.rb +45 -17
- data/lib/slack/real_time/stores/base.rb +28 -14
- data/lib/slack/real_time/stores/starter.rb +325 -297
- data/lib/slack/real_time/stores/store.rb +271 -196
- data/lib/slack/real_time/stores.rb +2 -7
- data/lib/slack/version.rb +2 -1
- data/lib/slack/web/api/endpoints/admin_analytics.rb +28 -0
- data/lib/slack/web/api/endpoints/admin_apps.rb +78 -0
- data/lib/slack/web/api/endpoints/admin_apps_approved.rb +35 -0
- data/lib/slack/web/api/endpoints/admin_apps_requests.rb +51 -0
- data/lib/slack/web/api/endpoints/admin_apps_restricted.rb +35 -0
- data/lib/slack/web/api/endpoints/admin_audit_anomaly_allow.rb +34 -0
- data/lib/slack/web/api/endpoints/admin_auth_policy.rb +72 -0
- data/lib/slack/web/api/endpoints/admin_barriers.rb +82 -0
- data/lib/slack/web/api/endpoints/admin_conversations.rb +264 -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_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 +163 -0
- data/lib/slack/web/api/endpoints/admin_users_session.rb +122 -0
- data/lib/slack/web/api/endpoints/admin_users_unsupportedVersions.rb +25 -0
- data/lib/slack/web/api/endpoints/api.rb +2 -3
- data/lib/slack/web/api/endpoints/apps.rb +27 -0
- 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/apps_manifest.rb +77 -0
- data/lib/slack/web/api/endpoints/auth.rb +2 -1
- data/lib/slack/web/api/endpoints/auth_teams.rb +33 -0
- data/lib/slack/web/api/endpoints/bookmarks.rb +88 -0
- data/lib/slack/web/api/endpoints/bots.rb +4 -1
- 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/chat.rb +168 -65
- data/lib/slack/web/api/endpoints/chat_scheduledMessages.rb +40 -0
- data/lib/slack/web/api/endpoints/conversations.rb +182 -67
- data/lib/slack/web/api/endpoints/dialog.rb +5 -4
- data/lib/slack/web/api/endpoints/dnd.rb +9 -4
- data/lib/slack/web/api/endpoints/emoji.rb +1 -0
- data/lib/slack/web/api/endpoints/files.rb +69 -37
- data/lib/slack/web/api/endpoints/files_comments.rb +4 -36
- data/lib/slack/web/api/endpoints/files_remote.rb +127 -0
- data/lib/slack/web/api/endpoints/migration.rb +6 -3
- data/lib/slack/web/api/endpoints/oauth.rb +7 -31
- data/lib/slack/web/api/endpoints/oauth_v2.rb +48 -0
- data/lib/slack/web/api/endpoints/openid_connect.rb +42 -0
- data/lib/slack/web/api/endpoints/pins.rb +11 -18
- data/lib/slack/web/api/endpoints/reactions.rb +22 -21
- data/lib/slack/web/api/endpoints/reminders.rb +23 -10
- data/lib/slack/web/api/endpoints/rtm.rb +3 -25
- data/lib/slack/web/api/endpoints/search.rb +31 -16
- data/lib/slack/web/api/endpoints/stars.rb +14 -11
- data/lib/slack/web/api/endpoints/team.rb +15 -4
- data/lib/slack/web/api/endpoints/team_billing.rb +21 -0
- data/lib/slack/web/api/endpoints/team_preferences.rb +21 -0
- data/lib/slack/web/api/endpoints/team_profile.rb +2 -1
- data/lib/slack/web/api/endpoints/tooling_tokens.rb +24 -0
- data/lib/slack/web/api/endpoints/usergroups.rb +31 -20
- data/lib/slack/web/api/endpoints/usergroups_users.rb +13 -8
- data/lib/slack/web/api/endpoints/users.rb +24 -23
- data/lib/slack/web/api/endpoints/users_admin.rb +3 -2
- data/lib/slack/web/api/endpoints/users_prefs.rb +1 -0
- data/lib/slack/web/api/endpoints/users_profile.rb +8 -7
- data/lib/slack/web/api/endpoints/views.rb +102 -0
- data/lib/slack/web/api/endpoints/workflows.rb +61 -0
- data/lib/slack/web/api/endpoints.rb +82 -18
- data/lib/slack/web/api/error.rb +1 -0
- data/lib/slack/web/api/errors/server_error.rb +37 -0
- data/lib/slack/web/api/errors/slack_error.rb +14 -1
- data/lib/slack/web/api/errors/too_many_requests_error.rb +2 -4
- data/lib/slack/web/api/errors.rb +1116 -0
- data/lib/slack/web/api/mixins/{channels.id.rb → conversations.id.rb} +5 -6
- data/lib/slack/web/api/mixins/ids.id.rb +3 -2
- data/lib/slack/web/api/mixins/users.id.rb +3 -4
- data/lib/slack/web/api/mixins/users.search.rb +3 -1
- data/lib/slack/web/api/mixins.rb +2 -2
- data/lib/slack/web/api/patches/chat.attachments-blocks.patch +69 -0
- data/lib/slack/web/api/patches/{dialog.1.open-json-support.patch → dialog.encoded-json.patch} +4 -4
- data/lib/slack/web/api/patches/views.view-json.patch +55 -0
- data/lib/slack/web/api/templates/command.erb +1 -0
- data/lib/slack/web/api/templates/commands.erb +1 -0
- data/lib/slack/web/api/templates/endpoints.erb +2 -2
- data/lib/slack/web/api/templates/errors.erb +20 -0
- data/lib/slack/web/api/templates/method.erb +6 -2
- data/lib/slack/web/api/templates/method_spec.erb +2 -1
- data/lib/slack/web/client.rb +2 -1
- data/lib/slack/web/config.rb +5 -2
- data/lib/slack/web/faraday/connection.rb +24 -20
- data/lib/slack/web/faraday/request.rb +5 -1
- data/lib/slack/web/faraday/response/raise_error.rb +14 -7
- data/lib/slack/web/faraday/response/wrap_error.rb +24 -0
- data/lib/slack/web/pagination/cursor.rb +7 -7
- data/lib/slack-ruby-client.rb +12 -5
- data/lib/slack.rb +1 -0
- data/lib/slack_ruby_client.rb +1 -0
- data/lib/tasks/git.rake +1 -0
- data/lib/tasks/real_time.rake +51 -21
- data/lib/tasks/update.rake +1 -0
- data/lib/tasks/web.rake +48 -12
- data/screenshots/create-app.png +0 -0
- data/slack-ruby-client.gemspec +7 -12
- data/spec/fixtures/slack/web/429_error.yml +50 -54
- data/spec/fixtures/slack/web/auth_test_error.yml +51 -18
- data/spec/fixtures/slack/web/auth_test_success.yml +50 -26
- data/spec/fixtures/slack/web/conversations_info.yml +167 -0
- data/spec/fixtures/slack/web/conversations_setTopic.yml +84 -0
- data/spec/fixtures/slack/web/conversations_setTopic_one_page.yml +172 -0
- data/spec/fixtures/slack/web/conversations_setTopic_paginated.yml +253 -0
- data/spec/fixtures/slack/web/paginated_users_list.yml +501 -69
- data/spec/fixtures/slack/web/rtm_connect.yml +347 -26
- data/spec/fixtures/slack/web/users_info.yml +153 -69
- data/spec/fixtures/slack/web/users_list.yml +102 -41
- data/spec/fixtures/slack/web/views_open_error.yml +83 -0
- data/spec/integration/integration_spec.rb +115 -47
- data/spec/slack/config_spec.rb +2 -0
- data/spec/slack/events/config_spec.rb +35 -0
- data/spec/slack/events/request_spec.rb +188 -0
- data/spec/slack/messages/formatting_spec.rb +35 -13
- data/spec/slack/real_time/api/message_spec.rb +7 -2
- data/spec/slack/real_time/api/ping_spec.rb +3 -1
- data/spec/slack/real_time/api/typing_spec.rb +6 -2
- data/spec/slack/real_time/client_spec.rb +300 -142
- data/spec/slack/real_time/concurrency/it_behaves_like_a_realtime_socket.rb +2 -0
- 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/event_handlers/bot_spec.rb +20 -17
- data/spec/slack/real_time/event_handlers/event_handlers_spec.rb +3 -2
- data/spec/slack/real_time/event_handlers/im_spec.rb +31 -27
- data/spec/slack/real_time/event_handlers/{group_spec.rb → private_channel_spec.rb} +36 -27
- data/spec/slack/real_time/event_handlers/{channel_spec.rb → public_channel_spec.rb} +31 -24
- data/spec/slack/real_time/event_handlers/team_spec.rb +8 -7
- data/spec/slack/real_time/event_handlers/user_spec.rb +7 -5
- data/spec/slack/real_time/rtm_connect_spec.rb +2 -1
- data/spec/slack/real_time/stores/store_spec.rb +50 -0
- data/spec/slack/slack_spec.rb +41 -6
- data/spec/slack/version_spec.rb +2 -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_requests_spec.rb +13 -0
- data/spec/slack/web/api/endpoints/admin_apps_restricted_spec.rb +8 -0
- data/spec/slack/web/api/endpoints/admin_apps_spec.rb +18 -0
- data/spec/slack/web/api/endpoints/admin_audit_anomaly_allow_spec.rb +8 -0
- data/spec/slack/web/api/endpoints/admin_auth_policy_spec.rb +35 -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 +98 -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 +41 -0
- data/spec/slack/web/api/endpoints/admin_users_spec.rb +67 -0
- data/spec/slack/web/api/endpoints/admin_users_unsupportedVersions_spec.rb +8 -0
- data/spec/slack/web/api/endpoints/api_spec.rb +1 -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_manifest_spec.rb +36 -0
- data/spec/slack/web/api/endpoints/apps_spec.rb +16 -0
- data/spec/slack/web/api/endpoints/{apps_permissions_resources_spec.rb → auth_teams_spec.rb} +2 -1
- data/spec/slack/web/api/endpoints/bookmarks_spec.rb +40 -0
- data/spec/slack/web/api/endpoints/bots_spec.rb +1 -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/chat_scheduledMessages_spec.rb +8 -0
- data/spec/slack/web/api/endpoints/custom_specs/auth_spec.rb +9 -7
- data/spec/slack/web/api/endpoints/custom_specs/chat_spec.rb +144 -40
- data/spec/slack/web/api/endpoints/custom_specs/conversations_spec.rb +13 -0
- data/spec/slack/web/api/endpoints/custom_specs/dialog_spec.rb +18 -6
- data/spec/slack/web/api/endpoints/custom_specs/users_spec.rb +8 -3
- data/spec/slack/web/api/endpoints/custom_specs/views_spec.rb +112 -0
- data/spec/slack/web/api/endpoints/dnd_spec.rb +4 -3
- data/spec/slack/web/api/endpoints/emoji_spec.rb +1 -0
- data/spec/slack/web/api/endpoints/files_comments_spec.rb +3 -21
- data/spec/slack/web/api/endpoints/files_remote_spec.rb +24 -0
- data/spec/slack/web/api/endpoints/files_spec.rb +18 -4
- data/spec/slack/web/api/endpoints/migration_spec.rb +1 -0
- data/spec/slack/web/api/endpoints/oauth_spec.rb +1 -22
- data/spec/slack/web/api/endpoints/oauth_v2_spec.rb +16 -0
- data/spec/slack/web/api/endpoints/openid_connect_spec.rb +8 -0
- data/spec/slack/web/api/endpoints/pins_spec.rb +1 -0
- data/spec/slack/web/api/endpoints/reactions_spec.rb +8 -1
- data/spec/slack/web/api/endpoints/reminders_spec.rb +3 -2
- data/spec/slack/web/api/endpoints/rtm_spec.rb +1 -0
- data/spec/slack/web/api/endpoints/search_spec.rb +1 -0
- data/spec/slack/web/api/endpoints/stars_spec.rb +1 -0
- data/spec/slack/web/api/endpoints/{apps_permissions_scopes_spec.rb → team_billing_spec.rb} +2 -1
- data/spec/slack/web/api/endpoints/team_preferences_spec.rb +8 -0
- data/spec/slack/web/api/endpoints/team_profile_spec.rb +1 -0
- data/spec/slack/web/api/endpoints/team_spec.rb +1 -0
- data/spec/slack/web/api/endpoints/tooling_tokens_spec.rb +13 -0
- data/spec/slack/web/api/endpoints/usergroups_spec.rb +1 -0
- data/spec/slack/web/api/endpoints/usergroups_users_spec.rb +3 -2
- data/spec/slack/web/api/endpoints/users_admin_spec.rb +1 -0
- data/spec/slack/web/api/endpoints/users_prefs_spec.rb +1 -0
- data/spec/slack/web/api/endpoints/users_profile_spec.rb +1 -0
- data/spec/slack/web/api/endpoints/workflows_spec.rb +26 -0
- data/spec/slack/web/api/error_spec.rb +7 -7
- data/spec/slack/web/api/errors/slack_error_spec.rb +26 -7
- data/spec/slack/web/api/mixins/conversations_list_spec.rb +21 -0
- data/spec/slack/web/api/mixins/conversations_spec.rb +45 -0
- data/spec/slack/web/api/mixins/users_spec.rb +19 -8
- data/spec/slack/web/api/pagination/cursor_spec.rb +47 -15
- data/spec/slack/web/client_spec.rb +199 -22
- data/spec/slack/web/faraday/request_spec.rb +80 -0
- data/spec/slack/web/faraday/response/raise_error_spec.rb +48 -12
- data/spec/spec_helper.rb +9 -2
- data/spec/support/queue_with_timeout.rb +5 -4
- data/spec/support/real_time/concurrency/mock.rb +1 -0
- data/spec/support/real_time/connected_client.rb +6 -6
- data/spec/support/real_time/event.rb +1 -0
- data/spec/support/real_time/loaded_client.rb +120 -0
- data/spec/support/token.rb +1 -0
- data/spec/support/vcr.rb +37 -1
- metadata +174 -262
- data/.travis.yml +0 -32
- data/bin/commands/apps_permissions.rb +0 -22
- data/bin/commands/apps_permissions_resources.rb +0 -14
- data/bin/commands/apps_permissions_scopes.rb +0 -12
- data/bin/commands/apps_permissions_users.rb +0 -25
- data/bin/commands/channels.rb +0 -175
- data/bin/commands/groups.rb +0 -174
- data/bin/commands/im.rb +0 -67
- data/bin/commands/mpim.rb +0 -65
- data/examples/hi_real_time/Gemfile +0 -5
- data/examples/hi_real_time/hi.gif +0 -0
- data/examples/hi_real_time/hi.rb +0 -37
- data/examples/hi_real_time_async_celluloid/Gemfile +0 -6
- data/examples/hi_real_time_async_celluloid/Procfile +0 -2
- data/examples/hi_real_time_async_celluloid/hi.rb +0 -35
- data/examples/hi_real_time_async_eventmachine/Gemfile +0 -6
- data/examples/hi_real_time_async_eventmachine/Procfile +0 -2
- data/examples/hi_real_time_async_eventmachine/hi.rb +0 -35
- data/lib/slack/real_time/concurrency/celluloid.rb +0 -118
- data/lib/slack/real_time/concurrency/eventmachine.rb +0 -66
- data/lib/slack/web/api/endpoints/apps_permissions.rb +0 -35
- data/lib/slack/web/api/endpoints/apps_permissions_resources.rb +0 -30
- data/lib/slack/web/api/endpoints/apps_permissions_scopes.rb +0 -20
- data/lib/slack/web/api/endpoints/apps_permissions_users.rb +0 -49
- data/lib/slack/web/api/endpoints/channels.rb +0 -266
- data/lib/slack/web/api/endpoints/groups.rb +0 -265
- data/lib/slack/web/api/endpoints/im.rb +0 -113
- data/lib/slack/web/api/endpoints/mpim.rb +0 -108
- data/lib/slack/web/api/endpoints/presence.rb +0 -23
- data/lib/slack/web/api/mixins/channels.id.json +0 -20
- data/lib/slack/web/api/mixins/groups.id.json +0 -20
- data/lib/slack/web/api/mixins/groups.id.rb +0 -26
- 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 -13
- data/screenshots/register-bot.png +0 -0
- data/spec/fixtures/slack/web/503_error.yml +0 -14
- data/spec/fixtures/slack/web/channels_info.yml +0 -46
- data/spec/fixtures/slack/web/groups_info.yml +0 -43
- data/spec/fixtures/slack/web/rtm_start.yml +0 -104
- data/spec/slack/real_time/concurrency/celluloid_spec.rb +0 -106
- data/spec/slack/real_time/concurrency/eventmachine_spec.rb +0 -47
- data/spec/slack/real_time/rtm_start_spec.rb +0 -13
- data/spec/slack/real_time/store_spec.rb +0 -11
- data/spec/slack/web/api/endpoints/apps_permissions_spec.rb +0 -15
- data/spec/slack/web/api/endpoints/apps_permissions_users_spec.rb +0 -18
- data/spec/slack/web/api/endpoints/conversations_spec.rb +0 -100
- data/spec/slack/web/api/endpoints/custom_specs/channels_spec.rb +0 -11
- data/spec/slack/web/api/endpoints/custom_specs/groups_spec.rb +0 -11
- data/spec/slack/web/api/endpoints/im_spec.rb +0 -38
- data/spec/slack/web/api/endpoints/mpim_spec.rb +0 -38
- data/spec/slack/web/api/errors/service_unavailable_spec.rb +0 -14
- data/spec/slack/web/api/mixins/channels_spec.rb +0 -33
- data/spec/slack/web/api/mixins/groups_spec.rb +0 -33
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
1
2
|
require 'spec_helper'
|
|
2
3
|
|
|
3
4
|
RSpec.shared_examples_for 'a realtime socket' do
|
|
@@ -9,6 +10,7 @@ RSpec.shared_examples_for 'a realtime socket' do
|
|
|
9
10
|
expect(socket.url).to eq url
|
|
10
11
|
end
|
|
11
12
|
end
|
|
13
|
+
|
|
12
14
|
describe 'api' do
|
|
13
15
|
%i[start_sync start_sync disconnect! connect! connected? send_data close].each do |m|
|
|
14
16
|
it m do
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
require 'spec_helper'
|
|
3
|
+
|
|
4
|
+
RSpec.describe 'with CONCURRENCY', skip: ( # rubocop:disable RSpec/DescribeClass
|
|
5
|
+
(!ENV['CONCURRENCY']) && 'missing CONCURRENCY'
|
|
6
|
+
) do
|
|
7
|
+
it 'detects concurrency' do
|
|
8
|
+
expect(Slack::RealTime::Config.concurrency).to eq Slack::RealTime::Concurrency::Async
|
|
9
|
+
end
|
|
10
|
+
end
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
require 'spec_helper'
|
|
3
|
+
|
|
4
|
+
RSpec.describe 'without CONCURRENCY', skip: ( # rubocop:disable RSpec/DescribeClass
|
|
5
|
+
(ENV['CONCURRENCY']) && 'CONCURRENCY is set'
|
|
6
|
+
) do
|
|
7
|
+
it 'raises NoConcurrencyError' do
|
|
8
|
+
expect { Slack::RealTime::Config.concurrency }.to raise_error Slack::RealTime::Config::NoConcurrencyError
|
|
9
|
+
end
|
|
10
|
+
end
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
1
2
|
require 'spec_helper'
|
|
2
3
|
|
|
3
|
-
RSpec.describe Slack::RealTime::Client, vcr: { cassette_name: 'web/
|
|
4
|
+
RSpec.describe Slack::RealTime::Client, vcr: { cassette_name: 'web/rtm_connect' } do
|
|
4
5
|
include_context 'connected client'
|
|
5
6
|
|
|
6
7
|
context 'bot' do
|
|
7
|
-
it 'sets bot data on rtm.start' do
|
|
8
|
-
expect(client.bots.count).to eq 16
|
|
9
|
-
end
|
|
10
8
|
it 'bot_added' do
|
|
11
9
|
expect do
|
|
12
10
|
event = Slack::RealTime::Event.new(
|
|
@@ -26,19 +24,24 @@ RSpec.describe Slack::RealTime::Client, vcr: { cassette_name: 'web/rtm_start' }
|
|
|
26
24
|
expect(bot['name']).to eq 'hugbot'
|
|
27
25
|
expect(bot['icons']['image_48']).to eq 'https:\/\/slack.com\/path\/to\/hugbot_48.png'
|
|
28
26
|
end
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
27
|
+
|
|
28
|
+
context 'with bot loaded in the store' do
|
|
29
|
+
include_context 'loaded client'
|
|
30
|
+
|
|
31
|
+
it 'bot_changed' do
|
|
32
|
+
expect do
|
|
33
|
+
event = Slack::RealTime::Event.new(
|
|
34
|
+
'type' => 'bot_changed',
|
|
35
|
+
'bot' => {
|
|
36
|
+
'id' => 'B0751JU2H',
|
|
37
|
+
'name' => 'hugbot'
|
|
38
|
+
}
|
|
39
|
+
)
|
|
40
|
+
client.send(:dispatch, event)
|
|
41
|
+
end.not_to change(client.bots, :count)
|
|
42
|
+
bot = client.bots['B0751JU2H']
|
|
43
|
+
expect(bot['name']).to eq 'hugbot'
|
|
44
|
+
end
|
|
42
45
|
end
|
|
43
46
|
end
|
|
44
47
|
end
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
1
2
|
require 'spec_helper'
|
|
2
3
|
|
|
3
|
-
RSpec.describe Slack::RealTime::Client, vcr: { cassette_name: 'web/
|
|
4
|
+
RSpec.describe Slack::RealTime::Client, vcr: { cassette_name: 'web/rtm_connect' } do
|
|
4
5
|
include_context 'connected client'
|
|
5
6
|
|
|
6
7
|
it 'is not fatal' do
|
|
@@ -10,6 +11,6 @@ RSpec.describe Slack::RealTime::Client, vcr: { cassette_name: 'web/rtm_start' }
|
|
|
10
11
|
'value' => 'updated.mp3'
|
|
11
12
|
)
|
|
12
13
|
expect(client.self).to receive(:prefs) { raise ArgumentError }
|
|
13
|
-
expect { client.send(:dispatch, event) }.
|
|
14
|
+
expect { client.send(:dispatch, event) }.not_to raise_error
|
|
14
15
|
end
|
|
15
16
|
end
|
|
@@ -1,14 +1,12 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
1
2
|
require 'spec_helper'
|
|
2
3
|
|
|
3
|
-
RSpec.describe Slack::RealTime::Client, vcr: { cassette_name: 'web/
|
|
4
|
+
RSpec.describe Slack::RealTime::Client, vcr: { cassette_name: 'web/rtm_connect' } do
|
|
4
5
|
include_context 'connected client'
|
|
5
6
|
|
|
6
7
|
context 'im' do
|
|
7
|
-
it 'sets im data' do
|
|
8
|
-
expect(client.ims.count).to eq 2
|
|
9
|
-
end
|
|
10
8
|
it 'im_created' do
|
|
11
|
-
expect(client.ims['CDEADBEEF']).to
|
|
9
|
+
expect(client.ims['CDEADBEEF']).to be_nil
|
|
12
10
|
event = Slack::RealTime::Event.new(
|
|
13
11
|
'type' => 'im_created',
|
|
14
12
|
'channel' => {
|
|
@@ -18,30 +16,36 @@ RSpec.describe Slack::RealTime::Client, vcr: { cassette_name: 'web/rtm_start' }
|
|
|
18
16
|
)
|
|
19
17
|
client.send(:dispatch, event)
|
|
20
18
|
im = client.ims['CDEADBEEF']
|
|
21
|
-
expect(im).
|
|
19
|
+
expect(im).not_to be_nil
|
|
22
20
|
expect(im.name).to eq 'beef'
|
|
23
21
|
end
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
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
|
|
45
49
|
end
|
|
46
50
|
end
|
|
47
51
|
end
|
|
@@ -1,14 +1,17 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
1
2
|
require 'spec_helper'
|
|
2
3
|
|
|
3
|
-
RSpec.describe Slack::RealTime::Client, vcr: { cassette_name: 'web/
|
|
4
|
+
RSpec.describe Slack::RealTime::Client, vcr: { cassette_name: 'web/rtm_connect' } do
|
|
4
5
|
include_context 'connected client'
|
|
6
|
+
include_context 'loaded client'
|
|
5
7
|
|
|
6
|
-
context '
|
|
7
|
-
it 'sets
|
|
8
|
-
expect(client.
|
|
8
|
+
context 'private channel' do
|
|
9
|
+
it 'sets private channel data' do
|
|
10
|
+
expect(client.private_channels.count).to eq 1
|
|
9
11
|
end
|
|
12
|
+
|
|
10
13
|
it 'group_joined' do
|
|
11
|
-
expect(client.
|
|
14
|
+
expect(client.private_channels['CDEADBEEF']).to be_nil
|
|
12
15
|
event = Slack::RealTime::Event.new(
|
|
13
16
|
'type' => 'group_joined',
|
|
14
17
|
'channel' => {
|
|
@@ -17,43 +20,47 @@ RSpec.describe Slack::RealTime::Client, vcr: { cassette_name: 'web/rtm_start' }
|
|
|
17
20
|
}
|
|
18
21
|
)
|
|
19
22
|
client.send(:dispatch, event)
|
|
20
|
-
|
|
21
|
-
expect(
|
|
22
|
-
expect(
|
|
23
|
+
channel = client.private_channels['CDEADBEEF']
|
|
24
|
+
expect(channel).not_to be_nil
|
|
25
|
+
expect(channel.name).to eq 'beef'
|
|
23
26
|
end
|
|
27
|
+
|
|
24
28
|
it 'group_left' do
|
|
25
|
-
|
|
26
|
-
expect(
|
|
29
|
+
channel = client.private_channels['G0K7EV5A7']
|
|
30
|
+
expect(channel.members).to include client.self.id
|
|
27
31
|
event = Slack::RealTime::Event.new(
|
|
28
32
|
'type' => 'group_left',
|
|
29
33
|
'channel' => 'G0K7EV5A7'
|
|
30
34
|
)
|
|
31
35
|
client.send(:dispatch, event)
|
|
32
|
-
expect(
|
|
36
|
+
expect(client.private_channels['G0K7EV5A7']).to be_nil
|
|
33
37
|
end
|
|
38
|
+
|
|
34
39
|
it 'group_archive' do
|
|
35
|
-
|
|
36
|
-
expect(
|
|
40
|
+
channel = client.private_channels['G0K7EV5A7']
|
|
41
|
+
expect(channel.is_archived).to be false
|
|
37
42
|
event = Slack::RealTime::Event.new(
|
|
38
43
|
'type' => 'group_archive',
|
|
39
44
|
'channel' => 'G0K7EV5A7'
|
|
40
45
|
)
|
|
41
46
|
client.send(:dispatch, event)
|
|
42
|
-
expect(
|
|
47
|
+
expect(channel.is_archived).to be true
|
|
43
48
|
end
|
|
49
|
+
|
|
44
50
|
it 'group_unarchive' do
|
|
45
|
-
|
|
46
|
-
|
|
51
|
+
channel = client.private_channels['G0K7EV5A7']
|
|
52
|
+
channel.is_archived = true
|
|
47
53
|
event = Slack::RealTime::Event.new(
|
|
48
54
|
'type' => 'group_unarchive',
|
|
49
55
|
'channel' => 'G0K7EV5A7'
|
|
50
56
|
)
|
|
51
57
|
client.send(:dispatch, event)
|
|
52
|
-
expect(
|
|
58
|
+
expect(channel.is_archived).to be false
|
|
53
59
|
end
|
|
60
|
+
|
|
54
61
|
it 'group_rename' do
|
|
55
|
-
|
|
56
|
-
expect(
|
|
62
|
+
channel = client.private_channels['G0K7EV5A7']
|
|
63
|
+
expect(channel.name).to eq 'mpdm-dblock--rubybot--player1-1'
|
|
57
64
|
event = Slack::RealTime::Event.new(
|
|
58
65
|
'type' => 'group_rename',
|
|
59
66
|
'channel' => {
|
|
@@ -63,28 +70,30 @@ RSpec.describe Slack::RealTime::Client, vcr: { cassette_name: 'web/rtm_start' }
|
|
|
63
70
|
}
|
|
64
71
|
)
|
|
65
72
|
client.send(:dispatch, event)
|
|
66
|
-
expect(
|
|
73
|
+
expect(channel.name).to eq 'updated'
|
|
67
74
|
end
|
|
75
|
+
|
|
68
76
|
it 'group_open' do
|
|
69
|
-
|
|
70
|
-
expect(
|
|
77
|
+
channel = client.private_channels['G0K7EV5A7']
|
|
78
|
+
expect(channel).not_to be_nil
|
|
71
79
|
event = Slack::RealTime::Event.new(
|
|
72
80
|
'type' => 'group_open',
|
|
73
81
|
'channel' => 'G0K7EV5A7'
|
|
74
82
|
)
|
|
75
83
|
client.send(:dispatch, event)
|
|
76
|
-
expect(
|
|
84
|
+
expect(channel.is_open).to be true
|
|
77
85
|
end
|
|
86
|
+
|
|
78
87
|
it 'group_close' do
|
|
79
|
-
|
|
80
|
-
expect(
|
|
81
|
-
|
|
88
|
+
channel = client.private_channels['G0K7EV5A7']
|
|
89
|
+
expect(channel).not_to be_nil
|
|
90
|
+
channel.is_open = true
|
|
82
91
|
event = Slack::RealTime::Event.new(
|
|
83
92
|
'type' => 'group_close',
|
|
84
93
|
'channel' => 'G0K7EV5A7'
|
|
85
94
|
)
|
|
86
95
|
client.send(:dispatch, event)
|
|
87
|
-
expect(
|
|
96
|
+
expect(channel.is_open).to be false
|
|
88
97
|
end
|
|
89
98
|
end
|
|
90
99
|
end
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
1
2
|
require 'spec_helper'
|
|
2
3
|
|
|
3
|
-
RSpec.describe Slack::RealTime::Client, vcr: { cassette_name: 'web/
|
|
4
|
+
RSpec.describe Slack::RealTime::Client, vcr: { cassette_name: 'web/rtm_connect' } do
|
|
4
5
|
include_context 'connected client'
|
|
6
|
+
include_context 'loaded client'
|
|
5
7
|
|
|
6
|
-
context 'channel' do
|
|
7
|
-
it 'sets channel data' do
|
|
8
|
-
expect(client.channels.count).to eq 37
|
|
9
|
-
end
|
|
8
|
+
context 'public channel' do
|
|
10
9
|
it 'channel_archive' do
|
|
11
|
-
channel = client.
|
|
10
|
+
channel = client.public_channels['C0HNTD0CW']
|
|
12
11
|
expect(channel.is_archived).to be false
|
|
13
12
|
event = Slack::RealTime::Event.new(
|
|
14
13
|
'type' => 'channel_archive',
|
|
@@ -18,36 +17,39 @@ RSpec.describe Slack::RealTime::Client, vcr: { cassette_name: 'web/rtm_start' }
|
|
|
18
17
|
client.send(:dispatch, event)
|
|
19
18
|
expect(channel.is_archived).to be true
|
|
20
19
|
end
|
|
20
|
+
|
|
21
21
|
it 'channel_created' do
|
|
22
|
-
expect(client.
|
|
22
|
+
expect(client.public_channels['C024BE91L']).to be_nil
|
|
23
23
|
event = Slack::RealTime::Event.new(
|
|
24
24
|
'type' => 'channel_created',
|
|
25
25
|
'channel' => {
|
|
26
26
|
'id' => 'C024BE91L',
|
|
27
27
|
'name' => 'fun',
|
|
28
|
-
'created' =>
|
|
28
|
+
'created' => 1360782804,
|
|
29
29
|
'creator' => 'U04KB5WQR'
|
|
30
30
|
}
|
|
31
31
|
)
|
|
32
32
|
client.send(:dispatch, event)
|
|
33
|
-
channel = client.
|
|
34
|
-
expect(channel).
|
|
33
|
+
channel = client.public_channels['C024BE91L']
|
|
34
|
+
expect(channel).not_to be_nil
|
|
35
35
|
expect(channel.name).to eq 'fun'
|
|
36
36
|
expect(channel.creator).to eq 'U04KB5WQR'
|
|
37
|
-
expect(channel.created).to eq
|
|
37
|
+
expect(channel.created).to eq 1360782804
|
|
38
38
|
end
|
|
39
|
+
|
|
39
40
|
it 'channel_deleted' do
|
|
40
|
-
expect(client.
|
|
41
|
+
expect(client.public_channels['C0HLE0BBL']).not_to be_nil
|
|
41
42
|
event = Slack::RealTime::Event.new(
|
|
42
43
|
'type' => 'channel_deleted',
|
|
43
44
|
'channel' => 'C0HLE0BBL'
|
|
44
45
|
)
|
|
45
46
|
client.send(:dispatch, event)
|
|
46
|
-
expect(client.
|
|
47
|
+
expect(client.public_channels['C0HLE0BBL']).to be_nil
|
|
47
48
|
end
|
|
49
|
+
|
|
48
50
|
context 'channel_joined' do
|
|
49
51
|
it 'creates channel' do
|
|
50
|
-
expect(client.
|
|
52
|
+
expect(client.public_channels['CDEADBEEF']).to be_nil
|
|
51
53
|
event = Slack::RealTime::Event.new(
|
|
52
54
|
'type' => 'channel_joined',
|
|
53
55
|
'channel' => {
|
|
@@ -56,13 +58,15 @@ RSpec.describe Slack::RealTime::Client, vcr: { cassette_name: 'web/rtm_start' }
|
|
|
56
58
|
}
|
|
57
59
|
)
|
|
58
60
|
client.send(:dispatch, event)
|
|
59
|
-
channel = client.
|
|
60
|
-
expect(channel).
|
|
61
|
+
channel = client.public_channels['CDEADBEEF']
|
|
62
|
+
expect(channel).not_to be_nil
|
|
61
63
|
expect(channel.name).to eq 'beef'
|
|
62
64
|
end
|
|
65
|
+
|
|
63
66
|
it 'updates channel' do
|
|
64
|
-
expect(client.
|
|
65
|
-
client.
|
|
67
|
+
expect(client.public_channels['CDEADBEEF']).to be_nil
|
|
68
|
+
client.public_channels['CDEADBEEF'] =
|
|
69
|
+
Slack::RealTime::Models::Channel.new('id' => 'CDEADBEEF', name: 'beef')
|
|
66
70
|
event = Slack::RealTime::Event.new(
|
|
67
71
|
'type' => 'channel_joined',
|
|
68
72
|
'channel' => {
|
|
@@ -72,23 +76,25 @@ RSpec.describe Slack::RealTime::Client, vcr: { cassette_name: 'web/rtm_start' }
|
|
|
72
76
|
}
|
|
73
77
|
)
|
|
74
78
|
client.send(:dispatch, event)
|
|
75
|
-
channel = client.
|
|
76
|
-
expect(channel).
|
|
79
|
+
channel = client.public_channels['CDEADBEEF']
|
|
80
|
+
expect(channel).not_to be_nil
|
|
77
81
|
expect(channel.updated).to be true
|
|
78
82
|
end
|
|
79
83
|
end
|
|
84
|
+
|
|
80
85
|
it 'channel_left' do
|
|
81
|
-
channel = client.
|
|
86
|
+
channel = client.public_channels['C0JHNAB5H']
|
|
82
87
|
expect(channel.members).to include client.self.id
|
|
83
88
|
event = Slack::RealTime::Event.new(
|
|
84
89
|
'type' => 'channel_left',
|
|
85
90
|
'channel' => 'C0JHNAB5H'
|
|
86
91
|
)
|
|
87
92
|
client.send(:dispatch, event)
|
|
88
|
-
expect(channel.members).
|
|
93
|
+
expect(channel.members).not_to include client.self.id
|
|
89
94
|
end
|
|
95
|
+
|
|
90
96
|
it 'channel_rename' do
|
|
91
|
-
channel = client.
|
|
97
|
+
channel = client.public_channels['C0HLE0BBL']
|
|
92
98
|
expect(channel.name).to eq 'gifs'
|
|
93
99
|
event = Slack::RealTime::Event.new(
|
|
94
100
|
'type' => 'channel_rename',
|
|
@@ -101,8 +107,9 @@ RSpec.describe Slack::RealTime::Client, vcr: { cassette_name: 'web/rtm_start' }
|
|
|
101
107
|
client.send(:dispatch, event)
|
|
102
108
|
expect(channel.name).to eq 'updated'
|
|
103
109
|
end
|
|
110
|
+
|
|
104
111
|
it 'channel_unarchive' do
|
|
105
|
-
channel = client.
|
|
112
|
+
channel = client.public_channels['C0HLE0BBL']
|
|
106
113
|
expect(channel.is_archived).to be true
|
|
107
114
|
event = Slack::RealTime::Event.new(
|
|
108
115
|
'type' => 'channel_unarchive',
|
|
@@ -1,19 +1,16 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
1
2
|
require 'spec_helper'
|
|
2
3
|
|
|
3
4
|
[Slack::RealTime::Stores::Store, Slack::RealTime::Stores::Starter].each do |store_class|
|
|
4
|
-
RSpec.describe store_class, vcr: { cassette_name:
|
|
5
|
+
RSpec.describe store_class, vcr: { cassette_name: 'web/rtm_connect' } do
|
|
5
6
|
include_context 'connected client', store_class: store_class
|
|
6
7
|
|
|
7
8
|
context 'team' do
|
|
8
|
-
it 'sets team data on rtm.
|
|
9
|
+
it 'sets team data on rtm.connect' do
|
|
9
10
|
expect(client.team.name).to eq 'dblock'
|
|
10
11
|
expect(client.team.domain).to eq 'dblockdotorg'
|
|
11
|
-
if store_class == Slack::RealTime::Stores::Store
|
|
12
|
-
expect(client.team.email_domain).to eq 'dblock.org'
|
|
13
|
-
expect(client.team.prefs.invites_only_admins).to be true
|
|
14
|
-
expect(client.team.plan).to eq ''
|
|
15
|
-
end
|
|
16
12
|
end
|
|
13
|
+
|
|
17
14
|
it 'team_domain_change' do
|
|
18
15
|
event = Slack::RealTime::Event.new(
|
|
19
16
|
'type' => 'team_domain_change',
|
|
@@ -24,6 +21,7 @@ require 'spec_helper'
|
|
|
24
21
|
expect(client.team.domain).to eq 'my'
|
|
25
22
|
expect(client.team['url']).to eq 'https://my.slack.com'
|
|
26
23
|
end
|
|
24
|
+
|
|
27
25
|
it 'email_domain_changed' do
|
|
28
26
|
event = Slack::RealTime::Event.new(
|
|
29
27
|
'type' => 'email_domain_changed',
|
|
@@ -32,6 +30,7 @@ require 'spec_helper'
|
|
|
32
30
|
client.send(:dispatch, event)
|
|
33
31
|
expect(client.team.email_domain).to eq 'example.com'
|
|
34
32
|
end
|
|
33
|
+
|
|
35
34
|
it 'team_pref_change' do
|
|
36
35
|
event = Slack::RealTime::Event.new(
|
|
37
36
|
'type' => 'team_pref_change',
|
|
@@ -41,6 +40,7 @@ require 'spec_helper'
|
|
|
41
40
|
client.send(:dispatch, event)
|
|
42
41
|
expect(client.team.prefs.invites_only_admins).to be false
|
|
43
42
|
end
|
|
43
|
+
|
|
44
44
|
it 'team_rename' do
|
|
45
45
|
event = Slack::RealTime::Event.new(
|
|
46
46
|
'type' => 'team_rename',
|
|
@@ -49,6 +49,7 @@ require 'spec_helper'
|
|
|
49
49
|
client.send(:dispatch, event)
|
|
50
50
|
expect(client.team.name).to eq 'New Team Name Inc.'
|
|
51
51
|
end
|
|
52
|
+
|
|
52
53
|
it 'team_plan_change' do
|
|
53
54
|
event = Slack::RealTime::Event.new(
|
|
54
55
|
'type' => 'team_plan_change',
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
1
2
|
require 'spec_helper'
|
|
2
3
|
|
|
3
|
-
RSpec.describe Slack::RealTime::Client, vcr: { cassette_name: 'web/
|
|
4
|
+
RSpec.describe Slack::RealTime::Client, vcr: { cassette_name: 'web/rtm_connect' } do
|
|
4
5
|
include_context 'connected client'
|
|
6
|
+
include_context 'loaded client'
|
|
5
7
|
|
|
6
8
|
context 'user' do
|
|
7
|
-
it 'combines user and self data on rtm.start' do
|
|
8
|
-
expect(client.users['U07518DTL'].name).to eq 'rubybot'
|
|
9
|
-
expect(client.users['U07518DTL']['prefs']['push_sound']).to eq 'b2.mp3'
|
|
10
|
-
end
|
|
11
9
|
it 'user_change' do
|
|
12
10
|
expect(client.users['U07KECJ77'].name).to eq 'aws'
|
|
13
11
|
event = Slack::RealTime::Event.new(
|
|
@@ -19,6 +17,7 @@ RSpec.describe Slack::RealTime::Client, vcr: { cassette_name: 'web/rtm_start' }
|
|
|
19
17
|
client.send(:dispatch, event)
|
|
20
18
|
expect(client.users['U07KECJ77'].name).to eq 'renamed'
|
|
21
19
|
end
|
|
20
|
+
|
|
22
21
|
it 'team_join' do
|
|
23
22
|
expect do
|
|
24
23
|
event = Slack::RealTime::Event.new(
|
|
@@ -31,6 +30,7 @@ RSpec.describe Slack::RealTime::Client, vcr: { cassette_name: 'web/rtm_start' }
|
|
|
31
30
|
end.to change(client.users, :count).by(1)
|
|
32
31
|
expect(client.users['DEADBEEF'].name).to eq 'added'
|
|
33
32
|
end
|
|
33
|
+
|
|
34
34
|
it 'pref_change' do
|
|
35
35
|
event = Slack::RealTime::Event.new(
|
|
36
36
|
'type' => 'pref_change',
|
|
@@ -40,6 +40,7 @@ RSpec.describe Slack::RealTime::Client, vcr: { cassette_name: 'web/rtm_start' }
|
|
|
40
40
|
client.send(:dispatch, event)
|
|
41
41
|
expect(client.self.prefs['push_sound']).to eq 'updated.mp3'
|
|
42
42
|
end
|
|
43
|
+
|
|
43
44
|
it 'presence_change' do
|
|
44
45
|
expect(client.users['U07KECJ77'].presence).to eq 'away'
|
|
45
46
|
event = Slack::RealTime::Event.new(
|
|
@@ -50,6 +51,7 @@ RSpec.describe Slack::RealTime::Client, vcr: { cassette_name: 'web/rtm_start' }
|
|
|
50
51
|
client.send(:dispatch, event)
|
|
51
52
|
expect(client.users['U07KECJ77'].presence).to eq 'updated'
|
|
52
53
|
end
|
|
54
|
+
|
|
53
55
|
it 'manual_presence_change' do
|
|
54
56
|
expect(client.self['presence']).to eq 'away'
|
|
55
57
|
event = Slack::RealTime::Event.new(
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
1
2
|
# require 'spec_helper'
|
|
2
3
|
|
|
3
4
|
#
|
|
4
5
|
# to re-record a rtm_connect fixture run with
|
|
5
|
-
# SLACK_API_TOKEN=... CONCURRENCY=
|
|
6
|
+
# SLACK_API_TOKEN=... CONCURRENCY=async-websocket rspec spec/slack/real_time/rtm_connect_spec.rb
|
|
6
7
|
# edit rtm_connect.yml and remove the token, fix wss:// path (run specs, fix failures)
|
|
7
8
|
#
|
|
8
9
|
|
|
@@ -0,0 +1,50 @@
|
|
|
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
|