Skip to content

Commit

Permalink
rubykube#13: rename classes, routes to withdrawals to make it universal
Browse files Browse the repository at this point in the history
  • Loading branch information
subaru9 committed Jun 15, 2018
1 parent f9396f1 commit 630d911
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion app/api/api_v1/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class Base < Grape::API
use APIv1::CORS::Middleware
use APIv1::Auth::Middleware

mount APIv1::Withdraw
mount APIv1::Withdrawals

add_swagger_documentation base_path: BaseAPI::PREFIX,
mount_path: '/swagger',
Expand Down
4 changes: 2 additions & 2 deletions app/api/api_v1/withdraw.rb → app/api/api_v1/withdrawals.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

module APIv1
class Withdraw < Grape::API
class Withdrawals < Grape::API
before { authenticate! }

desc 'Request a withdraw'
Expand All @@ -20,7 +20,7 @@ class Withdraw < Grape::API
desc: 'The beneficiary ID or wallet address on the Blockchain.'
end

post '/withdraws' do
post '/withdrawals' do
Peatio::ManagementAPIv1Client.new.create_withdraw \
uid: current_uid,
currency: params[:currency],
Expand Down
8 changes: 4 additions & 4 deletions spec/api/v1/cors_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

describe APIv1::Withdraw, type: :request do
describe APIv1::Withdrawals, type: :request do
let(:token) { jwt_build(uid: 'O90Y88JDPQ7167') }

def check_cors(response)
Expand All @@ -14,19 +14,19 @@ def check_cors(response)

it 'sends CORS headers when requesting using OPTIONS' do
reset! unless integration_session
integration_session.send :process, 'OPTIONS', '/api/v1/withdraws'
integration_session.send :process, 'OPTIONS', '/api/v1/withdrawals'
expect(response).to be_successful
check_cors(response)
end

it 'sends CORS headers ever when user is not authenticated' do
api_post '/api/v1/withdraws'
api_post '/api/v1/withdrawals'
expect(response).to have_http_status 401
check_cors(response)
end

it 'sends CORS headers when invalid parameter supplied' do
api_post '/api/v1/withdraws', token: token, params: { currency: 'uah' }
api_post '/api/v1/withdrawals', token: token, params: { currency: 'uah' }
expect(response).to have_http_status 422
check_cors(response)
end
Expand Down

0 comments on commit 630d911

Please sign in to comment.