Skip to content

Commit

Permalink
Add missing files
Browse files Browse the repository at this point in the history
  • Loading branch information
dhilst committed Sep 30, 2018
1 parent 856a02d commit d0348e4
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 0 deletions.
4 changes: 4 additions & 0 deletions app/models/category.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
class Category < ApplicationRecord
# rails already devine transaction method
has_one :transaction_, foreign_key: :category_id
end
11 changes: 11 additions & 0 deletions db/migrate/20180930115502_create_categories.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class CreateCategories < ActiveRecord::Migration[5.2]
def change
create_table :categories do |t|
t.string :name
t.string :color
t.string :help

t.timestamps
end
end
end
5 changes: 5 additions & 0 deletions db/migrate/20180930121500_add_category_to_transaction.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddCategoryToTransaction < ActiveRecord::Migration[5.2]
def change
add_reference :transactions, :category, foreign_key: true
end
end
6 changes: 6 additions & 0 deletions db/migrate/20180930123515_add_display_name_to_category.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class AddDisplayNameToCategory < ActiveRecord::Migration[5.2]
def change
add_column :categories, :display_name, :string
add_index :categories, %i[name], unique: true
end
end
Binary file added tenk_development.db
Binary file not shown.
9 changes: 9 additions & 0 deletions test/fixtures/categories.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html

one:
name: MyString
color: MyString

two:
name: MyString
color: MyString
7 changes: 7 additions & 0 deletions test/models/category_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
require 'test_helper'

class CategoryTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end

0 comments on commit d0348e4

Please sign in to comment.