double_entry 0.10.0 → 0.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rspec +2 -1
- data/.rubocop.yml +55 -0
- data/.travis.yml +23 -12
- data/README.md +5 -1
- data/Rakefile +8 -3
- data/double_entry.gemspec +4 -3
- data/lib/active_record/locking_extensions.rb +28 -40
- data/lib/active_record/locking_extensions/log_subscriber.rb +4 -4
- data/lib/double_entry.rb +0 -2
- data/lib/double_entry/account.rb +13 -16
- data/lib/double_entry/account_balance.rb +0 -4
- data/lib/double_entry/balance_calculator.rb +4 -5
- data/lib/double_entry/configurable.rb +0 -2
- data/lib/double_entry/configuration.rb +2 -3
- data/lib/double_entry/errors.rb +2 -2
- data/lib/double_entry/line.rb +13 -16
- data/lib/double_entry/locking.rb +13 -18
- data/lib/double_entry/reporting.rb +2 -3
- data/lib/double_entry/reporting/aggregate.rb +90 -88
- data/lib/double_entry/reporting/aggregate_array.rb +58 -58
- data/lib/double_entry/reporting/day_range.rb +37 -35
- data/lib/double_entry/reporting/hour_range.rb +40 -37
- data/lib/double_entry/reporting/line_aggregate.rb +27 -28
- data/lib/double_entry/reporting/month_range.rb +67 -67
- data/lib/double_entry/reporting/time_range.rb +40 -38
- data/lib/double_entry/reporting/time_range_array.rb +3 -5
- data/lib/double_entry/reporting/week_range.rb +77 -78
- data/lib/double_entry/reporting/year_range.rb +27 -27
- data/lib/double_entry/transfer.rb +14 -15
- data/lib/double_entry/validation/line_check.rb +92 -86
- data/lib/double_entry/version.rb +1 -1
- data/lib/generators/double_entry/install/install_generator.rb +1 -2
- data/lib/generators/double_entry/install/templates/migration.rb +0 -2
- data/script/jack_hammer +1 -1
- data/spec/active_record/locking_extensions_spec.rb +45 -38
- data/spec/double_entry/account_balance_spec.rb +4 -5
- data/spec/double_entry/account_spec.rb +43 -44
- data/spec/double_entry/balance_calculator_spec.rb +6 -8
- data/spec/double_entry/configuration_spec.rb +14 -16
- data/spec/double_entry/line_spec.rb +25 -26
- data/spec/double_entry/locking_spec.rb +34 -39
- data/spec/double_entry/reporting/aggregate_array_spec.rb +8 -10
- data/spec/double_entry/reporting/aggregate_spec.rb +84 -44
- data/spec/double_entry/reporting/line_aggregate_spec.rb +7 -6
- data/spec/double_entry/reporting/month_range_spec.rb +109 -103
- data/spec/double_entry/reporting/time_range_array_spec.rb +145 -135
- data/spec/double_entry/reporting/time_range_spec.rb +36 -35
- data/spec/double_entry/reporting/week_range_spec.rb +82 -76
- data/spec/double_entry/reporting_spec.rb +9 -13
- data/spec/double_entry/transfer_spec.rb +13 -15
- data/spec/double_entry/validation/line_check_spec.rb +73 -79
- data/spec/double_entry_spec.rb +65 -68
- data/spec/generators/double_entry/install/install_generator_spec.rb +7 -10
- data/spec/spec_helper.rb +68 -10
- data/spec/support/accounts.rb +2 -4
- data/spec/support/double_entry_spec_helper.rb +4 -4
- data/spec/support/gemfiles/Gemfile.rails-3.2.x +1 -0
- metadata +31 -2
@@ -1,44 +1,45 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
-
|
3
|
-
module
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
2
|
+
module DoubleEntry
|
3
|
+
module Reporting
|
4
|
+
RSpec.describe TimeRange do
|
5
|
+
it 'should correctly calculate a month range' do
|
6
|
+
ar = TimeRange.make(:year => 2009, :month => 10)
|
7
|
+
expect(ar.start.to_s).to eq Time.mktime(2009, 10, 1, 0, 0, 0).to_s
|
8
|
+
expect(ar.finish.to_s).to eq Time.mktime(2009, 10, 31, 23, 59, 59).to_s
|
9
|
+
end
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
11
|
+
it 'should correctly calculate the beginning of the financial year' do
|
12
|
+
range = TimeRange.make(:year => 2009, :month => 6).beginning_of_financial_year
|
13
|
+
expect(range.month).to eq 7
|
14
|
+
expect(range.year).to eq 2008
|
15
|
+
range = TimeRange.make(:year => 2009, :month => 7).beginning_of_financial_year
|
16
|
+
expect(range.month).to eq 7
|
17
|
+
expect(range.year).to eq 2009
|
18
|
+
end
|
19
19
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
20
|
+
it "should correctly calculate the current week range for New Year's Day" do
|
21
|
+
Timecop.freeze Time.mktime(2009, 1, 1) do
|
22
|
+
expect(WeekRange.current.week).to eq 1
|
23
|
+
end
|
24
|
+
end
|
25
25
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
26
|
+
it 'should correctly calculate the current week range for the first Sunday in the year after New Years' do
|
27
|
+
Timecop.freeze Time.mktime(2009, 1, 4) do
|
28
|
+
expect(WeekRange.current.week).to eq 1
|
29
|
+
end
|
30
|
+
end
|
31
31
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
32
|
+
it 'should correctly calculate the current week range for the first Monday in the year after New Years' do
|
33
|
+
Timecop.freeze Time.mktime(2009, 1, 5) do
|
34
|
+
expect(WeekRange.current.week).to eq 2
|
35
|
+
end
|
36
|
+
end
|
37
37
|
|
38
|
-
|
39
|
-
|
40
|
-
|
38
|
+
it 'should correctly calculate the current week range for my birthday' do
|
39
|
+
Timecop.freeze Time.mktime(2009, 3, 27) do
|
40
|
+
expect(WeekRange.current.week).to eq 13
|
41
|
+
end
|
42
|
+
end
|
41
43
|
end
|
42
44
|
end
|
43
|
-
end
|
44
45
|
end
|
@@ -1,97 +1,103 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
-
|
3
|
-
module
|
4
|
-
describe WeekRange do
|
2
|
+
module DoubleEntry
|
3
|
+
module Reporting
|
4
|
+
RSpec.describe WeekRange do
|
5
|
+
it 'should start week 1 of a year in the first week that has any day in the year' do
|
6
|
+
range = WeekRange.new(:year => 2011, :week => 1)
|
7
|
+
expect(range.start).to eq Time.parse('2010-12-27 00:00:00')
|
8
|
+
end
|
5
9
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
+
it 'should handle times in the last week of the year properly' do
|
11
|
+
range = WeekRange.from_time(Time.parse('2010-12-29 11:30:00'))
|
12
|
+
expect(range.year).to eq 2011
|
13
|
+
expect(range.week).to eq 1
|
14
|
+
expect(range.start).to eq Time.parse('2010-12-27 00:00:00')
|
15
|
+
end
|
10
16
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
+
it 'handles daylight savings time properly' do
|
18
|
+
Time.use_zone('America/Los_Angeles') do
|
19
|
+
time = Time.zone.parse('Mon, 10 Mar 2014')
|
20
|
+
range = WeekRange.from_time time
|
21
|
+
expect(range.start.day).to eq 10
|
22
|
+
end
|
23
|
+
end
|
17
24
|
|
18
|
-
|
19
|
-
|
20
|
-
time = Time.zone.parse('Mon, 10 Mar 2014')
|
21
|
-
range = WeekRange.from_time time
|
22
|
-
expect(range.start.day).to eq 10
|
23
|
-
end
|
24
|
-
end
|
25
|
+
describe '::from_time' do
|
26
|
+
subject(:from_time) { WeekRange.from_time(given_time) }
|
25
27
|
|
26
|
-
|
27
|
-
|
28
|
+
context 'given the Time 31st March 2012' do
|
29
|
+
let(:given_time) { Time.new(2012, 3, 31) }
|
30
|
+
its(:year) { should eq 2012 }
|
31
|
+
its(:week) { should eq 14 }
|
32
|
+
end
|
28
33
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
+
context 'given the Date 31st March 2012' do
|
35
|
+
let(:given_time) { Date.parse('2012-03-31') }
|
36
|
+
its(:year) { should eq 2012 }
|
37
|
+
its(:week) { should eq 14 }
|
38
|
+
end
|
39
|
+
end
|
34
40
|
|
35
|
-
|
36
|
-
|
37
|
-
its(:year) { should eq 2012 }
|
38
|
-
its(:week) { should eq 14 }
|
39
|
-
end
|
40
|
-
end
|
41
|
+
describe '::reportable_weeks' do
|
42
|
+
subject(:reportable_weeks) { WeekRange.reportable_weeks }
|
41
43
|
|
42
|
-
|
43
|
-
|
44
|
+
context 'The date is 1st Feb 1970' do
|
45
|
+
before { Timecop.freeze(Time.new(1970, 2, 1)) }
|
44
46
|
|
45
|
-
|
46
|
-
|
47
|
+
specify do
|
48
|
+
should eq [
|
49
|
+
WeekRange.new(:year => 1970, :week => 1),
|
50
|
+
WeekRange.new(:year => 1970, :week => 2),
|
51
|
+
WeekRange.new(:year => 1970, :week => 3),
|
52
|
+
WeekRange.new(:year => 1970, :week => 4),
|
53
|
+
WeekRange.new(:year => 1970, :week => 5),
|
54
|
+
]
|
55
|
+
end
|
47
56
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
] }
|
57
|
+
context 'My business started on 25th Jan 1970' do
|
58
|
+
before do
|
59
|
+
DoubleEntry::Reporting.configure do |config|
|
60
|
+
config.start_of_business = Time.new(1970, 1, 25)
|
61
|
+
end
|
62
|
+
end
|
55
63
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
64
|
+
specify do
|
65
|
+
should eq [
|
66
|
+
WeekRange.new(:year => 1970, :week => 4),
|
67
|
+
WeekRange.new(:year => 1970, :week => 5),
|
68
|
+
]
|
69
|
+
end
|
60
70
|
end
|
61
71
|
end
|
62
72
|
|
63
|
-
|
64
|
-
|
65
|
-
WeekRange.new(year: 1970, week: 5),
|
66
|
-
] }
|
67
|
-
end
|
68
|
-
end
|
73
|
+
context 'The date is 1st Jan 1970' do
|
74
|
+
before { Timecop.freeze(Time.new(1970, 1, 1)) }
|
69
75
|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
it { should eq [ WeekRange.new(year: 1970, week: 1) ] }
|
74
|
-
end
|
76
|
+
it { should eq [WeekRange.new(:year => 1970, :week => 1)] }
|
77
|
+
end
|
75
78
|
|
76
|
-
|
77
|
-
|
79
|
+
context 'Given a start time of 3rd Dec 1982' do
|
80
|
+
subject(:reportable_weeks) { WeekRange.reportable_weeks(:from => Time.new(1982, 12, 3)) }
|
78
81
|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
82
|
+
context 'The date is 12nd Jan 1983' do
|
83
|
+
before { Timecop.freeze(Time.new(1983, 2, 2)) }
|
84
|
+
specify do
|
85
|
+
should eq [
|
86
|
+
WeekRange.new(:year => 1982, :week => 49),
|
87
|
+
WeekRange.new(:year => 1982, :week => 50),
|
88
|
+
WeekRange.new(:year => 1982, :week => 51),
|
89
|
+
WeekRange.new(:year => 1982, :week => 52),
|
90
|
+
WeekRange.new(:year => 1983, :week => 1),
|
91
|
+
WeekRange.new(:year => 1983, :week => 2),
|
92
|
+
WeekRange.new(:year => 1983, :week => 3),
|
93
|
+
WeekRange.new(:year => 1983, :week => 4),
|
94
|
+
WeekRange.new(:year => 1983, :week => 5),
|
95
|
+
WeekRange.new(:year => 1983, :week => 6),
|
96
|
+
]
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
93
100
|
end
|
94
101
|
end
|
95
102
|
end
|
96
|
-
end
|
97
103
|
end
|
@@ -1,12 +1,10 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
-
|
3
|
-
describe
|
4
|
-
|
5
|
-
describe "::configure" do
|
6
|
-
describe "start_of_business" do
|
2
|
+
RSpec.describe DoubleEntry::Reporting do
|
3
|
+
describe '::configure' do
|
4
|
+
describe 'start_of_business' do
|
7
5
|
subject(:start_of_business) { DoubleEntry::Reporting.configuration.start_of_business }
|
8
6
|
|
9
|
-
context
|
7
|
+
context 'configured to 2011-03-12' do
|
10
8
|
before do
|
11
9
|
DoubleEntry::Reporting.configure do |config|
|
12
10
|
config.start_of_business = Time.new(2011, 3, 12)
|
@@ -16,34 +14,32 @@ describe DoubleEntry::Reporting do
|
|
16
14
|
it { should eq Time.new(2011, 3, 12) }
|
17
15
|
end
|
18
16
|
|
19
|
-
context
|
17
|
+
context 'not configured' do
|
20
18
|
it { should eq Time.new(1970, 1, 1) }
|
21
19
|
end
|
22
20
|
end
|
23
21
|
end
|
24
22
|
|
25
|
-
describe
|
23
|
+
describe '::scopes_with_minimum_balance_for_account' do
|
26
24
|
subject(:scopes) { DoubleEntry::Reporting.scopes_with_minimum_balance_for_account(minimum_balance, :checking) }
|
27
25
|
|
28
26
|
context "a 'checking' account with balance $100" do
|
29
27
|
let!(:user) { User.make!(:checking_balance => Money.new(100_00)) }
|
30
28
|
|
31
|
-
context
|
29
|
+
context 'when searching for balance $99' do
|
32
30
|
let(:minimum_balance) { Money.new(99_00) }
|
33
31
|
it { should include user.id }
|
34
32
|
end
|
35
33
|
|
36
|
-
context
|
34
|
+
context 'when searching for balance $100' do
|
37
35
|
let(:minimum_balance) { Money.new(100_00) }
|
38
36
|
it { should include user.id }
|
39
37
|
end
|
40
38
|
|
41
|
-
context
|
39
|
+
context 'when searching for balance $101' do
|
42
40
|
let(:minimum_balance) { Money.new(101_00) }
|
43
41
|
it { should_not include user.id }
|
44
42
|
end
|
45
43
|
end
|
46
44
|
end
|
47
|
-
|
48
|
-
|
49
45
|
end
|
@@ -1,18 +1,16 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
-
require 'spec_helper'
|
3
2
|
module DoubleEntry
|
4
|
-
describe Transfer do
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
let(:code) { "xxxxxxxxxxxxxxxx 47 characters xxxxxxxxxxxxxxxx" }
|
3
|
+
RSpec.describe Transfer do
|
4
|
+
describe '::new' do
|
5
|
+
context 'given a code 47 characters in length' do
|
6
|
+
let(:code) { 'xxxxxxxxxxxxxxxx 47 characters xxxxxxxxxxxxxxxx' }
|
9
7
|
specify do
|
10
8
|
expect { Transfer.new(:code => code) }.to_not raise_error
|
11
9
|
end
|
12
10
|
end
|
13
11
|
|
14
|
-
context
|
15
|
-
let(:code) {
|
12
|
+
context 'given a code 48 characters in length' do
|
13
|
+
let(:code) { 'xxxxxxxxxxxxxxxx 48 characters xxxxxxxxxxxxxxxxx' }
|
16
14
|
specify do
|
17
15
|
expect { Transfer.new(:code => code) }.to raise_error TransferCodeTooLongError, /'#{code}'/
|
18
16
|
end
|
@@ -20,18 +18,18 @@ module DoubleEntry
|
|
20
18
|
end
|
21
19
|
|
22
20
|
describe Transfer::Set do
|
23
|
-
describe
|
21
|
+
describe '#define' do
|
24
22
|
before do
|
25
23
|
subject.define(
|
26
|
-
:code =>
|
27
|
-
:from => double(:identifier =>
|
28
|
-
:to => double(:identifier =>
|
24
|
+
:code => 'code',
|
25
|
+
:from => double(:identifier => 'from'),
|
26
|
+
:to => double(:identifier => 'to'),
|
29
27
|
)
|
30
28
|
end
|
31
29
|
its(:first) { should be_a Transfer }
|
32
|
-
its(
|
33
|
-
its(
|
34
|
-
its(
|
30
|
+
its('first.code') { should eq 'code' }
|
31
|
+
its('first.from.identifier') { should eq 'from' }
|
32
|
+
its('first.to.identifier') { should eq 'to' }
|
35
33
|
end
|
36
34
|
end
|
37
35
|
end
|
@@ -1,105 +1,99 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
-
|
3
|
-
module
|
4
|
-
|
5
|
-
|
6
|
-
|
2
|
+
module DoubleEntry
|
3
|
+
module Validation
|
4
|
+
RSpec.describe LineCheck do
|
5
|
+
describe '#last' do
|
6
|
+
context 'Given some checks have been created' do
|
7
|
+
before do
|
8
|
+
Timecop.freeze 3.minutes.ago do
|
9
|
+
LineCheck.create! :last_line_id => 100, :errors_found => false, :log => ''
|
10
|
+
end
|
11
|
+
Timecop.freeze 1.minute.ago do
|
12
|
+
LineCheck.create! :last_line_id => 300, :errors_found => false, :log => ''
|
13
|
+
end
|
14
|
+
Timecop.freeze 2.minutes.ago do
|
15
|
+
LineCheck.create! :last_line_id => 200, :errors_found => false, :log => ''
|
16
|
+
end
|
17
|
+
end
|
7
18
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
LineCheck.create! :last_line_id => 100, :errors_found => false, :log => ''
|
12
|
-
end
|
13
|
-
Timecop.freeze 1.minute.ago do
|
14
|
-
LineCheck.create! :last_line_id => 300, :errors_found => false, :log => ''
|
15
|
-
end
|
16
|
-
Timecop.freeze 2.minutes.ago do
|
17
|
-
LineCheck.create! :last_line_id => 200, :errors_found => false, :log => ''
|
19
|
+
it 'should find the newest LineCheck created (by creation_date)' do
|
20
|
+
expect(LineCheck.last.last_line_id).to eq 300
|
21
|
+
end
|
18
22
|
end
|
19
23
|
end
|
20
24
|
|
21
|
-
|
22
|
-
|
23
|
-
end
|
24
|
-
end
|
25
|
+
describe '#perform!' do
|
26
|
+
subject(:performed_line_check) { LineCheck.perform! }
|
25
27
|
|
26
|
-
|
27
|
-
|
28
|
-
describe '#perform!' do
|
29
|
-
subject(:performed_line_check) { LineCheck.perform! }
|
28
|
+
context 'Given a user with 100 dollars' do
|
29
|
+
before { User.make!(:savings_balance => Money.new(100_00)) }
|
30
30
|
|
31
|
-
|
32
|
-
|
31
|
+
context 'And all is consistent' do
|
32
|
+
context 'And all lines have been checked' do
|
33
|
+
before { LineCheck.perform! }
|
33
34
|
|
34
|
-
|
35
|
+
it { should be_nil }
|
35
36
|
|
36
|
-
|
37
|
-
|
37
|
+
it 'should not persist a new LineCheck' do
|
38
|
+
expect { LineCheck.perform! }.
|
39
|
+
to_not change { LineCheck.count }
|
40
|
+
end
|
41
|
+
end
|
38
42
|
|
39
|
-
|
43
|
+
it { should be_instance_of LineCheck }
|
44
|
+
its(:errors_found) { should eq false }
|
40
45
|
|
41
|
-
|
42
|
-
|
43
|
-
LineCheck.
|
44
|
-
|
46
|
+
it 'should persist the LineCheck' do
|
47
|
+
line_check = LineCheck.perform!
|
48
|
+
expect(LineCheck.last).to eq line_check
|
49
|
+
end
|
45
50
|
end
|
46
|
-
end
|
47
|
-
|
48
|
-
it { should be_instance_of LineCheck }
|
49
|
-
its(:errors_found) { should eq false }
|
50
|
-
|
51
|
-
it 'should persist the LineCheck' do
|
52
|
-
line_check = LineCheck.perform!
|
53
|
-
expect(LineCheck.last).to eq line_check
|
54
|
-
end
|
55
|
-
end
|
56
51
|
|
57
|
-
|
58
|
-
|
52
|
+
context 'And there is a consistency error in lines' do
|
53
|
+
before { DoubleEntry::Line.order(:id).limit(1).update_all('balance = balance + 1') }
|
59
54
|
|
60
|
-
|
61
|
-
|
55
|
+
its(:errors_found) { should be true }
|
56
|
+
its(:log) { should match(/Error on line/) }
|
62
57
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
58
|
+
it 'should correct the running balance' do
|
59
|
+
expect { LineCheck.perform! }.
|
60
|
+
to change { DoubleEntry::Line.order(:id).first.balance }.
|
61
|
+
by Money.new(-1)
|
62
|
+
end
|
63
|
+
end
|
69
64
|
|
70
|
-
|
71
|
-
|
65
|
+
context 'And there is a consistency error in account balance' do
|
66
|
+
before { DoubleEntry::AccountBalance.order(:id).limit(1).update_all('balance = balance + 1') }
|
72
67
|
|
73
|
-
|
68
|
+
its(:errors_found) { should be true }
|
74
69
|
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
70
|
+
it 'should correct the account balance' do
|
71
|
+
expect { LineCheck.perform! }.
|
72
|
+
to change { DoubleEntry::AccountBalance.order(:id).first.balance }.
|
73
|
+
by Money.new(-1)
|
74
|
+
end
|
75
|
+
end
|
79
76
|
end
|
80
|
-
end
|
81
|
-
end
|
82
77
|
|
78
|
+
context 'Given a user with a non default currency balance' do
|
79
|
+
before { User.make!(:bitcoin_balance => Money.new(100_00, 'BTC')) }
|
80
|
+
its(:errors_found) { should eq false }
|
81
|
+
context 'And there is a consistency error in lines' do
|
82
|
+
before { DoubleEntry::Line.order(:id).limit(1).update_all('balance = balance + 1') }
|
83
|
+
|
84
|
+
its(:errors_found) { should eq true }
|
85
|
+
it 'should correct the running balance' do
|
86
|
+
expect { LineCheck.perform! }.
|
87
|
+
to change { DoubleEntry::Line.order(:id).first.balance }.
|
88
|
+
by Money.new(-1, 'BTC')
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
83
92
|
|
84
|
-
|
85
|
-
|
86
|
-
its(:errors_found) { should eq false }
|
87
|
-
context 'And there is a consistency error in lines' do
|
88
|
-
before { DoubleEntry::Line.order(:id).limit(1).update_all('balance = balance + 1') }
|
89
|
-
|
90
|
-
its(:errors_found) { should eq true }
|
91
|
-
it 'should correct the running balance' do
|
92
|
-
expect {
|
93
|
-
LineCheck.perform!
|
94
|
-
}.to change { DoubleEntry::Line.order(:id).first.balance }.by Money.new(-1, 'BTC')
|
93
|
+
it 'has a table name prefixed with double_entry_' do
|
94
|
+
expect(LineCheck.table_name).to eq 'double_entry_line_checks'
|
95
95
|
end
|
96
96
|
end
|
97
97
|
end
|
98
|
-
|
99
|
-
it "has a table name prefixed with double_entry_" do
|
100
|
-
expect(LineCheck.table_name).to eq "double_entry_line_checks"
|
101
|
-
end
|
102
|
-
|
103
98
|
end
|
104
|
-
end
|
105
99
|
end
|