Skip to content

Commit

Permalink
Add Post model
Browse files Browse the repository at this point in the history
  • Loading branch information
Piotr Wodziński committed Oct 31, 2017
1 parent 2be8807 commit d72c68f
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app/models/post.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class Post < ApplicationRecord
end
11 changes: 11 additions & 0 deletions db/migrate/20171031090614_create_posts.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class CreatePosts < ActiveRecord::Migration[5.1]
def change
create_table :posts do |t|
t.string :title
t.string :description
t.string :tag

t.timestamps
end
end
end
5 changes: 5 additions & 0 deletions db/migrate/20171031090759_add_user_id_to_post.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddUserIdToPost < ActiveRecord::Migration[5.1]
def change
add_reference :posts, :user, foreign_key: true
end
end
13 changes: 13 additions & 0 deletions test/fixtures/posts.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html

one:
title: MyString
description: MyString
tag: MyString
user_id: 1

two:
title: MyString
description: MyString
tag: MyString
user_id: 1
7 changes: 7 additions & 0 deletions test/models/post_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
require 'test_helper'

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

0 comments on commit d72c68f

Please sign in to comment.