From a73c020658d7e71d95f983d550fe698b949b5783 Mon Sep 17 00:00:00 2001 From: baarkerlounger Date: Wed, 8 Sep 2021 16:28:22 +0100 Subject: [PATCH] Add a case log --- app/controllers/case_logs_controller.rb | 7 +++++++ app/models/case_log.rb | 3 +++ app/views/case_logs/index.html.erb | 0 app/views/case_logs/show.html.erb | 3 +++ config/routes.rb | 2 ++ db/migrate/20210908122819_add_case_log.rb | 8 ++++++++ db/schema.rb | 24 +++++++++++++++++++++++ spec/factories/case_log.rb | 6 ++++++ spec/features/case_log_spec.rb | 11 +++++++++++ 9 files changed, 64 insertions(+) create mode 100644 app/controllers/case_logs_controller.rb create mode 100644 app/models/case_log.rb create mode 100644 app/views/case_logs/index.html.erb create mode 100644 app/views/case_logs/show.html.erb create mode 100644 db/migrate/20210908122819_add_case_log.rb create mode 100644 db/schema.rb create mode 100644 spec/factories/case_log.rb create mode 100644 spec/features/case_log_spec.rb diff --git a/app/controllers/case_logs_controller.rb b/app/controllers/case_logs_controller.rb new file mode 100644 index 000000000..262fff240 --- /dev/null +++ b/app/controllers/case_logs_controller.rb @@ -0,0 +1,7 @@ +class CaseLogsController < ApplicationController + def index; end + + def show + @case_log = CaseLog.find(params[:id]) + end +end diff --git a/app/models/case_log.rb b/app/models/case_log.rb new file mode 100644 index 000000000..9fd005fb7 --- /dev/null +++ b/app/models/case_log.rb @@ -0,0 +1,3 @@ +class CaseLog < ApplicationRecord + enum status: ["in progress", "submitted"] +end diff --git a/app/views/case_logs/index.html.erb b/app/views/case_logs/index.html.erb new file mode 100644 index 000000000..e69de29bb diff --git a/app/views/case_logs/show.html.erb b/app/views/case_logs/show.html.erb new file mode 100644 index 000000000..5c42fa4db --- /dev/null +++ b/app/views/case_logs/show.html.erb @@ -0,0 +1,3 @@ +

Tasklist for log <%= @case_log.id %>

+ +

This submission is <%= @case_log.status %>

diff --git a/config/routes.rb b/config/routes.rb index 092edea76..c7af26f3f 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -3,4 +3,6 @@ Rails.application.routes.draw do get "about", to: "about#index" get "/", to: "test#index" get "form", to: "form#index" + + resources :case_logs end diff --git a/db/migrate/20210908122819_add_case_log.rb b/db/migrate/20210908122819_add_case_log.rb new file mode 100644 index 000000000..f3368b2a4 --- /dev/null +++ b/db/migrate/20210908122819_add_case_log.rb @@ -0,0 +1,8 @@ +class AddCaseLog < ActiveRecord::Migration[6.1] + def change + create_table :case_logs do |t| + t.integer :status, default: 0 + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb new file mode 100644 index 000000000..936791fa2 --- /dev/null +++ b/db/schema.rb @@ -0,0 +1,24 @@ +# 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. +# +# This file is the source Rails uses to define your schema when running `bin/rails +# db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to +# be faster and is potentially less error prone than running all of your +# migrations from scratch. Old migrations may fail to apply correctly if those +# migrations use external dependencies or application code. +# +# It's strongly recommended that you check this file into your version control system. + +ActiveRecord::Schema.define(version: 2021_09_08_122819) do + + # These are extensions that must be enabled in order to support this database + enable_extension "plpgsql" + + create_table "case_logs", force: :cascade do |t| + t.integer "status", default: 0 + t.datetime "created_at", precision: 6, null: false + t.datetime "updated_at", precision: 6, null: false + end + +end diff --git a/spec/factories/case_log.rb b/spec/factories/case_log.rb new file mode 100644 index 000000000..cefc12c97 --- /dev/null +++ b/spec/factories/case_log.rb @@ -0,0 +1,6 @@ +FactoryBot.define do + factory :case_log do + id { 342351 } + status { 0 } + end +end diff --git a/spec/features/case_log_spec.rb b/spec/features/case_log_spec.rb new file mode 100644 index 000000000..05bdaa6c1 --- /dev/null +++ b/spec/features/case_log_spec.rb @@ -0,0 +1,11 @@ +require "rails_helper" +RSpec.describe "Test Features" do + let!(:case_log){ FactoryBot.create(:case_log) } + let(:id){ case_log.id } + let(:status) { case_log.status } + + it "Displays a tasklist header" do + visit("/case_logs/342351") + expect(page).to have_content("Tasklist for log 342351") + end +end