Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated graph_endpoint to slack_endpoint because of Slack single action URL #30

Merged
merged 1 commit into from
Jul 4, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
### Changelog

* 7/4/2016: [#28](https://github.com/dblock/slack-market/issues/28): Rename Slack action endpoint - [@ddruker](https://github.com/ddruker).
* 7/2/2016: [#26](https://github.com/dblock/slack-market/issues/26): Supports lowercase ticker symbols, eg. `$aapl` - [@dblock](https://github.com/dblock).
* 7/2/2016: Require a 1.99$ subscription after 7 days - [@dblock](https://github.com/dblock).
* 7/2/2016: [#1](https://github.com/dblock/slack-market/issues/1): Display other types of graphs - [@ddruker](https://github.com/ddruker).
Expand Down
2 changes: 1 addition & 1 deletion slack-market/api/endpoints.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
require 'slack-market/api/endpoints/teams_endpoint'
require 'slack-market/api/endpoints/subscriptions_endpoint'
require 'slack-market/api/endpoints/status_endpoint'
require 'slack-market/api/endpoints/graph_endpoint'
require 'slack-market/api/endpoints/slack_endpoint'
require 'slack-market/api/endpoints/root_endpoint'
2 changes: 1 addition & 1 deletion slack-market/api/endpoints/root_endpoint.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class RootEndpoint < Grape::API
end

mount Api::Endpoints::StatusEndpoint
mount Api::Endpoints::GraphEndpoint
mount Api::Endpoints::SlackEndpoint
mount Api::Endpoints::TeamsEndpoint
mount Api::Endpoints::SubscriptionsEndpoint

Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
require 'pp'
module Api
module Endpoints
class GraphEndpoint < Grape::API
class SlackEndpoint < Grape::API
format :json

namespace :graph do
desc 'Select graph.'
namespace :slack do
desc 'Respond to interactive slack buttons and actions.'

params do
requires :payload, type: String
end

post do
post '/action' do
payload = JSON.parse(params[:payload])
button_name = payload['actions'][0]['name']
button_value = payload['actions'][0]['value']
Expand Down
2 changes: 1 addition & 1 deletion spec/api/documentation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
JSON.parse(last_response.body)
end
it 'documents root level apis' do
expect(subject['paths'].keys).to eq ['/api/status', '/api/graph', '/api/teams/{id}', '/api/teams', '/api/subscriptions']
expect(subject['paths'].keys).to eq ['/api/status', '/api/slack/action', '/api/teams/{id}', '/api/teams', '/api/subscriptions']
end
end

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
require 'spec_helper'

describe Api::Endpoints::GraphEndpoint do
describe Api::Endpoints::SlackEndpoint do
include Api::Test::EndpointTest

context 'graph' do
it 'parses a good payload', vcr: { cassette_name: 'msft' } do
post '/api/graph', payload: {
post '/api/slack/action', payload: {
'actions': [{ 'name' => '1m', 'value' => 'MSFT- 1m' }],
'channel': { 'id' => '424242424', 'name' => 'directmessage' },
'token': ENV['SLACK_VERIFICATION_TOKEN'],
Expand All @@ -16,7 +16,7 @@
expect(last_response.status).to eq 201
end
it 'returns an error with a non-matching verification token', vcr: { cassette_name: 'msft' } do
post '/api/graph', payload: {
post '/api/slack/action', payload: {
'actions': [{ 'name' => '1m', 'value' => 'MSFT- 1m' }],
'channel': { 'id' => '424242424', 'name' => 'directmessage' },
'token': 'invalid-token',
Expand Down