Skip to content

Commit

Permalink
Budget and BudgetCategory tables
Browse files Browse the repository at this point in the history
  • Loading branch information
dreikanter committed Oct 21, 2015
1 parent f3730ad commit acb12f6
Show file tree
Hide file tree
Showing 9 changed files with 82 additions and 1 deletion.
2 changes: 2 additions & 0 deletions app/models/budget.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class Budget < ActiveRecord::Base
end
2 changes: 2 additions & 0 deletions app/models/budget_category.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class BudgetCategory < ActiveRecord::Base
end
11 changes: 11 additions & 0 deletions db/migrate/20151021121704_create_budgets.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class CreateBudgets < ActiveRecord::Migration
def change
create_table :budgets do |t|
t.datetime :start_at, null: false
t.datetime :end_at, null: false
t.string :memo, null: false, default: ''

t.timestamps null: false
end
end
end
12 changes: 12 additions & 0 deletions db/migrate/20151021121959_create_budget_categories.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
class CreateBudgetCategories < ActiveRecord::Migration
def change
create_table :budget_categories do |t|
t.integer :budget_id, null: false
t.integer :category_id, null: false
t.monetize :planned, null: false, default: 0
t.string :memo, null: false, default: 0

t.timestamps null: false
end
end
end
20 changes: 19 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20151018185207) do
ActiveRecord::Schema.define(version: 20151021121959) do

create_table "accounts", force: :cascade do |t|
t.string "currency", null: false
Expand All @@ -30,6 +30,24 @@
t.datetime "updated_at", null: false
end

create_table "budget_categories", force: :cascade do |t|
t.integer "budget_id", null: false
t.integer "category_id", null: false
t.integer "planned_cents", default: 0, null: false
t.string "planned_currency", default: "USD", null: false
t.string "memo", default: "0", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end

create_table "budgets", force: :cascade do |t|
t.datetime "start_at", null: false
t.datetime "end_at", null: false
t.string "memo", default: "", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end

create_table "categories", force: :cascade do |t|
t.string "code", default: "", null: false
t.string "title", null: false
Expand Down
10 changes: 10 additions & 0 deletions test/factories/budget_categories.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FactoryGirl.define do
factory :budget_category do
budget_id 1
category_id 1
planned ""
memo "MyString"
order 1
end

end
8 changes: 8 additions & 0 deletions test/factories/budgets.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FactoryGirl.define do
factory :budget do
start_at "2015-10-21 15:17:05"
end_at "2015-10-21 15:17:05"
memo "MyString"
end

end
9 changes: 9 additions & 0 deletions test/models/budget_category_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
require "test_helper"

describe BudgetCategory do
let(:budget_category) { BudgetCategory.new }

it "must be valid" do
value(budget_category).must_be :valid?
end
end
9 changes: 9 additions & 0 deletions test/models/budget_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
require "test_helper"

describe Budget do
let(:budget) { Budget.new }

it "must be valid" do
value(budget).must_be :valid?
end
end

0 comments on commit acb12f6

Please sign in to comment.