diff --git a/app/resources/api/rest/admin/account_resource.rb b/app/resources/api/rest/admin/account_resource.rb index f23bcaa00..bc49c15fd 100644 --- a/app/resources/api/rest/admin/account_resource.rb +++ b/app/resources/api/rest/admin/account_resource.rb @@ -1,6 +1,8 @@ class Api::Rest::Admin::AccountResource < ::BaseResource - attributes :name, :min_balance, :max_balance, :external_id, + attributes :name, + :balance, :min_balance, :max_balance, :balance_low_threshold, :balance_high_threshold, :send_balance_notifications_to, + :external_id, :uuid, :origination_capacity, :termination_capacity, :send_invoices_to has_one :contractor @@ -24,6 +26,8 @@ def send_balance_notifications_to=(value) def self.updatable_fields(_context) [ :name, + :uuid, + :external_id, :min_balance, :max_balance, :balance_low_threshold, diff --git a/spec/controllers/api/rest/admin/accounts_controller_spec.rb b/spec/controllers/api/rest/admin/accounts_controller_spec.rb index 815c93837..f1e3d4025 100755 --- a/spec/controllers/api/rest/admin/accounts_controller_spec.rb +++ b/spec/controllers/api/rest/admin/accounts_controller_spec.rb @@ -37,9 +37,15 @@ it { expect(response_data['id']).to eq(account.id.to_s) } it 'has balance threshold attributes' do expect(response_data['attributes']).to include( + 'name', + 'balance','min-balance', 'max-balance', + 'uuid', + 'external-id', + 'origination-capacity', 'termination-capacity', 'send-invoices-to', 'balance-low-threshold', 'balance-high-threshold', - 'send-balance-notifications-to') + 'send-balance-notifications-to' + ) end end @@ -63,13 +69,17 @@ context 'when attributes are valid' do let(:attributes) do { - name: 'name', + name: 'name', 'min-balance': 1, 'external-id': 100, + 'uuid': '29161666-c29c-11e8-a11d-a088b4454590', 'max-balance': 10, 'balance-low-threshold': 90, 'balance-high-threshold': 95, - 'send-balance-notifications-to': Array.wrap(Billing::Contact.collection.first.id) + 'send-balance-notifications-to': Array.wrap(Billing::Contact.collection.first.id), + 'send-invoices-to': Billing::Contact.collection.first.id, + 'origination-capacity': 10, + 'termination-capacity': 3 } end @@ -106,10 +116,16 @@ let(:attributes) do { name: 'name', + 'external-id': 110, + 'uuid': '5d24297a-c29c-11e8-a11d-a088b4454590', + 'min-balance': -100, + 'max-balance': 100, 'balance-low-threshold': 90, 'balance-high-threshold': 95, 'send-balance-notifications-to': Billing::Contact.collection.first.id, - 'send-invoices-to': Billing::Contact.collection.first.id + 'send-invoices-to': Billing::Contact.collection.first.id, + 'origination-capacity': 10, + 'termination-capacity': 3 } end @@ -125,10 +141,10 @@ end context 'when attributes are not updatable' do - let(:attributes) { { 'external-id': 200 } } + let(:attributes) { { 'balance': 2100.2 } } it { expect(response.status).to eq(400) } - it { expect(account.reload.external_id).to_not eq(200) } + it { expect(account.reload.external_id).to_not eq(2100.2) } end end