mirror of
https://github.com/internetee/registry.git
synced 2025-06-07 21:25:39 +02:00
REPP: Accounts balance test
This commit is contained in:
parent
06ad8c8c77
commit
a43df5ca95
2 changed files with 23 additions and 1 deletions
|
@ -4,7 +4,7 @@ module Repp
|
||||||
def balance
|
def balance
|
||||||
resp = { balance: current_user.registrar.cash_account.balance,
|
resp = { balance: current_user.registrar.cash_account.balance,
|
||||||
currency: current_user.registrar.cash_account.currency }
|
currency: current_user.registrar.cash_account.currency }
|
||||||
render(json: resp, status: :ok)
|
render_success(data: resp)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
22
test/integration/repp/v1/accounts/balance_test.rb
Normal file
22
test/integration/repp/v1/accounts/balance_test.rb
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
require 'test_helper'
|
||||||
|
|
||||||
|
class ReppV1BalanceTest < ActionDispatch::IntegrationTest
|
||||||
|
def setup
|
||||||
|
@registrar = users(:api_bestnames)
|
||||||
|
token = Base64.encode64("#{@registrar.username}:#{@registrar.plain_text_password}")
|
||||||
|
token = "Basic #{token}"
|
||||||
|
|
||||||
|
@auth_headers = { 'Authorization' => token }
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_can_query_balance
|
||||||
|
get '/repp/v1/accounts/balance', headers: @auth_headers
|
||||||
|
json = JSON.parse(response.body, symbolize_names: true)
|
||||||
|
|
||||||
|
assert_response :ok
|
||||||
|
assert_equal 1000, json[:code]
|
||||||
|
assert_equal 'Command completed successfully', json[:message]
|
||||||
|
assert_equal @registrar.registrar.cash_account.balance.to_s, json[:data][:balance]
|
||||||
|
assert_equal @registrar.registrar.cash_account.currency, json[:data][:currency]
|
||||||
|
end
|
||||||
|
end
|
Loading…
Add table
Add a link
Reference in a new issue