keepr 0.3.2 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,9 +1,9 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Keepr::ContactExport do
4
- let!(:account_1000) { FactoryGirl.create :account, :kind => :asset, :number => 1000, :name => 'Kasse' }
5
- let!(:account_10000) { FactoryGirl.create :account, :kind => :creditor, :number => 10000, :name => 'Meyer GmbH' }
6
- let!(:account_70000) { FactoryGirl.create :account, :kind => :debtor, :number => 70000, :name => 'Schulze AG' }
4
+ let!(:account_1000) { FactoryBot.create :account, kind: :asset, number: 1000, name: 'Kasse' }
5
+ let!(:account_10000) { FactoryBot.create :account, kind: :creditor, number: 10000, name: 'Meyer GmbH' }
6
+ let!(:account_70000) { FactoryBot.create :account, kind: :debtor, number: 70000, name: 'Schulze AG' }
7
7
 
8
8
  let(:scope) { Keepr::Account.all }
9
9
 
@@ -1,15 +1,15 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Keepr::CostCenter do
4
- let(:cost_center) { FactoryGirl.create(:cost_center) }
5
- let(:account) { FactoryGirl.create(:account, :number => 8400, :kind => :revenue) }
4
+ let(:cost_center) { FactoryBot.create(:cost_center) }
5
+ let(:account) { FactoryBot.create(:account, number: 8400, kind: :revenue) }
6
6
 
7
7
  it 'should have postings' do
8
- posting = Keepr::Posting.create! :amount => 10,
9
- :side => 'debit',
10
- :keepr_account => account,
11
- :keepr_cost_center => cost_center,
12
- :keepr_journal_id => 42
8
+ posting = Keepr::Posting.create! amount: 10,
9
+ side: 'debit',
10
+ keepr_account: account,
11
+ keepr_cost_center: cost_center,
12
+ keepr_journal_id: 42
13
13
 
14
14
  expect(cost_center.keepr_postings).to eq([posting])
15
15
  end
@@ -3,13 +3,13 @@ require 'spec_helper'
3
3
  describe Keepr::Group do
4
4
  describe 'validations' do
5
5
  it "should allow is_result for liability" do
6
- group = Keepr::Group.new(:is_result => true, :target => :liability, :name => 'foo')
6
+ group = Keepr::Group.new(is_result: true, target: :liability, name: 'foo')
7
7
  expect(group).to be_valid
8
8
  end
9
9
 
10
10
  [ :asset, :profit_and_loss ].each do |target|
11
11
  it "should not allow is_result for #{target}" do
12
- group = Keepr::Group.new(:is_result => true, :target => target, :name => 'foo')
12
+ group = Keepr::Group.new(is_result: true, target: target, name: 'foo')
13
13
  expect(group).not_to be_valid
14
14
  expect(group.errors.added? :base, :liability_needed_for_result).to eq(true)
15
15
  end
@@ -18,8 +18,8 @@ describe Keepr::Group do
18
18
 
19
19
  describe :get_from_parent do
20
20
  it 'should preset parent' do
21
- root = FactoryGirl.create :group, :target => :asset
22
- child = root.children.create! :name => 'Bar'
21
+ root = FactoryBot.create :group, target: :asset
22
+ child = root.children.create! name: 'Bar'
23
23
 
24
24
  expect(child.target).to eq('asset')
25
25
  end
@@ -27,8 +27,8 @@ describe Keepr::Group do
27
27
 
28
28
  describe :keepr_accounts do
29
29
  it 'should not destroy if there are accounts' do
30
- group = FactoryGirl.create :group
31
- account = FactoryGirl.create :account, :number => 1000, :keepr_group => group
30
+ group = FactoryBot.create :group
31
+ account = FactoryBot.create :account, number: 1000, keepr_group: group
32
32
 
33
33
  expect { group.destroy }.to_not change { Keepr::Group.count }
34
34
  expect(group.destroy).to eq(false)
@@ -36,7 +36,7 @@ describe Keepr::Group do
36
36
  end
37
37
 
38
38
  it 'should destroy if there are no accounts' do
39
- group = FactoryGirl.create :group
39
+ group = FactoryBot.create :group
40
40
 
41
41
  expect { group.destroy }.to change { Keepr::Group.count }.by(-1)
42
42
  end
@@ -44,37 +44,37 @@ describe Keepr::Group do
44
44
 
45
45
  describe :keepr_postings do
46
46
  # Simple asset group hierarchy
47
- let(:group_1) { FactoryGirl.create :group, :target => :asset }
48
- let(:group_1_1) { FactoryGirl.create :group, :target => :asset, :parent => group_1 }
49
- let(:group_1_1_1) { FactoryGirl.create :group, :target => :asset, :parent => group_1_1 }
47
+ let(:group_1) { FactoryBot.create :group, target: :asset }
48
+ let(:group_1_1) { FactoryBot.create :group, target: :asset, parent: group_1 }
49
+ let(:group_1_1_1) { FactoryBot.create :group, target: :asset, parent: group_1_1 }
50
50
 
51
51
  # Group for P&L accounts
52
- let(:group_2) { FactoryGirl.create :group, :target => :profit_and_loss }
52
+ let(:group_2) { FactoryBot.create :group, target: :profit_and_loss }
53
53
 
54
54
  # Group for balance result
55
- let(:group_result){ FactoryGirl.create :group, :target => :liability, :is_result => true }
55
+ let(:group_result){ FactoryBot.create :group, target: :liability, is_result: true }
56
56
 
57
57
  # Accounts
58
- let(:account_1a) { FactoryGirl.create :account, :number => '0001', :keepr_group => group_1_1_1 }
59
- let(:account_1b) { FactoryGirl.create :account, :number => '0011', :keepr_group => group_1_1_1 }
60
- let(:account_1c) { FactoryGirl.create :account, :number => '0111', :keepr_group => group_1_1_1 }
58
+ let(:account_1a) { FactoryBot.create :account, number: '0001', keepr_group: group_1_1_1 }
59
+ let(:account_1b) { FactoryBot.create :account, number: '0011', keepr_group: group_1_1_1 }
60
+ let(:account_1c) { FactoryBot.create :account, number: '0111', keepr_group: group_1_1_1 }
61
61
 
62
- let(:account_2) { FactoryGirl.create :account, :number => '8400', :keepr_group => group_2, :kind => :revenue }
62
+ let(:account_2) { FactoryBot.create :account, number: '8400', keepr_group: group_2, kind: :revenue }
63
63
 
64
64
  # Journals
65
- let!(:journal1) { Keepr::Journal.create! :keepr_postings_attributes => [
66
- { :keepr_account => account_1a, :amount => 100.99, :side => 'debit' },
67
- { :keepr_account => account_2, :amount => 100.99, :side => 'credit' }
65
+ let!(:journal1) { Keepr::Journal.create! keepr_postings_attributes: [
66
+ { keepr_account: account_1a, amount: 100.99, side: 'debit' },
67
+ { keepr_account: account_2, amount: 100.99, side: 'credit' }
68
68
  ]
69
69
  }
70
- let!(:journal2) { Keepr::Journal.create! :keepr_postings_attributes => [
71
- { :keepr_account => account_1b, :amount => 100.99, :side => 'debit' },
72
- { :keepr_account => account_2, :amount => 100.99, :side => 'credit' }
70
+ let!(:journal2) { Keepr::Journal.create! keepr_postings_attributes: [
71
+ { keepr_account: account_1b, amount: 100.99, side: 'debit' },
72
+ { keepr_account: account_2, amount: 100.99, side: 'credit' }
73
73
  ]
74
74
  }
75
- let!(:journal3) { Keepr::Journal.create! :keepr_postings_attributes => [
76
- { :keepr_account => account_1c, :amount => 100.99, :side => 'debit' },
77
- { :keepr_account => account_2, :amount => 100.99, :side => 'credit' }
75
+ let!(:journal3) { Keepr::Journal.create! keepr_postings_attributes: [
76
+ { keepr_account: account_1c, amount: 100.99, side: 'debit' },
77
+ { keepr_account: account_2, amount: 100.99, side: 'credit' }
78
78
  ]
79
79
  }
80
80
 
@@ -1,19 +1,19 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Keepr::JournalExport do
4
- let(:ust) { Keepr::Tax.create! :name => 'USt19', :value => 19.0, :keepr_account => account_1776 }
5
- let(:vst) { Keepr::Tax.create! :name => 'VSt19', :value => 19.0, :keepr_account => account_1576 }
4
+ let(:ust) { Keepr::Tax.create! name: 'USt19', value: 19.0, keepr_account: account_1776 }
5
+ let(:vst) { Keepr::Tax.create! name: 'VSt19', value: 19.0, keepr_account: account_1576 }
6
6
 
7
- let(:account_1000) { FactoryGirl.create :account, :number => 1000, :kind => :asset }
8
- let(:account_1200) { FactoryGirl.create :account, :number => 1200, :kind => :asset }
9
- let(:account_1576) { FactoryGirl.create :account, :number => 1576, :kind => :asset }
10
- let(:account_1776) { FactoryGirl.create :account, :number => 1776, :kind => :liability }
11
- let(:account_1600) { FactoryGirl.create :account, :number => 1600, :kind => :liability }
12
- let(:account_1718) { FactoryGirl.create :account, :number => 1718, :kind => :liability, :keepr_tax => ust }
13
- let(:account_4920) { FactoryGirl.create :account, :number => 4920, :kind => :expense, :keepr_tax => vst }
14
- let(:account_8400) { FactoryGirl.create :account, :number => 8400, :kind => :revenue, :keepr_tax => ust }
7
+ let(:account_1000) { FactoryBot.create :account, number: 1000, kind: :asset }
8
+ let(:account_1200) { FactoryBot.create :account, number: 1200, kind: :asset }
9
+ let(:account_1576) { FactoryBot.create :account, number: 1576, kind: :asset }
10
+ let(:account_1776) { FactoryBot.create :account, number: 1776, kind: :liability }
11
+ let(:account_1600) { FactoryBot.create :account, number: 1600, kind: :liability }
12
+ let(:account_1718) { FactoryBot.create :account, number: 1718, kind: :liability, keepr_tax: ust }
13
+ let(:account_4920) { FactoryBot.create :account, number: 4920, kind: :expense, keepr_tax: vst }
14
+ let(:account_8400) { FactoryBot.create :account, number: 8400, kind: :revenue, keepr_tax: ust }
15
15
 
16
- let(:account_10000) { FactoryGirl.create :account, :number => 10000, :kind => :debtor }
16
+ let(:account_10000) { FactoryBot.create :account, number: 10000, kind: :debtor }
17
17
 
18
18
  let(:scope) { Keepr::Journal.reorder(:number) }
19
19
 
@@ -51,12 +51,12 @@ describe Keepr::JournalExport do
51
51
 
52
52
  context "Journal without tax" do
53
53
  let!(:journal_without_tax) do
54
- Keepr::Journal.create! :number => 'BELEG-1',
55
- :subject => 'Geldautomat',
56
- :date => Date.new(2016,06,23),
57
- :keepr_postings_attributes => [
58
- { :keepr_account => account_1000, :amount => 105, :side => 'debit' },
59
- { :keepr_account => account_1200, :amount => 105, :side => 'credit' }
54
+ Keepr::Journal.create! number: 'BELEG-1',
55
+ subject: 'Geldautomat',
56
+ date: Date.new(2016,06,23),
57
+ keepr_postings_attributes: [
58
+ { keepr_account: account_1000, amount: 105, side: 'debit' },
59
+ { keepr_account: account_1200, amount: 105, side: 'credit' }
60
60
  ]
61
61
  end
62
62
 
@@ -75,13 +75,13 @@ describe Keepr::JournalExport do
75
75
 
76
76
  context "Journal with tax" do
77
77
  let!(:journal_with_tax) do
78
- Keepr::Journal.create! :number => 'BELEG-2',
79
- :subject => 'Telefonrechnung',
80
- :date => Date.new(2016,06,24),
81
- :keepr_postings_attributes => [
82
- { :keepr_account => account_4920, :amount => 8.40, :side => 'debit' },
83
- { :keepr_account => account_1576, :amount => 1.60, :side => 'debit' },
84
- { :keepr_account => account_1600, :amount => 10.00, :side => 'credit' }
78
+ Keepr::Journal.create! number: 'BELEG-2',
79
+ subject: 'Telefonrechnung',
80
+ date: Date.new(2016,06,24),
81
+ keepr_postings_attributes: [
82
+ { keepr_account: account_4920, amount: 8.40, side: 'debit' },
83
+ { keepr_account: account_1576, amount: 1.60, side: 'debit' },
84
+ { keepr_account: account_1600, amount: 10.00, side: 'credit' }
85
85
  ]
86
86
  end
87
87
 
@@ -108,16 +108,16 @@ describe Keepr::JournalExport do
108
108
 
109
109
  context "Journal with debtor" do
110
110
  let!(:journal_with_debtor) do
111
- Keepr::Journal.create! :number => 'BELEG-3',
112
- :subject => 'Warenverkauf mit Anzahlung',
113
- :date => Date.new(2016,06,25),
114
- :keepr_postings_attributes => [
115
- { :keepr_account => account_10000, :amount => 4760.00, :side => 'debit' },
116
- { :keepr_account => account_1718, :amount => 1000.00, :side => 'debit' },
117
- { :keepr_account => account_1776, :amount => 190.00, :side => 'debit' },
118
-
119
- { :keepr_account => account_8400, :amount => 5000.00, :side => 'credit' },
120
- { :keepr_account => account_1776, :amount => 950.00, :side => 'credit' }
111
+ Keepr::Journal.create! number: 'BELEG-3',
112
+ subject: 'Warenverkauf mit Anzahlung',
113
+ date: Date.new(2016,06,25),
114
+ keepr_postings_attributes: [
115
+ { keepr_account: account_10000, amount: 4760.00, side: 'debit' },
116
+ { keepr_account: account_1718, amount: 1000.00, side: 'debit' },
117
+ { keepr_account: account_1776, amount: 190.00, side: 'debit' },
118
+
119
+ { keepr_account: account_8400, amount: 5000.00, side: 'credit' },
120
+ { keepr_account: account_1776, amount: 950.00, side: 'credit' }
121
121
  ]
122
122
  end
123
123
 
@@ -1,26 +1,26 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Keepr::Journal do
4
- let!(:account_1000) { FactoryGirl.create(:account, :number => 1000, :kind => :asset) }
5
- let!(:account_1200) { FactoryGirl.create(:account, :number => 1200, :kind => :asset) }
6
- let!(:account_1210) { FactoryGirl.create(:account, :number => 1210, :kind => :asset) }
7
- let!(:account_4910) { FactoryGirl.create(:account, :number => 4910, :kind => :expense) }
8
- let!(:account_4920) { FactoryGirl.create(:account, :number => 4920, :kind => :expense) }
9
- let!(:account_1576) { FactoryGirl.create(:account, :number => 1576, :kind => :asset) }
10
- let!(:account_1600) { FactoryGirl.create(:account, :number => 1600, :kind => :liability) }
4
+ let!(:account_1000) { FactoryBot.create(:account, number: 1000, kind: :asset) }
5
+ let!(:account_1200) { FactoryBot.create(:account, number: 1200, kind: :asset) }
6
+ let!(:account_1210) { FactoryBot.create(:account, number: 1210, kind: :asset) }
7
+ let!(:account_4910) { FactoryBot.create(:account, number: 4910, kind: :expense) }
8
+ let!(:account_4920) { FactoryBot.create(:account, number: 4920, kind: :expense) }
9
+ let!(:account_1576) { FactoryBot.create(:account, number: 1576, kind: :asset) }
10
+ let!(:account_1600) { FactoryBot.create(:account, number: 1600, kind: :liability) }
11
11
 
12
12
  let :simple_journal do
13
- Keepr::Journal.create :keepr_postings_attributes => [
14
- { :keepr_account => account_1000, :amount => 100.99, :side => 'debit' },
15
- { :keepr_account => account_1200, :amount => 100.99, :side => 'credit' }
13
+ Keepr::Journal.create keepr_postings_attributes: [
14
+ { keepr_account: account_1000, amount: 100.99, side: 'debit' },
15
+ { keepr_account: account_1200, amount: 100.99, side: 'credit' }
16
16
  ]
17
17
  end
18
18
 
19
19
  let :complex_journal do
20
- Keepr::Journal.create :keepr_postings_attributes => [
21
- { :keepr_account => account_4920, :amount => 8.40, :side => 'debit' },
22
- { :keepr_account => account_1576, :amount => 1.60, :side => 'debit' },
23
- { :keepr_account => account_1600, :amount => 10.00, :side => 'credit' }
20
+ Keepr::Journal.create keepr_postings_attributes: [
21
+ { keepr_account: account_4920, amount: 8.40, side: 'debit' },
22
+ { keepr_account: account_1576, amount: 1.60, side: 'debit' },
23
+ { keepr_account: account_1600, amount: 10.00, side: 'credit' }
24
24
  ]
25
25
  end
26
26
 
@@ -34,7 +34,7 @@ describe Keepr::Journal do
34
34
  context 'with date given' do
35
35
  it 'should not modify the date' do
36
36
  old_date = Date.new(2013,10,1)
37
- expect(Keepr::Journal.new(:date => old_date).date).to eq(old_date)
37
+ expect(Keepr::Journal.new(date: old_date).date).to eq(old_date)
38
38
  end
39
39
  end
40
40
  end
@@ -47,41 +47,41 @@ describe Keepr::Journal do
47
47
 
48
48
  it 'should accept journal with postings marked for destruction' do
49
49
  complex_journal.keepr_postings.first.mark_for_destruction
50
- complex_journal.keepr_postings.build :keepr_account => account_4910, :amount => 8.4, :side => 'debit'
50
+ complex_journal.keepr_postings.build keepr_account: account_4910, amount: 8.4, side: 'debit'
51
51
 
52
52
  expect(complex_journal).to be_valid
53
53
  end
54
54
 
55
55
  it 'should fail for journal with only one posting' do
56
- journal = Keepr::Journal.create :keepr_postings_attributes => [
57
- { :keepr_account => account_4920, :amount => 8.40, :side => 'debit' }
56
+ journal = Keepr::Journal.create keepr_postings_attributes: [
57
+ { keepr_account: account_4920, amount: 8.40, side: 'debit' }
58
58
  ]
59
59
  expect(journal).not_to be_valid
60
60
  expect(journal.errors.added? :base, :account_missing).to eq(true)
61
61
  end
62
62
 
63
63
  it 'should fail for booking the same account twice' do
64
- journal = Keepr::Journal.create :keepr_postings_attributes => [
65
- { :keepr_account => account_1000, :amount => 10, :side => 'debit' },
66
- { :keepr_account => account_1000, :amount => 10, :side => 'credit' }
64
+ journal = Keepr::Journal.create keepr_postings_attributes: [
65
+ { keepr_account: account_1000, amount: 10, side: 'debit' },
66
+ { keepr_account: account_1000, amount: 10, side: 'credit' }
67
67
  ]
68
68
  expect(journal).not_to be_valid
69
69
  expect(journal.errors.added? :base, :account_missing).to eq(true)
70
70
  end
71
71
 
72
72
  it 'should fail for unbalanced journal' do
73
- journal = Keepr::Journal.create :keepr_postings_attributes => [
74
- { :keepr_account => account_1000, :amount => 10, :side => 'debit' },
75
- { :keepr_account => account_1200, :amount => 10, :side => 'debit' }
73
+ journal = Keepr::Journal.create keepr_postings_attributes: [
74
+ { keepr_account: account_1000, amount: 10, side: 'debit' },
75
+ { keepr_account: account_1200, amount: 10, side: 'debit' }
76
76
  ]
77
77
  expect(journal).not_to be_valid
78
78
  expect(journal.errors.added? :base, :amount_mismatch).to eq(true)
79
79
  end
80
80
 
81
81
  it 'should fail for nil amount' do
82
- journal = Keepr::Journal.create :keepr_postings_attributes => [
83
- { :keepr_account => account_1000, :amount => 10, :side => 'debit' },
84
- { :keepr_account => account_1200, :amount => nil, :side => 'credit' }
82
+ journal = Keepr::Journal.create keepr_postings_attributes: [
83
+ { keepr_account: account_1000, amount: 10, side: 'debit' },
84
+ { keepr_account: account_1200, amount: nil, side: 'credit' }
85
85
  ]
86
86
  expect(journal).not_to be_valid
87
87
  expect(journal.errors.added? :base, :amount_mismatch).to eq(true)
@@ -90,11 +90,11 @@ describe Keepr::Journal do
90
90
 
91
91
  describe :permanent do
92
92
  before :each do
93
- simple_journal.update_attributes! :permanent => true
93
+ simple_journal.update_attributes! permanent: true
94
94
  end
95
95
 
96
96
  it "should not allow update" do
97
- expect(simple_journal.update_attributes :subject => 'foo').to eq(false)
97
+ expect(simple_journal.update_attributes subject: 'foo').to eq(false)
98
98
  expect(simple_journal.errors.added? :base, :changes_not_allowed).to eq(true)
99
99
  end
100
100
 
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Keepr::Posting do
4
- let!(:account_1000) { FactoryGirl.create(:account, :number => 1000, :kind => :asset) }
4
+ let!(:account_1000) { FactoryBot.create(:account, number: 1000, kind: :asset) }
5
5
 
6
6
  describe 'side/amount' do
7
7
  it 'should handle empty object' do
@@ -11,7 +11,7 @@ describe Keepr::Posting do
11
11
  end
12
12
 
13
13
  it 'should set credit amount' do
14
- posting = Keepr::Posting.new :amount => 10, :side => 'credit'
14
+ posting = Keepr::Posting.new amount: 10, side: 'credit'
15
15
 
16
16
  expect(posting).to be_credit
17
17
  expect(posting.amount).to eq(10)
@@ -19,7 +19,7 @@ describe Keepr::Posting do
19
19
  end
20
20
 
21
21
  it 'should set debit amount' do
22
- posting = Keepr::Posting.new :amount => 10, :side => 'debit'
22
+ posting = Keepr::Posting.new amount: 10, side: 'debit'
23
23
 
24
24
  expect(posting).to be_debit
25
25
  expect(posting.amount).to eq(10)
@@ -39,7 +39,7 @@ describe Keepr::Posting do
39
39
  end
40
40
 
41
41
  it 'should change to credit' do
42
- posting = Keepr::Posting.new :amount => 10, :side => 'debit'
42
+ posting = Keepr::Posting.new amount: 10, side: 'debit'
43
43
  posting.side = 'credit'
44
44
 
45
45
  expect(posting).to be_credit
@@ -47,7 +47,7 @@ describe Keepr::Posting do
47
47
  end
48
48
 
49
49
  it 'should change to debit' do
50
- posting = Keepr::Posting.new :amount => 10, :side => 'credit'
50
+ posting = Keepr::Posting.new amount: 10, side: 'credit'
51
51
  posting.side = 'debit'
52
52
 
53
53
  expect(posting).to be_debit
@@ -55,21 +55,21 @@ describe Keepr::Posting do
55
55
  end
56
56
 
57
57
  it 'should default to debit' do
58
- posting = Keepr::Posting.new :amount => 10
58
+ posting = Keepr::Posting.new amount: 10
59
59
 
60
60
  expect(posting).to be_debit
61
61
  expect(posting.amount).to eq(10)
62
62
  end
63
63
 
64
64
  it 'should handle string amount' do
65
- posting = Keepr::Posting.new :amount => '0.5'
65
+ posting = Keepr::Posting.new amount: '0.5'
66
66
 
67
67
  expect(posting).to be_debit
68
68
  expect(posting.amount).to eq(0.5)
69
69
  end
70
70
 
71
71
  it 'should recognized saved debit posting' do
72
- posting = Keepr::Posting.create!(:amount => 10, :side => 'debit', :keepr_account => account_1000, :keepr_journal_id => 42)
72
+ posting = Keepr::Posting.create!(amount: 10, side: 'debit', keepr_account: account_1000, keepr_journal_id: 42)
73
73
  posting.reload
74
74
 
75
75
  expect(posting).to be_debit
@@ -77,7 +77,7 @@ describe Keepr::Posting do
77
77
  end
78
78
 
79
79
  it 'should recognized saved credit posting' do
80
- posting = Keepr::Posting.create!(:amount => 10, :side => 'credit', :keepr_account => account_1000, :keepr_journal_id => 42)
80
+ posting = Keepr::Posting.create!(amount: 10, side: 'credit', keepr_account: account_1000, keepr_journal_id: 42)
81
81
  posting.reload
82
82
 
83
83
  expect(posting).to be_credit
@@ -86,20 +86,20 @@ describe Keepr::Posting do
86
86
 
87
87
  it 'should fail for negative amount' do
88
88
  expect {
89
- Keepr::Posting.new(:amount => -10)
89
+ Keepr::Posting.new(amount: -10)
90
90
  }.to raise_error(ArgumentError)
91
91
  end
92
92
 
93
93
  it 'should fail for unknown side' do
94
94
  expect {
95
- Keepr::Posting.new(:side => 'foo')
95
+ Keepr::Posting.new(side: 'foo')
96
96
  }.to raise_error(ArgumentError)
97
97
  end
98
98
  end
99
99
 
100
100
  describe 'scopes' do
101
- let!(:debit_posting) { Keepr::Posting.create!(:amount => 10, :side => 'debit', :keepr_account => account_1000, :keepr_journal_id => 42) }
102
- let!(:credit_posting) { Keepr::Posting.create!(:amount => 10, :side => 'credit', :keepr_account => account_1000, :keepr_journal_id => 42) }
101
+ let!(:debit_posting) { Keepr::Posting.create!(amount: 10, side: 'debit', keepr_account: account_1000, keepr_journal_id: 42) }
102
+ let!(:credit_posting) { Keepr::Posting.create!(amount: 10, side: 'credit', keepr_account: account_1000, keepr_journal_id: 42) }
103
103
 
104
104
  it 'should filter' do
105
105
  expect(account_1000.keepr_postings.debits).to eq([debit_posting])
@@ -108,16 +108,16 @@ describe Keepr::Posting do
108
108
  end
109
109
 
110
110
  describe 'cost_center handling' do
111
- let!(:cost_center) { FactoryGirl.create(:cost_center) }
112
- let!(:account_8400) { FactoryGirl.create(:account, :number => 8400, :kind => :revenue) }
111
+ let!(:cost_center) { FactoryBot.create(:cost_center) }
112
+ let!(:account_8400) { FactoryBot.create(:account, number: 8400, kind: :revenue) }
113
113
 
114
114
  it "should allow cost_center" do
115
- posting = Keepr::Posting.new :keepr_account => account_8400, :amount => 100, :keepr_cost_center => cost_center
115
+ posting = Keepr::Posting.new keepr_account: account_8400, amount: 100, keepr_cost_center: cost_center
116
116
  expect(posting).to be_valid
117
117
  end
118
118
 
119
119
  it "should not allow cost_center" do
120
- posting = Keepr::Posting.new :keepr_account => account_1000, :amount => 100, :keepr_cost_center => cost_center
120
+ posting = Keepr::Posting.new keepr_account: account_1000, amount: 100, keepr_cost_center: cost_center
121
121
  expect(posting).to_not be_valid
122
122
  end
123
123
  end