Skip to content

Commit

Permalink
feat: generate task model and make unit tests pass.
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielGordon1 committed Jun 27, 2019
1 parent 33381b4 commit ca0ccc0
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 2 deletions.
3 changes: 3 additions & 0 deletions app/models/task.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class Task < ApplicationRecord
validates :action, presence: true, uniqueness: true
end
11 changes: 11 additions & 0 deletions db/migrate/20190627172238_create_tasks.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class CreateTasks < ActiveRecord::Migration[5.2]
def change
create_table :tasks do |t|
t.string :action
t.boolean :done, default: false
t.datetime :finished_at

t.timestamps
end
end
end
26 changes: 26 additions & 0 deletions db/schema.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# 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: 2019_06_27_172238) do

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

create_table "tasks", force: :cascade do |t|
t.string "action"
t.boolean "done", default: false
t.datetime "finished_at"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end

end
4 changes: 2 additions & 2 deletions spec/models/task_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
end
it "has an action" do
task = Task.new(valid_attributes)
expect(task.action).to eq("Finish Unit tests")
expect(task.action).to eq("Finish unit tests")
end
it "it has a done property that defaults to false" do
task = Task.new(valid_attributes)
Expand All @@ -22,7 +22,7 @@
end
it "is only valid if the action is unique and present" do
Task.create!(valid_attributes)
task = Task.new(action: "Finish Unit tests")
task = Task.new(action: "Finish unit tests")

expect(task).not_to be_valid
end
Expand Down

0 comments on commit ca0ccc0

Please sign in to comment.