Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
b57c609
added @filter variable in show method
Oct 17, 2013
ca243ae
added instance variable @transactions
Oct 18, 2013
9c36ef2
changed query in active transaction method
Oct 18, 2013
f07a3f0
changed variable @account to @transactions
Oct 18, 2013
02af398
changed method transactions to grouped_transactions
Oct 18, 2013
29811c7
used the variable transaction
Oct 18, 2013
d786216
added faker gem and few dummy data to application works, also comment…
Oct 14, 2013
00136af
created seeds to bernard application
Oct 14, 2013
b375358
added category_id in the transactions view
Oct 14, 2013
9161194
refactor seed to have relation between transactions and splits
Oct 15, 2013
99e0764
change value from true to false
Oct 15, 2013
04ee6b9
increased seeds to transactions and accounts
Oct 15, 2013
c3ee360
added group test in gemfile
Oct 14, 2013
6580d9d
added rspec-rails
Oct 14, 2013
1dc0c24
added some basic test
Oct 15, 2013
5dfba28
added rspec_rails
Oct 15, 2013
e34395a
added gems
Oct 15, 2013
d6e7b0c
added factories to create account, category, department, payee and tr…
Oct 15, 2013
956346f
added test at models
Oct 15, 2013
54d3237
refactored seed in create transactions
Oct 15, 2013
983d984
increased number of seeds
Oct 15, 2013
1b37b74
added factories and refactored factory to account
Oct 15, 2013
20d6ebc
change factory split at transaction factory file
Oct 16, 2013
7a0a201
created spec/controllers folder and test to index in TransactionsCont…
Oct 16, 2013
4de84e7
added test to get methods
Oct 16, 2013
655229b
completed get methods
Oct 16, 2013
e19f650
add test to create method
Oct 16, 2013
70d7aa9
added vadilation of presece to transaction model in amount and accoun…
Oct 16, 2013
55dd014
added test to create method
Oct 16, 2013
f92bf63
added tests to transactions controller in put method
Oct 16, 2013
5a41e12
uncommented require pocket_money
Oct 17, 2013
e9198fb
ignored my database
Oct 17, 2013
3c557df
reverted change in category_name
Oct 17, 2013
e72feb9
added validation to enviroment diferent to test
Oct 18, 2013
eeafc9d
added validation to enviroment diferent to test
Oct 18, 2013
8950a9f
Merge branch 'fix/pockt-money-to-test' into jose-romero
Oct 18, 2013
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@
config/database.yml
config/config.yml


PocketMoneyDB.sql
**/.DS_Store
1 change: 1 addition & 0 deletions .rspec
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--color
9 changes: 9 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ gem 'haml'
gem 'twitter-bootstrap-rails', :git => 'git://github.com/seyhunak/twitter-bootstrap-rails.git'
gem 'less-rails'
gem "therubyracer"
gem "faker"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Faker goes inside the test block


group :doc do
# bundle exec rake doc:rails generates the API under doc/api.
Expand All @@ -46,6 +47,14 @@ gem 'pry-rails'

gem 'ruby-progressbar'

group :test do
gem 'rspec'
gem 'rspec-rails'
gem 'capybara'
gem 'factory_girl'
gem 'factory_girl_rails'
end

# Use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'

Expand Down
40 changes: 40 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ GEM
arel (4.0.0)
atomic (1.1.9)
builder (3.1.4)
capybara (2.1.0)
mime-types (>= 1.16)
nokogiri (>= 1.3.3)
rack (>= 1.0.0)
rack-test (>= 0.5.4)
xpath (~> 2.0)
coderay (1.0.9)
coffee-rails (4.0.0)
coffee-script (>= 2.2.0)
Expand All @@ -47,9 +53,17 @@ GEM
execjs
coffee-script-source (1.6.2)
commonjs (0.2.6)
diff-lcs (1.2.4)
erubis (2.7.0)
execjs (1.4.0)
multi_json (~> 1.0)
factory_girl (4.2.0)
activesupport (>= 3.0.0)
factory_girl_rails (4.2.1)
factory_girl (~> 4.2.0)
railties (>= 3.0.0)
faker (1.2.0)
i18n (~> 0.5)
haml (4.0.3)
tilt
hike (1.2.2)
Expand All @@ -71,8 +85,11 @@ GEM
treetop (~> 1.4.8)
method_source (0.8.1)
mime-types (1.23)
mini_portile (0.5.1)
minitest (4.7.4)
multi_json (1.7.4)
nokogiri (1.6.0)
mini_portile (~> 0.5.0)
pg (0.15.1)
polyglot (0.3.3)
pry (0.9.12.2)
Expand Down Expand Up @@ -104,6 +121,21 @@ GEM
rdoc (3.12.2)
json (~> 1.4)
ref (1.0.5)
rspec (2.14.1)
rspec-core (~> 2.14.0)
rspec-expectations (~> 2.14.0)
rspec-mocks (~> 2.14.0)
rspec-core (2.14.5)
rspec-expectations (2.14.3)
diff-lcs (>= 1.1.3, < 2.0)
rspec-mocks (2.14.3)
rspec-rails (2.14.0)
actionpack (>= 3.0)
activesupport (>= 3.0)
railties (>= 3.0)
rspec-core (~> 2.14.0)
rspec-expectations (~> 2.14.0)
rspec-mocks (~> 2.14.0)
ruby-progressbar (1.1.1)
sass (3.2.9)
sass-rails (4.0.0.rc1)
Expand Down Expand Up @@ -141,13 +173,19 @@ GEM
uglifier (2.1.1)
execjs (>= 0.3.0)
multi_json (~> 1.0, >= 1.0.2)
xpath (2.0.0)
nokogiri (~> 1.3)
yard (0.8.7)

PLATFORMS
ruby

DEPENDENCIES
capybara
coffee-rails (~> 4.0.0)
factory_girl
factory_girl_rails
faker
haml
jbuilder (~> 1.0.1)
jquery-rails
Expand All @@ -157,6 +195,8 @@ DEPENDENCIES
pry-doc
pry-rails
rails (= 4.0.0.rc1)
rspec
rspec-rails
ruby-progressbar
sass-rails (~> 4.0.0.rc1)
sdoc
Expand Down
1 change: 1 addition & 0 deletions app/controllers/accounts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ def index

def show
@account = Account.find(params[:id])
@transactions = @account.active_transactions
end
end
2 changes: 1 addition & 1 deletion app/models/account.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def type_name


def active_transactions
transactions.active.balance
transactions.transaction_includes.active.balance
end

def basic_balance
Expand Down
5 changes: 3 additions & 2 deletions app/models/transaction.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ class Transaction < ActiveRecord::Base

belongs_to :account
has_many :splits

validates :account_id, presence: true
validates :amount, presence: true

def split?
@split ||= splits.size > 1
Expand Down Expand Up @@ -154,7 +155,7 @@ def transaction_query
t = transaction_interval
t = t.where(pm_type: pm_type) if pm_type
t = t.where(account_id: account_id) if account_id
t = t.where('categories.id = ?', category_id) if category_id
#t = t.where('categories.id = ?', category_id) if category_id
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the comment?
I'd rather remove lines than commenting them...

t
end

Expand Down
2 changes: 1 addition & 1 deletion app/views/accounts/show.haml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
= ['(',@account.transactions.count, ')'].join


= render_transactions @account.active_transactions, show_balance: true
= render_transactions @transactions.group_by {|t| t.date.to_s(:short_date) } , show_balance: true

40 changes: 20 additions & 20 deletions app/views/transactions/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@
<%= f.label :category_id %><br>
<%= f.number_field :category_id %>
</div>
<div class="field">
<%= f.label :class_id %><br>
<%= f.number_field :class_id %>
</div>
<div class="field">
<%= f.label :memo %><br>
<%= f.text_area :memo %>
</div>
<%#<div class="field">%>
<%#<%= f.label :class_id %><br>%>
<%#<%= f.number_field :class_id %>%>
<%#</div>%>
<%#<div class="field">%>
<%#<%= f.label :memo %><br>%>
<%#<%= f.text_area :memo %>%>
<%#</div>%>
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this commented lines?

<div class="field">
<%= f.label :amount %><br>
<%= f.text_field :amount %>
Expand All @@ -47,18 +47,18 @@
<%= f.label :cleared %><br>
<%= f.check_box :cleared %>
</div>
<div class="field">
<%= f.label :currency_id %><br>
<%= f.text_field :currency_id %>
</div>
<div class="field">
<%= f.label :currency_exchange_rate %><br>
<%= f.text_field :currency_exchange_rate %>
</div>
<div class="field">
<%= f.label :balance %><br>
<%= f.text_field :balance %>
</div>
<%#<div class="field">%>
<%#<%= f.label :currency_id %><br>%>
<%#<%= f.text_field :currency_id %>%>
<%#</div>%>
<%#<div class="field">%>
<%#<%= f.label :currency_exchange_rate %><br>%>
<%#<%= f.text_field :currency_exchange_rate %>%>
<%#</div>%>
<%#<div class="field">%>
<%#<%= f.label :balance %><br>%>
<%#<%= f.text_field :balance %>%>
<%#</div>%>
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the comments?

<div class="actions">
<%= f.submit %>
</div>
Expand Down
2 changes: 1 addition & 1 deletion app/views/transactions/_transaction.haml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
%td= link_to transaction.date.to_s(:short_date), transaction
%td= transaction.account.name
%td= transaction.payee_name
%td= transaction.category_name
%td= transaction.category_name
%td.currency= money transaction.amount

- if show_balance
Expand Down
2 changes: 1 addition & 1 deletion app/views/transactions/_transactions.haml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
%th Balance

%tbody
- @filter.grouped_transactions.each do |header, transactions|
- transactions.each do |header, transactions|
%tr
%td.split(colspan=5)
= header
Expand Down
2 changes: 1 addition & 1 deletion app/views/transactions/index.haml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
= render partial: 'filters'
.span9
= render partial: 'header'
= render_transactions @filter.transactions, show_balance: false
= render_transactions @filter.grouped_transactions, show_balance: false

%br

Expand Down
2 changes: 1 addition & 1 deletion config/initializers/pocket_money.rb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
require 'pocket_money'
require 'pocket_money' if ENV["RAILS_ENV"] != 'test'
2 changes: 1 addition & 1 deletion db/migrate/20130531005809_create_transactions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def change
t.integer :payee_id
t.integer :category_id
t.integer :department_id
t.decimal :amount
t.decimal :amount, :precision => 10, :scale => 2
t.boolean :cleared
t.string :uuid

Expand Down
5 changes: 1 addition & 4 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@

ActiveRecord::Schema.define(version: 20130718222102) do

# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"

create_table "accounts", force: true do |t|
t.boolean "deleted"
t.datetime "updated_at"
Expand Down Expand Up @@ -134,7 +131,7 @@
t.integer "payee_id"
t.integer "category_id"
t.integer "department_id"
t.decimal "amount"
t.decimal "amount", precision: 10, scale: 2
t.boolean "cleared"
t.string "uuid"
t.datetime "created_at"
Expand Down
Loading