acts_as_account 2.0.3 → 3.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/CHANGELOG.md +5 -0
- data/Gemfile +7 -6
- data/Gemfile.lock +77 -77
- data/README.rdoc +5 -1
- data/Rakefile +9 -24
- data/VERSION +1 -1
- data/acts_as_account.gemspec +16 -19
- data/features/account/account_creation.feature +8 -2
- data/features/step_definitions/account_steps.rb +26 -21
- data/features/support/env.rb +0 -6
- data/features/support/user.rb +2 -1
- data/lib/acts_as_account/account.rb +1 -1
- data/lib/acts_as_account/active_record_extensions.rb +5 -4
- data/lib/acts_as_account/posting.rb +4 -12
- metadata +48 -33
- data/.travis.yml +0 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b7bc13b86109af52ad3c4ea1e49d3388e6f6bd27
|
4
|
+
data.tar.gz: 3981321a1ae869e72270881953704e7bc4a8b4e6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 91489dd37949d4288748296de2d67d972c78d38a2bcdb19affb789d7f10ddc9d2b151f8b45a21424644aec7cc62da45a04c56ce9d3f4270f864298dbe08099ab
|
7
|
+
data.tar.gz: 34a8d296b69f07de19701c66f3bf1ba68e6c905e0e52cc26d41fb857ce14d0f1b41128d80c266965cc82a80f0b235819839910098811903aae12fac2082ce10d
|
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
acts_as_account
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.0.0
|
data/CHANGELOG.md
ADDED
data/Gemfile
CHANGED
@@ -1,13 +1,14 @@
|
|
1
1
|
source "http://rubygems.org"
|
2
2
|
|
3
3
|
group :development do
|
4
|
-
gem '
|
5
|
-
gem '
|
6
|
-
gem '
|
4
|
+
gem 'rspec'
|
5
|
+
gem 'jeweler'
|
6
|
+
gem 'cucumber'
|
7
|
+
gem 'mysql'
|
7
8
|
end
|
8
9
|
|
9
10
|
group :default do
|
10
|
-
gem 'activerecord', '~>
|
11
|
-
gem 'actionpack' , '~>
|
12
|
-
gem 'database_cleaner'
|
11
|
+
gem 'activerecord', '~> 4.1.0'
|
12
|
+
gem 'actionpack' , '~> 4.1.0'
|
13
|
+
gem 'database_cleaner'
|
13
14
|
end
|
data/Gemfile.lock
CHANGED
@@ -1,108 +1,108 @@
|
|
1
1
|
GEM
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
|
-
actionpack (
|
5
|
-
|
6
|
-
activesupport (=
|
7
|
-
|
4
|
+
actionpack (4.1.0)
|
5
|
+
actionview (= 4.1.0)
|
6
|
+
activesupport (= 4.1.0)
|
7
|
+
rack (~> 1.5.2)
|
8
|
+
rack-test (~> 0.6.2)
|
9
|
+
actionview (4.1.0)
|
10
|
+
activesupport (= 4.1.0)
|
11
|
+
builder (~> 3.1)
|
8
12
|
erubis (~> 2.7.0)
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
tzinfo (~>
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
arel (3.0.3)
|
27
|
-
builder (3.0.4)
|
28
|
-
cucumber (1.3.17)
|
13
|
+
activemodel (4.1.0)
|
14
|
+
activesupport (= 4.1.0)
|
15
|
+
builder (~> 3.1)
|
16
|
+
activerecord (4.1.0)
|
17
|
+
activemodel (= 4.1.0)
|
18
|
+
activesupport (= 4.1.0)
|
19
|
+
arel (~> 5.0.0)
|
20
|
+
activesupport (4.1.0)
|
21
|
+
i18n (~> 0.6, >= 0.6.9)
|
22
|
+
json (~> 1.7, >= 1.7.7)
|
23
|
+
minitest (~> 5.1)
|
24
|
+
thread_safe (~> 0.1)
|
25
|
+
tzinfo (~> 1.1)
|
26
|
+
addressable (2.3.5)
|
27
|
+
arel (5.0.1.20140414130214)
|
28
|
+
builder (3.1.4)
|
29
|
+
cucumber (1.3.10)
|
29
30
|
builder (>= 2.1.2)
|
30
31
|
diff-lcs (>= 1.1.3)
|
31
32
|
gherkin (~> 2.12)
|
32
33
|
multi_json (>= 1.7.5, < 2.0)
|
33
|
-
multi_test (>= 0.
|
34
|
-
database_cleaner (1.
|
35
|
-
descendants_tracker (0.0.4)
|
36
|
-
thread_safe (~> 0.3, >= 0.3.1)
|
34
|
+
multi_test (>= 0.0.2)
|
35
|
+
database_cleaner (1.2.0)
|
37
36
|
diff-lcs (1.2.5)
|
38
37
|
erubis (2.7.0)
|
39
|
-
faraday (0.
|
40
|
-
multipart-post (
|
38
|
+
faraday (0.8.8)
|
39
|
+
multipart-post (~> 1.2.0)
|
41
40
|
gherkin (2.12.2)
|
42
41
|
multi_json (~> 1.3)
|
43
|
-
git (1.2.
|
44
|
-
github_api (0.
|
45
|
-
addressable
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
nokogiri (~> 1.6.3)
|
42
|
+
git (1.2.6)
|
43
|
+
github_api (0.10.1)
|
44
|
+
addressable
|
45
|
+
faraday (~> 0.8.1)
|
46
|
+
hashie (>= 1.2)
|
47
|
+
multi_json (~> 1.4)
|
48
|
+
nokogiri (~> 1.5.2)
|
51
49
|
oauth2
|
52
|
-
hashie (
|
53
|
-
highline (1.6.
|
54
|
-
|
55
|
-
i18n (0.6.
|
56
|
-
jeweler (
|
50
|
+
hashie (2.0.5)
|
51
|
+
highline (1.6.20)
|
52
|
+
httpauth (0.2.0)
|
53
|
+
i18n (0.6.9)
|
54
|
+
jeweler (1.8.8)
|
57
55
|
builder
|
58
|
-
bundler (
|
56
|
+
bundler (~> 1.0)
|
59
57
|
git (>= 1.2.5)
|
60
|
-
github_api
|
58
|
+
github_api (= 0.10.1)
|
61
59
|
highline (>= 1.6.15)
|
62
|
-
nokogiri (
|
60
|
+
nokogiri (= 1.5.10)
|
63
61
|
rake
|
64
62
|
rdoc
|
65
|
-
journey (1.0.4)
|
66
63
|
json (1.8.1)
|
67
|
-
jwt (1.
|
68
|
-
|
69
|
-
|
70
|
-
|
64
|
+
jwt (0.1.8)
|
65
|
+
multi_json (>= 1.5)
|
66
|
+
minitest (5.3.3)
|
67
|
+
multi_json (1.8.2)
|
68
|
+
multi_test (0.0.2)
|
71
69
|
multi_xml (0.5.5)
|
72
|
-
multipart-post (2.0
|
70
|
+
multipart-post (1.2.0)
|
73
71
|
mysql (2.9.1)
|
74
|
-
nokogiri (1.
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
jwt (~> 1.
|
79
|
-
multi_json (~> 1.
|
72
|
+
nokogiri (1.5.10)
|
73
|
+
oauth2 (0.9.2)
|
74
|
+
faraday (~> 0.8)
|
75
|
+
httpauth (~> 0.2)
|
76
|
+
jwt (~> 0.1.4)
|
77
|
+
multi_json (~> 1.0)
|
80
78
|
multi_xml (~> 0.5)
|
81
79
|
rack (~> 1.2)
|
82
|
-
rack (1.
|
83
|
-
rack-cache (1.2)
|
84
|
-
rack (>= 0.4)
|
80
|
+
rack (1.5.2)
|
85
81
|
rack-test (0.6.2)
|
86
82
|
rack (>= 1.0)
|
87
|
-
rake (10.
|
88
|
-
rdoc (4.1
|
83
|
+
rake (10.1.0)
|
84
|
+
rdoc (4.0.1)
|
89
85
|
json (~> 1.4)
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
86
|
+
rspec (2.14.1)
|
87
|
+
rspec-core (~> 2.14.0)
|
88
|
+
rspec-expectations (~> 2.14.0)
|
89
|
+
rspec-mocks (~> 2.14.0)
|
90
|
+
rspec-core (2.14.7)
|
91
|
+
rspec-expectations (2.14.4)
|
92
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
93
|
+
rspec-mocks (2.14.4)
|
94
|
+
thread_safe (0.3.3)
|
95
|
+
tzinfo (1.1.0)
|
96
|
+
thread_safe (~> 0.1)
|
98
97
|
|
99
98
|
PLATFORMS
|
100
99
|
ruby
|
101
100
|
|
102
101
|
DEPENDENCIES
|
103
|
-
actionpack (~>
|
104
|
-
activerecord (~>
|
105
|
-
cucumber
|
106
|
-
database_cleaner
|
107
|
-
jeweler
|
108
|
-
mysql
|
102
|
+
actionpack (~> 4.1.0)
|
103
|
+
activerecord (~> 4.1.0)
|
104
|
+
cucumber
|
105
|
+
database_cleaner
|
106
|
+
jeweler
|
107
|
+
mysql
|
108
|
+
rspec
|
data/README.rdoc
CHANGED
@@ -13,6 +13,10 @@ tables is needed.
|
|
13
13
|
We also hook into the ActionController request cycle to warn the developer
|
14
14
|
if a request has left the uncommitted changes in the system.
|
15
15
|
|
16
|
+
== Support
|
17
|
+
|
18
|
+
Rails 4 is supported since version 3.1.0
|
19
|
+
|
16
20
|
== How to test
|
17
21
|
|
18
22
|
Run the cucumber features from the acs_as_account gem, just execute
|
@@ -33,4 +37,4 @@ This gem was written for the payment backend of betterplace.org by Thies C. Arnt
|
|
33
37
|
|
34
38
|
== Copyright
|
35
39
|
|
36
|
-
Copyright (c) 2010 gut.org gAG
|
40
|
+
Copyright (c) 2010 gut.org gAG
|
data/Rakefile
CHANGED
@@ -13,43 +13,28 @@ require 'rake'
|
|
13
13
|
begin
|
14
14
|
require 'jeweler'
|
15
15
|
Jeweler::Tasks.new do |gem|
|
16
|
-
gem.name
|
17
|
-
gem.summary
|
16
|
+
gem.name = "acts_as_account"
|
17
|
+
gem.summary = %Q{acts_as_account implements double entry accounting for Rails models}
|
18
18
|
gem.description = %Q{acts_as_account implements double entry accounting for Rails models. Your models get accounts and you can do consistent transactions between them. Since the documentation is sparse, see the transfer.feature for usage examples.}
|
19
|
-
gem.email
|
20
|
-
gem.homepage
|
21
|
-
gem.authors
|
22
|
-
gem.license = 'Apache-2.0'
|
23
|
-
#gem.add_dependency 'activerecord'
|
24
|
-
#gem.add_dependency 'actionpack'
|
25
|
-
#gem.add_dependency 'database_cleaner'
|
19
|
+
gem.email = "developers@betterplace.org"
|
20
|
+
gem.homepage = "http://github.com/betterplace/acts_as_account"
|
21
|
+
gem.authors = ["Thies C. Arntzen, Norman Timmler, Matthias Frick, Phillip Oertel"]
|
26
22
|
end
|
27
23
|
Jeweler::GemcutterTasks.new
|
28
24
|
rescue LoadError
|
29
25
|
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
30
26
|
end
|
31
27
|
|
32
|
-
def connect_database
|
33
|
-
require 'rubygems'
|
34
|
-
require 'active_record'
|
35
|
-
access_data = YAML.load_file(File.dirname(__FILE__) + '/db/database.yml')['acts_as_account']
|
36
|
-
ActiveRecord::Base.establish_connection(Hash[access_data.select { |k, v| k != 'database'}]).connection
|
37
|
-
end
|
38
|
-
|
39
28
|
namespace :features do
|
40
29
|
desc "create test database out of db/schema.rb"
|
41
30
|
task :create_database do
|
42
|
-
|
31
|
+
require 'rubygems'
|
32
|
+
require 'active_record'
|
33
|
+
access_data = YAML.load_file(File.dirname(__FILE__) + '/db/database.yml')['acts_as_account']
|
34
|
+
conn = ActiveRecord::Base.establish_connection(Hash[access_data.select { |k, v| k != 'database'}]).connection
|
43
35
|
conn.execute('DROP DATABASE IF EXISTS acts_as_account')
|
44
36
|
conn.execute('CREATE DATABASE acts_as_account')
|
45
37
|
conn.execute('USE acts_as_account')
|
46
38
|
load(File.dirname(__FILE__) + '/db/schema.rb')
|
47
39
|
end
|
48
40
|
end
|
49
|
-
|
50
|
-
desc "Run features"
|
51
|
-
task :features => :'features:create_database' do
|
52
|
-
ruby '-S', 'cucumber'
|
53
|
-
end
|
54
|
-
|
55
|
-
task :default => :features
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
3.1.0
|
data/acts_as_account.gemspec
CHANGED
@@ -2,23 +2,27 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
+
# stub: acts_as_account 3.1.0 ruby lib
|
5
6
|
|
6
7
|
Gem::Specification.new do |s|
|
7
8
|
s.name = "acts_as_account"
|
8
|
-
s.version = "
|
9
|
+
s.version = "3.1.0"
|
9
10
|
|
10
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
|
+
s.require_paths = ["lib"]
|
11
13
|
s.authors = ["Thies C. Arntzen, Norman Timmler, Matthias Frick, Phillip Oertel"]
|
12
|
-
s.date = "
|
14
|
+
s.date = "2014-08-19"
|
13
15
|
s.description = "acts_as_account implements double entry accounting for Rails models. Your models get accounts and you can do consistent transactions between them. Since the documentation is sparse, see the transfer.feature for usage examples."
|
14
|
-
s.email = "
|
16
|
+
s.email = "developers@betterplace.org"
|
15
17
|
s.extra_rdoc_files = [
|
16
18
|
"LICENSE",
|
17
19
|
"README.rdoc"
|
18
20
|
]
|
19
21
|
s.files = [
|
20
|
-
".
|
22
|
+
".ruby-gemset",
|
23
|
+
".ruby-version",
|
21
24
|
".specification",
|
25
|
+
"CHANGELOG.md",
|
22
26
|
"Gemfile",
|
23
27
|
"Gemfile.lock",
|
24
28
|
"LICENSE",
|
@@ -49,44 +53,37 @@ Gem::Specification.new do |s|
|
|
49
53
|
"lib/acts_as_account/transfer.rb"
|
50
54
|
]
|
51
55
|
s.homepage = "http://github.com/betterplace/acts_as_account"
|
52
|
-
s.
|
53
|
-
s.rubygems_version = "1.8.24"
|
56
|
+
s.rubygems_version = "2.2.2"
|
54
57
|
s.summary = "acts_as_account implements double entry accounting for Rails models"
|
55
58
|
|
56
59
|
if s.respond_to? :specification_version then
|
57
|
-
s.specification_version =
|
60
|
+
s.specification_version = 4
|
58
61
|
|
59
62
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
60
|
-
s.add_runtime_dependency(%q<activerecord>, ["~>
|
61
|
-
s.add_runtime_dependency(%q<actionpack>, ["~>
|
63
|
+
s.add_runtime_dependency(%q<activerecord>, ["~> 4.1.0"])
|
64
|
+
s.add_runtime_dependency(%q<actionpack>, ["~> 4.1.0"])
|
62
65
|
s.add_runtime_dependency(%q<database_cleaner>, [">= 0"])
|
63
66
|
s.add_development_dependency(%q<rspec>, [">= 0"])
|
64
67
|
s.add_development_dependency(%q<jeweler>, [">= 0"])
|
65
68
|
s.add_development_dependency(%q<cucumber>, [">= 0"])
|
66
69
|
s.add_development_dependency(%q<mysql>, [">= 0"])
|
67
|
-
s.add_runtime_dependency(%q<actionpack>, [">= 0"])
|
68
|
-
s.add_runtime_dependency(%q<database_cleaner>, [">= 0"])
|
69
70
|
else
|
70
|
-
s.add_dependency(%q<activerecord>, ["~>
|
71
|
-
s.add_dependency(%q<actionpack>, ["~>
|
71
|
+
s.add_dependency(%q<activerecord>, ["~> 4.1.0"])
|
72
|
+
s.add_dependency(%q<actionpack>, ["~> 4.1.0"])
|
72
73
|
s.add_dependency(%q<database_cleaner>, [">= 0"])
|
73
74
|
s.add_dependency(%q<rspec>, [">= 0"])
|
74
75
|
s.add_dependency(%q<jeweler>, [">= 0"])
|
75
76
|
s.add_dependency(%q<cucumber>, [">= 0"])
|
76
77
|
s.add_dependency(%q<mysql>, [">= 0"])
|
77
|
-
s.add_dependency(%q<actionpack>, [">= 0"])
|
78
|
-
s.add_dependency(%q<database_cleaner>, [">= 0"])
|
79
78
|
end
|
80
79
|
else
|
81
|
-
s.add_dependency(%q<activerecord>, ["~>
|
82
|
-
s.add_dependency(%q<actionpack>, ["~>
|
80
|
+
s.add_dependency(%q<activerecord>, ["~> 4.1.0"])
|
81
|
+
s.add_dependency(%q<actionpack>, ["~> 4.1.0"])
|
83
82
|
s.add_dependency(%q<database_cleaner>, [">= 0"])
|
84
83
|
s.add_dependency(%q<rspec>, [">= 0"])
|
85
84
|
s.add_dependency(%q<jeweler>, [">= 0"])
|
86
85
|
s.add_dependency(%q<cucumber>, [">= 0"])
|
87
86
|
s.add_dependency(%q<mysql>, [">= 0"])
|
88
|
-
s.add_dependency(%q<actionpack>, [">= 0"])
|
89
|
-
s.add_dependency(%q<database_cleaner>, [">= 0"])
|
90
87
|
end
|
91
88
|
end
|
92
89
|
|
@@ -10,12 +10,18 @@ Feature: Creating an Account
|
|
10
10
|
And I create an Account named default for User A
|
11
11
|
Then I get the original account
|
12
12
|
|
13
|
+
Scenario: Creating a Account with a different name
|
14
|
+
And I create an Account named default for User A
|
15
|
+
And I create an Account named not_default for User A
|
16
|
+
Then I can get the default Account of User A
|
17
|
+
Then I can get the not_default Account of User A
|
18
|
+
|
13
19
|
Scenario: Race condition while creating account
|
14
20
|
Given I have the same user in memory
|
15
21
|
And I disable the account existence check on those
|
16
22
|
When I call 'account' on both it should be possible
|
17
23
|
|
18
|
-
Scenario: Accounts on a
|
24
|
+
Scenario: Accounts on a subclass
|
19
25
|
Given I have a user A that inherits from an abstract class
|
20
26
|
And I autocreate an account for inheriting user A
|
21
|
-
Then the account of user A should be there
|
27
|
+
Then the account of user A should be there
|
@@ -16,12 +16,12 @@ end
|
|
16
16
|
|
17
17
|
Given /^I autocreate an account for inheriting user (\w+)$/ do |name|
|
18
18
|
@created_account = InheritingUser.find_by_name(name).account
|
19
|
-
|
19
|
+
@created_account.should_not be_nil
|
20
20
|
end
|
21
21
|
|
22
22
|
Then /^the account of user (\w+) should be there$/ do |name|
|
23
23
|
account = InheritingUser.find_by_name(name).account
|
24
|
-
|
24
|
+
@created_account.should eq account
|
25
25
|
end
|
26
26
|
|
27
27
|
Given /^I create a global ([_\w]+) account$/ do |name|
|
@@ -30,7 +30,7 @@ end
|
|
30
30
|
|
31
31
|
Then /^an account for user (\w+) exists$/ do |name|
|
32
32
|
@account = User.find_by_name(name).account
|
33
|
-
|
33
|
+
@account.should_not be_nil
|
34
34
|
end
|
35
35
|
|
36
36
|
Then /^the account has (\d+) journals?$/ do |num_journals|
|
@@ -42,23 +42,23 @@ Then /^the account has (\d+) journals?$/ do |num_journals|
|
|
42
42
|
@journals = @account.journals
|
43
43
|
end
|
44
44
|
|
45
|
-
|
45
|
+
num_journals.should eq @account.journals.count
|
46
46
|
end
|
47
47
|
|
48
48
|
Then /^the journal has (\d+) postings? with an amount of (\d+) €$/ do |num_postings, amount|
|
49
49
|
@postings = @journal.postings
|
50
|
-
|
50
|
+
num_postings.to_i.should eq @postings.size
|
51
51
|
@postings.each do |posting|
|
52
|
-
|
52
|
+
amount.to_i.should eq posting.amount
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
56
56
|
Then /^(\w+)'s account balance is (-?\d+) €$/ do |name, balance|
|
57
|
-
|
57
|
+
balance.to_i.should eq User.find_by_name(name).account.balance
|
58
58
|
end
|
59
59
|
|
60
60
|
Then /^the global (\w+) account balance is (-?\d+) €$/ do |name, balance|
|
61
|
-
|
61
|
+
balance.to_i.should eq Account.for(name).balance
|
62
62
|
end
|
63
63
|
|
64
64
|
When /^I transfer (-?\d+) € from (\w+)'s account to (\w+)'s account$/ do |amount, from, to|
|
@@ -75,12 +75,12 @@ end
|
|
75
75
|
|
76
76
|
Then /^the balance\-sheet should be:$/ do |table|
|
77
77
|
table.hashes.each do |row|
|
78
|
-
|
78
|
+
row['Balance'].to_i.should eq User.find_by_name(row['User']).account.balance
|
79
79
|
end
|
80
80
|
end
|
81
81
|
|
82
82
|
Then /^I fail with (.+)$/ do |exception|
|
83
|
-
|
83
|
+
exception.constantize.should eq @last_exception.class
|
84
84
|
end
|
85
85
|
|
86
86
|
When /^I create a Journal via (.+)$/ do |method|
|
@@ -94,12 +94,12 @@ When /^I create a Journal via (.+)$/ do |method|
|
|
94
94
|
end
|
95
95
|
|
96
96
|
Then /^I have a Journal$/ do
|
97
|
-
|
97
|
+
Journal.should eq @journal.class
|
98
98
|
end
|
99
99
|
|
100
100
|
Then /^User (\w+) has an Account named (\w+)$/ do |user_name, account_name|
|
101
101
|
@account = User.find_by_name(user_name).account
|
102
|
-
|
102
|
+
account_name.should eq @account.name
|
103
103
|
end
|
104
104
|
|
105
105
|
Given /^I create an Account named (\w+) for User (\w+)$/ do |account_name, user_name|
|
@@ -108,7 +108,12 @@ Given /^I create an Account named (\w+) for User (\w+)$/ do |account_name, user_
|
|
108
108
|
end
|
109
109
|
|
110
110
|
Then /^I get the original account$/ do
|
111
|
-
|
111
|
+
@account.should eq @created_account
|
112
|
+
end
|
113
|
+
|
114
|
+
Then(/^I can get the (\w+) Account of User (\w+)$/) do |account_name, user_name|
|
115
|
+
account = User.find_by_name(user_name).__send__(:"#{account_name}_account")
|
116
|
+
account.should be_kind_of ActsAsAccount::Account
|
112
117
|
end
|
113
118
|
|
114
119
|
Given /I transfer (\d+) € from (\w+)'s account to (\w+)'s account referencing a (\w+) with (\w+) (\w+)$/ do |amount, from, to, reference, name, value|
|
@@ -117,9 +122,9 @@ Given /I transfer (\d+) € from (\w+)'s account to (\w+)'s account referencing
|
|
117
122
|
end
|
118
123
|
|
119
124
|
Then /^all postings reference (\w+) with (\w+) (\w+)$/ do |reference_class, name, value|
|
120
|
-
reference = reference_class.constantize.
|
125
|
+
reference = reference_class.constantize.where("#{name} = #{value}").first
|
121
126
|
Posting.all.each do |posting|
|
122
|
-
|
127
|
+
reference.should eq posting.reference
|
123
128
|
end
|
124
129
|
end
|
125
130
|
|
@@ -131,20 +136,20 @@ end
|
|
131
136
|
Then /^all postings have (\S+) (\S+) as the booking time$/ do |booking_date, booking_time|
|
132
137
|
valuta = german_date_time_to_local(booking_date, booking_time)
|
133
138
|
Posting.all.each do |posting|
|
134
|
-
|
139
|
+
valuta.should eq posting.valuta
|
135
140
|
end
|
136
141
|
end
|
137
142
|
|
138
143
|
Then /^(\w+) with (\w+) (\w+) references all postings$/ do |reference_class, name, value|
|
139
|
-
reference = reference_class.constantize.
|
140
|
-
|
144
|
+
reference = reference_class.constantize.where("#{name} = #{value}").first
|
145
|
+
Posting.all.to_a.should eq reference.postings
|
141
146
|
end
|
142
147
|
|
143
148
|
Then /^the order of the postings is correct$/ do
|
144
149
|
# make sure we always book "Soll an Haben"
|
145
150
|
Posting.all.in_groups_of(2) do |from, to|
|
146
|
-
|
147
|
-
|
151
|
+
from.amount.should be < 0
|
152
|
+
to.amount.should be > 0
|
148
153
|
end
|
149
154
|
end
|
150
155
|
|
@@ -161,4 +166,4 @@ end
|
|
161
166
|
|
162
167
|
When /^I call 'account' on both it should be possible$/ do
|
163
168
|
[@user1, @user2].each { |user| user.account }
|
164
|
-
end
|
169
|
+
end
|
data/features/support/env.rb
CHANGED
@@ -1,12 +1,6 @@
|
|
1
|
-
require 'test/unit/assertions'
|
2
|
-
|
3
|
-
World(Test::Unit::Assertions)
|
4
|
-
|
5
1
|
require File.dirname(__FILE__) + '/../../lib/acts_as_account'
|
6
2
|
ActiveRecord::Base.establish_connection(YAML.load_file(File.dirname(__FILE__) + '/../../db/database.yml')['acts_as_account'])
|
7
3
|
|
8
|
-
#ActiveRecord::Base.logger = Logger.new(STDOUT)
|
9
|
-
|
10
4
|
require 'database_cleaner'
|
11
5
|
require 'database_cleaner/cucumber'
|
12
6
|
DatabaseCleaner.strategy = :transaction
|
data/features/support/user.rb
CHANGED
@@ -12,14 +12,15 @@ module ActsAsAccount
|
|
12
12
|
module ClassMethods
|
13
13
|
|
14
14
|
def has_account(name = :default)
|
15
|
-
has_one "#{name}_account",
|
15
|
+
has_one :"#{name}_account", -> { where name: name }, class_name: "ActsAsAccount::Account", as: :holder
|
16
|
+
|
16
17
|
unless instance_methods.include?('accounts')
|
17
|
-
has_many :accounts, :
|
18
|
+
has_many :accounts, class_name: "ActsAsAccount::Account", as: :holder
|
18
19
|
end
|
19
20
|
end
|
20
21
|
|
21
22
|
def is_reference
|
22
|
-
has_many :postings, :
|
23
|
+
has_many :postings, class_name: "ActsAsAccount::Posting", as: :reference
|
23
24
|
class_eval <<-EOS
|
24
25
|
def booked?
|
25
26
|
postings.any?
|
@@ -36,4 +37,4 @@ module ActsAsAccount
|
|
36
37
|
end
|
37
38
|
end
|
38
39
|
end
|
39
|
-
end
|
40
|
+
end
|
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'time'
|
2
|
-
|
3
1
|
module ActsAsAccount
|
4
2
|
class Posting < ActiveRecord::Base
|
5
3
|
self.table_name = :acts_as_account_postings
|
@@ -9,15 +7,9 @@ module ActsAsAccount
|
|
9
7
|
belongs_to :journal, :class_name => 'ActsAsAccount::Journal'
|
10
8
|
belongs_to :reference, :polymorphic => true
|
11
9
|
|
12
|
-
scope :soll,
|
13
|
-
scope :haben, where('amount < 0')
|
14
|
-
scope :start_date,
|
15
|
-
|
16
|
-
{ :conditions => [ 'valuta >= ?', date ] }
|
17
|
-
}
|
18
|
-
scope :end_date, lambda{ |date|
|
19
|
-
date = Time.parse(date.to_s).utc.to_s(:db)
|
20
|
-
{ :conditions => [ 'valuta <= ?', date ] }
|
21
|
-
}
|
10
|
+
scope :soll, -> { where('amount >= 0') }
|
11
|
+
scope :haben, -> { where('amount < 0') }
|
12
|
+
scope :start_date, -> date { where ['DATE(valuta) >= ?', date] }
|
13
|
+
scope :end_date, -> date { where ['DATE(valuta) <= ?', date] }
|
22
14
|
end
|
23
15
|
end
|
metadata
CHANGED
@@ -1,111 +1,127 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: acts_as_account
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thies C. Arntzen, Norman Timmler, Matthias Frick, Phillip Oertel
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-08-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ~>
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 4.1.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ~>
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 4.1.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: actionpack
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ~>
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 4.1.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ~>
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: 4.1.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: database_cleaner
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - '>='
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '0'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - '>='
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: jeweler
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
58
72
|
requirements:
|
59
|
-
- -
|
73
|
+
- - '>='
|
60
74
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
75
|
+
version: '0'
|
62
76
|
type: :development
|
63
77
|
prerelease: false
|
64
78
|
version_requirements: !ruby/object:Gem::Requirement
|
65
79
|
requirements:
|
66
|
-
- -
|
80
|
+
- - '>='
|
67
81
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
82
|
+
version: '0'
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: cucumber
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
72
86
|
requirements:
|
73
|
-
- -
|
87
|
+
- - '>='
|
74
88
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
89
|
+
version: '0'
|
76
90
|
type: :development
|
77
91
|
prerelease: false
|
78
92
|
version_requirements: !ruby/object:Gem::Requirement
|
79
93
|
requirements:
|
80
|
-
- -
|
94
|
+
- - '>='
|
81
95
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
96
|
+
version: '0'
|
83
97
|
- !ruby/object:Gem::Dependency
|
84
98
|
name: mysql
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|
86
100
|
requirements:
|
87
|
-
- -
|
101
|
+
- - '>='
|
88
102
|
- !ruby/object:Gem::Version
|
89
|
-
version: '
|
103
|
+
version: '0'
|
90
104
|
type: :development
|
91
105
|
prerelease: false
|
92
106
|
version_requirements: !ruby/object:Gem::Requirement
|
93
107
|
requirements:
|
94
|
-
- -
|
108
|
+
- - '>='
|
95
109
|
- !ruby/object:Gem::Version
|
96
|
-
version: '
|
110
|
+
version: '0'
|
97
111
|
description: acts_as_account implements double entry accounting for Rails models.
|
98
112
|
Your models get accounts and you can do consistent transactions between them. Since
|
99
113
|
the documentation is sparse, see the transfer.feature for usage examples.
|
100
|
-
email:
|
114
|
+
email: developers@betterplace.org
|
101
115
|
executables: []
|
102
116
|
extensions: []
|
103
117
|
extra_rdoc_files:
|
104
118
|
- LICENSE
|
105
119
|
- README.rdoc
|
106
120
|
files:
|
107
|
-
-
|
108
|
-
-
|
121
|
+
- .ruby-gemset
|
122
|
+
- .ruby-version
|
123
|
+
- .specification
|
124
|
+
- CHANGELOG.md
|
109
125
|
- Gemfile
|
110
126
|
- Gemfile.lock
|
111
127
|
- LICENSE
|
@@ -135,8 +151,7 @@ files:
|
|
135
151
|
- lib/acts_as_account/posting.rb
|
136
152
|
- lib/acts_as_account/transfer.rb
|
137
153
|
homepage: http://github.com/betterplace/acts_as_account
|
138
|
-
licenses:
|
139
|
-
- Apache-2.0
|
154
|
+
licenses: []
|
140
155
|
metadata: {}
|
141
156
|
post_install_message:
|
142
157
|
rdoc_options: []
|
@@ -144,12 +159,12 @@ require_paths:
|
|
144
159
|
- lib
|
145
160
|
required_ruby_version: !ruby/object:Gem::Requirement
|
146
161
|
requirements:
|
147
|
-
- -
|
162
|
+
- - '>='
|
148
163
|
- !ruby/object:Gem::Version
|
149
164
|
version: '0'
|
150
165
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
151
166
|
requirements:
|
152
|
-
- -
|
167
|
+
- - '>='
|
153
168
|
- !ruby/object:Gem::Version
|
154
169
|
version: '0'
|
155
170
|
requirements: []
|