mirror of
https://github.com/internetee/registry.git
synced 2025-06-06 12:47:29 +02:00
Merge pull request #1204 from internetee/convert-specs-to-tests
Convert specs to tests
This commit is contained in:
commit
d85e57d800
4 changed files with 28 additions and 92 deletions
|
@ -1,11 +0,0 @@
|
|||
FactoryBot.define do
|
||||
factory :bank_statement do
|
||||
bank_code { '767' }
|
||||
iban { 'EE557700771000598731' }
|
||||
queried_at { Time.zone.now }
|
||||
|
||||
after :build do |bank_statement|
|
||||
bank_statement.bank_transactions << FactoryBot.create_pair(:bank_transaction)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,81 +0,0 @@
|
|||
require 'rails_helper'
|
||||
|
||||
describe BankStatement do
|
||||
context 'with invalid attribute' do
|
||||
before :all do
|
||||
@bank_statement = BankStatement.new
|
||||
end
|
||||
|
||||
it 'should not be valid' do
|
||||
@bank_statement.valid?
|
||||
@bank_statement.errors.full_messages.should match_array([
|
||||
"Bank code is missing",
|
||||
"Iban is missing"
|
||||
])
|
||||
end
|
||||
|
||||
it 'should not have any versions' do
|
||||
@bank_statement.versions.should == []
|
||||
end
|
||||
end
|
||||
|
||||
context 'with valid attributes' do
|
||||
before do
|
||||
@bank_statement = create(:bank_statement)
|
||||
end
|
||||
|
||||
it 'should be valid' do
|
||||
@bank_statement.valid?
|
||||
@bank_statement.errors.full_messages.should match_array([])
|
||||
end
|
||||
|
||||
it 'should be valid twice' do
|
||||
@bank_statement = create(:bank_statement)
|
||||
@bank_statement.valid?
|
||||
@bank_statement.errors.full_messages.should match_array([])
|
||||
end
|
||||
|
||||
it 'should not bind transactions with invalid match data' do
|
||||
r = create(:registrar, reference_no: '1234')
|
||||
|
||||
create(:account, registrar: r, account_type: 'cash', balance: 0)
|
||||
|
||||
r.issue_prepayment_invoice(200, 'add some money')
|
||||
|
||||
bs = create(:bank_statement, bank_transactions: [
|
||||
create(:bank_transaction, {
|
||||
sum: 240.0, # with vat
|
||||
reference_no: 'RF7086666662',
|
||||
description: 'Invoice no. 1'
|
||||
}),
|
||||
create(:bank_transaction, {
|
||||
sum: 240.0,
|
||||
reference_no: '1234',
|
||||
description: 'Invoice no. 4948934'
|
||||
})
|
||||
])
|
||||
|
||||
bs.bank_transactions.count.should == 4
|
||||
|
||||
AccountActivity.count.should == 0
|
||||
bs.bind_invoices
|
||||
|
||||
AccountActivity.count.should == 0
|
||||
|
||||
r.cash_account.balance.should == 0.0
|
||||
|
||||
bs.bank_transactions.unbinded.count.should == 4
|
||||
bs.not_binded?.should == true
|
||||
end
|
||||
|
||||
it 'should have one version' do
|
||||
with_versioning do
|
||||
@bank_statement.versions.should == []
|
||||
@bank_statement.bank_code = 'new_code'
|
||||
@bank_statement.save
|
||||
@bank_statement.errors.full_messages.should match_array([])
|
||||
@bank_statement.versions.size.should == 1
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
3
test/fixtures/bank_statements.yml
vendored
Normal file
3
test/fixtures/bank_statements.yml
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
one:
|
||||
bank_code: '1234'
|
||||
iban: GB33BUKB20201555555555
|
25
test/models/bank_statement_test.rb
Normal file
25
test/models/bank_statement_test.rb
Normal file
|
@ -0,0 +1,25 @@
|
|||
require 'test_helper'
|
||||
|
||||
class BankStatementTest < ActiveSupport::TestCase
|
||||
def test_valid_bank_statement_fixture_is_valid
|
||||
assert valid_bank_statement.valid?, proc { valid_bank_statement.errors.full_messages }
|
||||
end
|
||||
|
||||
def test_invalid_without_bank_code
|
||||
bank_statement = valid_bank_statement
|
||||
bank_statement.bank_code = ''
|
||||
assert bank_statement.invalid?
|
||||
end
|
||||
|
||||
def test_invalid_without_iban
|
||||
bank_statement = valid_bank_statement
|
||||
bank_statement.iban = ''
|
||||
assert bank_statement.invalid?
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def valid_bank_statement
|
||||
bank_statements(:one)
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue