Skip to content

Commit bdf4d21

Browse files
authored
Fix actions endpoint for block dropdowns (#10)
1 parent e2de3c0 commit bdf4d21

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
* [#13](https://github.com/slack-ruby/slack-ruby-bot-server-events/pull/13): Replace Travis CI with Github Actions - [@CrazyOptimist](https://github.com/CrazyOptimist).
66
* Your contribution here.
7+
* [#10](https://github.com/slack-ruby/slack-ruby-bot-server-events/pull/10): Fix actions endpoint for block dropdowns - [@maths22](https://github.com/maths22).
78

89
#### 0.3.1 (2/4/2021)
910

lib/slack-ruby-bot-server-events/api/endpoints/slack/actions_endpoint.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class ActionsEndpoint < Grape::API
4040

4141
given type: ->(val) { val == 'block_actions' } do
4242
optional :trigger_id, type: String
43-
requires :response_url, type: String
43+
optional :response_url, type: String
4444
requires :token, type: String
4545
requires :user, type: Hash do
4646
requires :id, type: String

spec/slack-ruby-bot-server-events/api/endpoints/slack/actions_endpoint_spec.rb

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,18 @@
113113
}
114114
end
115115

116+
let(:payload_without_response_url) do
117+
{
118+
type: 'block_actions',
119+
user: { id: 'user_id' },
120+
team: { id: 'team_id' },
121+
token: 'deprecated',
122+
actions: [
123+
{ type: 'button', action_id: 'action_id' }
124+
]
125+
}
126+
end
127+
116128
context 'with an action handler' do
117129
before do
118130
SlackRubyBotServer::Events.configure do |config|
@@ -128,6 +140,13 @@
128140
response = JSON.parse(last_response.body)
129141
expect(response).to eq('text' => 'block_actions/action_id')
130142
end
143+
144+
it 'performs action when payload has no response url' do
145+
post '/api/slack/action', payload: payload_without_response_url.to_json
146+
expect(last_response.status).to eq 201
147+
response = JSON.parse(last_response.body)
148+
expect(response).to eq('text' => 'block_actions/action_id')
149+
end
131150
end
132151

133152
context 'with a block type actions handler' do

0 commit comments

Comments
 (0)