plutus 0.12.2 → 0.13

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ff6db3055f833f230341e09d485329f5e2150d7d
4
- data.tar.gz: bfc7ded7630f7a77c4bd79ebb17f723db77c7596
3
+ metadata.gz: baf78f34f534da86425756a8213a9651d531467e
4
+ data.tar.gz: a3c1df3ffd80619d1e0522794c03c02324d4cc68
5
5
  SHA512:
6
- metadata.gz: 05d28ad8fabc751e2fcf36ca759a11d3daf8103b6e62c933a8933cfc6515a9fa9c510f602efbc4faf51bf3769d7e72886a7115d097cb048bb6c6a7517d3ef22e
7
- data.tar.gz: fb15f1b5870bff1159c0b3eab675f3298cd973e96ffa82740aed24263bd037750a59f33b5a5d975d9e5c50d9dda05dfe414782b68f6da76ea69a025d93a54c0e
6
+ metadata.gz: 1502ce1be2995f71f55c4e902ff27894dd88ff91cfc9a5df02a850998e236e377ef1b5c76febf1312a1540e545d9ed9f2e2f22c10ea0979359a2648b676a8232
7
+ data.tar.gz: 9c127eafa076bad39a64c01c913e8db559bc3e2295d9571f1f9b78e7f14c5b5af8287f8ca5f18b9b3c1d330b246bc161e97249670844a287213f89114987f36a
@@ -7,8 +7,8 @@ The Plutus plugin is a Ruby on Rails Engine which provides a double entry accoun
7
7
  Compatibility
8
8
  =============
9
9
 
10
- * Ruby versions: MRI 1.9.3 - 2.2, Rubinius 2.2, JRuby 1.7+
11
- * Rails versions: ~> 4.0
10
+ * Ruby versions: MRI 2.2.2+ (should work with earlier versions if using Rails 4)
11
+ * Rails versions: ~> 5.0, ~> 4.0
12
12
 
13
13
  For earlier versions, and upgrading, please see the section titled [Previous Versions](https://github.com/mbulat/plutus#previous-versions)
14
14
 
@@ -291,6 +291,19 @@ Plutus.config do |config|
291
291
  config.tenant_class = 'Tenant'
292
292
  end
293
293
  ```
294
+ *NOTE: When building entries, be sure to specify the account directly, rather than use the `account_name` feature. Otherwise you'll probably end up with the wrong account.*
295
+
296
+ ```ruby
297
+ debit_account = Plutus::Acount.where(:name => "Cash", :tenant => my_tenant).last
298
+ credit_account = Plutus::Acount.where(:name => "Unearned Revenue", :tenant => my_tenant).last
299
+ entry = Plutus::Entry.new(
300
+ :description => "Order placed for widgets",
301
+ :date => Date.yesterday,
302
+ :debits => [
303
+ {:account => debit_account, :amount => 100.00}],
304
+ :credits => [
305
+ {:account => credit_account, :amount => 100.00}])
306
+ ```
294
307
 
295
308
  Reporting Views
296
309
  ===============
@@ -315,7 +328,7 @@ Previous Versions
315
328
 
316
329
  For the rails 3 version, you can go here:
317
330
 
318
- [https://github.com/mbulat/plutus](https://github.com/mbulat/plutus/tree/rails3)
331
+ [https://github.com/mbulat/plutus/tree/rails3](https://github.com/mbulat/plutus/tree/rails3)
319
332
 
320
333
  For the rails 2 version, you can go here:
321
334
 
@@ -379,4 +392,4 @@ For a complete reference on Accounting principles, we recommend the following te
379
392
 
380
393
  * * *
381
394
 
382
- Copyright (c) 2010-2012 Michael Bulat
395
+ Copyright (c) 2010-2016 Michael Bulat
@@ -12,5 +12,5 @@
12
12
  //
13
13
  //= require jquery
14
14
  //= require jquery_ujs
15
- //= require jquery.ui.datepicker
15
+ //= require jquery-ui/datepicker
16
16
  //= require_tree .
@@ -13,7 +13,7 @@
13
13
  *= require_tree .
14
14
  *= require bootstrap.min
15
15
  *= require bootstrap-theme.min
16
- *= require jquery.ui.datepicker
16
+ *= require jquery-ui/datepicker
17
17
  *= require_self
18
18
  */
19
19
  body { padding-top: 60px; }
@@ -17,7 +17,12 @@ module Plutus
17
17
  # GET /entries.xml
18
18
  # GET /entries.json
19
19
  def index
20
- @entries = Entry.limit(100).order('date DESC')
20
+ if params[:order] == 'ascending'
21
+ order = 'ASC'
22
+ else
23
+ order = 'DESC'
24
+ end
25
+ @entries = Entry.page(params[:page]).per(params[:limit]).order("date #{order}")
21
26
 
22
27
  respond_to do |format|
23
28
  format.html # index.html.erb
@@ -32,8 +32,10 @@ module Plutus
32
32
  class Account < ActiveRecord::Base
33
33
  class_attribute :normal_credit_balance
34
34
 
35
+ has_many :amounts
35
36
  has_many :credit_amounts, :extend => AmountsExtension, :class_name => 'Plutus::CreditAmount'
36
37
  has_many :debit_amounts, :extend => AmountsExtension, :class_name => 'Plutus::DebitAmount'
38
+ has_many :entries, through: :amounts, source: :entry
37
39
  has_many :credit_entries, :through => :credit_amounts, :source => :entry, :class_name => 'Plutus::Entry'
38
40
  has_many :debit_entries, :through => :debit_amounts, :source => :entry, :class_name => 'Plutus::Entry'
39
41
 
@@ -18,16 +18,5 @@ module Plutus
18
18
  end
19
19
 
20
20
  protected
21
-
22
- # Support constructing amounts with account = "name" syntax
23
- def account_with_name_lookup=(v)
24
- if v.kind_of?(String)
25
- ActiveSupport::Deprecation.warn('Plutus was given an :account String (use account_name instead)', caller)
26
- self.account_name = v
27
- else
28
- self.account_without_name_lookup = v
29
- end
30
- end
31
- alias_method_chain :account=, :name_lookup
32
21
  end
33
22
  end
@@ -32,10 +32,8 @@ module Plutus
32
32
  def balance_for_new_record
33
33
  balance = BigDecimal.new('0')
34
34
  each do |amount_record|
35
- if amount_record.amount
36
- balance += amount_record.amount
37
- else
38
- balance = nil
35
+ if amount_record.amount && !amount_record.marked_for_destruction?
36
+ balance += amount_record.amount # unless amount_record.marked_for_destruction?
39
37
  end
40
38
  end
41
39
  return balance
@@ -23,7 +23,13 @@ module Plutus
23
23
  # @author Michael Bulat
24
24
  class Entry < ActiveRecord::Base
25
25
  before_save :default_date
26
- belongs_to :commercial_document, :polymorphic => true
26
+
27
+ if ActiveRecord::VERSION::MAJOR > 4
28
+ belongs_to :commercial_document, :polymorphic => true, optional: true
29
+ else
30
+ belongs_to :commercial_document, :polymorphic => true
31
+ end
32
+
27
33
  has_many :credit_amounts, :extend => AmountsExtension, :class_name => 'Plutus::CreditAmount', :inverse_of => :entry
28
34
  has_many :debit_amounts, :extend => AmountsExtension, :class_name => 'Plutus::DebitAmount', :inverse_of => :entry
29
35
  has_many :credit_accounts, :through => :credit_amounts, :source => :account, :class_name => 'Plutus::Account'
@@ -35,7 +41,7 @@ module Plutus
35
41
  validate :amounts_cancel?
36
42
 
37
43
  # Support construction using 'credits' and 'debits' keys
38
- accepts_nested_attributes_for :credit_amounts, :debit_amounts
44
+ accepts_nested_attributes_for :credit_amounts, :debit_amounts, allow_destroy: true
39
45
  alias_method :credits=, :credit_amounts_attributes=
40
46
  alias_method :debits=, :debit_amounts_attributes=
41
47
  # attr_accessible :credits, :debits
@@ -52,7 +58,8 @@ module Plutus
52
58
 
53
59
  private
54
60
  def default_date
55
- self.date ||= Date.today
61
+ todays_date = ActiveRecord::Base.default_timezone == :utc ? Time.now.utc : Time.now
62
+ self.date ||= todays_date
56
63
  end
57
64
 
58
65
  def has_credit_amounts?
@@ -5,7 +5,11 @@ module Plutus
5
5
  included do
6
6
  validates :name, presence: true, uniqueness: { scope: :tenant_id }
7
7
 
8
- belongs_to :tenant, class_name: Plutus.tenant_class
8
+ if ActiveRecord::VERSION::MAJOR > 4
9
+ belongs_to :tenant, class_name: Plutus.tenant_class, optional: true
10
+ else
11
+ belongs_to :tenant, class_name: Plutus.tenant_class
12
+ end
9
13
  end
10
14
  end
11
15
  end
@@ -2,6 +2,13 @@
2
2
  <center>
3
3
  <h1>Journal</h1>
4
4
  <br>
5
+ <%= form_tag({:action => 'index'}, {:method => :get, :class => 'form-inline'}) do%>
6
+ <div class="form-group">
7
+ Per page: <%= select_tag :limit, options_for_select([25, 100, 200, 300], selected: params[:limit]), class: 'form-control' %>
8
+ Order: <%= select_tag :order, options_for_select(['descending', 'ascending'], selected: params[:order]), class: 'form-control' %>
9
+ </div>
10
+ <button type="submit" class="btn btn-default">Refresh</button>
11
+ <% end %>
5
12
  </center>
6
13
 
7
14
  <table class="table table-striped table-hover">
@@ -47,4 +54,6 @@
47
54
  </tbody>
48
55
  </table>
49
56
 
57
+ <%= paginate @entries %>
58
+
50
59
  </div>
@@ -1,4 +1,4 @@
1
- class AddDateToPlutusEntries < ActiveRecord::Migration
1
+ class AddDateToPlutusEntries < ActiveRecord::Migration[4.2]
2
2
  def change
3
3
  add_column :plutus_entries, :date, :date
4
4
  add_index :plutus_entries, :date
@@ -1,4 +1,4 @@
1
- class CreatePlutusTables < ActiveRecord::Migration
1
+ class CreatePlutusTables < ActiveRecord::Migration[4.2]
2
2
  def self.up
3
3
  create_table :plutus_accounts do |t|
4
4
  t.string :name
@@ -1,4 +1,4 @@
1
- class TenantPlutusTables < ActiveRecord::Migration
1
+ class TenantPlutusTables < ActiveRecord::Migration[4.2]
2
2
  def change
3
3
  # add a tenant column to plutus accounts table.
4
4
  add_column :plutus_accounts, :tenant_id, :integer, index: true
@@ -1,4 +1,4 @@
1
- class UpdatePlutusTables < ActiveRecord::Migration
1
+ class UpdatePlutusTables < ActiveRecord::Migration[4.2]
2
2
  def change
3
3
  # we have to remove these indexes because the temporary
4
4
  # table index name is too long
@@ -1,3 +1,3 @@
1
1
  module Plutus
2
- VERSION = "0.12.2"
2
+ VERSION = "0.13"
3
3
  end
@@ -10,9 +10,9 @@ module Plutus
10
10
 
11
11
  describe "GET index" do
12
12
  it "assigns all accounts as @accounts" do
13
- Account.stub(:all).and_return([mock_account])
13
+ allow(Account).to receive(:all).and_return([mock_account])
14
14
  get :index
15
- assigns[:accounts].should == [mock_account]
15
+ expect(assigns[:accounts]).to eq([mock_account])
16
16
  end
17
17
  end
18
18
  end
@@ -10,9 +10,9 @@ module Plutus
10
10
 
11
11
  describe "GET index" do
12
12
  it "assigns all entries as @entries" do
13
- Entry.stub_chain(:limit, :order).and_return([mock_entry])
13
+ allow(Entry).to receive_message_chain(:per, :order).and_return([mock_entry])
14
14
  get :index
15
- assigns[:entries].should == [mock_entry]
15
+ expect(assigns[:entries]).to eq([mock_entry])
16
16
  end
17
17
  end
18
18
  end
@@ -10,14 +10,14 @@ module Plutus
10
10
 
11
11
  describe "GET balance_sheet" do
12
12
  it "renders when one entry exists" do
13
- Entry.stub_chain(:order).and_return([mock_entry])
13
+ allow(Entry).to receive_message_chain(:order).and_return([mock_entry])
14
14
  get :balance_sheet
15
- response.should be_success
15
+ expect(response).to be_success
16
16
  end
17
17
  it "renders when no entries exist" do
18
- Entry.stub_chain(:order).and_return([])
18
+ allow(Entry).to receive_message_chain(:order).and_return([])
19
19
  get :balance_sheet
20
- response.should be_success
20
+ expect(response).to be_success
21
21
  end
22
22
  end
23
23
  end
@@ -5,16 +5,16 @@ module Plutus
5
5
  let(:account) { FactoryGirl.build(:account) }
6
6
  subject { account }
7
7
 
8
- it { should_not be_valid } # must construct a child type instead
8
+ it { is_expected.not_to be_valid } # must construct a child type instead
9
9
 
10
10
  describe "when using a child type" do
11
11
  let(:account) { FactoryGirl.create(:account, type: "Finance::Asset") }
12
- it { should be_valid }
12
+ it { is_expected.to be_valid }
13
13
 
14
14
  it "should be unique per name" do
15
15
  conflict = FactoryGirl.build(:account, name: account.name, type: account.type)
16
- conflict.should_not be_valid
17
- conflict.errors[:name].should == ["has already been taken"]
16
+ expect(conflict).not_to be_valid
17
+ expect(conflict.errors[:name]).to eq(["has already been taken"])
18
18
  end
19
19
  end
20
20
 
@@ -28,10 +28,10 @@ module Plutus
28
28
 
29
29
  describe ".trial_balance" do
30
30
  subject { Account.trial_balance }
31
- it { should be_kind_of BigDecimal }
31
+ it { is_expected.to be_kind_of BigDecimal }
32
32
 
33
33
  context "when given no entries" do
34
- it { should == 0 }
34
+ it { is_expected.to eq(0) }
35
35
  end
36
36
 
37
37
  context "when given correct entries" do
@@ -69,8 +69,65 @@ module Plutus
69
69
  FactoryGirl.create(:entry, :credit_amounts => [ca5], :debit_amounts => [da5])
70
70
  }
71
71
 
72
- it { should == 0 }
72
+ it { is_expected.to eq(0) }
73
73
  end
74
74
  end
75
+
76
+ describe "#amounts" do
77
+ it "returns all credit and debit amounts" do
78
+ equity = FactoryGirl.create(:equity)
79
+ asset = FactoryGirl.create(:asset)
80
+ expense = FactoryGirl.create(:expense)
81
+
82
+ investment = Entry.new(
83
+ description: "Initial investment",
84
+ date: Date.today,
85
+ debits: [{ account_name: equity.name, amount: 1000 }],
86
+ credits: [{ account_name: asset.name, amount: 1000 }],
87
+ )
88
+ investment.save
89
+
90
+ purchase = Entry.new(
91
+ description: "First computer",
92
+ date: Date.today,
93
+ debits: [{ account_name: asset.name, amount: 900 }],
94
+ credits: [{ account_name: expense.name, amount: 900 }],
95
+ )
96
+ purchase.save
97
+
98
+ expect(equity.amounts.size).to eq 1
99
+ expect(asset.amounts.size).to eq 2
100
+ expect(expense.amounts.size).to eq 1
101
+ end
102
+ end
103
+
104
+ describe "#entries" do
105
+ it "returns all credit and debit entries" do
106
+ equity = FactoryGirl.create(:equity)
107
+ asset = FactoryGirl.create(:asset)
108
+ expense = FactoryGirl.create(:expense)
109
+
110
+ investment = Entry.new(
111
+ description: "Initial investment",
112
+ date: Date.today,
113
+ debits: [{ account_name: equity.name, amount: 1000 }],
114
+ credits: [{ account_name: asset.name, amount: 1000 }],
115
+ )
116
+ investment.save
117
+
118
+ purchase = Entry.new(
119
+ description: "First computer",
120
+ date: Date.today,
121
+ debits: [{ account_name: asset.name, amount: 900 }],
122
+ credits: [{ account_name: expense.name, amount: 900 }],
123
+ )
124
+ purchase.save
125
+
126
+ expect(equity.entries.size).to eq 1
127
+ expect(asset.entries.size).to eq 2
128
+ expect(expense.entries.size).to eq 1
129
+ end
130
+ end
131
+
75
132
  end
76
133
  end
@@ -3,6 +3,6 @@ require 'spec_helper'
3
3
  module Plutus
4
4
  describe Amount do
5
5
  subject { FactoryGirl.build(:amount) }
6
- it { should_not be_valid } # construct a child class instead
6
+ it { is_expected.not_to be_valid } # construct a child class instead
7
7
  end
8
8
  end
@@ -5,15 +5,15 @@ module Plutus
5
5
  let(:entry) { FactoryGirl.build(:entry) }
6
6
  subject { entry }
7
7
 
8
- it { should_not be_valid }
8
+ it { is_expected.not_to be_valid }
9
9
 
10
10
  context "with credit and debit" do
11
11
  let(:entry) { FactoryGirl.build(:entry_with_credit_and_debit) }
12
- it { should be_valid }
12
+ it { is_expected.to be_valid }
13
13
 
14
14
  it "should require a description" do
15
15
  entry.description = nil
16
- entry.should_not be_valid
16
+ expect(entry).not_to be_valid
17
17
  end
18
18
  end
19
19
 
@@ -21,13 +21,13 @@ module Plutus
21
21
  before {
22
22
  entry.debit_amounts << FactoryGirl.build(:debit_amount, entry: entry)
23
23
  }
24
- it { should_not be_valid }
24
+ it { is_expected.not_to be_valid }
25
25
 
26
26
  context "with an invalid credit" do
27
27
  before {
28
28
  entry.credit_amounts << FactoryGirl.build(:credit_amount, entry: entry, amount: nil)
29
29
  }
30
- it { should_not be_valid }
30
+ it { is_expected.not_to be_valid }
31
31
  end
32
32
  end
33
33
 
@@ -35,13 +35,13 @@ module Plutus
35
35
  before {
36
36
  entry.credit_amounts << FactoryGirl.build(:credit_amount, entry: entry)
37
37
  }
38
- it { should_not be_valid }
38
+ it { is_expected.not_to be_valid }
39
39
 
40
40
  context "with an invalid debit" do
41
41
  before {
42
42
  entry.debit_amounts << FactoryGirl.build(:debit_amount, entry: entry, amount: nil)
43
43
  }
44
- it { should_not be_valid }
44
+ it { is_expected.not_to be_valid }
45
45
  end
46
46
  end
47
47
 
@@ -50,23 +50,32 @@ module Plutus
50
50
 
51
51
  context "should assign a default date before being saved" do
52
52
  before { entry.save! }
53
- its(:date) { should == Date.today }
53
+ its(:date) { is_expected.to eq(Time.now.to_date) }
54
54
  end
55
55
  end
56
56
 
57
57
  it "should require the debit and credit amounts to cancel" do
58
58
  entry.credit_amounts << FactoryGirl.build(:credit_amount, :amount => 100, :entry => entry)
59
59
  entry.debit_amounts << FactoryGirl.build(:debit_amount, :amount => 200, :entry => entry)
60
- entry.should_not be_valid
61
- entry.errors['base'].should == ["The credit and debit amounts are not equal"]
60
+ expect(entry).not_to be_valid
61
+ expect(entry.errors['base']).to eq(["The credit and debit amounts are not equal"])
62
62
  end
63
63
 
64
64
  it "should require the debit and credit amounts to cancel even with fractions" do
65
65
  entry = FactoryGirl.build(:entry)
66
66
  entry.credit_amounts << FactoryGirl.build(:credit_amount, :amount => 100.1, :entry => entry)
67
67
  entry.debit_amounts << FactoryGirl.build(:debit_amount, :amount => 100.2, :entry => entry)
68
- entry.should_not be_valid
69
- entry.errors['base'].should == ["The credit and debit amounts are not equal"]
68
+ expect(entry).not_to be_valid
69
+ expect(entry.errors['base']).to eq(["The credit and debit amounts are not equal"])
70
+ end
71
+
72
+ it "should ignore debit and credit amounts marked for destruction to cancel" do
73
+ entry.credit_amounts << FactoryGirl.build(:credit_amount, :amount => 100, :entry => entry)
74
+ debit_amount = FactoryGirl.build(:debit_amount, :amount => 100, :entry => entry)
75
+ debit_amount.mark_for_destruction
76
+ entry.debit_amounts << debit_amount
77
+ expect(entry).not_to be_valid
78
+ expect(entry.errors['base']).to eq(["The credit and debit amounts are not equal"])
70
79
  end
71
80
 
72
81
  it "should have a polymorphic commercial document associations" do
@@ -74,7 +83,7 @@ module Plutus
74
83
  entry = FactoryGirl.build(:entry_with_credit_and_debit, commercial_document: mock_document)
75
84
  entry.save!
76
85
  saved_entry = Entry.find(entry.id)
77
- saved_entry.commercial_document.should == mock_document
86
+ expect(saved_entry.commercial_document).to eq(mock_document)
78
87
  end
79
88
 
80
89
  context "given a set of accounts" do
@@ -84,13 +93,13 @@ module Plutus
84
93
  let!(:sales_tax_payable) { FactoryGirl.create(:liability, name: "Sales Tax Payable") }
85
94
 
86
95
  shared_examples_for 'a built-from-hash Plutus::Entry' do
87
- its(:credit_amounts) { should_not be_empty }
88
- its(:debit_amounts) { should_not be_empty }
89
- it { should be_valid }
96
+ its(:credit_amounts) { is_expected.not_to be_empty }
97
+ its(:debit_amounts) { is_expected.not_to be_empty }
98
+ it { is_expected.to be_valid }
90
99
 
91
100
  context "when saved" do
92
101
  before { entry.save! }
93
- its(:id) { should_not be_nil }
102
+ its(:id) { is_expected.not_to be_nil }
94
103
 
95
104
  context "when reloaded" do
96
105
  let(:saved_transaction) { Entry.find(entry.id) }
@@ -135,31 +144,6 @@ module Plutus
135
144
  }
136
145
  include_examples 'a built-from-hash Plutus::Entry'
137
146
  end
138
-
139
- context "when given a credit/debits hash with :account => String" do
140
- let(:hash) {
141
- {
142
- description: "Sold some widgets",
143
- commercial_document: mock_document,
144
- debits: [{account: accounts_receivable.name, amount: 50}],
145
- credits: [
146
- {account: sales_revenue.name, amount: 45},
147
- {account: sales_tax_payable.name, amount: 5}
148
- ]
149
- }
150
- }
151
-
152
- before { ::ActiveSupport::Deprecation.silenced = true }
153
- after { ::ActiveSupport::Deprecation.silenced = false }
154
-
155
- it("should be deprecated") {
156
- # one deprecation per account looked up
157
- ::ActiveSupport::Deprecation.should_receive(:warn).exactly(3).times
158
- entry
159
- }
160
-
161
- include_examples 'a built-from-hash Plutus::Entry'
162
- end
163
147
  end
164
148
 
165
149
  describe ".build" do
@@ -174,32 +158,11 @@ module Plutus
174
158
 
175
159
  it("should be deprecated") {
176
160
  # .build is the only thing deprecated
177
- ::ActiveSupport::Deprecation.should_receive(:warn).once
161
+ expect(::ActiveSupport::Deprecation).to receive(:warn).once
178
162
  entry
179
163
  }
180
164
  end
181
165
 
182
- context "when given a credit/debits hash with :account => String" do
183
- let(:hash) {
184
- {
185
- description: "Sold some widgets",
186
- commercial_document: mock_document,
187
- debits: [{account: accounts_receivable.name, amount: 50}],
188
- credits: [
189
- {account: sales_revenue.name, amount: 45},
190
- {account: sales_tax_payable.name, amount: 5}
191
- ]
192
- }
193
- }
194
-
195
- it("should be deprecated") {
196
- # one deprecation for build, plus three for accounts as strings
197
- ::ActiveSupport::Deprecation.should_receive(:warn).exactly(4).times
198
- entry
199
- }
200
-
201
- include_examples 'a built-from-hash Plutus::Entry'
202
- end
203
166
  end
204
167
  end
205
168
 
@@ -30,15 +30,15 @@ module Plutus
30
30
  account = FactoryGirl.create(:asset, tenant_id: 10)
31
31
 
32
32
  record = FactoryGirl.build(:asset, name: account.name, tenant_id: 10)
33
- record.should_not be_valid
34
- record.errors[:name].should == ['has already been taken']
33
+ expect(record).not_to be_valid
34
+ expect(record.errors[:name]).to eq(['has already been taken'])
35
35
  end
36
36
 
37
37
  it 'allows same name scoped under a different tenant' do
38
38
  account = FactoryGirl.create(:asset, tenant_id: 10)
39
39
 
40
40
  record = FactoryGirl.build(:asset, name: account.name, tenant_id: 11)
41
- record.should be_valid
41
+ expect(record).to be_valid
42
42
  end
43
43
  end
44
44
  end
@@ -6,7 +6,7 @@ module Plutus
6
6
 
7
7
  describe "routing" do
8
8
  it "recognizes and generates #index" do
9
- { :get => "/accounts" }.should route_to(:controller => "plutus/accounts", :action => "index")
9
+ expect(:get => "/accounts").to route_to(:controller => "plutus/accounts", :action => "index")
10
10
  end
11
11
  end
12
12
  end
@@ -6,7 +6,7 @@ module Plutus
6
6
 
7
7
  describe "routing" do
8
8
  it "recognizes and generates #index" do
9
- { :get => "/entries" }.should route_to(:controller => "plutus/entries", :action => "index")
9
+ expect(:get => "/entries").to route_to(:controller => "plutus/entries", :action => "index")
10
10
  end
11
11
  end
12
12
  end
@@ -9,6 +9,7 @@ require 'rspec/rails'
9
9
 
10
10
  $: << File.expand_path(File.dirname(__FILE__) + '/../lib/')
11
11
  require 'plutus'
12
+ require 'kaminari'
12
13
 
13
14
  Dir[File.expand_path(File.join(File.dirname(__FILE__),'support','**','*.rb'))].each {|f| require f}
14
15
 
@@ -5,28 +5,28 @@ shared_examples_for 'a Plutus::Account subtype' do |elements|
5
5
 
6
6
  describe "class methods" do
7
7
  subject { account.class }
8
- its(:balance) { should be_kind_of(BigDecimal) }
8
+ its(:balance) { is_expected.to be_kind_of(BigDecimal) }
9
9
  describe "trial_balance" do
10
10
  it "should raise NoMethodError" do
11
- lambda { subject.trial_balance }.should raise_error NoMethodError
11
+ expect { subject.trial_balance }.to raise_error NoMethodError
12
12
  end
13
13
  end
14
14
  end
15
15
 
16
16
  describe "instance methods" do
17
- its(:balance) { should be_kind_of(BigDecimal) }
17
+ its(:balance) { is_expected.to be_kind_of(BigDecimal) }
18
18
 
19
19
  it "reports a balance with date range" do
20
- account.balance(:from_date => "2014-01-01", :to_date => Date.today).should be_kind_of(BigDecimal)
20
+ expect(account.balance(:from_date => "2014-01-01", :to_date => Date.today)).to be_kind_of(BigDecimal)
21
21
  end
22
22
 
23
- it { should respond_to(:credit_entries) }
24
- it { should respond_to(:debit_entries) }
23
+ it { is_expected.to respond_to(:credit_entries) }
24
+ it { is_expected.to respond_to(:debit_entries) }
25
25
  end
26
26
 
27
27
  it "requires a name" do
28
28
  account.name = nil
29
- account.should_not be_valid
29
+ expect(account).not_to be_valid
30
30
  end
31
31
 
32
32
  # Figure out which way credits and debits should apply
@@ -40,21 +40,21 @@ shared_examples_for 'a Plutus::Account subtype' do |elements|
40
40
 
41
41
  describe "when given a debit" do
42
42
  before { FactoryGirl.create(:debit_amount, account: account) }
43
- its(:balance) { should be.send(debit_condition, 0) }
43
+ its(:balance) { is_expected.to be.send(debit_condition, 0) }
44
44
 
45
45
  describe "on a contra account" do
46
46
  let(:contra) { true }
47
- its(:balance) { should be.send(credit_condition, 0) }
47
+ its(:balance) { is_expected.to be.send(credit_condition, 0) }
48
48
  end
49
49
  end
50
50
 
51
51
  describe "when given a credit" do
52
52
  before { FactoryGirl.create(:credit_amount, account: account) }
53
- its(:balance) { should be.send(credit_condition, 0) }
53
+ its(:balance) { is_expected.to be.send(credit_condition, 0) }
54
54
 
55
55
  describe "on a contra account" do
56
56
  let(:contra) { true }
57
- its(:balance) { should be.send(debit_condition, 0) }
57
+ its(:balance) { is_expected.to be.send(debit_condition, 0) }
58
58
  end
59
59
  end
60
60
  end
@@ -2,20 +2,20 @@ shared_examples_for 'a Plutus::Amount subtype' do |elements|
2
2
  let(:amount) { FactoryGirl.build(elements[:kind]) }
3
3
  subject { amount }
4
4
 
5
- it { should be_valid }
5
+ it { is_expected.to be_valid }
6
6
 
7
7
  it "should require an amount" do
8
8
  amount.amount = nil
9
- amount.should_not be_valid
9
+ expect(amount).not_to be_valid
10
10
  end
11
11
 
12
12
  it "should require a entry" do
13
13
  amount.entry = nil
14
- amount.should_not be_valid
14
+ expect(amount).not_to be_valid
15
15
  end
16
16
 
17
17
  it "should require an account" do
18
18
  amount.account = nil
19
- amount.should_not be_valid
19
+ expect(amount).not_to be_valid
20
20
  end
21
21
  end
metadata CHANGED
@@ -1,27 +1,27 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: plutus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.2
4
+ version: '0.13'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Bulat
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-21 00:00:00.000000000 Z
11
+ date: 2017-07-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '4.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
26
  version: '4.0'
27
27
  - !ruby/object:Gem::Dependency
@@ -44,14 +44,28 @@ dependencies:
44
44
  requirements:
45
45
  - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: '4.0'
47
+ version: 4.2.2
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: '4.0'
54
+ version: 4.2.2
55
+ - !ruby/object:Gem::Dependency
56
+ name: kaminari
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.0'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: yard
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -177,7 +191,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
177
191
  version: 1.3.6
178
192
  requirements: []
179
193
  rubyforge_project:
180
- rubygems_version: 2.4.2
194
+ rubygems_version: 2.5.2
181
195
  signing_key:
182
196
  specification_version: 3
183
197
  summary: A Plugin providing a Double Entry Accounting Engine for Rails
@@ -209,4 +223,3 @@ test_files:
209
223
  - spec/models/amount_spec.rb
210
224
  - spec/models/equity_spec.rb
211
225
  - spec/models/entry_spec.rb
212
- has_rdoc: