Skip to content

Commit

Permalink
List account types
Browse files Browse the repository at this point in the history
Allow users of app to refer to this constant to show available submodels
  • Loading branch information
ramontayag committed Dec 14, 2016
1 parent aa66ebc commit 6227e18
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
10 changes: 10 additions & 0 deletions app/models/plutus/account.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,16 @@ class Account < ActiveRecord::Base

validates_presence_of :type

def self.types
[
::Plutus::Asset,
::Plutus::Equity,
::Plutus::Expense,
::Plutus::Liability,
::Plutus::Revenue,
]
end

if Plutus.enable_tenancy
include Plutus::Tenancy
else
Expand Down
7 changes: 7 additions & 0 deletions spec/models/account_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ module Plutus

it { should_not be_valid } # must construct a child type instead

describe ".types" do
it "lists the available types" do
expect(described_class.types).
to match_array([Asset, Equity, Expense, Liability, Revenue])
end
end

describe "when using a child type" do
let(:account) { FactoryGirl.create(:account, type: "Finance::Asset") }
it { should be_valid }
Expand Down

0 comments on commit 6227e18

Please sign in to comment.