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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1e4b9d9a8021a37ab77cd81cb132783f6a97a6a2
4
- data.tar.gz: 6a814f056664c1ac989a4475409968b3dbd0b11e
3
+ metadata.gz: b7bc13b86109af52ad3c4ea1e49d3388e6f6bd27
4
+ data.tar.gz: 3981321a1ae869e72270881953704e7bc4a8b4e6
5
5
  SHA512:
6
- metadata.gz: 62dc3234a50a85aa9e26d9ddc59580cfb01386262b0d981c956f05b07c09655e77e40562ae7887fc4734d78f6674525a1b3a33e86f11d7e75a7c6ff6278645f4
7
- data.tar.gz: 42fa52c418890778f3ec3d9a8ffa69b8be79574bba1f9b545dd20d380c07770cc988f95400029b964d65baf0db0c97dd06edd794d6cce9c0e487f82c3057060c
6
+ metadata.gz: 91489dd37949d4288748296de2d67d972c78d38a2bcdb19affb789d7f10ddc9d2b151f8b45a21424644aec7cc62da45a04c56ce9d3f4270f864298dbe08099ab
7
+ data.tar.gz: 34a8d296b69f07de19701c66f3bf1ba68e6c905e0e52cc26d41fb857ce14d0f1b41128d80c266965cc82a80f0b235819839910098811903aae12fac2082ce10d
@@ -0,0 +1 @@
1
+ acts_as_account
@@ -0,0 +1 @@
1
+ 2.0.0
@@ -0,0 +1,5 @@
1
+ # Changelog
2
+
3
+ [jop] 2014-08-18
4
+ * Rails 4 compatibility
5
+ * Added changelog
data/Gemfile CHANGED
@@ -1,13 +1,14 @@
1
1
  source "http://rubygems.org"
2
2
 
3
3
  group :development do
4
- gem 'jeweler', '~> 2.0'
5
- gem 'cucumber', '~> 1.3'
6
- gem 'mysql', '~> 2.9'
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', '~> 3.2'
11
- gem 'actionpack' , '~> 3.2'
12
- gem 'database_cleaner', '~> 1.3'
11
+ gem 'activerecord', '~> 4.1.0'
12
+ gem 'actionpack' , '~> 4.1.0'
13
+ gem 'database_cleaner'
13
14
  end
@@ -1,108 +1,108 @@
1
1
  GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
- actionpack (3.2.19)
5
- activemodel (= 3.2.19)
6
- activesupport (= 3.2.19)
7
- builder (~> 3.0.0)
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
- journey (~> 1.0.4)
10
- rack (~> 1.4.5)
11
- rack-cache (~> 1.2)
12
- rack-test (~> 0.6.1)
13
- sprockets (~> 2.2.1)
14
- activemodel (3.2.19)
15
- activesupport (= 3.2.19)
16
- builder (~> 3.0.0)
17
- activerecord (3.2.19)
18
- activemodel (= 3.2.19)
19
- activesupport (= 3.2.19)
20
- arel (~> 3.0.2)
21
- tzinfo (~> 0.3.29)
22
- activesupport (3.2.19)
23
- i18n (~> 0.6, >= 0.6.4)
24
- multi_json (~> 1.0)
25
- addressable (2.3.6)
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.1.1)
34
- database_cleaner (1.3.0)
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.9.0)
40
- multipart-post (>= 1.2, < 3)
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.8)
44
- github_api (0.12.1)
45
- addressable (~> 2.3)
46
- descendants_tracker (~> 0.0.4)
47
- faraday (~> 0.8, < 0.10)
48
- hashie (>= 3.2)
49
- multi_json (>= 1.7.5, < 2.0)
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 (3.3.1)
53
- highline (1.6.21)
54
- hike (1.2.3)
55
- i18n (0.6.11)
56
- jeweler (2.0.1)
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 (>= 1.0)
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 (>= 1.5.10)
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.0.0)
68
- mini_portile (0.6.0)
69
- multi_json (1.10.1)
70
- multi_test (0.1.1)
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.0)
70
+ multipart-post (1.2.0)
73
71
  mysql (2.9.1)
74
- nokogiri (1.6.3.1)
75
- mini_portile (= 0.6.0)
76
- oauth2 (1.0.0)
77
- faraday (>= 0.8, < 0.10)
78
- jwt (~> 1.0)
79
- multi_json (~> 1.3)
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.4.5)
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.3.2)
88
- rdoc (4.1.2)
83
+ rake (10.1.0)
84
+ rdoc (4.0.1)
89
85
  json (~> 1.4)
90
- sprockets (2.2.2)
91
- hike (~> 1.2)
92
- multi_json (~> 1.0)
93
- rack (~> 1.0)
94
- tilt (~> 1.1, != 1.3.0)
95
- thread_safe (0.3.4)
96
- tilt (1.4.1)
97
- tzinfo (0.3.41)
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 (~> 3.2)
104
- activerecord (~> 3.2)
105
- cucumber (~> 1.3)
106
- database_cleaner (~> 1.3)
107
- jeweler (~> 2.0)
108
- mysql (~> 2.9)
102
+ actionpack (~> 4.1.0)
103
+ activerecord (~> 4.1.0)
104
+ cucumber
105
+ database_cleaner
106
+ jeweler
107
+ mysql
108
+ rspec
@@ -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 = "acts_as_account"
17
- gem.summary = %Q{acts_as_account implements double entry accounting for Rails models}
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 = "thieso@gmail.com"
20
- gem.homepage = "http://github.com/betterplace/acts_as_account"
21
- gem.authors = ["Thies C. Arntzen, Norman Timmler, Matthias Frick, Phillip Oertel"]
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
- conn = connect_database
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
- 2.0.3
1
+ 3.1.0
@@ -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 = "2.0.1"
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 = "2012-10-04"
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 = "thieso@gmail.com"
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
- ".rvmrc",
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.require_paths = ["lib"]
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 = 3
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>, ["~> 3.2.8"])
61
- s.add_runtime_dependency(%q<actionpack>, ["~> 3.2.8"])
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>, ["~> 3.2.8"])
71
- s.add_dependency(%q<actionpack>, ["~> 3.2.8"])
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>, ["~> 3.2.8"])
82
- s.add_dependency(%q<actionpack>, ["~> 3.2.8"])
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 sublcass
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
- assert_not_nil @created_account
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
- assert_equal @created_account, account
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
- assert_not_nil @account
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
- assert_equal num_journals, @account.journals.count
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
- assert_equal num_postings.to_i, @postings.size
50
+ num_postings.to_i.should eq @postings.size
51
51
  @postings.each do |posting|
52
- assert_equal amount.to_i, posting.amount
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
- assert_equal balance.to_i, User.find_by_name(name).account.balance
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
- assert_equal balance.to_i, Account.for(name).balance
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
- assert_equal row['Balance'].to_i, User.find_by_name(row['User']).account.balance
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
- assert_equal exception.constantize, @last_exception.class
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
- assert_equal Journal, @journal.class
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
- assert_equal account_name, @account.name
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
- assert_equal @account, @created_account
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.find(:first, :conditions => "#{name} = #{value}")
125
+ reference = reference_class.constantize.where("#{name} = #{value}").first
121
126
  Posting.all.each do |posting|
122
- assert_equal reference, posting.reference
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
- assert_equal valuta, posting.valuta
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.find(:first, :conditions => "#{name} = #{value}")
140
- assert_equal Posting.all, reference.postings
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
- assert from.amount < 0
147
- assert to.amount > 0
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
@@ -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
@@ -1,3 +1,4 @@
1
1
  class User < ActiveRecord::Base
2
2
  has_account
3
- end
3
+ has_account(:not_default)
4
+ end
@@ -42,7 +42,7 @@ module ActsAsAccount
42
42
  end
43
43
 
44
44
  def for(name)
45
- GlobalAccount.find_or_create_by_name(name.to_s).account
45
+ GlobalAccount.find_or_create_by(name: name).account
46
46
  end
47
47
 
48
48
  def create!(attributes = nil)
@@ -12,14 +12,15 @@ module ActsAsAccount
12
12
  module ClassMethods
13
13
 
14
14
  def has_account(name = :default)
15
- has_one "#{name}_account", :conditions => "name = '#{name}'", :class_name => "ActsAsAccount::Account", :as => :holder
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, :class_name => "ActsAsAccount::Account", :as => :holder
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, :class_name => "ActsAsAccount::Posting", :as => :reference
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, where('amount >= 0')
13
- scope :haben, where('amount < 0')
14
- scope :start_date, lambda { |date|
15
- date = Time.parse(date.to_s).utc.to_s(:db)
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: 2.0.3
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: 2015-01-14 00:00:00.000000000 Z
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: '3.2'
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: '3.2'
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: '3.2'
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: '3.2'
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: '1.3'
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: '1.3'
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: '2.0'
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: '2.0'
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: '1.3'
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: '1.3'
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: '2.9'
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: '2.9'
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: thieso@gmail.com
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
- - ".specification"
108
- - ".travis.yml"
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: []
@@ -1,13 +0,0 @@
1
- rvm:
2
- - 1.9.2
3
- - 1.9.3
4
- - 2.0.0
5
- - 2.1.2
6
- - ruby-head
7
- - rbx-19mode
8
- - jruby-19mode
9
- matrix:
10
- allow_failures:
11
- - rvm: ruby-head
12
- - rvm: rbx-19mode
13
- - rvm: jruby-19mode