Improve "account_activities" DB table structure

#475
This commit is contained in:
Artur Beljajev 2017-05-07 14:05:32 +03:00
parent 1891a6305b
commit f55169c2b4
2 changed files with 7 additions and 44 deletions

View file

@ -37,7 +37,7 @@ class Epp::DomainsController < EppController
sum: @domain_pricelist.price.amount,
description: "#{I18n.t('create')} #{@domain.name}",
activity_type: AccountActivity::CREATE,
log_pricelist_id: @domain_pricelist.id
price: @domain_pricelist
})
render_epp_response '/epp/domains/create'
@ -124,7 +124,7 @@ class Epp::DomainsController < EppController
sum: @domain_pricelist.price.amount,
description: "#{I18n.t('renew')} #{@domain.name}",
activity_type: AccountActivity::RENEW,
log_pricelist_id: @domain_pricelist.id
price: @domain_pricelist
})
render_epp_response '/epp/domains/renew'

View file

@ -1,48 +1,11 @@
require 'rails_helper'
RSpec.describe Account do
context 'with invalid attribute' do
before :all do
@account = Account.new
end
it 'should not be valid' do
@account.valid?
@account.errors.full_messages.should match_array(["Account type is missing"])
end
it 'should not have any versions' do
@account.versions.should == []
end
end
context 'with valid attributes' do
before :all do
@account = Fabricate(:account)
end
it 'should be valid' do
@account.valid?
@account.errors.full_messages.should match_array([])
s = 0.0
@account.activities.map { |x| s += x.sum }
@account.balance.should == s
end
it 'should be valid twice' do
@account = Fabricate(:account)
@account.valid?
@account.errors.full_messages.should match_array([])
end
it 'should have one version' do
with_versioning do
@account.versions.should == []
@account.account_type = 'new_type'
@account.save
@account.errors.full_messages.should match_array([])
@account.versions.size.should == 1
end
it 'has versions' do
with_versioning do
price = build(:account)
price.save!
expect(price.versions.size).to be(1)
end
end