Maintain backwards compatibility with existing slash command.

This commit is contained in:
Guo Xiang Tan 2017-10-10 13:30:44 +08:00
parent ba883e0af4
commit 6bbac0a1e9
2 changed files with 17 additions and 0 deletions

View File

@ -2,4 +2,7 @@ Discourse::Application.routes.append do
mount ::DiscourseChat::AdminEngine, at: '/admin/plugins/chat', constraints: AdminConstraint.new
mount ::DiscourseChat::PublicEngine, at: '/chat-transcript/', as: 'chat-transcript'
mount ::DiscourseChat::Provider::HookEngine, at: '/chat-integration/'
# For backwards compatibility with Slack plugin
post "/slack/command" => "discourse_chat/provider/slack_provider/slack_command#command"
end

View File

@ -53,6 +53,20 @@ describe 'Slack Command Controller', type: :request do
end
end
describe 'backwards compatibility with discourse-slack-official' do
it 'should return the right response' do
token = 'secret sauce'
SiteSetting.chat_integration_slack_incoming_webhook_token = token
post '/slack/command.json', params: {
text: 'help', token: token
}
expect(response.status).to eq(200)
expect(JSON.parse(response.body)["text"]).to be_present
end
end
describe 'when incoming webhook token has not been set' do
it 'should raise the right error' do
post '/chat-integration/slack/command.json', params: {