From f19751fe68a12269fd7f9d307b42260d2e72d554 Mon Sep 17 00:00:00 2001 From: Jesus Romero Date: Mon, 14 Oct 2013 11:13:46 -0500 Subject: [PATCH 01/76] added faker gem and few dummy data to application works, also comment some lines --- Gemfile | 1 + Gemfile.lock | 3 ++ app/models/transaction.rb | 2 +- app/views/transactions/_form.html.erb | 40 ++++++++++++------------ app/views/transactions/_transaction.haml | 2 +- db/schema.rb | 16 ---------- db/seeds.rb | 6 ++++ 7 files changed, 32 insertions(+), 38 deletions(-) diff --git a/Gemfile b/Gemfile index f58c20f..bd697e5 100644 --- a/Gemfile +++ b/Gemfile @@ -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" group :doc do # bundle exec rake doc:rails generates the API under doc/api. diff --git a/Gemfile.lock b/Gemfile.lock index cb0d74c..f7a381a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -50,6 +50,8 @@ GEM erubis (2.7.0) execjs (1.4.0) multi_json (~> 1.0) + faker (1.2.0) + i18n (~> 0.5) haml (4.0.3) tilt hike (1.2.2) @@ -148,6 +150,7 @@ PLATFORMS DEPENDENCIES coffee-rails (~> 4.0.0) + faker haml jbuilder (~> 1.0.1) jquery-rails diff --git a/app/models/transaction.rb b/app/models/transaction.rb index ee2cc2b..f817a05 100644 --- a/app/models/transaction.rb +++ b/app/models/transaction.rb @@ -154,7 +154,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 t end diff --git a/app/views/transactions/_form.html.erb b/app/views/transactions/_form.html.erb index 9258302..984c17f 100644 --- a/app/views/transactions/_form.html.erb +++ b/app/views/transactions/_form.html.erb @@ -31,14 +31,14 @@ <%= f.label :category_id %>
<%= f.number_field :category_id %> -
- <%= f.label :class_id %>
- <%= f.number_field :class_id %> -
-
- <%= f.label :memo %>
- <%= f.text_area :memo %> -
+ <%#
%> + <%#<%= f.label :class_id %>
%> + <%#<%= f.number_field :class_id %>%> + <%#
%> + <%#
%> + <%#<%= f.label :memo %>
%> + <%#<%= f.text_area :memo %>%> + <%#
%>
<%= f.label :amount %>
<%= f.text_field :amount %> @@ -47,18 +47,18 @@ <%= f.label :cleared %>
<%= f.check_box :cleared %>
-
- <%= f.label :currency_id %>
- <%= f.text_field :currency_id %> -
-
- <%= f.label :currency_exchange_rate %>
- <%= f.text_field :currency_exchange_rate %> -
-
- <%= f.label :balance %>
- <%= f.text_field :balance %> -
+ <%#
%> + <%#<%= f.label :currency_id %>
%> + <%#<%= f.text_field :currency_id %>%> + <%#
%> + <%#
%> + <%#<%= f.label :currency_exchange_rate %>
%> + <%#<%= f.text_field :currency_exchange_rate %>%> + <%#
%> + <%#
%> + <%#<%= f.label :balance %>
%> + <%#<%= f.text_field :balance %>%> + <%#
%>
<%= f.submit %>
diff --git a/app/views/transactions/_transaction.haml b/app/views/transactions/_transaction.haml index b1adf79..a33df5f 100644 --- a/app/views/transactions/_transaction.haml +++ b/app/views/transactions/_transaction.haml @@ -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= "Category" %td.currency= money transaction.amount - if show_balance diff --git a/db/schema.rb b/db/schema.rb index af83078..925310b 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -1,21 +1,5 @@ -# encoding: UTF-8 -# This file is auto-generated from the current state of the database. Instead -# of editing this file, please use the migrations feature of Active Record to -# incrementally modify your database, and then regenerate this schema definition. -# -# Note that this schema.rb definition is the authoritative source for your -# database schema. If you need to create the application database on another -# system, you should be using db:schema:load, not running all the migrations -# from scratch. The latter is a flawed and unsustainable approach (the more migrations -# you'll amass, the slower it'll run and the greater likelihood for issues). -# -# It's strongly recommended that you check this file into your version control system. - 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" diff --git a/db/seeds.rb b/db/seeds.rb index 4edb1e8..77b6dd7 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -5,3 +5,9 @@ # # cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }]) # Mayor.create(name: 'Emanuel', city: cities.first) +Account.create( + deleted: false + pm_id: 1 + pm_acunt_type: 1 + + From 345f2c151f340502023d42eda977f956d7b3817d Mon Sep 17 00:00:00 2001 From: Jesus Romero Date: Mon, 14 Oct 2013 14:07:22 -0500 Subject: [PATCH 02/76] created seeds to bernard application --- db/seeds.rb | 134 +++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 123 insertions(+), 11 deletions(-) diff --git a/db/seeds.rb b/db/seeds.rb index 77b6dd7..adb7c24 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -1,13 +1,125 @@ -# This file should contain all the record creation needed to seed the database with its default values. -# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup). -# -# Examples: -# -# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }]) -# Mayor.create(name: 'Emanuel', city: cities.first) -Account.create( - deleted: false - pm_id: 1 - pm_acunt_type: 1 +boolean = [true, false] +currency = ["AED", "ALL", "CAD", "CNY", "MXN", "IRR", "JPY", "USD", "UYU"] +#Seed to Account table +5.times do + Account.create( + deleted: false, + pm_id: rand(0..8), + pm_account_type: rand(0..8), + display_order: rand(1..4), + name: Faker::Company.name, + balance_overall: rand*(5), + balance_cleared: rand*(5), + number: Faker::Number.number(2), + institution: Faker::Company.suffix, + phone: Faker::PhoneNumber.cell_phone, + expiration_date: Faker::Business.credit_card_expiry_date.strftime("%d,%m,%Y"), + check_number: Faker::Number.digit, + notes: Faker::Lorem.paragraph, + pm_icon: "image", + url: Faker::Internet.url, + of_x_id: "dummy", + of_x_url: Faker::Internet.domain_word, + password: Faker::Internet.password, + fee: rand*(100), + fixed_percent: rand*(20), + limit_amount: 1000 + rand*(9_000), + limit: boolean.sample, + total_worth: boolean.sample, + exchange_rate: rand*(10), + currency_code: currency.sample, + last_sync_time: (Time.now - rand(60).days).to_date, + routing_number: rand(100), + overdraft_account_id: rand(30).to_s, + keep_the_change_account_id: rand(30).to_s, + heek_change_round_to: rand*(5), + uuid: Faker::Code.isbn(64) + ) + #seed to category table + Category.create( + name: Faker::Commerce.department, + deleted: boolean.sample, + pm_id: rand(0..8), + pm_type: rand(0..8), + budget_period: rand(100..10000), + budget_limit: rand(500..5000), + include_subcategories: boolean.sample, + rollover: boolean.sample, + uuid: Faker::Code.isbn + ) + #seed to department table + Department.create( + name: Faker::Commerce.product_name, + pm_id: rand(0..8), + uuid: Faker::Code.isbn, + deleted: boolean.sample + ) + #seed to Payee table + Payee.create( + name: Faker::Name.name, + deleted: boolean.sample, + pm_id: rand(0..8), + latitude: Faker::Address.latitude, + longitude: Faker::Address.longitude, + uuid: Faker::Code.isbn + ) +end + +10.times do + + pm = rand(0..2) + pm_id = rand(0..8) + account = Account.all.map(&:id).sample + payee = Payee.all.map(&:id).sample + #seed to transaction table + Transaction.create( + pm_type: pm, + pm_id: pm_id, + account_id: account, + pm_account_id: account, + pm_payee: Payee.find(payee).name, + pm_sub_total: rand*(1_000), + pm_of_x_id: "dummy", + pm_image: "dummy", + pm_overdraft_id: rand(30).to_s, + date: Time.now - rand(0..60).days, + deleted: boolean.sample, + check_number: rand(10).to_s, + payee_name: Payee.find(payee).name, + payee_id: payee, + category_id: Category.all.map(&:id).sample, + department_id: Department.all.map(&:id).sample, + amount: 10 + rand*(10_000), + cleared: boolean.sample, + uuid: Faker::Code.isbn + ) + +end +3.times do + transaction_id = Transaction.all.map(&:id).sample + transaction = Transaction.find(transaction_id) + #seed to split table + Split.create( + pm_id: transaction.pm_id, + transaction_id: transaction_id, + amount: transaction.amount, + xrate: rand*(5), + category_id: transaction.category_id, + class_id: rand(0..10), + memo: Faker::Lorem.paragraph, + transfer_to_account_id: rand(100), + currency_code: currency.sample, + of_x_id: "dummy" + ) +end + + + + + + + + + From 3941501420b79f0b0b120f0105dac7a0957bb768 Mon Sep 17 00:00:00 2001 From: Jesus Romero Date: Mon, 14 Oct 2013 14:09:37 -0500 Subject: [PATCH 03/76] added category_id in the transactions view --- app/views/transactions/_transaction.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/transactions/_transaction.haml b/app/views/transactions/_transaction.haml index a33df5f..76a66b7 100644 --- a/app/views/transactions/_transaction.haml +++ b/app/views/transactions/_transaction.haml @@ -3,7 +3,7 @@ %td= link_to transaction.date.to_s(:short_date), transaction %td= transaction.account.name %td= transaction.payee_name - %td= "Category" + %td= transaction.category_id %td.currency= money transaction.amount - if show_balance From 63fd48bb9b7a41f9cd4caaeb3a1f13becb68e91d Mon Sep 17 00:00:00 2001 From: Jesus Romero Date: Tue, 15 Oct 2013 10:47:44 -0500 Subject: [PATCH 04/76] refactor seed to have relation between transactions and splits --- .rspec | 1 + config/initializers/pocket_money.rb | 2 +- .../20130531005809_create_transactions.rb | 2 +- db/schema.rb | 15 ++++- db/seeds.rb | 63 +++++++++++-------- 5 files changed, 54 insertions(+), 29 deletions(-) create mode 100644 .rspec diff --git a/.rspec b/.rspec new file mode 100644 index 0000000..4e1e0d2 --- /dev/null +++ b/.rspec @@ -0,0 +1 @@ +--color diff --git a/config/initializers/pocket_money.rb b/config/initializers/pocket_money.rb index d147d71..37ad7c4 100644 --- a/config/initializers/pocket_money.rb +++ b/config/initializers/pocket_money.rb @@ -1 +1 @@ -require 'pocket_money' +#require 'pocket_money' diff --git a/db/migrate/20130531005809_create_transactions.rb b/db/migrate/20130531005809_create_transactions.rb index 9ca3316..8e02e5b 100644 --- a/db/migrate/20130531005809_create_transactions.rb +++ b/db/migrate/20130531005809_create_transactions.rb @@ -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 diff --git a/db/schema.rb b/db/schema.rb index 925310b..3965c60 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -1,3 +1,16 @@ +# encoding: UTF-8 +# This file is auto-generated from the current state of the database. Instead +# of editing this file, please use the migrations feature of Active Record to +# incrementally modify your database, and then regenerate this schema definition. +# +# Note that this schema.rb definition is the authoritative source for your +# database schema. If you need to create the application database on another +# system, you should be using db:schema:load, not running all the migrations +# from scratch. The latter is a flawed and unsustainable approach (the more migrations +# you'll amass, the slower it'll run and the greater likelihood for issues). +# +# It's strongly recommended that you check this file into your version control system. + ActiveRecord::Schema.define(version: 20130718222102) do create_table "accounts", force: true do |t| @@ -118,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" diff --git a/db/seeds.rb b/db/seeds.rb index adb7c24..54dfcce 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -1,4 +1,4 @@ -boolean = [true, false] +boolean = [true] #To have inactive transactions, add false at array [true, false] currency = ["AED", "ALL", "CAD", "CNY", "MXN", "IRR", "JPY", "USD", "UYU"] #Seed to Account table 5.times do @@ -40,7 +40,7 @@ name: Faker::Commerce.department, deleted: boolean.sample, pm_id: rand(0..8), - pm_type: rand(0..8), + pm_type: rand(0..2), budget_period: rand(100..10000), budget_limit: rand(500..5000), include_subcategories: boolean.sample, @@ -65,17 +65,19 @@ ) end +account_all = Account.all.map(&:id) +payee_all = Payee.all.map(&:id) + 10.times do - pm = rand(0..2) - pm_id = rand(0..8) - account = Account.all.map(&:id).sample - payee = Payee.all.map(&:id).sample - + account = account_all.sample + amount = 10 + rand*(10_000) + payee = payee_all.sample + #seed to transaction table Transaction.create( - pm_type: pm, - pm_id: pm_id, + pm_type: rand(0..2), + pm_id: rand(0..8), account_id: account, pm_account_id: account, pm_payee: Payee.find(payee).name, @@ -90,20 +92,36 @@ payee_id: payee, category_id: Category.all.map(&:id).sample, department_id: Department.all.map(&:id).sample, - amount: 10 + rand*(10_000), + amount: amount, cleared: boolean.sample, uuid: Faker::Code.isbn ) - -end -3.times do - transaction_id = Transaction.all.map(&:id).sample - transaction = Transaction.find(transaction_id) - #seed to split table + #create split to transaction + transaction = Transaction.last + num_of_split = rand(1..5) + max_amount_split = amount/(num_of_split - 1) + sum_split_amount = 0 + (num_of_split - 1).times do + split_amount = 1 + rand(max_amount_split) + sum_split_amount += split_amount + Split.create( + pm_id: transaction.pm_id, + transaction_id: transaction.id, + amount: split_amount, + xrate: rand*(5), + category_id: transaction.category_id, + class_id: rand(0..10), + memo: Faker::Lorem.paragraph, + transfer_to_account_id: rand(100), + currency_code: currency.sample, + of_x_id: "dummy" + ) + end + last_split_amount = amount - sum_split_amount Split.create( pm_id: transaction.pm_id, - transaction_id: transaction_id, - amount: transaction.amount, + transaction_id: transaction.id, + amount: last_split_amount, xrate: rand*(5), category_id: transaction.category_id, class_id: rand(0..10), @@ -112,14 +130,7 @@ currency_code: currency.sample, of_x_id: "dummy" ) -end - - - - - - - +end From 3c9404cbc15d34f5cc1f8507143297070d9f6b1f Mon Sep 17 00:00:00 2001 From: Jesus Romero Date: Tue, 15 Oct 2013 11:08:02 -0500 Subject: [PATCH 05/76] change value from true to false --- db/seeds.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/seeds.rb b/db/seeds.rb index 54dfcce..20986f6 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -1,4 +1,4 @@ -boolean = [true] #To have inactive transactions, add false at array [true, false] +boolean = [false] #To have inactive transactions, add true at array [true, false] currency = ["AED", "ALL", "CAD", "CNY", "MXN", "IRR", "JPY", "USD", "UYU"] #Seed to Account table 5.times do From eae53a9e8924f48e83fa2b1ac20a09a032efe9b4 Mon Sep 17 00:00:00 2001 From: Jesus Romero Date: Tue, 15 Oct 2013 11:12:04 -0500 Subject: [PATCH 06/76] increased seeds to transactions and accounts --- db/seeds.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/db/seeds.rb b/db/seeds.rb index 20986f6..455ee5a 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -1,7 +1,7 @@ boolean = [false] #To have inactive transactions, add true at array [true, false] currency = ["AED", "ALL", "CAD", "CNY", "MXN", "IRR", "JPY", "USD", "UYU"] #Seed to Account table -5.times do +10.times do Account.create( deleted: false, pm_id: rand(0..8), @@ -68,7 +68,7 @@ account_all = Account.all.map(&:id) payee_all = Payee.all.map(&:id) -10.times do +30.times do account = account_all.sample amount = 10 + rand*(10_000) From 6a954704f7a2e7a7286fded1ea1ecc797cd507e8 Mon Sep 17 00:00:00 2001 From: Jesus Romero Date: Mon, 14 Oct 2013 16:27:55 -0500 Subject: [PATCH 07/76] added group test in gemfile --- Gemfile | 6 ++++++ Gemfile.lock | 25 +++++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/Gemfile b/Gemfile index bd697e5..a8d12f9 100644 --- a/Gemfile +++ b/Gemfile @@ -47,6 +47,12 @@ gem 'pry-rails' gem 'ruby-progressbar' +group :test do + gem 'rspec' + gem 'capybara' + gem 'factory_girl' +end + # Use ActiveModel has_secure_password # gem 'bcrypt-ruby', '~> 3.0.0' diff --git a/Gemfile.lock b/Gemfile.lock index f7a381a..0d1bb75 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -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) @@ -47,9 +53,12 @@ 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) faker (1.2.0) i18n (~> 0.5) haml (4.0.3) @@ -73,8 +82,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) @@ -106,6 +118,14 @@ 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) ruby-progressbar (1.1.1) sass (3.2.9) sass-rails (4.0.0.rc1) @@ -143,13 +163,17 @@ 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 faker haml jbuilder (~> 1.0.1) @@ -160,6 +184,7 @@ DEPENDENCIES pry-doc pry-rails rails (= 4.0.0.rc1) + rspec ruby-progressbar sass-rails (~> 4.0.0.rc1) sdoc From d82a9ad059021ac71403f6ce7a16fe88f4a16060 Mon Sep 17 00:00:00 2001 From: Jesus Romero Date: Mon, 14 Oct 2013 16:52:54 -0500 Subject: [PATCH 08/76] added rspec-rails --- Gemfile | 1 + Gemfile.lock | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/Gemfile b/Gemfile index a8d12f9..f8659ad 100644 --- a/Gemfile +++ b/Gemfile @@ -49,6 +49,7 @@ gem 'ruby-progressbar' group :test do gem 'rspec' + gem 'rspec-rails' gem 'capybara' gem 'factory_girl' end diff --git a/Gemfile.lock b/Gemfile.lock index 0d1bb75..7de74a2 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -126,6 +126,13 @@ GEM 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) @@ -185,6 +192,7 @@ DEPENDENCIES pry-rails rails (= 4.0.0.rc1) rspec + rspec-rails ruby-progressbar sass-rails (~> 4.0.0.rc1) sdoc From b32d2aad494e5e3f4bc7cd746fea95715a1b3a5e Mon Sep 17 00:00:00 2001 From: Jesus Romero Date: Tue, 15 Oct 2013 09:55:07 -0500 Subject: [PATCH 09/76] added some basic test --- spec/factories/account.rb | 39 +++++++++++++++++++++++++++++++++++++ spec/factories_spec.rb | 13 +++++++++++++ spec/models/account_spec.rb | 10 ++++++++++ spec/spec_helper.rb | 21 ++++++++++++++++++++ 4 files changed, 83 insertions(+) create mode 100644 spec/factories/account.rb create mode 100644 spec/factories_spec.rb create mode 100644 spec/models/account_spec.rb create mode 100644 spec/spec_helper.rb diff --git a/spec/factories/account.rb b/spec/factories/account.rb new file mode 100644 index 0000000..2249665 --- /dev/null +++ b/spec/factories/account.rb @@ -0,0 +1,39 @@ +require 'faker' + +boolean = [true, false] +currency = ["AED", "ALL", "CAD", "CNY", "MXN", "IRR", "JPY", "USD", "UYU"] +FactoryGirl.define do + factory :account do + deleted false + pm_id Faker::Number.digit + pm_account_type Faker::Number.digit + display_order Faker::Number.digit + name Faker::Company.name + balance_overall Faker::Number.digit + balance_cleared Faker::Number.digit + number Faker::Number.number(2) + institution Faker::Company.suffix + phone Faker::PhoneNumber.cell_phone + expiration_date Faker::Business.credit_card_expiry_date.strftime("%d%m%Y") + check_number Faker::Number.digit + notes Faker::Lorem.paragraph + pm_icon "image" + url Faker::Internet.url + of_x_id "dummy" + of_x_url Faker::Internet.domain_word + password Faker::Internet.password + fee Faker::Number.digit + fixed_percent Faker::Number.digit + limit_amount Faker::Number.digit + limit boolean.sample + total_worth boolean.sample + exchange_rate Faker::Number.digit + currency_code currency.sample + last_sync_time Time.now + routing_number Faker::Number.digit + overdraft_account_id Faker::Number.digit + keep_the_change_account_id Faker::Number.digit + heek_change_round_to Faker::Number.digit + uuid Faker::Code.isbn(64) + end +end diff --git a/spec/factories_spec.rb b/spec/factories_spec.rb new file mode 100644 index 0000000..d2e7753 --- /dev/null +++ b/spec/factories_spec.rb @@ -0,0 +1,13 @@ +require 'spec_helper' +describe 'validate FactoryGirl factories' do + FactoryGirl.factories.each do |factory| + context "with factory for: #{factory.name}" do + subject { FactoryGirl.build(factory.name) } + + it "is valid" do + subject.should be_valid if subject.class.ancestors.include?(ActiveRecord::Base) + end + end + end +end + diff --git a/spec/models/account_spec.rb b/spec/models/account_spec.rb new file mode 100644 index 0000000..e59d45c --- /dev/null +++ b/spec/models/account_spec.rb @@ -0,0 +1,10 @@ +require 'spec_helper' + +describe Account do + let(:account) {create(:account)} + + it "has a valid account" do + account.should be_valid + end +end + diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb new file mode 100644 index 0000000..a7c3d62 --- /dev/null +++ b/spec/spec_helper.rb @@ -0,0 +1,21 @@ +ENV["RAILS_ENV"] ||= 'test' +require File.expand_path("../../config/environment", __FILE__) +require 'rspec/rails' +require 'rspec/autorun' + +Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f } + +ActiveRecord::Migration.check_pending! if defined?(ActiveRecord::Migration) + +RSpec.configure do |config| + + config.include FactoryGirl::Syntax::Methods + config.treat_symbols_as_metadata_keys_with_true_values = true + config.use_transactional_fixtures = true + + config.infer_base_class_for_anonymous_controllers = false + + config.order = "random" + + +end From 8649b02ed412f774cb89a4136fc31fdcd9ec82a9 Mon Sep 17 00:00:00 2001 From: Jesus Romero Date: Tue, 15 Oct 2013 09:55:41 -0500 Subject: [PATCH 10/76] added rspec_rails --- Gemfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Gemfile b/Gemfile index f8659ad..e8dc562 100644 --- a/Gemfile +++ b/Gemfile @@ -52,6 +52,7 @@ group :test do gem 'rspec-rails' gem 'capybara' gem 'factory_girl' + gem 'factory_girl_rails' end # Use ActiveModel has_secure_password From cba86f23a01ae594efb75aba4a7198dd3095c08a Mon Sep 17 00:00:00 2001 From: Jesus Romero Date: Tue, 15 Oct 2013 11:06:47 -0500 Subject: [PATCH 11/76] added gems --- Gemfile.lock | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Gemfile.lock b/Gemfile.lock index 7de74a2..accc559 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -59,6 +59,9 @@ GEM 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) @@ -181,6 +184,7 @@ DEPENDENCIES capybara coffee-rails (~> 4.0.0) factory_girl + factory_girl_rails faker haml jbuilder (~> 1.0.1) From 2c68325d545cc144f05e6dce468190a37cff24e3 Mon Sep 17 00:00:00 2001 From: Jesus Romero Date: Tue, 15 Oct 2013 16:24:22 -0500 Subject: [PATCH 12/76] added factories to create account, category, department, payee and transaction --- spec/factories/account.rb | 4 ++-- spec/factories/category.rb | 15 +++++++++++++++ spec/factories/department.rb | 11 +++++++++++ spec/factories/payee.rb | 13 +++++++++++++ spec/factories/transaction.rb | 31 +++++++++++++++++++++++++++++++ 5 files changed, 72 insertions(+), 2 deletions(-) create mode 100644 spec/factories/category.rb create mode 100644 spec/factories/department.rb create mode 100644 spec/factories/payee.rb create mode 100644 spec/factories/transaction.rb diff --git a/spec/factories/account.rb b/spec/factories/account.rb index 2249665..b37cd23 100644 --- a/spec/factories/account.rb +++ b/spec/factories/account.rb @@ -5,8 +5,8 @@ FactoryGirl.define do factory :account do deleted false - pm_id Faker::Number.digit - pm_account_type Faker::Number.digit + pm_id (0..2).to_a.sample + pm_account_type (0..8).to_a.sample display_order Faker::Number.digit name Faker::Company.name balance_overall Faker::Number.digit diff --git a/spec/factories/category.rb b/spec/factories/category.rb new file mode 100644 index 0000000..018c146 --- /dev/null +++ b/spec/factories/category.rb @@ -0,0 +1,15 @@ +require 'faker' + +FactoryGirl.define do + factory :category do + name Faker::Commerce.department + deleted false + pm_id (0..8).to_a.sample + pm_type (0..2).to_a.sample + budget_period (100..1000).to_a.sample + budget_limit (50..500).to_a.sample + include_subcategories false + rollover false + uuid Faker::Code.isbn + end +end diff --git a/spec/factories/department.rb b/spec/factories/department.rb new file mode 100644 index 0000000..a3b4e5d --- /dev/null +++ b/spec/factories/department.rb @@ -0,0 +1,11 @@ +require 'faker' + +FactoryGirl.define do + factory :department do + name Faker::Commerce.product_name + pm_id (0..8).to_a.sample + uuid Faker::Code.isbn + deleted false + end +end + diff --git a/spec/factories/payee.rb b/spec/factories/payee.rb new file mode 100644 index 0000000..934c205 --- /dev/null +++ b/spec/factories/payee.rb @@ -0,0 +1,13 @@ +require 'faker' + +FactoryGirl.define do + factory :payee do + name Faker::Name.name + deleted false + pm_id (0..8).to_a.sample + latitude Faker::Address.latitude + longitude Faker::Address.longitude + uuid Faker::Code.isbn + + end +end diff --git a/spec/factories/transaction.rb b/spec/factories/transaction.rb new file mode 100644 index 0000000..6aef20f --- /dev/null +++ b/spec/factories/transaction.rb @@ -0,0 +1,31 @@ +require 'faker' + +account = FactoryGirl.create(:account) +payee = FactoryGirl.create(:payee) +department = FactoryGirl.create(:department) +category = FactoryGirl.create(:category) + +FactoryGirl.define do + factory :transaction do + pm_type (0..2).to_a.sample + pm_id (0..8).to_a.sample + account_id account.id + pm_account_id account.id + pm_payee payee.name + pm_sub_total (10..10_000).to_a.sample + pm_of_x_id "dummy" + pm_image "dummy" + pm_overdraft_id (1..30).to_a.sample.to_s + date Time.now + deleted false + check_number (1..10).to_a.sample + payee_name payee.name + payee_id payee.id + category_id category.id + department_id department.id + amount Faker::Number.number(2) + cleared true + uuid Faker::Code.isbn + + end +end From 76ff1373ecfa9ae506ecf096e02cca9d048e3dbf Mon Sep 17 00:00:00 2001 From: Jesus Romero Date: Tue, 15 Oct 2013 16:25:01 -0500 Subject: [PATCH 13/76] added test at models --- spec/models/category_spec.rb | 9 +++++++++ spec/models/department_spec.rb | 9 +++++++++ spec/models/payee_spec.rb | 9 +++++++++ spec/models/transaction_spec.rb | 9 +++++++++ 4 files changed, 36 insertions(+) create mode 100644 spec/models/category_spec.rb create mode 100644 spec/models/department_spec.rb create mode 100644 spec/models/payee_spec.rb create mode 100644 spec/models/transaction_spec.rb diff --git a/spec/models/category_spec.rb b/spec/models/category_spec.rb new file mode 100644 index 0000000..5396105 --- /dev/null +++ b/spec/models/category_spec.rb @@ -0,0 +1,9 @@ +require 'spec_helper' + +describe Category do + let(:category) {create(:category)} + + it "has a valid category" do + category.should be_valid + end +end diff --git a/spec/models/department_spec.rb b/spec/models/department_spec.rb new file mode 100644 index 0000000..343e023 --- /dev/null +++ b/spec/models/department_spec.rb @@ -0,0 +1,9 @@ +require 'department' + +describe Department do + let(:department) {create(:department)} + + it "has avalid department" do + department.should be_valid + end +end diff --git a/spec/models/payee_spec.rb b/spec/models/payee_spec.rb new file mode 100644 index 0000000..eeb8cf0 --- /dev/null +++ b/spec/models/payee_spec.rb @@ -0,0 +1,9 @@ +require 'spec_helper' + +describe Payee do + let(:payee) {create(:payee)} + + it "has a valid payee" do + payee.should be_valid + end +end diff --git a/spec/models/transaction_spec.rb b/spec/models/transaction_spec.rb new file mode 100644 index 0000000..85c7179 --- /dev/null +++ b/spec/models/transaction_spec.rb @@ -0,0 +1,9 @@ +require 'spec_helper' + +describe Transaction do + let(:transaction) {create(:transaction)} + + it "has a valid transaction" do + transaction.should be_valid + end +end From 4803fe5f6f3a8dddffd8fee547265067705281c7 Mon Sep 17 00:00:00 2001 From: Jesus Romero Date: Tue, 15 Oct 2013 16:39:34 -0500 Subject: [PATCH 14/76] refactored seed in create transactions --- db/seeds.rb | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/db/seeds.rb b/db/seeds.rb index 455ee5a..7fd3892 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -65,22 +65,19 @@ ) end -account_all = Account.all.map(&:id) -payee_all = Payee.all.map(&:id) 30.times do - - account = account_all.sample + payee = Payee.all.sample + account = Account.all.sample amount = 10 + rand*(10_000) - payee = payee_all.sample #seed to transaction table Transaction.create( pm_type: rand(0..2), pm_id: rand(0..8), - account_id: account, - pm_account_id: account, - pm_payee: Payee.find(payee).name, + account_id: account.id, + pm_account_id: account.pm_id, + pm_payee: payee.pm_id, pm_sub_total: rand*(1_000), pm_of_x_id: "dummy", pm_image: "dummy", @@ -88,8 +85,8 @@ date: Time.now - rand(0..60).days, deleted: boolean.sample, check_number: rand(10).to_s, - payee_name: Payee.find(payee).name, - payee_id: payee, + payee_name: payee.name, + payee_id: payee.id, category_id: Category.all.map(&:id).sample, department_id: Department.all.map(&:id).sample, amount: amount, From 6efcd2c69d38a85a448c75e5c2800ebdb7efccd5 Mon Sep 17 00:00:00 2001 From: Jesus Romero Date: Tue, 15 Oct 2013 16:40:43 -0500 Subject: [PATCH 15/76] increased number of seeds --- db/seeds.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/db/seeds.rb b/db/seeds.rb index 7fd3892..34aafb4 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -1,7 +1,7 @@ boolean = [false] #To have inactive transactions, add true at array [true, false] currency = ["AED", "ALL", "CAD", "CNY", "MXN", "IRR", "JPY", "USD", "UYU"] #Seed to Account table -10.times do +15.times do Account.create( deleted: false, pm_id: rand(0..8), @@ -66,7 +66,7 @@ end -30.times do +40.times do payee = Payee.all.sample account = Account.all.sample amount = 10 + rand*(10_000) From 46f7ab22aa34586f765f2cbab164082243eed6bc Mon Sep 17 00:00:00 2001 From: Jesus Romero Date: Tue, 15 Oct 2013 18:50:29 -0500 Subject: [PATCH 16/76] added factories and refactored factory to account --- Gemfile | 3 +-- spec/factories/account.rb | 24 ++++++++++++------------ spec/factories/split.rb | 20 ++++++++++++++++++++ spec/factories/transaction.rb | 16 ++++++++-------- spec/factories_spec.rb | 1 + spec/models/split_spec.rb | 10 ++++++++++ 6 files changed, 52 insertions(+), 22 deletions(-) create mode 100644 spec/factories/split.rb create mode 100644 spec/models/split_spec.rb diff --git a/Gemfile b/Gemfile index e8dc562..eb59ee3 100644 --- a/Gemfile +++ b/Gemfile @@ -52,9 +52,8 @@ group :test do gem 'rspec-rails' gem 'capybara' gem 'factory_girl' - gem 'factory_girl_rails' end - +gem 'factory_girl_rails' # Use ActiveModel has_secure_password # gem 'bcrypt-ruby', '~> 3.0.0' diff --git a/spec/factories/account.rb b/spec/factories/account.rb index b37cd23..f52af00 100644 --- a/spec/factories/account.rb +++ b/spec/factories/account.rb @@ -7,33 +7,33 @@ deleted false pm_id (0..2).to_a.sample pm_account_type (0..8).to_a.sample - display_order Faker::Number.digit + display_order (1..9).to_a.sample name Faker::Company.name - balance_overall Faker::Number.digit - balance_cleared Faker::Number.digit + balance_overall (1..9).to_a.sample + balance_cleared (1..9).to_a.sample number Faker::Number.number(2) institution Faker::Company.suffix phone Faker::PhoneNumber.cell_phone expiration_date Faker::Business.credit_card_expiry_date.strftime("%d%m%Y") - check_number Faker::Number.digit + check_number (1..9).to_a.sample notes Faker::Lorem.paragraph pm_icon "image" url Faker::Internet.url of_x_id "dummy" of_x_url Faker::Internet.domain_word password Faker::Internet.password - fee Faker::Number.digit - fixed_percent Faker::Number.digit - limit_amount Faker::Number.digit + fee (1..9).to_a.sample + fixed_percent (1..9).to_a.sample + limit_amount (1..9).to_a.sample limit boolean.sample total_worth boolean.sample - exchange_rate Faker::Number.digit + exchange_rate (1..9).to_a.sample currency_code currency.sample last_sync_time Time.now - routing_number Faker::Number.digit - overdraft_account_id Faker::Number.digit - keep_the_change_account_id Faker::Number.digit - heek_change_round_to Faker::Number.digit + routing_number (1..9).to_a.sample + overdraft_account_id (1..9).to_a.sample + keep_the_change_account_id (1..9).to_a.sample + heek_change_round_to (1..9).to_a.sample uuid Faker::Code.isbn(64) end end diff --git a/spec/factories/split.rb b/spec/factories/split.rb new file mode 100644 index 0000000..68fa4c8 --- /dev/null +++ b/spec/factories/split.rb @@ -0,0 +1,20 @@ +require 'faker' + +currency = ["AED", "ALL", "CAD", "CNY", "MXN", "IRR", "JPY", "USD", "UYU"] +transaction = FactoryGirl.create(:transaction) +FactoryGirl.define do + factory :split do + pm_id transaction.pm_id + transaction_id transaction.id + amount transaction.amount + xrate (1..10).to_a.sample + category_id transaction.category_id + class_id (0..10).to_a.sample + memo Faker::Lorem.paragraph + transfer_to_account_id (1..100).to_a.sample + currency_code currency.sample + x_of_id "dummy" + end +end + + diff --git a/spec/factories/transaction.rb b/spec/factories/transaction.rb index 6aef20f..4d80912 100644 --- a/spec/factories/transaction.rb +++ b/spec/factories/transaction.rb @@ -1,18 +1,18 @@ require 'faker' -account = FactoryGirl.create(:account) -payee = FactoryGirl.create(:payee) -department = FactoryGirl.create(:department) -category = FactoryGirl.create(:category) +account = FactoryGirl.create(:account) +payee = FactoryGirl.create(:payee) +department = FactoryGirl.create(:department) +category = FactoryGirl.create(:category) FactoryGirl.define do factory :transaction do pm_type (0..2).to_a.sample pm_id (0..8).to_a.sample account_id account.id - pm_account_id account.id + pm_account_id account.pm_id pm_payee payee.name - pm_sub_total (10..10_000).to_a.sample + pm_sub_total (10..10_000).to_a.sample pm_of_x_id "dummy" pm_image "dummy" pm_overdraft_id (1..30).to_a.sample.to_s @@ -20,12 +20,12 @@ deleted false check_number (1..10).to_a.sample payee_name payee.name - payee_id payee.id + payee_id payee.pm_id category_id category.id department_id department.id amount Faker::Number.number(2) cleared true uuid Faker::Code.isbn - end end + diff --git a/spec/factories_spec.rb b/spec/factories_spec.rb index d2e7753..83a1c36 100644 --- a/spec/factories_spec.rb +++ b/spec/factories_spec.rb @@ -2,6 +2,7 @@ describe 'validate FactoryGirl factories' do FactoryGirl.factories.each do |factory| context "with factory for: #{factory.name}" do + #binding.pry subject { FactoryGirl.build(factory.name) } it "is valid" do diff --git a/spec/models/split_spec.rb b/spec/models/split_spec.rb new file mode 100644 index 0000000..b957b06 --- /dev/null +++ b/spec/models/split_spec.rb @@ -0,0 +1,10 @@ +require 'spec_helper' + +describe Split do + let(:split) {create(:account)} + + it "has a valid split" do + split.should be_valid + end +end + From 53726c8f97cfff8867138618bf7c1897c89ae297 Mon Sep 17 00:00:00 2001 From: Jesus Romero Date: Wed, 16 Oct 2013 11:07:57 -0500 Subject: [PATCH 17/76] change factory split at transaction factory file --- spec/factories/payee.rb | 2 +- spec/factories/split.rb | 36 +++++++++++++++++------------------ spec/factories/transaction.rb | 19 ++++++++++++++++++ spec/factories_spec.rb | 1 - spec/models/split_spec.rb | 2 +- 5 files changed, 38 insertions(+), 22 deletions(-) diff --git a/spec/factories/payee.rb b/spec/factories/payee.rb index 934c205..e967919 100644 --- a/spec/factories/payee.rb +++ b/spec/factories/payee.rb @@ -2,7 +2,7 @@ FactoryGirl.define do factory :payee do - name Faker::Name.name + name Faker::Name.name deleted false pm_id (0..8).to_a.sample latitude Faker::Address.latitude diff --git a/spec/factories/split.rb b/spec/factories/split.rb index 68fa4c8..41e5390 100644 --- a/spec/factories/split.rb +++ b/spec/factories/split.rb @@ -1,20 +1,18 @@ -require 'faker' - -currency = ["AED", "ALL", "CAD", "CNY", "MXN", "IRR", "JPY", "USD", "UYU"] -transaction = FactoryGirl.create(:transaction) -FactoryGirl.define do - factory :split do - pm_id transaction.pm_id - transaction_id transaction.id - amount transaction.amount - xrate (1..10).to_a.sample - category_id transaction.category_id - class_id (0..10).to_a.sample - memo Faker::Lorem.paragraph - transfer_to_account_id (1..100).to_a.sample - currency_code currency.sample - x_of_id "dummy" - end -end - +#require 'faker' +#currency = ["AED", "ALL", "CAD", "CNY", "MXN", "IRR", "JPY", "USD", "UYU"] +#transaction = FactoryGirl.create(:transaction) +#FactoryGirl.define do + #factory :split do + #pm_id transaction.pm_id + #transaction_id transaction.id + #amount transaction.amount + #xrate (1..10).to_a.sample + #category_id transaction.category_id + #class_id (0..10).to_a.sample + #memo Faker::Lorem.paragraph + #transfer_to_account_id (1..100).to_a.sample + #currency_code currency.sample + #of_x_id "dummy" + #end +#end diff --git a/spec/factories/transaction.rb b/spec/factories/transaction.rb index 4d80912..60afb1a 100644 --- a/spec/factories/transaction.rb +++ b/spec/factories/transaction.rb @@ -1,10 +1,12 @@ require 'faker' +currency = ["AED", "ALL", "CAD", "CNY", "MXN", "IRR", "JPY", "USD", "UYU"] account = FactoryGirl.create(:account) payee = FactoryGirl.create(:payee) department = FactoryGirl.create(:department) category = FactoryGirl.create(:category) + FactoryGirl.define do factory :transaction do pm_type (0..2).to_a.sample @@ -29,3 +31,20 @@ end end +transaction = FactoryGirl.create(:transaction) + +FactoryGirl.define do + factory :split do + pm_id transaction.pm_id + transaction_id transaction.id + amount transaction.amount + xrate (1..10).to_a.sample + category_id transaction.category_id + class_id (0..10).to_a.sample + memo Faker::Lorem.paragraph + transfer_to_account_id (1..100).to_a.sample + currency_code currency.sample + of_x_id "dummy" + end +end + diff --git a/spec/factories_spec.rb b/spec/factories_spec.rb index 83a1c36..d2e7753 100644 --- a/spec/factories_spec.rb +++ b/spec/factories_spec.rb @@ -2,7 +2,6 @@ describe 'validate FactoryGirl factories' do FactoryGirl.factories.each do |factory| context "with factory for: #{factory.name}" do - #binding.pry subject { FactoryGirl.build(factory.name) } it "is valid" do diff --git a/spec/models/split_spec.rb b/spec/models/split_spec.rb index b957b06..edb1ab6 100644 --- a/spec/models/split_spec.rb +++ b/spec/models/split_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' describe Split do - let(:split) {create(:account)} + let(:split) {create(:split)} it "has a valid split" do split.should be_valid From c5a1ccc119c21640c973c411d18d9e716e0ec0b7 Mon Sep 17 00:00:00 2001 From: Jesus Romero Date: Wed, 16 Oct 2013 12:30:38 -0500 Subject: [PATCH 18/76] created spec/controllers folder and test to index in TransactionsController --- spec/controllers/transactions_controller_spec.rb | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 spec/controllers/transactions_controller_spec.rb diff --git a/spec/controllers/transactions_controller_spec.rb b/spec/controllers/transactions_controller_spec.rb new file mode 100644 index 0000000..3943e69 --- /dev/null +++ b/spec/controllers/transactions_controller_spec.rb @@ -0,0 +1,9 @@ +require 'spec_helper' +describe TransactionsController do + describe "Get index" do + it "render the index templates" do + get :index + expect(response).to render_template("index") + end + end +end From 66e875db38ed0a39cfcdd5e262a82251aef8201b Mon Sep 17 00:00:00 2001 From: Jesus Romero Date: Wed, 16 Oct 2013 13:20:45 -0500 Subject: [PATCH 19/76] added test to get methods --- .../transactions_controller_spec.rb | 30 ++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/spec/controllers/transactions_controller_spec.rb b/spec/controllers/transactions_controller_spec.rb index 3943e69..4692cee 100644 --- a/spec/controllers/transactions_controller_spec.rb +++ b/spec/controllers/transactions_controller_spec.rb @@ -1,9 +1,37 @@ require 'spec_helper' describe TransactionsController do + let(:transaction) { create(:transaction) } + #spec to GET methods describe "Get index" do - it "render the index templates" do + it "should render the index templates" do get :index expect(response).to render_template("index") end + it "should response with 200 http code" do + get :index + response.should be_succes + end + end + + describe 'GET #new' do + it 'should render new template' do + get :new + response.should render_template :new + end + it 'should response with 200 code' do + get :new + response.should be_success + end + end + + describe 'GET #show' do + it 'should redirect to #show view' do + get :show, id: transaction + response.should render_template :show + end + it 'should response with 200 http code' do + get :show, id: transaction + response.should be_success + end end end From 68a51ab9f940c2fd6ad87cb049966f85cc00a67e Mon Sep 17 00:00:00 2001 From: Jesus Romero Date: Wed, 16 Oct 2013 13:24:29 -0500 Subject: [PATCH 20/76] completed get methods --- spec/controllers/transactions_controller_spec.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/spec/controllers/transactions_controller_spec.rb b/spec/controllers/transactions_controller_spec.rb index 4692cee..a8519e7 100644 --- a/spec/controllers/transactions_controller_spec.rb +++ b/spec/controllers/transactions_controller_spec.rb @@ -34,4 +34,16 @@ response.should be_success end end + + describe 'GET #edit' do + it 'should render #edit view' do + get :edit, id: transaction + response.should render_template :edit + end + it 'should response with 200 http code' do + get :edit, id: transaction + response.should be_success + end + end + end From 4bbee80afeac57c33712d1d649eafc38c87ad566 Mon Sep 17 00:00:00 2001 From: Jesus Romero Date: Wed, 16 Oct 2013 15:05:58 -0500 Subject: [PATCH 21/76] add test to create method --- spec/controllers/transactions_controller_spec.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/spec/controllers/transactions_controller_spec.rb b/spec/controllers/transactions_controller_spec.rb index a8519e7..20b0d9d 100644 --- a/spec/controllers/transactions_controller_spec.rb +++ b/spec/controllers/transactions_controller_spec.rb @@ -45,5 +45,17 @@ response.should be_success end end + #spec to post methods + describe 'POST #create' do + it 'should create a new transaction' do + expect{ + post :create, transaction: attributes_for(:transaction) + }.to change(Transaction, :count).by(1) + end + it 'should redirect to #show view' do + post :create, transaction: attributes_for(:transaction) + response.should redirect_to Transaction.last + end + end end From 98668cb0f7d1f9da8e1a810ba042a6ec3b76bfd7 Mon Sep 17 00:00:00 2001 From: Jesus Romero Date: Wed, 16 Oct 2013 15:20:04 -0500 Subject: [PATCH 22/76] added vadilation of presece to transaction model in amount and account_id --- app/models/transaction.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/models/transaction.rb b/app/models/transaction.rb index f817a05..1e456a1 100644 --- a/app/models/transaction.rb +++ b/app/models/transaction.rb @@ -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 From 206e87ed40ef65bf5c10bc958c474511e26f647a Mon Sep 17 00:00:00 2001 From: Jesus Romero Date: Wed, 16 Oct 2013 15:20:35 -0500 Subject: [PATCH 23/76] added test to create method --- spec/controllers/transactions_controller_spec.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/spec/controllers/transactions_controller_spec.rb b/spec/controllers/transactions_controller_spec.rb index 20b0d9d..eab83a2 100644 --- a/spec/controllers/transactions_controller_spec.rb +++ b/spec/controllers/transactions_controller_spec.rb @@ -47,6 +47,7 @@ end #spec to post methods describe 'POST #create' do + context "valid attributes" do it 'should create a new transaction' do expect{ post :create, transaction: attributes_for(:transaction) @@ -56,6 +57,19 @@ post :create, transaction: attributes_for(:transaction) response.should redirect_to Transaction.last end + end + context "invalid attributes" do + it 'should not create a new transaction' do + expect{ + post :create, transaction: attributes_for(:transaction, account_id: nil, amount: nil) + }.to_not change(Transaction, :count) + end + it 'should render to #new view' do + post :create, transaction: attributes_for(:transaction, account_id: nil, amount: nil) + response.should render_template :new + end + + end end end From aa3a64d7999a29ad1c2290bbfe4661478ba72540 Mon Sep 17 00:00:00 2001 From: Jesus Romero Date: Wed, 16 Oct 2013 18:24:45 -0500 Subject: [PATCH 24/76] added tests to transactions controller in put method --- Gemfile | 3 +- .../transactions_controller_spec.rb | 39 +++++++++++++++++++ spec/spec_helper.rb | 1 + 3 files changed, 42 insertions(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index eb59ee3..e8dc562 100644 --- a/Gemfile +++ b/Gemfile @@ -52,8 +52,9 @@ group :test do gem 'rspec-rails' gem 'capybara' gem 'factory_girl' + gem 'factory_girl_rails' end -gem 'factory_girl_rails' + # Use ActiveModel has_secure_password # gem 'bcrypt-ruby', '~> 3.0.0' diff --git a/spec/controllers/transactions_controller_spec.rb b/spec/controllers/transactions_controller_spec.rb index eab83a2..037f4a5 100644 --- a/spec/controllers/transactions_controller_spec.rb +++ b/spec/controllers/transactions_controller_spec.rb @@ -72,4 +72,43 @@ end end + #spec to put method + describe 'PUT #update' do + new_uuid = "12yag172-1721nh-12" + new_amount = 99_999 + context 'valid attributes' do + it 'should located the requested transaction' do + put :update, id: transaction, transaction: FactoryGirl.attributes_for(:transaction) + assigns(:transaction).should eq(transaction) + end + it "should change the transaction's attributes" do + put :update, id: transaction, + transaction: FactoryGirl.attributes_for(:transaction, amount: new_amount) + transaction.reload + transaction.amount.should eq(new_amount) + end + it "should redirect to #show view" do + put :update, id: transaction, transaction: FactoryGirl.attributes_for(:transaction) + response.should redirect_to transaction + end + end + context 'invalid attributes' do + it 'should not located the requested boook' do + put :update, id: transaction, transaction: FactoryGirl.attributes_for(:transaction, uuid: nil, amount: nil) + assigns(:transaction2).should_not eq(transaction) + end + it "should not change the transaction's attributes" do + put :update, id: transaction, + transaction: FactoryGirl.attributes_for(:transaction, uuid: nil, amount: nil) + transaction.reload + transaction.amount.should_not eq(new_amount) + transaction.uuid.should_not eq(new_uuid) + end + it "should redirect to #edit view" do + put :update, id: transaction, + transaction: attributes_for(:transaction, uuid: nil, amount: nil) + response.should render_template :edit + end + end + end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index a7c3d62..dc2c0d4 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -2,6 +2,7 @@ require File.expand_path("../../config/environment", __FILE__) require 'rspec/rails' require 'rspec/autorun' +require 'factory_girl_rails' Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f } From 9b2256b18fef4ca2b0e522f65200649598343a16 Mon Sep 17 00:00:00 2001 From: Jesus Romero Date: Thu, 17 Oct 2013 15:57:51 -0500 Subject: [PATCH 25/76] uncommented require pocket_money --- config/initializers/pocket_money.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/initializers/pocket_money.rb b/config/initializers/pocket_money.rb index 37ad7c4..d147d71 100644 --- a/config/initializers/pocket_money.rb +++ b/config/initializers/pocket_money.rb @@ -1 +1 @@ -#require 'pocket_money' +require 'pocket_money' From 338aeea7c7c9313720a5b13b3342cbed18329965 Mon Sep 17 00:00:00 2001 From: Jesus Romero Date: Thu, 17 Oct 2013 15:58:43 -0500 Subject: [PATCH 26/76] ignored my database --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index ac13607..f627f9e 100644 --- a/.gitignore +++ b/.gitignore @@ -18,5 +18,5 @@ config/database.yml config/config.yml - +PocketMoneyDB.sql **/.DS_Store From 2d2120ed656f06aadf2df56938437c121b7f4c64 Mon Sep 17 00:00:00 2001 From: Jesus Romero Date: Thu, 17 Oct 2013 16:00:45 -0500 Subject: [PATCH 27/76] reverted change in category_name --- app/views/transactions/_transaction.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/transactions/_transaction.haml b/app/views/transactions/_transaction.haml index 76a66b7..b4a566b 100644 --- a/app/views/transactions/_transaction.haml +++ b/app/views/transactions/_transaction.haml @@ -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_id + %td= transaction.category_name %td.currency= money transaction.amount - if show_balance From aa391970f7926907ab15f2990c4b0e6d0cc25e80 Mon Sep 17 00:00:00 2001 From: Jesus Romero Date: Fri, 18 Oct 2013 11:12:39 -0500 Subject: [PATCH 28/76] comented code --- app/views/transactions/show.html.erb | 40 ++++++++++++++-------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/app/views/transactions/show.html.erb b/app/views/transactions/show.html.erb index 88f1c1a..ed4e5f8 100644 --- a/app/views/transactions/show.html.erb +++ b/app/views/transactions/show.html.erb @@ -25,15 +25,15 @@ <%= @transaction.category_id %>

-

- Class: - <%= @transaction.class_id %> -

+<%#

%> + <%#Class:%> + <%#<%= @transaction.class_id%>%> +<%#

%> -

- Memo: - <%= @transaction.memo %> -

+<%#

%> + <%#Memo:%> + <%#<%= @transaction.memo %>%> +<%#

%>

Amount: @@ -45,20 +45,20 @@ <%= @transaction.cleared %>

-

- Currency: - <%= @transaction.currency_id %> -

+<%#

%> + <%#Currency:%> + <%#<%= @transaction.currency_id %>%> +<%#

%> -

- Currency exchange rate: - <%= @transaction.currency_exchange_rate %> -

+<%#

%> + <%#Currency exchange rate:%> + <%#<%= @transaction.currency_exchange_rate %>%> +<%#

%> -

- Balance: - <%= @transaction.balance %> -

+<%#

%> + <%#Balance:%> + <%#<%= @transaction.balance %>%> +<%#

%> <%= link_to 'Edit', edit_transaction_path(@transaction) %> | <%= link_to 'Back', transactions_path %> From 3783baac5bc6c64902e1094054b907dbd244a094 Mon Sep 17 00:00:00 2001 From: Jesus Romero Date: Mon, 21 Oct 2013 13:36:48 -0500 Subject: [PATCH 29/76] added database cleaner gem --- Gemfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Gemfile b/Gemfile index e8dc562..a530cf3 100644 --- a/Gemfile +++ b/Gemfile @@ -48,6 +48,7 @@ gem 'pry-rails' gem 'ruby-progressbar' group :test do + gem 'database_cleaner' gem 'rspec' gem 'rspec-rails' gem 'capybara' From b9b05aba210eaa6ad22269a14538b52a6c28281e Mon Sep 17 00:00:00 2001 From: Jesus Romero Date: Mon, 21 Oct 2013 13:37:40 -0500 Subject: [PATCH 30/76] add validation for test enviroment --- Gemfile.lock | 2 ++ lib/pocket_money/tables.rb | 8 +++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index accc559..6b1c953 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -53,6 +53,7 @@ GEM execjs coffee-script-source (1.6.2) commonjs (0.2.6) + database_cleaner (1.2.0) diff-lcs (1.2.4) erubis (2.7.0) execjs (1.4.0) @@ -183,6 +184,7 @@ PLATFORMS DEPENDENCIES capybara coffee-rails (~> 4.0.0) + database_cleaner factory_girl factory_girl_rails faker diff --git a/lib/pocket_money/tables.rb b/lib/pocket_money/tables.rb index 9de66b2..369a5d7 100644 --- a/lib/pocket_money/tables.rb +++ b/lib/pocket_money/tables.rb @@ -1,8 +1,11 @@ - class PocketMoney module BaseTable def self.included(main) - main.establish_connection(adapter: :sqlite3, database: APP_CONFIG['pocket_money_database'], encoding:'iso-8859') + if ENV["RAILS_ENV"] != 'test' + main.establish_connection(adapter: :sqlite3, database: APP_CONFIG['pocket_money_database'], encoding:'iso-8859') + else + main.establish_connection(adapter: :sqlite3, database: APP_CONFIG['pocket_money_database_test'], encoding:'iso-8859') + end main.table_name = main.name.demodulize.sub(/(\w)/) {|w| w.downcase} main.inheritance_column = "rails_type" end @@ -10,7 +13,6 @@ def self.included(main) class Accounts < ActiveRecord::Base include BaseTable - end class Categories < ActiveRecord::Base include BaseTable From 6d9f24f8b27a65b18172d6ba7199457947d60a67 Mon Sep 17 00:00:00 2001 From: Jesus Romero Date: Mon, 21 Oct 2013 13:39:25 -0500 Subject: [PATCH 31/76] ignored test database --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index f627f9e..885f2a4 100644 --- a/.gitignore +++ b/.gitignore @@ -19,4 +19,5 @@ config/database.yml config/config.yml PocketMoneyDB.sql +PocketMoneyDBtest.sql **/.DS_Store From a35bbd3bdc90138ebfafbc5330391204b46c9dea Mon Sep 17 00:00:00 2001 From: Jesus Romero Date: Mon, 21 Oct 2013 13:42:34 -0500 Subject: [PATCH 32/76] added test to import pocket money database --- spec/lib/pocket_money_spec.rb | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 spec/lib/pocket_money_spec.rb diff --git a/spec/lib/pocket_money_spec.rb b/spec/lib/pocket_money_spec.rb new file mode 100644 index 0000000..4332ed1 --- /dev/null +++ b/spec/lib/pocket_money_spec.rb @@ -0,0 +1,19 @@ +require 'spec_helper' +require 'rake' +require 'pocket_money' +Bernard::Application.load_tasks +describe PocketMoney do + context "import data for a database knowed" do + + before (:all) do + Rake::Task['db:drop'].invoke + Rake::Task['db:create'].invoke + Rake::Task['db:migrate'].invoke + PocketMoney.import + end + + it "should have 3 accounts" do + (Account.all.count).should eq(3) + end + end +end From 17fdfbc7ab09f427ef460622c81f865fdbde5419 Mon Sep 17 00:00:00 2001 From: Jesus Romero Date: Mon, 21 Oct 2013 16:41:12 -0500 Subject: [PATCH 33/76] added some test at import proccess --- spec/lib/pocket_money_spec.rb | 67 +++++++++++++++++++++++++++++++++-- 1 file changed, 65 insertions(+), 2 deletions(-) diff --git a/spec/lib/pocket_money_spec.rb b/spec/lib/pocket_money_spec.rb index 4332ed1..db27692 100644 --- a/spec/lib/pocket_money_spec.rb +++ b/spec/lib/pocket_money_spec.rb @@ -3,7 +3,7 @@ require 'pocket_money' Bernard::Application.load_tasks describe PocketMoney do - context "import data for a database knowed" do + context "import data for a known database" do before (:all) do Rake::Task['db:drop'].invoke @@ -11,9 +11,72 @@ Rake::Task['db:migrate'].invoke PocketMoney.import end - + #Table accounts it "should have 3 accounts" do (Account.all.count).should eq(3) end + + it "should have 3 knowed account" do + (Account.all.map(&:name).sort).should eq(["Cuenta Ahorro", "Efectivo", "Tarjeta"]) + end + + it "should have $1,650.00 current balance in 'cuenta ahorro'" do + (Account.find_by_name("Cuenta Ahorro").current_balance.to_f).should eq(1650) + end + + it "should have $740 current balance in 'efectivo'" do + (Account.find_by_name("Efectivo").current_balance.to_f).should eq(740) + end + + it "should have $740 current balance in 'tarjeta'" do + (Account.find_by_name("Tarjeta").current_balance.to_f).should eq(350) + end + + #table transactions + it "should have 35 transactions" do + (Transaction.all.count).should eq(35) + end + + it "should have transactions with account id" do + ids_array = Transaction.all.map(&:account_id) + ids_array.include?(nil).should eq(false) + ids_array.include?("").should eq(false) + end + + it "should have transactions with amount" do + amount_array = Transaction.all.map(&:amount) + amount_array.include?(nil).should eq(false) + amount_array.include?("").should eq(false) + end + + it "first transaction should have category id 16" do + transaction = Transaction.first + (transaction.category_id).should eq(16) + end + + it "first transaction should have class personal" do + transaction = Transaction.first + (transaction.department_id).should eq(1) + end + #table split + it "all aplits should have a transaction id" do + all_splits = Split.all.map(&:transaction_id) + all_splits.include?(nil).should eq(false) + all_splits.include?("").should eq(false) + end + + it "the sum of the splits of a transactions should have same amount that transaction " do + 35.times do |count| + transaction = Transaction.find(count+1) + splits = transaction.splits + (splits.map(&:amount).sum.to_f).should eq(transaction.amount) + end + end + + it "first split should have a class id 1" do + split = Split.first + (split.class_id).should eq(1) + end + end end From 45eb3a6571bb0437e922b1b141da4f2d4a49710e Mon Sep 17 00:00:00 2001 From: Jesus Romero Date: Mon, 21 Oct 2013 19:00:00 -0500 Subject: [PATCH 34/76] added test --- spec/lib/pocket_money_spec.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/spec/lib/pocket_money_spec.rb b/spec/lib/pocket_money_spec.rb index db27692..e2dd606 100644 --- a/spec/lib/pocket_money_spec.rb +++ b/spec/lib/pocket_money_spec.rb @@ -23,6 +23,10 @@ it "should have $1,650.00 current balance in 'cuenta ahorro'" do (Account.find_by_name("Cuenta Ahorro").current_balance.to_f).should eq(1650) end + + it "the second account should have a limit of $100" do + (Account.find(2).limit_amount.to_f).should eq(100) + end it "should have $740 current balance in 'efectivo'" do (Account.find_by_name("Efectivo").current_balance.to_f).should eq(740) @@ -78,5 +82,16 @@ (split.class_id).should eq(1) end + #table department <--- class + it "should have personal and negocios classes" do + (Department.all.map(&:name)).should eq(["Personal", "Negocios"]) + end + + it "all class should have a uuid" do + departments = Department.all.map(&:uuid) + (departments.include?(nil)).should eq(false) + (departments.include?("")).should eq(false) + end + end end From 48f2bc62ab099d892d3716feb119fc790d79b54e Mon Sep 17 00:00:00 2001 From: Jesus Romero Date: Tue, 22 Oct 2013 10:47:06 -0500 Subject: [PATCH 35/76] deleted comented lines --- app/views/transactions/show.html.erb | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/app/views/transactions/show.html.erb b/app/views/transactions/show.html.erb index ed4e5f8..98f3edb 100644 --- a/app/views/transactions/show.html.erb +++ b/app/views/transactions/show.html.erb @@ -25,15 +25,6 @@ <%= @transaction.category_id %>

-<%#

%> - <%#Class:%> - <%#<%= @transaction.class_id%>%> -<%#

%> - -<%#

%> - <%#Memo:%> - <%#<%= @transaction.memo %>%> -<%#

%>

Amount: @@ -45,20 +36,7 @@ <%= @transaction.cleared %>

-<%#

%> - <%#Currency:%> - <%#<%= @transaction.currency_id %>%> -<%#

%> - -<%#

%> - <%#Currency exchange rate:%> - <%#<%= @transaction.currency_exchange_rate %>%> -<%#

%> -<%#

%> - <%#Balance:%> - <%#<%= @transaction.balance %>%> -<%#

%> <%= link_to 'Edit', edit_transaction_path(@transaction) %> | <%= link_to 'Back', transactions_path %> From 113782ed14ac564f70bbbb62124444ff44d3a70b Mon Sep 17 00:00:00 2001 From: Jesus Romero Date: Tue, 22 Oct 2013 10:51:28 -0500 Subject: [PATCH 36/76] moved database test at spec folder --- .gitignore | 1 - spec/PocketMoneyDBtest.sql | Bin 0 -> 245760 bytes 2 files changed, 1 deletion(-) create mode 100644 spec/PocketMoneyDBtest.sql diff --git a/.gitignore b/.gitignore index 885f2a4..f627f9e 100644 --- a/.gitignore +++ b/.gitignore @@ -19,5 +19,4 @@ config/database.yml config/config.yml PocketMoneyDB.sql -PocketMoneyDBtest.sql **/.DS_Store diff --git a/spec/PocketMoneyDBtest.sql b/spec/PocketMoneyDBtest.sql new file mode 100644 index 0000000000000000000000000000000000000000..bf3ec98ca95d444459a0b6e96ad1ea79cf446a35 GIT binary patch literal 245760 zcmeI53zQsJd7!(xdipUv-FKvs)EbS(>d{z8ji*e#x~du*$)nNOR*)qznvvwhMpI9z zaZmTSyGKZHAVfZnU_ulXR_g39{{B`V2hpKJ2=rx*4X1l1whGQHT zyQx@=#bQ5#|8IoHnO*HTBh0E44ZK$H{{O2NRDaevK#bFT@+M$Ku-Ml)ixYi-!uS!o&o3kKHz{ znroYF_jIFKbz9x7(V4l~>G|2>{Pg}qv&C+FagXEH+_vjv;J5$Ckwdf7hl>YhZ=PN_ zG+z{_+SMhu)i#%wA@$(l`Po}$=ca2#6l|$ zO|{(SS+~i`XDX+vb-T9WxW`tkZp+qbO|wy}H6Uj(`dicJlCm{fxMhNiRqKv>u61_} zOz4!k(r&Q*Q{56yN!{&j&~1tNEy==lW8B?L(5u$kZu3}B)t0~8+8Xr3!NUh;PZn3n z6ptJZqFTj0VIxboZcY|%jw|zQQ{CAhk!6U&_G)rHenmDODI7JOVs)E20DthEaV%=zYKV<}RDDH=E5h{l+<-B_u& zqej^=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0 HcmV?d00001 From 9191fcc6ad2587868bc1270c5776a74d2571d184 Mon Sep 17 00:00:00 2001 From: Jesus Romero Date: Tue, 22 Oct 2013 10:52:45 -0500 Subject: [PATCH 37/76] uncommented line in transaction model --- app/models/transaction.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/transaction.rb b/app/models/transaction.rb index 1e456a1..31eb538 100644 --- a/app/models/transaction.rb +++ b/app/models/transaction.rb @@ -155,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 t end From af5f927df1ab3881aef5f2dd616ec3a442780332 Mon Sep 17 00:00:00 2001 From: Jesus Romero Date: Tue, 22 Oct 2013 10:53:21 -0500 Subject: [PATCH 38/76] added tests --- spec/lib/pocket_money_spec.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/spec/lib/pocket_money_spec.rb b/spec/lib/pocket_money_spec.rb index e2dd606..58b2d59 100644 --- a/spec/lib/pocket_money_spec.rb +++ b/spec/lib/pocket_money_spec.rb @@ -28,6 +28,10 @@ (Account.find(2).limit_amount.to_f).should eq(100) end + it "all limit amount sum $600" do + (Account.all.map(&:limit_amount).sum.to_f).should eq(600) + end + it "should have $740 current balance in 'efectivo'" do (Account.find_by_name("Efectivo").current_balance.to_f).should eq(740) end From 3eedc88f1655d17bca2efac259a6591bff36c439 Mon Sep 17 00:00:00 2001 From: Jesus Romero Date: Tue, 22 Oct 2013 11:14:46 -0500 Subject: [PATCH 39/76] deleted validation to test enviroment --- lib/pocket_money/tables.rb | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/lib/pocket_money/tables.rb b/lib/pocket_money/tables.rb index 369a5d7..950c76f 100644 --- a/lib/pocket_money/tables.rb +++ b/lib/pocket_money/tables.rb @@ -1,11 +1,7 @@ class PocketMoney module BaseTable def self.included(main) - if ENV["RAILS_ENV"] != 'test' - main.establish_connection(adapter: :sqlite3, database: APP_CONFIG['pocket_money_database'], encoding:'iso-8859') - else - main.establish_connection(adapter: :sqlite3, database: APP_CONFIG['pocket_money_database_test'], encoding:'iso-8859') - end + main.establish_connection(adapter: :sqlite3, database: APP_CONFIG['pocket_money_database'], encoding:'iso-8859') main.table_name = main.name.demodulize.sub(/(\w)/) {|w| w.downcase} main.inheritance_column = "rails_type" end From 31213e22c7a12e669ce61f0040c1171489623026 Mon Sep 17 00:00:00 2001 From: Jesus Romero Date: Tue, 22 Oct 2013 12:32:28 -0500 Subject: [PATCH 40/76] added more tests --- spec/lib/pocket_money_spec.rb | 44 +++++++++++++++++++++++++++++++++-- 1 file changed, 42 insertions(+), 2 deletions(-) diff --git a/spec/lib/pocket_money_spec.rb b/spec/lib/pocket_money_spec.rb index 58b2d59..4081081 100644 --- a/spec/lib/pocket_money_spec.rb +++ b/spec/lib/pocket_money_spec.rb @@ -45,6 +45,16 @@ (Transaction.all.count).should eq(35) end + it "the first transaction should have $1750 of amount" do + (Transaction.first.amount.to_f).should eq(1750) + end + + it "should have transactions with transaction type" do + types = Transaction.all.map(&:pm_type) + types.include?(nil).should eq(false) + types.include?("").should eq(false) + end + it "should have transactions with account id" do ids_array = Transaction.all.map(&:account_id) ids_array.include?(nil).should eq(false) @@ -56,6 +66,12 @@ amount_array.include?(nil).should eq(false) amount_array.include?("").should eq(false) end + + it "should have transactions with date" do + dates = Transaction.all.map(&:date) + dates.include?(nil).should eq(false) + dates.include?("").should eq(false) + end it "first transaction should have category id 16" do transaction = Transaction.first @@ -66,6 +82,7 @@ transaction = Transaction.first (transaction.department_id).should eq(1) end + #table split it "all aplits should have a transaction id" do all_splits = Split.all.map(&:transaction_id) @@ -73,6 +90,12 @@ all_splits.include?("").should eq(false) end + it "all splits should have a transaction with currency code" do + currency_codes = Split.all.map(&:currency_code) + currency_codes.include?(nil).should eq(false) + currency_codes.include?("").should eq(false) + end + it "the sum of the splits of a transactions should have same amount that transaction " do 35.times do |count| transaction = Transaction.find(count+1) @@ -93,8 +116,25 @@ it "all class should have a uuid" do departments = Department.all.map(&:uuid) - (departments.include?(nil)).should eq(false) - (departments.include?("")).should eq(false) + departments.include?(nil).should eq(false) + departments.include?("").should eq(false) + end + + #table category + it "should have 20 Categories" do + (Category.all.count).should eq(20) + end + + it "all categories should have a uuid" do + uuids = Category.all.map(&:uuid) + uuids.include?(nil).should eq(false) + uuids.include?("").should eq(false) + end + + it "should include 'Salario' category" do + names = Category.all.map(&:name) + names.include?(nil).should eq(false) + names.include?("").should eq(false) end end From 583b96fb016120d878bef15499279a5532ed7ff9 Mon Sep 17 00:00:00 2001 From: Jesus Romero Date: Tue, 22 Oct 2013 12:40:37 -0500 Subject: [PATCH 41/76] edited test --- spec/lib/pocket_money_spec.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/spec/lib/pocket_money_spec.rb b/spec/lib/pocket_money_spec.rb index 4081081..ccfefaa 100644 --- a/spec/lib/pocket_money_spec.rb +++ b/spec/lib/pocket_money_spec.rb @@ -133,8 +133,7 @@ it "should include 'Salario' category" do names = Category.all.map(&:name) - names.include?(nil).should eq(false) - names.include?("").should eq(false) + names.include?("Salario").should eq(true) end end From fc89d8b4910a1382bb73508acacd65c0bd2a4bf0 Mon Sep 17 00:00:00 2001 From: Jesus Romero Date: Tue, 22 Oct 2013 17:14:32 -0500 Subject: [PATCH 42/76] added more tests and updated database test with repeating transactions --- spec/PocketMoneyDBtest.sql | Bin 245760 -> 245760 bytes spec/lib/pocket_money_spec.rb | 12 +++++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/spec/PocketMoneyDBtest.sql b/spec/PocketMoneyDBtest.sql index bf3ec98ca95d444459a0b6e96ad1ea79cf446a35..7200edf70c2cc91b0c84742add421468bc3a008b 100644 GIT binary patch delta 1182 zcma)5U1%It6y7^`W_MI=^ zOa;{c)#M(I2G28yhP(G;pHRG^z(2M!5z2- z%WxL1!a3-`$#|RO05`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spec.rb @@ -36,7 +36,7 @@ (Account.find_by_name("Efectivo").current_balance.to_f).should eq(740) end - it "should have $740 current balance in 'tarjeta'" do + it "should have $350 current balance in 'tarjeta'" do (Account.find_by_name("Tarjeta").current_balance.to_f).should eq(350) end @@ -136,5 +136,15 @@ names.include?("Salario").should eq(true) end + #table Payee + it "should have 9 payees" do + (Payee.all.count).should eq(9) + end + + it "should include 'TangoSource' payee" do + names = Payee.all.map(&:name) + names.include?("TangoSource").should eq(true) + end + end end From b29c52168c32d84ea3e03f5d42b2486ce55f810d Mon Sep 17 00:00:00 2001 From: Jesus Romero Date: Tue, 22 Oct 2013 17:14:51 -0500 Subject: [PATCH 43/76] added more tests --- spec/lib/pocket_money_spec.rb | 40 +++++++++++++++++++++++++++++------ 1 file changed, 34 insertions(+), 6 deletions(-) diff --git a/spec/lib/pocket_money_spec.rb b/spec/lib/pocket_money_spec.rb index 11a97f6..b727ab3 100644 --- a/spec/lib/pocket_money_spec.rb +++ b/spec/lib/pocket_money_spec.rb @@ -1,4 +1,5 @@ require 'spec_helper' +require 'active_support/core_ext/date/acts_like' require 'rake' require 'pocket_money' Bernard::Application.load_tasks @@ -41,8 +42,8 @@ end #table transactions - it "should have 35 transactions" do - (Transaction.all.count).should eq(35) + it "should have 37 transactions" do + (Transaction.all.count).should eq(37) end it "the first transaction should have $1750 of amount" do @@ -52,7 +53,7 @@ it "should have transactions with transaction type" do types = Transaction.all.map(&:pm_type) types.include?(nil).should eq(false) - types.include?("").should eq(false) + types.include?("").should end it "should have transactions with account id" do @@ -67,10 +68,11 @@ amount_array.include?("").should eq(false) end - it "should have transactions with date" do + it "should have transactions with valid date" do dates = Transaction.all.map(&:date) - dates.include?(nil).should eq(false) - dates.include?("").should eq(false) + dates.each do |date| + (date.acts_like?(:time)).should eq(true) + end end it "first transaction should have category id 16" do @@ -109,6 +111,18 @@ (split.class_id).should eq(1) end + it "amount of transaction 2 should equal at transaction 37" do + transaction_2 = Transaction.find(2).amount.to_f + transaction_37 = Transaction.find(37).amount.to_f + transaction_2.should eq(transaction_37) + end + + it "amount of transaction 4 should equal at transaction 36" do + transaction_4 = Transaction.find(4).amount.to_f + transaction_36 = Transaction.find(36).amount.to_f + transaction_4.should eq(transaction_36) + end + #table department <--- class it "should have personal and negocios classes" do (Department.all.map(&:name)).should eq(["Personal", "Negocios"]) @@ -146,5 +160,19 @@ names.include?("TangoSource").should eq(true) end + it "Last payee should be 'Ahorro' " do + (Payee.last.name).should eq("Ahorro") + end + + #table repeating_transactions + it "should have 2 repeating transactions" do + (RepeatingTransaction.all.count).should eq(2) + end + + it "last repeating transaction should have a valid date" do + transaction = RepeatingTransaction.last + (transaction.end_date.acts_like?(:time)).should eq(true) + end + end end From d8ae2beb54c1ebf5dbcfd1cc37c0bbc1cf9035b7 Mon Sep 17 00:00:00 2001 From: Jesus Romero Date: Tue, 22 Oct 2013 18:54:08 -0500 Subject: [PATCH 44/76] added more test and refactored one test --- spec/lib/pocket_money_spec.rb | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/spec/lib/pocket_money_spec.rb b/spec/lib/pocket_money_spec.rb index b727ab3..a0333a6 100644 --- a/spec/lib/pocket_money_spec.rb +++ b/spec/lib/pocket_money_spec.rb @@ -5,6 +5,7 @@ Bernard::Application.load_tasks describe PocketMoney do context "import data for a known database" do + accounts = Account.all before (:all) do Rake::Task['db:drop'].invoke @@ -14,11 +15,11 @@ end #Table accounts it "should have 3 accounts" do - (Account.all.count).should eq(3) + (accounts.count).should eq(3) end it "should have 3 knowed account" do - (Account.all.map(&:name).sort).should eq(["Cuenta Ahorro", "Efectivo", "Tarjeta"]) + (accounts.map(&:name).sort).should eq(["Cuenta Ahorro", "Efectivo", "Tarjeta"]) end it "should have $1,650.00 current balance in 'cuenta ahorro'" do @@ -30,7 +31,7 @@ end it "all limit amount sum $600" do - (Account.all.map(&:limit_amount).sum.to_f).should eq(600) + (accounts.map(&:limit_amount).sum.to_f).should eq(600) end it "should have $740 current balance in 'efectivo'" do @@ -56,10 +57,12 @@ types.include?("").should end - it "should have transactions with account id" do - ids_array = Transaction.all.map(&:account_id) - ids_array.include?(nil).should eq(false) - ids_array.include?("").should eq(false) + it "should have transactions with valid account id" do + transactions_account_id = Transaction.all.map(&:account_id) + ids_accounts = accounts.map(&:id) + transactions_account_id.each do |account_id| + (ids_accounts.include?(account_id)).should eq(true) + end end it "should have transactions with amount" do @@ -174,5 +177,10 @@ (transaction.end_date.acts_like?(:time)).should eq(true) end + it "transaction 36 should have pm_type 5" do + transaction = Transaction.find(36) + (transaction.pm_type).should eq(5) + end + end end From 8fbc32234c963e2caac93a8c439a1bff9fe52f12 Mon Sep 17 00:00:00 2001 From: Jesus Romero Date: Tue, 22 Oct 2013 18:58:23 -0500 Subject: [PATCH 45/76] refactored some tests --- spec/lib/pocket_money_spec.rb | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/spec/lib/pocket_money_spec.rb b/spec/lib/pocket_money_spec.rb index a0333a6..9e1dce4 100644 --- a/spec/lib/pocket_money_spec.rb +++ b/spec/lib/pocket_money_spec.rb @@ -5,7 +5,8 @@ Bernard::Application.load_tasks describe PocketMoney do context "import data for a known database" do - accounts = Account.all + accounts = Account.all + transactions = Transaction.all before (:all) do Rake::Task['db:drop'].invoke @@ -44,7 +45,7 @@ #table transactions it "should have 37 transactions" do - (Transaction.all.count).should eq(37) + (transactions.count).should eq(37) end it "the first transaction should have $1750 of amount" do @@ -52,13 +53,13 @@ end it "should have transactions with transaction type" do - types = Transaction.all.map(&:pm_type) + types = transactions.map(&:pm_type) types.include?(nil).should eq(false) types.include?("").should end it "should have transactions with valid account id" do - transactions_account_id = Transaction.all.map(&:account_id) + transactions_account_id = transactions.map(&:account_id) ids_accounts = accounts.map(&:id) transactions_account_id.each do |account_id| (ids_accounts.include?(account_id)).should eq(true) @@ -66,13 +67,13 @@ end it "should have transactions with amount" do - amount_array = Transaction.all.map(&:amount) + amount_array = transactions.map(&:amount) amount_array.include?(nil).should eq(false) amount_array.include?("").should eq(false) end it "should have transactions with valid date" do - dates = Transaction.all.map(&:date) + dates = transactions.map(&:date) dates.each do |date| (date.acts_like?(:time)).should eq(true) end From f78f9d5c0b178bbab9249812cac26b16a0c7ad19 Mon Sep 17 00:00:00 2001 From: Jesus Romero Date: Wed, 23 Oct 2013 11:16:06 -0500 Subject: [PATCH 46/76] refactored tests --- spec/lib/pocket_money_spec.rb | 61 +++++++++++++++++++---------------- 1 file changed, 33 insertions(+), 28 deletions(-) diff --git a/spec/lib/pocket_money_spec.rb b/spec/lib/pocket_money_spec.rb index 9e1dce4..99dd8bd 100644 --- a/spec/lib/pocket_money_spec.rb +++ b/spec/lib/pocket_money_spec.rb @@ -5,8 +5,13 @@ Bernard::Application.load_tasks describe PocketMoney do context "import data for a known database" do - accounts = Account.all - transactions = Transaction.all + accounts = Account.all + transactions = Transaction.all + categories = Category.all + payees = Payee.all + departments = Department.all + splits = Split.all + repeating_transactions = RepeatingTransaction.all before (:all) do Rake::Task['db:drop'].invoke @@ -24,11 +29,11 @@ end it "should have $1,650.00 current balance in 'cuenta ahorro'" do - (Account.find_by_name("Cuenta Ahorro").current_balance.to_f).should eq(1650) + (accounts.find_by_name("Cuenta Ahorro").current_balance.to_f).should eq(1150) end it "the second account should have a limit of $100" do - (Account.find(2).limit_amount.to_f).should eq(100) + (accounts[1].limit_amount.to_f).should eq(100) end it "all limit amount sum $600" do @@ -36,11 +41,11 @@ end it "should have $740 current balance in 'efectivo'" do - (Account.find_by_name("Efectivo").current_balance.to_f).should eq(740) + (accounts.find_by_name("Efectivo").current_balance.to_f).should eq(1240) end it "should have $350 current balance in 'tarjeta'" do - (Account.find_by_name("Tarjeta").current_balance.to_f).should eq(350) + (accounts.find_by_name("Tarjeta").current_balance.to_f).should eq(350) end #table transactions @@ -49,7 +54,7 @@ end it "the first transaction should have $1750 of amount" do - (Transaction.first.amount.to_f).should eq(1750) + (transactions.first.amount.to_f).should eq(1750) end it "should have transactions with transaction type" do @@ -80,106 +85,106 @@ end it "first transaction should have category id 16" do - transaction = Transaction.first + transaction = transactions.first (transaction.category_id).should eq(16) end it "first transaction should have class personal" do - transaction = Transaction.first + transaction = transactions.first (transaction.department_id).should eq(1) end #table split it "all aplits should have a transaction id" do - all_splits = Split.all.map(&:transaction_id) + all_splits = splits.map(&:transaction_id) all_splits.include?(nil).should eq(false) all_splits.include?("").should eq(false) end it "all splits should have a transaction with currency code" do - currency_codes = Split.all.map(&:currency_code) + currency_codes = splits.map(&:currency_code) currency_codes.include?(nil).should eq(false) currency_codes.include?("").should eq(false) end it "the sum of the splits of a transactions should have same amount that transaction " do 35.times do |count| - transaction = Transaction.find(count+1) + transaction = transactions[count] splits = transaction.splits (splits.map(&:amount).sum.to_f).should eq(transaction.amount) end end it "first split should have a class id 1" do - split = Split.first + split = splits.first (split.class_id).should eq(1) end it "amount of transaction 2 should equal at transaction 37" do - transaction_2 = Transaction.find(2).amount.to_f - transaction_37 = Transaction.find(37).amount.to_f + transaction_2 = transactions[1].amount.to_f + transaction_37 = transactions[36].amount.to_f transaction_2.should eq(transaction_37) end it "amount of transaction 4 should equal at transaction 36" do - transaction_4 = Transaction.find(4).amount.to_f - transaction_36 = Transaction.find(36).amount.to_f + transaction_4 = transactions[3].amount.to_f + transaction_36 = transactions[35].amount.to_f transaction_4.should eq(transaction_36) end #table department <--- class it "should have personal and negocios classes" do - (Department.all.map(&:name)).should eq(["Personal", "Negocios"]) + (departments.map(&:name)).should eq(["Personal", "Negocios"]) end it "all class should have a uuid" do - departments = Department.all.map(&:uuid) + departments = departments.map(&:uuid) departments.include?(nil).should eq(false) departments.include?("").should eq(false) end #table category it "should have 20 Categories" do - (Category.all.count).should eq(20) + (categories.count).should eq(20) end it "all categories should have a uuid" do - uuids = Category.all.map(&:uuid) + uuids = categories.map(&:uuid) uuids.include?(nil).should eq(false) uuids.include?("").should eq(false) end it "should include 'Salario' category" do - names = Category.all.map(&:name) + names = categories.map(&:name) names.include?("Salario").should eq(true) end #table Payee it "should have 9 payees" do - (Payee.all.count).should eq(9) + (payees.count).should eq(9) end it "should include 'TangoSource' payee" do - names = Payee.all.map(&:name) + names = payees.map(&:name) names.include?("TangoSource").should eq(true) end it "Last payee should be 'Ahorro' " do - (Payee.last.name).should eq("Ahorro") + (payees.last.name).should eq("Ahorro") end #table repeating_transactions it "should have 2 repeating transactions" do - (RepeatingTransaction.all.count).should eq(2) + (repeating_transactions.count).should eq(2) end it "last repeating transaction should have a valid date" do - transaction = RepeatingTransaction.last + transaction = repeating_transactions.last (transaction.end_date.acts_like?(:time)).should eq(true) end it "transaction 36 should have pm_type 5" do - transaction = Transaction.find(36) + transaction = transactions[35] (transaction.pm_type).should eq(5) end From 973e2ab16e23c712f72b446cfa2fff760457deb2 Mon Sep 17 00:00:00 2001 From: Jesus Romero Date: Wed, 23 Oct 2013 15:49:52 -0500 Subject: [PATCH 47/76] changed test database --- spec/PocketMoneyDBtest.sql | Bin 245760 -> 245760 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/spec/PocketMoneyDBtest.sql b/spec/PocketMoneyDBtest.sql index 7200edf70c2cc91b0c84742add421468bc3a008b..171de3dc3d7ea437c1a309bda8e2284af10d1873 100644 GIT binary patch delta 139 zcmZo@;BRQ)pCHXBH&Mo!QEp?xUq9vyBgV-I{?S01Ve>wJ>2N_#7Dg5hMqXYf-cSbK zpbR5{$*-0fV2Wck@1f>2N^~7Dg5hMqXYf-cSaH zpu|YN$*-0fV2Wuf Kmt4#ITnGS}6(UXm From 655a4908ee674cf41c575309376059df9ced1608 Mon Sep 17 00:00:00 2001 From: Jesus Romero Date: Wed, 23 Oct 2013 15:50:38 -0500 Subject: [PATCH 48/76] update expected values of current balance --- spec/lib/pocket_money_spec.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spec/lib/pocket_money_spec.rb b/spec/lib/pocket_money_spec.rb index 99dd8bd..7670e24 100644 --- a/spec/lib/pocket_money_spec.rb +++ b/spec/lib/pocket_money_spec.rb @@ -29,7 +29,7 @@ end it "should have $1,650.00 current balance in 'cuenta ahorro'" do - (accounts.find_by_name("Cuenta Ahorro").current_balance.to_f).should eq(1150) + (accounts.find_by_name("Cuenta Ahorro").current_balance.to_f).should eq(950) end it "the second account should have a limit of $100" do @@ -41,11 +41,11 @@ end it "should have $740 current balance in 'efectivo'" do - (accounts.find_by_name("Efectivo").current_balance.to_f).should eq(1240) + (accounts.find_by_name("Efectivo").current_balance.to_f).should eq(4740) end it "should have $350 current balance in 'tarjeta'" do - (accounts.find_by_name("Tarjeta").current_balance.to_f).should eq(350) + (accounts.find_by_name("Tarjeta").current_balance.to_f).should eq(2050) end #table transactions From 998d0d06be21b105844fa15801d9ed05a5585cc3 Mon Sep 17 00:00:00 2001 From: Jesus Romero Date: Wed, 23 Oct 2013 16:06:29 -0500 Subject: [PATCH 49/76] moved before all method from pocket_money_spec to spec_helper --- spec/lib/pocket_money_spec.rb | 8 +------- spec/spec_helper.rb | 6 ++++++ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/spec/lib/pocket_money_spec.rb b/spec/lib/pocket_money_spec.rb index 7670e24..3ca5ed0 100644 --- a/spec/lib/pocket_money_spec.rb +++ b/spec/lib/pocket_money_spec.rb @@ -13,13 +13,7 @@ splits = Split.all repeating_transactions = RepeatingTransaction.all - before (:all) do - Rake::Task['db:drop'].invoke - Rake::Task['db:create'].invoke - Rake::Task['db:migrate'].invoke - PocketMoney.import - end - #Table accounts + #Table accounts it "should have 3 accounts" do (accounts.count).should eq(3) end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index dc2c0d4..46396c6 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -10,6 +10,12 @@ RSpec.configure do |config| + config.before(:all) do + Rake::Task['db:drop'].invoke + Rake::Task['db:create'].invoke + Rake::Task['db:migrate'].invoke + PocketMoney.import + end config.include FactoryGirl::Syntax::Methods config.treat_symbols_as_metadata_keys_with_true_values = true config.use_transactional_fixtures = true From 1271ef3b4cb4db663eaa7e08ddc9e6d482428003 Mon Sep 17 00:00:00 2001 From: Jesus Romero Date: Wed, 23 Oct 2013 16:30:59 -0500 Subject: [PATCH 50/76] refactored proccess import to tests --- spec/import_pocket_money.rb | 6 ++++++ spec/lib/pocket_money_spec.rb | 1 - spec/spec_helper.rb | 8 +------- 3 files changed, 7 insertions(+), 8 deletions(-) create mode 100644 spec/import_pocket_money.rb diff --git a/spec/import_pocket_money.rb b/spec/import_pocket_money.rb new file mode 100644 index 0000000..c936616 --- /dev/null +++ b/spec/import_pocket_money.rb @@ -0,0 +1,6 @@ +Bernard::Application.load_tasks +Rake::Task['db:drop'].invoke +Rake::Task['db:create'].invoke +Rake::Task['db:migrate'].invoke +PocketMoney.import + diff --git a/spec/lib/pocket_money_spec.rb b/spec/lib/pocket_money_spec.rb index 3ca5ed0..211b4a9 100644 --- a/spec/lib/pocket_money_spec.rb +++ b/spec/lib/pocket_money_spec.rb @@ -2,7 +2,6 @@ require 'active_support/core_ext/date/acts_like' require 'rake' require 'pocket_money' -Bernard::Application.load_tasks describe PocketMoney do context "import data for a known database" do accounts = Account.all diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 46396c6..cf0c582 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,5 +1,6 @@ ENV["RAILS_ENV"] ||= 'test' require File.expand_path("../../config/environment", __FILE__) +require 'import_pocket_money' require 'rspec/rails' require 'rspec/autorun' require 'factory_girl_rails' @@ -9,13 +10,6 @@ ActiveRecord::Migration.check_pending! if defined?(ActiveRecord::Migration) RSpec.configure do |config| - - config.before(:all) do - Rake::Task['db:drop'].invoke - Rake::Task['db:create'].invoke - Rake::Task['db:migrate'].invoke - PocketMoney.import - end config.include FactoryGirl::Syntax::Methods config.treat_symbols_as_metadata_keys_with_true_values = true config.use_transactional_fixtures = true From e240cada193345c4e3bc97c5d97bfc68c6e905b2 Mon Sep 17 00:00:00 2001 From: Jesus Romero Date: Wed, 23 Oct 2013 18:31:36 -0500 Subject: [PATCH 51/76] added shoulda matchers gem --- Gemfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Gemfile b/Gemfile index a530cf3..015dec7 100644 --- a/Gemfile +++ b/Gemfile @@ -54,6 +54,7 @@ group :test do gem 'capybara' gem 'factory_girl' gem 'factory_girl_rails' + gem 'shoulda-matchers' end # Use ActiveModel has_secure_password From e0e9e09b84a13e8a8bc34574e86cd87d8cf2793d Mon Sep 17 00:00:00 2001 From: Jesus Romero Date: Wed, 23 Oct 2013 18:32:49 -0500 Subject: [PATCH 52/76] added some test --- spec/models/transaction_spec.rb | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/spec/models/transaction_spec.rb b/spec/models/transaction_spec.rb index 85c7179..5817c87 100644 --- a/spec/models/transaction_spec.rb +++ b/spec/models/transaction_spec.rb @@ -1,9 +1,25 @@ require 'spec_helper' describe Transaction do - let(:transaction) {create(:transaction)} + transactions = Transaction.all + + it { should belong_to(:account) } + + it { should have_many(:splits) } it "has a valid transaction" do - transaction.should be_valid + (transactions.first).should be_valid + end + + #scopes + it "should have 33 active transactions" do + transactions.active.count.should eq(33) + end + + it "should find a transaction given a uuid" do + (transactions.search("TangoSource").count).should eq(2) + end + + it "" do end end From 9e1245f490b3e49cf42fe5f74350d2c10b424775 Mon Sep 17 00:00:00 2001 From: Jesus Romero Date: Wed, 23 Oct 2013 18:51:04 -0500 Subject: [PATCH 53/76] refactored test --- spec/lib/pocket_money_spec.rb | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/spec/lib/pocket_money_spec.rb b/spec/lib/pocket_money_spec.rb index 211b4a9..12da596 100644 --- a/spec/lib/pocket_money_spec.rb +++ b/spec/lib/pocket_money_spec.rb @@ -4,13 +4,13 @@ require 'pocket_money' describe PocketMoney do context "import data for a known database" do - accounts = Account.all - transactions = Transaction.all - categories = Category.all - payees = Payee.all - departments = Department.all - splits = Split.all - repeating_transactions = RepeatingTransaction.all + let(:accounts) { Account.all } + let(:transactions) { Transaction.all } + let(:categories) { Category.all } + let(:payees) { Payee.all } + let(:departments) { Department.all } + let(:splits) { Split.all } + let(:repeating_transactions) { RepeatingTransaction.all } #Table accounts it "should have 3 accounts" do From 5d694759faf83f421dca367d0e09d8996b1ff468 Mon Sep 17 00:00:00 2001 From: Jesus Romero Date: Wed, 23 Oct 2013 18:52:46 -0500 Subject: [PATCH 54/76] added some tests --- spec/models/transaction_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/models/transaction_spec.rb b/spec/models/transaction_spec.rb index 5817c87..bbecfec 100644 --- a/spec/models/transaction_spec.rb +++ b/spec/models/transaction_spec.rb @@ -8,7 +8,7 @@ it { should have_many(:splits) } it "has a valid transaction" do - (transactions.first).should be_valid + (transactions.sample).should be_valid end #scopes From 47c33028ea460b845a74de336ace261f9c6389e2 Mon Sep 17 00:00:00 2001 From: Jesus Romero Date: Wed, 23 Oct 2013 18:56:24 -0500 Subject: [PATCH 55/76] refactored test --- spec/lib/pocket_money_spec.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spec/lib/pocket_money_spec.rb b/spec/lib/pocket_money_spec.rb index 12da596..f591497 100644 --- a/spec/lib/pocket_money_spec.rb +++ b/spec/lib/pocket_money_spec.rb @@ -131,9 +131,9 @@ end it "all class should have a uuid" do - departments = departments.map(&:uuid) - departments.include?(nil).should eq(false) - departments.include?("").should eq(false) + departments_uuids = departments.map(&:uuid) + departments_uuids.include?(nil).should eq(false) + departments_uuids.include?("").should eq(false) end #table category From 89cda44795eaeab83d0707748ce13ac19a469a1b Mon Sep 17 00:00:00 2001 From: Jesus Romero Date: Thu, 24 Oct 2013 12:40:50 -0500 Subject: [PATCH 56/76] added more tests at transaction model --- spec/lib/pocket_money_spec.rb | 3 ++- spec/models/transaction_spec.rb | 12 ++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/spec/lib/pocket_money_spec.rb b/spec/lib/pocket_money_spec.rb index f591497..255460c 100644 --- a/spec/lib/pocket_money_spec.rb +++ b/spec/lib/pocket_money_spec.rb @@ -2,6 +2,7 @@ require 'active_support/core_ext/date/acts_like' require 'rake' require 'pocket_money' + describe PocketMoney do context "import data for a known database" do let(:accounts) { Account.all } @@ -10,7 +11,7 @@ let(:payees) { Payee.all } let(:departments) { Department.all } let(:splits) { Split.all } - let(:repeating_transactions) { RepeatingTransaction.all } + let(:repeating_transactions) { RepeatingTransaction.all } #Table accounts it "should have 3 accounts" do diff --git a/spec/models/transaction_spec.rb b/spec/models/transaction_spec.rb index bbecfec..e7aab27 100644 --- a/spec/models/transaction_spec.rb +++ b/spec/models/transaction_spec.rb @@ -1,8 +1,7 @@ require 'spec_helper' describe Transaction do - transactions = Transaction.all - + transactions = Transaction.all it { should belong_to(:account) } it { should have_many(:splits) } @@ -16,10 +15,15 @@ transactions.active.count.should eq(33) end - it "should find a transaction given a uuid" do + it "should find a transaction given a payee name" do (transactions.search("TangoSource").count).should eq(2) end - it "" do + it "should find a transaction given a uuid" do + (transactions.uuid("d75b07fb-702d-4fe5-a89f-69b3db98cb1f").payee_name).should eq("Coopel") + end + + it "when is passed a invalid uuid should return all records" do + (transactions.uuid("####-####-##-01").count).should eq(37) end end From d48052b05c011e3104231cb38f82591a70b7dc5a Mon Sep 17 00:00:00 2001 From: Jesus Romero Date: Thu, 24 Oct 2013 13:33:06 -0500 Subject: [PATCH 57/76] updated database test in order to have cleared transactions --- spec/PocketMoneyDBtest.sql | Bin 245760 -> 245760 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/spec/PocketMoneyDBtest.sql b/spec/PocketMoneyDBtest.sql index 171de3dc3d7ea437c1a309bda8e2284af10d1873..1af63a8d4f86919fedb4e7a4f9fc1e88ca408452 100644 GIT binary patch delta 292 zcmZo@;BRQ)pCHX>I#I@%(R5?N9DT;T&42Z|3K$tDb1ZOVjM(h8fR|l{!B&x3gIYRYdI-_!&4^7+E+NkrYf`v%Hd*lT#V4Wz%M( z6}~LIoQ&ddp|;6AYb<~wvT%{5n=h_$VFU^xOqw)VY281dNeD%AHtVjx Date: Thu, 24 Oct 2013 13:33:39 -0500 Subject: [PATCH 58/76] added more tests --- spec/models/transaction_spec.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/spec/models/transaction_spec.rb b/spec/models/transaction_spec.rb index e7aab27..eab3f3f 100644 --- a/spec/models/transaction_spec.rb +++ b/spec/models/transaction_spec.rb @@ -26,4 +26,8 @@ it "when is passed a invalid uuid should return all records" do (transactions.uuid("####-####-##-01").count).should eq(37) end + + it "should return records with cleared value true " do + (transactions.cleared.count).should eq(6) + end end From 75cfb3a95c0e63e8ac06fe06481ca7b15f11101f Mon Sep 17 00:00:00 2001 From: Jesus Romero Date: Thu, 24 Oct 2013 13:41:57 -0500 Subject: [PATCH 59/76] updated expected values in current balances of accounts --- spec/lib/pocket_money_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/lib/pocket_money_spec.rb b/spec/lib/pocket_money_spec.rb index 255460c..60f4eff 100644 --- a/spec/lib/pocket_money_spec.rb +++ b/spec/lib/pocket_money_spec.rb @@ -35,11 +35,11 @@ end it "should have $740 current balance in 'efectivo'" do - (accounts.find_by_name("Efectivo").current_balance.to_f).should eq(4740) + (accounts.find_by_name("Efectivo").current_balance.to_f).should eq(2740) end it "should have $350 current balance in 'tarjeta'" do - (accounts.find_by_name("Tarjeta").current_balance.to_f).should eq(2050) + (accounts.find_by_name("Tarjeta").current_balance.to_f).should eq(3050) end #table transactions From a321d19c05d715fc56ebd0cf43cb682aed684dd1 Mon Sep 17 00:00:00 2001 From: Jesus Romero Date: Thu, 24 Oct 2013 18:17:04 -0500 Subject: [PATCH 60/76] added more tests --- spec/models/transaction_spec.rb | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/spec/models/transaction_spec.rb b/spec/models/transaction_spec.rb index eab3f3f..cdf1607 100644 --- a/spec/models/transaction_spec.rb +++ b/spec/models/transaction_spec.rb @@ -1,7 +1,9 @@ require 'spec_helper' describe Transaction do - transactions = Transaction.all + + let(:transactions) { Transaction.all } + it { should belong_to(:account) } it { should have_many(:splits) } @@ -30,4 +32,18 @@ it "should return records with cleared value true " do (transactions.cleared.count).should eq(6) end + + it "should return records valid given two dates" do + (transactions.interval("20131016", "20131021").count).should eq(32) + end + + it "not should return records given two dates known" do + (transactions.interval("19991016", "20021021").count).should eq(0) + end + + it "should show the balance given a transaction" do + transaction_balance = transactions.balance[36].balance + (transaction_balance.to_f).should eq(1150) + end + end From eb07298b9953ab72d9581cb13577c03a6e258335 Mon Sep 17 00:00:00 2001 From: Jesus Romero Date: Thu, 24 Oct 2013 18:33:57 -0500 Subject: [PATCH 61/76] deleted unecesary files --- spec/factories/account.rb | 39 --------------------------- spec/factories/category.rb | 15 ----------- spec/factories/department.rb | 11 -------- spec/factories/payee.rb | 13 --------- spec/factories/split.rb | 18 ------------- spec/factories/transaction.rb | 50 ----------------------------------- spec/factories_spec.rb | 13 --------- 7 files changed, 159 deletions(-) delete mode 100644 spec/factories/account.rb delete mode 100644 spec/factories/category.rb delete mode 100644 spec/factories/department.rb delete mode 100644 spec/factories/payee.rb delete mode 100644 spec/factories/split.rb delete mode 100644 spec/factories/transaction.rb delete mode 100644 spec/factories_spec.rb diff --git a/spec/factories/account.rb b/spec/factories/account.rb deleted file mode 100644 index f52af00..0000000 --- a/spec/factories/account.rb +++ /dev/null @@ -1,39 +0,0 @@ -require 'faker' - -boolean = [true, false] -currency = ["AED", "ALL", "CAD", "CNY", "MXN", "IRR", "JPY", "USD", "UYU"] -FactoryGirl.define do - factory :account do - deleted false - pm_id (0..2).to_a.sample - pm_account_type (0..8).to_a.sample - display_order (1..9).to_a.sample - name Faker::Company.name - balance_overall (1..9).to_a.sample - balance_cleared (1..9).to_a.sample - number Faker::Number.number(2) - institution Faker::Company.suffix - phone Faker::PhoneNumber.cell_phone - expiration_date Faker::Business.credit_card_expiry_date.strftime("%d%m%Y") - check_number (1..9).to_a.sample - notes Faker::Lorem.paragraph - pm_icon "image" - url Faker::Internet.url - of_x_id "dummy" - of_x_url Faker::Internet.domain_word - password Faker::Internet.password - fee (1..9).to_a.sample - fixed_percent (1..9).to_a.sample - limit_amount (1..9).to_a.sample - limit boolean.sample - total_worth boolean.sample - exchange_rate (1..9).to_a.sample - currency_code currency.sample - last_sync_time Time.now - routing_number (1..9).to_a.sample - overdraft_account_id (1..9).to_a.sample - keep_the_change_account_id (1..9).to_a.sample - heek_change_round_to (1..9).to_a.sample - uuid Faker::Code.isbn(64) - end -end diff --git a/spec/factories/category.rb b/spec/factories/category.rb deleted file mode 100644 index 018c146..0000000 --- a/spec/factories/category.rb +++ /dev/null @@ -1,15 +0,0 @@ -require 'faker' - -FactoryGirl.define do - factory :category do - name Faker::Commerce.department - deleted false - pm_id (0..8).to_a.sample - pm_type (0..2).to_a.sample - budget_period (100..1000).to_a.sample - budget_limit (50..500).to_a.sample - include_subcategories false - rollover false - uuid Faker::Code.isbn - end -end diff --git a/spec/factories/department.rb b/spec/factories/department.rb deleted file mode 100644 index a3b4e5d..0000000 --- a/spec/factories/department.rb +++ /dev/null @@ -1,11 +0,0 @@ -require 'faker' - -FactoryGirl.define do - factory :department do - name Faker::Commerce.product_name - pm_id (0..8).to_a.sample - uuid Faker::Code.isbn - deleted false - end -end - diff --git a/spec/factories/payee.rb b/spec/factories/payee.rb deleted file mode 100644 index e967919..0000000 --- a/spec/factories/payee.rb +++ /dev/null @@ -1,13 +0,0 @@ -require 'faker' - -FactoryGirl.define do - factory :payee do - name Faker::Name.name - deleted false - pm_id (0..8).to_a.sample - latitude Faker::Address.latitude - longitude Faker::Address.longitude - uuid Faker::Code.isbn - - end -end diff --git a/spec/factories/split.rb b/spec/factories/split.rb deleted file mode 100644 index 41e5390..0000000 --- a/spec/factories/split.rb +++ /dev/null @@ -1,18 +0,0 @@ -#require 'faker' -#currency = ["AED", "ALL", "CAD", "CNY", "MXN", "IRR", "JPY", "USD", "UYU"] -#transaction = FactoryGirl.create(:transaction) -#FactoryGirl.define do - #factory :split do - #pm_id transaction.pm_id - #transaction_id transaction.id - #amount transaction.amount - #xrate (1..10).to_a.sample - #category_id transaction.category_id - #class_id (0..10).to_a.sample - #memo Faker::Lorem.paragraph - #transfer_to_account_id (1..100).to_a.sample - #currency_code currency.sample - #of_x_id "dummy" - #end -#end - diff --git a/spec/factories/transaction.rb b/spec/factories/transaction.rb deleted file mode 100644 index 60afb1a..0000000 --- a/spec/factories/transaction.rb +++ /dev/null @@ -1,50 +0,0 @@ -require 'faker' - -currency = ["AED", "ALL", "CAD", "CNY", "MXN", "IRR", "JPY", "USD", "UYU"] -account = FactoryGirl.create(:account) -payee = FactoryGirl.create(:payee) -department = FactoryGirl.create(:department) -category = FactoryGirl.create(:category) - - -FactoryGirl.define do - factory :transaction do - pm_type (0..2).to_a.sample - pm_id (0..8).to_a.sample - account_id account.id - pm_account_id account.pm_id - pm_payee payee.name - pm_sub_total (10..10_000).to_a.sample - pm_of_x_id "dummy" - pm_image "dummy" - pm_overdraft_id (1..30).to_a.sample.to_s - date Time.now - deleted false - check_number (1..10).to_a.sample - payee_name payee.name - payee_id payee.pm_id - category_id category.id - department_id department.id - amount Faker::Number.number(2) - cleared true - uuid Faker::Code.isbn - end -end - -transaction = FactoryGirl.create(:transaction) - -FactoryGirl.define do - factory :split do - pm_id transaction.pm_id - transaction_id transaction.id - amount transaction.amount - xrate (1..10).to_a.sample - category_id transaction.category_id - class_id (0..10).to_a.sample - memo Faker::Lorem.paragraph - transfer_to_account_id (1..100).to_a.sample - currency_code currency.sample - of_x_id "dummy" - end -end - diff --git a/spec/factories_spec.rb b/spec/factories_spec.rb deleted file mode 100644 index d2e7753..0000000 --- a/spec/factories_spec.rb +++ /dev/null @@ -1,13 +0,0 @@ -require 'spec_helper' -describe 'validate FactoryGirl factories' do - FactoryGirl.factories.each do |factory| - context "with factory for: #{factory.name}" do - subject { FactoryGirl.build(factory.name) } - - it "is valid" do - subject.should be_valid if subject.class.ancestors.include?(ActiveRecord::Base) - end - end - end -end - From 7173f810a7b0e005a9de9363d77f0bd98b4e68b6 Mon Sep 17 00:00:00 2001 From: Jesus Romero Date: Thu, 24 Oct 2013 18:34:33 -0500 Subject: [PATCH 62/76] refactored tests --- spec/models/account_spec.rb | 2 +- spec/models/category_spec.rb | 2 +- spec/models/department_spec.rb | 4 ++-- spec/models/payee_spec.rb | 2 +- spec/models/split_spec.rb | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/spec/models/account_spec.rb b/spec/models/account_spec.rb index e59d45c..3c01f88 100644 --- a/spec/models/account_spec.rb +++ b/spec/models/account_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' describe Account do - let(:account) {create(:account)} + let(:account) {Account.first} it "has a valid account" do account.should be_valid diff --git a/spec/models/category_spec.rb b/spec/models/category_spec.rb index 5396105..ad00902 100644 --- a/spec/models/category_spec.rb +++ b/spec/models/category_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' describe Category do - let(:category) {create(:category)} + let(:category) {Category.first} it "has a valid category" do category.should be_valid diff --git a/spec/models/department_spec.rb b/spec/models/department_spec.rb index 343e023..5331ad8 100644 --- a/spec/models/department_spec.rb +++ b/spec/models/department_spec.rb @@ -1,7 +1,7 @@ -require 'department' +require 'spec_helper' describe Department do - let(:department) {create(:department)} + let(:department) { Department.first } it "has avalid department" do department.should be_valid diff --git a/spec/models/payee_spec.rb b/spec/models/payee_spec.rb index eeb8cf0..3f3a157 100644 --- a/spec/models/payee_spec.rb +++ b/spec/models/payee_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' describe Payee do - let(:payee) {create(:payee)} + let(:payee) { Payee.first } it "has a valid payee" do payee.should be_valid diff --git a/spec/models/split_spec.rb b/spec/models/split_spec.rb index edb1ab6..ba2b473 100644 --- a/spec/models/split_spec.rb +++ b/spec/models/split_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' describe Split do - let(:split) {create(:split)} + let(:split) { Split.first } it "has a valid split" do split.should be_valid From f84f2fa2451c97817987b9e4d827a944d1b01b88 Mon Sep 17 00:00:00 2001 From: Jesus Romero Date: Thu, 24 Oct 2013 18:52:38 -0500 Subject: [PATCH 63/76] deleted scope uuid --- app/models/transaction.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/app/models/transaction.rb b/app/models/transaction.rb index 31eb538..412d08d 100644 --- a/app/models/transaction.rb +++ b/app/models/transaction.rb @@ -9,7 +9,6 @@ class Transaction < ActiveRecord::Base # scope :search, ->(q) { where "payee_name like ? OR uuid = ?", "%#{q}%", q } - scope :uuid, ->(uuid) { where(uuid:uuid).first } scope :active, -> { where(deleted:false).where('transactions.pm_type <> 5') } scope :order_date, -> { order('date desc') } scope :cleared, -> { where(cleared:true) } From 263a935f8ce729883cf51b8ed34cebc599fb72f3 Mon Sep 17 00:00:00 2001 From: Jesus Romero Date: Thu, 24 Oct 2013 18:54:21 -0500 Subject: [PATCH 64/76] deleted tests to uuid scope --- spec/models/transaction_spec.rb | 8 -------- 1 file changed, 8 deletions(-) diff --git a/spec/models/transaction_spec.rb b/spec/models/transaction_spec.rb index cdf1607..1e15f86 100644 --- a/spec/models/transaction_spec.rb +++ b/spec/models/transaction_spec.rb @@ -21,14 +21,6 @@ (transactions.search("TangoSource").count).should eq(2) end - it "should find a transaction given a uuid" do - (transactions.uuid("d75b07fb-702d-4fe5-a89f-69b3db98cb1f").payee_name).should eq("Coopel") - end - - it "when is passed a invalid uuid should return all records" do - (transactions.uuid("####-####-##-01").count).should eq(37) - end - it "should return records with cleared value true " do (transactions.cleared.count).should eq(6) end From 3368a109fed2c194eaaebb917a5b0f2d287805a3 Mon Sep 17 00:00:00 2001 From: Jesus Romero Date: Thu, 24 Oct 2013 19:05:52 -0500 Subject: [PATCH 65/76] undeleted factories because are necesary to a one test --- .../transactions_controller_spec.rb | 2 +- spec/factories/account.rb | 39 +++++++++++++++ spec/factories/category.rb | 15 ++++++ spec/factories/department.rb | 11 ++++ spec/factories/payee.rb | 13 +++++ spec/factories/split.rb | 18 +++++++ spec/factories/transaction.rb | 50 +++++++++++++++++++ 7 files changed, 147 insertions(+), 1 deletion(-) create mode 100644 spec/factories/account.rb create mode 100644 spec/factories/category.rb create mode 100644 spec/factories/department.rb create mode 100644 spec/factories/payee.rb create mode 100644 spec/factories/split.rb create mode 100644 spec/factories/transaction.rb diff --git a/spec/controllers/transactions_controller_spec.rb b/spec/controllers/transactions_controller_spec.rb index 037f4a5..3407b85 100644 --- a/spec/controllers/transactions_controller_spec.rb +++ b/spec/controllers/transactions_controller_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' describe TransactionsController do - let(:transaction) { create(:transaction) } + let(:transaction) { Transaction.first } #spec to GET methods describe "Get index" do it "should render the index templates" do diff --git a/spec/factories/account.rb b/spec/factories/account.rb new file mode 100644 index 0000000..f52af00 --- /dev/null +++ b/spec/factories/account.rb @@ -0,0 +1,39 @@ +require 'faker' + +boolean = [true, false] +currency = ["AED", "ALL", "CAD", "CNY", "MXN", "IRR", "JPY", "USD", "UYU"] +FactoryGirl.define do + factory :account do + deleted false + pm_id (0..2).to_a.sample + pm_account_type (0..8).to_a.sample + display_order (1..9).to_a.sample + name Faker::Company.name + balance_overall (1..9).to_a.sample + balance_cleared (1..9).to_a.sample + number Faker::Number.number(2) + institution Faker::Company.suffix + phone Faker::PhoneNumber.cell_phone + expiration_date Faker::Business.credit_card_expiry_date.strftime("%d%m%Y") + check_number (1..9).to_a.sample + notes Faker::Lorem.paragraph + pm_icon "image" + url Faker::Internet.url + of_x_id "dummy" + of_x_url Faker::Internet.domain_word + password Faker::Internet.password + fee (1..9).to_a.sample + fixed_percent (1..9).to_a.sample + limit_amount (1..9).to_a.sample + limit boolean.sample + total_worth boolean.sample + exchange_rate (1..9).to_a.sample + currency_code currency.sample + last_sync_time Time.now + routing_number (1..9).to_a.sample + overdraft_account_id (1..9).to_a.sample + keep_the_change_account_id (1..9).to_a.sample + heek_change_round_to (1..9).to_a.sample + uuid Faker::Code.isbn(64) + end +end diff --git a/spec/factories/category.rb b/spec/factories/category.rb new file mode 100644 index 0000000..018c146 --- /dev/null +++ b/spec/factories/category.rb @@ -0,0 +1,15 @@ +require 'faker' + +FactoryGirl.define do + factory :category do + name Faker::Commerce.department + deleted false + pm_id (0..8).to_a.sample + pm_type (0..2).to_a.sample + budget_period (100..1000).to_a.sample + budget_limit (50..500).to_a.sample + include_subcategories false + rollover false + uuid Faker::Code.isbn + end +end diff --git a/spec/factories/department.rb b/spec/factories/department.rb new file mode 100644 index 0000000..a3b4e5d --- /dev/null +++ b/spec/factories/department.rb @@ -0,0 +1,11 @@ +require 'faker' + +FactoryGirl.define do + factory :department do + name Faker::Commerce.product_name + pm_id (0..8).to_a.sample + uuid Faker::Code.isbn + deleted false + end +end + diff --git a/spec/factories/payee.rb b/spec/factories/payee.rb new file mode 100644 index 0000000..e967919 --- /dev/null +++ b/spec/factories/payee.rb @@ -0,0 +1,13 @@ +require 'faker' + +FactoryGirl.define do + factory :payee do + name Faker::Name.name + deleted false + pm_id (0..8).to_a.sample + latitude Faker::Address.latitude + longitude Faker::Address.longitude + uuid Faker::Code.isbn + + end +end diff --git a/spec/factories/split.rb b/spec/factories/split.rb new file mode 100644 index 0000000..41e5390 --- /dev/null +++ b/spec/factories/split.rb @@ -0,0 +1,18 @@ +#require 'faker' +#currency = ["AED", "ALL", "CAD", "CNY", "MXN", "IRR", "JPY", "USD", "UYU"] +#transaction = FactoryGirl.create(:transaction) +#FactoryGirl.define do + #factory :split do + #pm_id transaction.pm_id + #transaction_id transaction.id + #amount transaction.amount + #xrate (1..10).to_a.sample + #category_id transaction.category_id + #class_id (0..10).to_a.sample + #memo Faker::Lorem.paragraph + #transfer_to_account_id (1..100).to_a.sample + #currency_code currency.sample + #of_x_id "dummy" + #end +#end + diff --git a/spec/factories/transaction.rb b/spec/factories/transaction.rb new file mode 100644 index 0000000..60afb1a --- /dev/null +++ b/spec/factories/transaction.rb @@ -0,0 +1,50 @@ +require 'faker' + +currency = ["AED", "ALL", "CAD", "CNY", "MXN", "IRR", "JPY", "USD", "UYU"] +account = FactoryGirl.create(:account) +payee = FactoryGirl.create(:payee) +department = FactoryGirl.create(:department) +category = FactoryGirl.create(:category) + + +FactoryGirl.define do + factory :transaction do + pm_type (0..2).to_a.sample + pm_id (0..8).to_a.sample + account_id account.id + pm_account_id account.pm_id + pm_payee payee.name + pm_sub_total (10..10_000).to_a.sample + pm_of_x_id "dummy" + pm_image "dummy" + pm_overdraft_id (1..30).to_a.sample.to_s + date Time.now + deleted false + check_number (1..10).to_a.sample + payee_name payee.name + payee_id payee.pm_id + category_id category.id + department_id department.id + amount Faker::Number.number(2) + cleared true + uuid Faker::Code.isbn + end +end + +transaction = FactoryGirl.create(:transaction) + +FactoryGirl.define do + factory :split do + pm_id transaction.pm_id + transaction_id transaction.id + amount transaction.amount + xrate (1..10).to_a.sample + category_id transaction.category_id + class_id (0..10).to_a.sample + memo Faker::Lorem.paragraph + transfer_to_account_id (1..100).to_a.sample + currency_code currency.sample + of_x_id "dummy" + end +end + From 28f1ea3e52ecd85865a143197ac3166a1aea2b7e Mon Sep 17 00:00:00 2001 From: Jesus Romero Date: Mon, 28 Oct 2013 11:42:53 -0600 Subject: [PATCH 66/76] deleted test --- Gemfile.lock | 3 +++ spec/models/transaction_spec.rb | 4 ---- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 6b1c953..b453bd4 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -147,6 +147,8 @@ GEM sdoc (0.3.20) json (>= 1.1.3) rdoc (~> 3.10) + shoulda-matchers (2.4.0) + activesupport (>= 3.0.0) slop (3.4.5) sprockets (2.10.0) hike (~> 1.2) @@ -202,6 +204,7 @@ DEPENDENCIES ruby-progressbar sass-rails (~> 4.0.0.rc1) sdoc + shoulda-matchers sqlite3 therubyracer turbolinks diff --git a/spec/models/transaction_spec.rb b/spec/models/transaction_spec.rb index 1e15f86..bfdbe6e 100644 --- a/spec/models/transaction_spec.rb +++ b/spec/models/transaction_spec.rb @@ -33,9 +33,5 @@ (transactions.interval("19991016", "20021021").count).should eq(0) end - it "should show the balance given a transaction" do - transaction_balance = transactions.balance[36].balance - (transaction_balance.to_f).should eq(1150) - end end From 63d3b54cc33c08e65aa76c8e8800bf0014b191b9 Mon Sep 17 00:00:00 2001 From: Jesus Romero Date: Tue, 29 Oct 2013 11:49:39 -0600 Subject: [PATCH 67/76] added first test on features folder --- .../see_total_amount_per_category_spec.rb | 18 ++++++++++++++++++ spec/models/transaction_spec.rb | 5 ++--- 2 files changed, 20 insertions(+), 3 deletions(-) create mode 100644 spec/features/see_total_amount_per_category_spec.rb diff --git a/spec/features/see_total_amount_per_category_spec.rb b/spec/features/see_total_amount_per_category_spec.rb new file mode 100644 index 0000000..825d76e --- /dev/null +++ b/spec/features/see_total_amount_per_category_spec.rb @@ -0,0 +1,18 @@ +require 'spec_helper' +feature 'check total amount per category' do + scenario 'Per category' do + visit root_path + click_link "This Year" + page.should have_content('Salario') + page.should have_content('$3,500.00') + page.should have_content('Personal') + page.should have_content('$8,900.00') + page.should have_content("Automóvil") + page.should have_content('-$200.00') + page.should have_content('Entretenimiento') + page.should have_content('$0.00') + end + + + +end diff --git a/spec/models/transaction_spec.rb b/spec/models/transaction_spec.rb index bfdbe6e..4cfb4dd 100644 --- a/spec/models/transaction_spec.rb +++ b/spec/models/transaction_spec.rb @@ -11,7 +11,7 @@ it "has a valid transaction" do (transactions.sample).should be_valid end - + #scopes it "should have 33 active transactions" do transactions.active.count.should eq(33) @@ -28,10 +28,9 @@ it "should return records valid given two dates" do (transactions.interval("20131016", "20131021").count).should eq(32) end - + it "not should return records given two dates known" do (transactions.interval("19991016", "20021021").count).should eq(0) end - end From 19c464afbeeaf591cb26594df3ab4884249474e3 Mon Sep 17 00:00:00 2001 From: Jesus Romero Date: Wed, 30 Oct 2013 12:08:27 -0600 Subject: [PATCH 68/76] added test for transactions per ccategories --- .../see_total_amount_per_category_spec.rb | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/spec/features/see_total_amount_per_category_spec.rb b/spec/features/see_total_amount_per_category_spec.rb index 825d76e..c79e0f5 100644 --- a/spec/features/see_total_amount_per_category_spec.rb +++ b/spec/features/see_total_amount_per_category_spec.rb @@ -1,5 +1,6 @@ require 'spec_helper' feature 'check total amount per category' do + scenario 'Per category' do visit root_path click_link "This Year" @@ -13,6 +14,50 @@ page.should have_content('$0.00') end + scenario "Salario Category" do + visit root_path + click_link "This Year" + click_link "Salario" + page.should have_content("10/16/13") + page.should have_content("10/31/13") + page.should have_content("$1,750.00") + page.should have_content("Deposit") + page.should have_content("$3,500.00") + end + + scenario "Personal Category" do + visit root_path + click_link "This Year" + click_link "Personal" + page.should have_content("10/18/13") + page.should have_content("$6,500.00") + page.should have_content("10/17/13") + page.should have_content("$2,400.00") + page.should have_content("Deposit") + page.should have_content("$9,000.00") + page.should have_content("Widthdrawals") + page.should have_content("$100.00") + end + scenario "Automovil Category" do + visit root_path + click_link "This Year" + click_link "Automóvil" + page.should have_content("10/17/13") + page.should have_content("-$200.00") + page.should have_content("Widthdrawals") + page.should have_content("$200.00") + end + scenario "Caridad Category" do + visit root_path + click_link "This Year" + click_link "Caridad" + page.should have_content("10/18/13") + page.should have_content("-$1,000.00") + page.should have_content("Transfer") + page.should have_content("$1,800.00") + page.should have_content("Widthdrawals") + page.should have_content("$1,000.00") + end end From 9e62b7aae7f3dff0bec1fc3ba6be890629c19d85 Mon Sep 17 00:00:00 2001 From: Jesus Romero Date: Wed, 30 Oct 2013 12:56:49 -0600 Subject: [PATCH 69/76] cretaed file to transaction type tests --- .../see_total_amount_per_transaction_type_spec.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 spec/features/see_total_amount_per_transaction_type_spec.rb diff --git a/spec/features/see_total_amount_per_transaction_type_spec.rb b/spec/features/see_total_amount_per_transaction_type_spec.rb new file mode 100644 index 0000000..74586bb --- /dev/null +++ b/spec/features/see_total_amount_per_transaction_type_spec.rb @@ -0,0 +1,13 @@ +require 'spec_helper' +feature 'check total amount per transaction type' do + + scenario "Deposit Transaction" do + end + + scenario "Transfer Transaction" do + end + + scenario "Widthdrawals Transaction" do + end + +end From ea9ee78da896fed35fd156db9007aa7a8ea88fd5 Mon Sep 17 00:00:00 2001 From: Jesus Romero Date: Thu, 31 Oct 2013 11:30:18 -0600 Subject: [PATCH 70/76] refactored tests --- .../see_total_amount_per_category_spec.rb | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/spec/features/see_total_amount_per_category_spec.rb b/spec/features/see_total_amount_per_category_spec.rb index c79e0f5..b0a49ec 100644 --- a/spec/features/see_total_amount_per_category_spec.rb +++ b/spec/features/see_total_amount_per_category_spec.rb @@ -1,9 +1,10 @@ require 'spec_helper' feature 'check total amount per category' do - - scenario 'Per category' do + before(:each) do visit root_path click_link "This Year" + end + scenario 'Per category' do page.should have_content('Salario') page.should have_content('$3,500.00') page.should have_content('Personal') @@ -15,8 +16,6 @@ end scenario "Salario Category" do - visit root_path - click_link "This Year" click_link "Salario" page.should have_content("10/16/13") page.should have_content("10/31/13") @@ -26,8 +25,6 @@ end scenario "Personal Category" do - visit root_path - click_link "This Year" click_link "Personal" page.should have_content("10/18/13") page.should have_content("$6,500.00") @@ -40,18 +37,14 @@ end scenario "Automovil Category" do - visit root_path - click_link "This Year" click_link "Automóvil" page.should have_content("10/17/13") page.should have_content("-$200.00") - page.should have_content("Widthdrawals") + page.should have_content("Widthdrawals") page.should have_content("$200.00") end scenario "Caridad Category" do - visit root_path - click_link "This Year" click_link "Caridad" page.should have_content("10/18/13") page.should have_content("-$1,000.00") From f573e186b58362f4b8365d1685ad759a8908c4b8 Mon Sep 17 00:00:00 2001 From: Jesus Romero Date: Thu, 31 Oct 2013 11:31:24 -0600 Subject: [PATCH 71/76] add tests --- ..._total_amount_per_transaction_type_spec.rb | 35 +++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/spec/features/see_total_amount_per_transaction_type_spec.rb b/spec/features/see_total_amount_per_transaction_type_spec.rb index 74586bb..5357a29 100644 --- a/spec/features/see_total_amount_per_transaction_type_spec.rb +++ b/spec/features/see_total_amount_per_transaction_type_spec.rb @@ -1,13 +1,44 @@ require 'spec_helper' feature 'check total amount per transaction type' do + before(:each) do + visit root_path + click_link "This Year" + end + scenario "Deposit Transaction" do + click_link "Deposit" + page.should have_content("10/16/13") + page.should have_content("$1,750.00") + page.should have_content("10/17/13") + page.should have_content("$2,500.00") + page.should have_content("10/18/13") + page.should have_content("$6,600.00") + page.should have_content("10/31/13") + page.should have_content("$1,750.00") + page.should have_content("$12,600.00") end scenario "Transfer Transaction" do - end + click_link "Transfer" + page.should have_content("10/17/13") + page.should have_content("-$1,250.00") + page.should have_content("10/18/13") + page.should have_content("-$3,250.00") + page.should have_content("10/23/13") + page.should have_content("-$500.00") + page.should have_content("$5,000.00") + end scenario "Widthdrawals Transaction" do - end + click_link "Widthdrawals" + page.should have_content("10/07/13") + page.should have_content("-$2,500.00") + page.should have_content("10/17/13") + page.should have_content("-$610.00") + page.should have_content("10/18/13") + page.should have_content("-$1,000.00") + page.should have_content("$4,110.00") + end end From 3b586a189ac671c800c5bc2fe4e5652197460c2c Mon Sep 17 00:00:00 2001 From: Jesus Romero Date: Thu, 31 Oct 2013 13:08:29 -0600 Subject: [PATCH 72/76] added more tests --- app/models/transaction.rb | 4 ++-- .../see_total_amount_per_account_spec.rb | 22 +++++++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 spec/features/see_total_amount_per_account_spec.rb diff --git a/app/models/transaction.rb b/app/models/transaction.rb index 412d08d..4258869 100644 --- a/app/models/transaction.rb +++ b/app/models/transaction.rb @@ -2,8 +2,8 @@ class Transaction < ActiveRecord::Base # pm_types # 0 Withdrawal # 1 Deposit - # 2 Transfer - # 3 + # 2 Transfer (-) + # 3 Transfer (+) # 4 # 5 Dunno but removed it for now # diff --git a/spec/features/see_total_amount_per_account_spec.rb b/spec/features/see_total_amount_per_account_spec.rb new file mode 100644 index 0000000..ce7819b --- /dev/null +++ b/spec/features/see_total_amount_per_account_spec.rb @@ -0,0 +1,22 @@ +require 'spec_helper' +feature "check total amount per account" do + + before(:each) do + visit accounts_path + end + + scenario "cheack all categories" do + page.should have_content("Efectivo") + page.should have_content("$550.00") + page.should have_content("$4,490.00") + page.should have_content("Tarjeta") + page.should have_content("-$250") + page.should have_content("$3,050.00") + page.should have_content("Cuenta Ahorro") + page.should have_content("$0.00") + page.should have_content("$950.00") + end + + scenario "Check Efectivo" do + end +end From c39a473b19fb7183933491ed5aa891cc8544fc85 Mon Sep 17 00:00:00 2001 From: Jesus Romero Date: Thu, 31 Oct 2013 13:40:22 -0600 Subject: [PATCH 73/76] added more tests --- .../see_total_amount_per_account_spec.rb | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/spec/features/see_total_amount_per_account_spec.rb b/spec/features/see_total_amount_per_account_spec.rb index ce7819b..aabd3bf 100644 --- a/spec/features/see_total_amount_per_account_spec.rb +++ b/spec/features/see_total_amount_per_account_spec.rb @@ -18,5 +18,40 @@ end scenario "Check Efectivo" do + click_link "Efectivo" + page.should have_content("(17)") + page.should have_content("$4,490.00") + page.should have_content("10/16/13") + page.should have_content("$1,750.00") + page.should have_content("10/17/13") + page.should have_content("$640.00") + page.should have_content("10/18/13") + page.should have_content("$150.00") + page.should have_content("10/23/13") + page.should have_content("$500.00") + page.should have_content("10/31/13") + page.should have_content("$1,750.00") end + + scenario "Check Tarjeta" do + click_link "Tarjeta" + page.should have_content("(11)") + page.should have_content("$3,050.00") + page.should have_content("10/07/13") + page.should have_content("-$2,500.00") + page.should have_content("10/17/13") + page.should have_content("$1,250.00") + page.should have_content("10/18/13") + page.should have_content("$4,300.00") + end + + scenario "Cuenta Ahorro" do + click_link "Cuenta Ahorro" + page.should have_content("(9)") + page.should have_content("$950.00") + page.should have_content("10/18/13") + page.should have_content("$1,450.00") + page.should have_content("10/23/13") + page.should have_content("-$500.00") + end end From 1c4a56d69f41544ce765081e2e9b629511610036 Mon Sep 17 00:00:00 2001 From: Jesus Romero Date: Thu, 31 Oct 2013 16:20:59 -0600 Subject: [PATCH 74/76] refactored tests --- .../see_total_amount_per_account_spec.rb | 66 +++++++++++-------- 1 file changed, 37 insertions(+), 29 deletions(-) diff --git a/spec/features/see_total_amount_per_account_spec.rb b/spec/features/see_total_amount_per_account_spec.rb index aabd3bf..fa34ca0 100644 --- a/spec/features/see_total_amount_per_account_spec.rb +++ b/spec/features/see_total_amount_per_account_spec.rb @@ -8,50 +8,58 @@ scenario "cheack all categories" do page.should have_content("Efectivo") page.should have_content("$550.00") - page.should have_content("$4,490.00") - page.should have_content("Tarjeta") - page.should have_content("-$250") - page.should have_content("$3,050.00") - page.should have_content("Cuenta Ahorro") - page.should have_content("$0.00") - page.should have_content("$950.00") + within ('table') do + page.should have_content("$4,490.00") + page.should have_content("Tarjeta") + page.should have_content("-$250") + page.should have_content("$3,050.00") + page.should have_content("Cuenta Ahorro") + page.should have_content("$0.00") + page.should have_content("$950.00") + end end scenario "Check Efectivo" do click_link "Efectivo" page.should have_content("(17)") page.should have_content("$4,490.00") - page.should have_content("10/16/13") - page.should have_content("$1,750.00") - page.should have_content("10/17/13") - page.should have_content("$640.00") - page.should have_content("10/18/13") - page.should have_content("$150.00") - page.should have_content("10/23/13") - page.should have_content("$500.00") - page.should have_content("10/31/13") - page.should have_content("$1,750.00") + within('table') do + page.should have_content("10/16/13") + page.should have_content("$1,750.00") + page.should have_content("10/17/13") + page.should have_content("$640.00") + page.should have_content("10/18/13") + page.should have_content("$150.00") + page.should have_content("10/23/13") + page.should have_content("$500.00") + page.should have_content("10/31/13") + page.should have_content("$1,750.00") + end end scenario "Check Tarjeta" do click_link "Tarjeta" page.should have_content("(11)") page.should have_content("$3,050.00") - page.should have_content("10/07/13") - page.should have_content("-$2,500.00") - page.should have_content("10/17/13") - page.should have_content("$1,250.00") - page.should have_content("10/18/13") - page.should have_content("$4,300.00") + within ('table') do + page.should have_content("10/07/13") + page.should have_content("-$2,500.00") + page.should have_content("10/17/13") + page.should have_content("$1,250.00") + page.should have_content("10/18/13") + page.should have_content("$4,300.00") + end end - + scenario "Cuenta Ahorro" do click_link "Cuenta Ahorro" page.should have_content("(9)") page.should have_content("$950.00") - page.should have_content("10/18/13") - page.should have_content("$1,450.00") - page.should have_content("10/23/13") - page.should have_content("-$500.00") - end + within ('table') do + page.should have_content("10/18/13") + page.should have_content("$1,450.00") + page.should have_content("10/23/13") + page.should have_content("-$500.00") + end + end end From b4e730acff0ab4e6e039bbd74f49c1bd785023c2 Mon Sep 17 00:00:00 2001 From: Jesus Romero Date: Thu, 31 Oct 2013 16:44:20 -0600 Subject: [PATCH 75/76] refactored tests --- .../see_total_amount_per_category_spec.rb | 32 ++++++++---- ..._total_amount_per_transaction_type_spec.rb | 50 +++++++++++-------- 2 files changed, 49 insertions(+), 33 deletions(-) diff --git a/spec/features/see_total_amount_per_category_spec.rb b/spec/features/see_total_amount_per_category_spec.rb index b0a49ec..1c45576 100644 --- a/spec/features/see_total_amount_per_category_spec.rb +++ b/spec/features/see_total_amount_per_category_spec.rb @@ -4,6 +4,7 @@ visit root_path click_link "This Year" end + scenario 'Per category' do page.should have_content('Salario') page.should have_content('$3,500.00') @@ -17,40 +18,49 @@ scenario "Salario Category" do click_link "Salario" - page.should have_content("10/16/13") - page.should have_content("10/31/13") - page.should have_content("$1,750.00") page.should have_content("Deposit") page.should have_content("$3,500.00") + within('table') do + page.should have_content("10/16/13") + page.should have_content("10/31/13") + page.should have_content("$1,750.00") + end end scenario "Personal Category" do click_link "Personal" - page.should have_content("10/18/13") - page.should have_content("$6,500.00") - page.should have_content("10/17/13") - page.should have_content("$2,400.00") page.should have_content("Deposit") page.should have_content("$9,000.00") page.should have_content("Widthdrawals") page.should have_content("$100.00") + within('table') do + page.should have_content("10/18/13") + page.should have_content("$6,500.00") + page.should have_content("10/17/13") + page.should have_content("$2,400.00") + end end scenario "Automovil Category" do click_link "Automóvil" - page.should have_content("10/17/13") - page.should have_content("-$200.00") page.should have_content("Widthdrawals") page.should have_content("$200.00") + within('table') do + page.should have_content("10/17/13") + page.should have_content("-$200.00") + end end scenario "Caridad Category" do click_link "Caridad" - page.should have_content("10/18/13") - page.should have_content("-$1,000.00") page.should have_content("Transfer") page.should have_content("$1,800.00") page.should have_content("Widthdrawals") page.should have_content("$1,000.00") + within('table') do + page.should have_content("10/18/13") + page.should have_content("-$1,000.00") + end end + end diff --git a/spec/features/see_total_amount_per_transaction_type_spec.rb b/spec/features/see_total_amount_per_transaction_type_spec.rb index 5357a29..6179d7d 100644 --- a/spec/features/see_total_amount_per_transaction_type_spec.rb +++ b/spec/features/see_total_amount_per_transaction_type_spec.rb @@ -8,37 +8,43 @@ scenario "Deposit Transaction" do click_link "Deposit" - page.should have_content("10/16/13") - page.should have_content("$1,750.00") - page.should have_content("10/17/13") - page.should have_content("$2,500.00") - page.should have_content("10/18/13") - page.should have_content("$6,600.00") - page.should have_content("10/31/13") - page.should have_content("$1,750.00") page.should have_content("$12,600.00") + within('table') do + page.should have_content("10/16/13") + page.should have_content("$1,750.00") + page.should have_content("10/17/13") + page.should have_content("$2,500.00") + page.should have_content("10/18/13") + page.should have_content("$6,600.00") + page.should have_content("10/31/13") + page.should have_content("$1,750.00") + end end scenario "Transfer Transaction" do click_link "Transfer" - page.should have_content("10/17/13") - page.should have_content("-$1,250.00") - page.should have_content("10/18/13") - page.should have_content("-$3,250.00") - page.should have_content("10/23/13") - page.should have_content("-$500.00") page.should have_content("$5,000.00") - end + within('table') do + page.should have_content("10/17/13") + page.should have_content("-$1,250.00") + page.should have_content("10/18/13") + page.should have_content("-$3,250.00") + page.should have_content("10/23/13") + page.should have_content("-$500.00") + end + end scenario "Widthdrawals Transaction" do click_link "Widthdrawals" - page.should have_content("10/07/13") - page.should have_content("-$2,500.00") - page.should have_content("10/17/13") - page.should have_content("-$610.00") - page.should have_content("10/18/13") - page.should have_content("-$1,000.00") page.should have_content("$4,110.00") - end + within('table') do + page.should have_content("10/07/13") + page.should have_content("-$2,500.00") + page.should have_content("10/17/13") + page.should have_content("-$610.00") + page.should have_content("10/18/13") + page.should have_content("-$1,000.00") + end + end end From d71c17250edc31fc059588aefa3f29aae2a17bc3 Mon Sep 17 00:00:00 2001 From: Jesus Romero Date: Mon, 4 Nov 2013 10:48:36 -0600 Subject: [PATCH 76/76] added test to active_transations scope --- spec/models/account_spec.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/spec/models/account_spec.rb b/spec/models/account_spec.rb index 3c01f88..55e3e25 100644 --- a/spec/models/account_spec.rb +++ b/spec/models/account_spec.rb @@ -6,5 +6,18 @@ it "has a valid account" do account.should be_valid end + + #scopes + it "should return 14 transaction for account id 1" do + (Account.find(1).active_transactions.count).should eq(14) + end + + it "should return 9 transaction for account id 2" do + (Account.find(2).active_transactions.count).should eq(9) + end + + it "should return 7 transaction for account id 3" do + (Account.find(3).active_transactions.count).should eq(7) + end end