double_entry 0.5.0 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -81,11 +81,7 @@ module DoubleEntry
81
81
  end
82
82
 
83
83
  def <=>(account)
84
- if scoped?
85
- [scope_identity, identifier.to_s] <=> [account.scope_identity, account.identifier.to_s]
86
- else
87
- identifier.to_s <=> account.identifier.to_s
88
- end
84
+ [scope_identity.to_s, identifier.to_s] <=> [account.scope_identity.to_s, account.identifier.to_s]
89
85
  end
90
86
 
91
87
  def hash
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module DoubleEntry
4
- VERSION = "0.5.0"
4
+ VERSION = "0.6.0"
5
5
  end
@@ -24,6 +24,7 @@ describe DoubleEntry::Locking do
24
24
  accounts.define(:identifier => :account_b, :scope_identifier => scope)
25
25
  accounts.define(:identifier => :account_c, :scope_identifier => scope)
26
26
  accounts.define(:identifier => :account_d, :scope_identifier => scope)
27
+ accounts.define(:identifier => :account_e)
27
28
  end
28
29
 
29
30
  config.define_transfers do |transfers|
@@ -36,6 +37,7 @@ describe DoubleEntry::Locking do
36
37
  @account_b = DoubleEntry.account(:account_b, :scope => "2")
37
38
  @account_c = DoubleEntry.account(:account_c, :scope => "3")
38
39
  @account_d = DoubleEntry.account(:account_d, :scope => "4")
40
+ @account_e = DoubleEntry.account(:account_e)
39
41
  end
40
42
 
41
43
  it "creates missing account balance records" do
@@ -130,6 +132,14 @@ describe DoubleEntry::Locking do
130
132
  expect(DoubleEntry.balance(@account_b)).to eq Money.new(0)
131
133
  end
132
134
 
135
+ it "allows locking a scoped account and a non scoped account" do
136
+ expect do
137
+ DoubleEntry::Locking.lock_accounts(@account_d, @account_e) do
138
+ # do nothing
139
+ end
140
+ end.to_not raise_error
141
+ end
142
+
133
143
  # sqlite cannot handle these cases so they don't run when DB=sqlite
134
144
  describe "concurrent locking", :unless => ENV['DB'] == 'sqlite' do
135
145
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: double_entry
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -16,7 +16,7 @@ authors:
16
16
  autorequire:
17
17
  bindir: bin
18
18
  cert_chain: []
19
- date: 2014-08-01 00:00:00.000000000 Z
19
+ date: 2014-08-23 00:00:00.000000000 Z
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
22
  name: money