Browse Source

Add a case log

pull/21/head
baarkerlounger 3 years ago
parent
commit
a73c020658
  1. 7
      app/controllers/case_logs_controller.rb
  2. 3
      app/models/case_log.rb
  3. 0
      app/views/case_logs/index.html.erb
  4. 3
      app/views/case_logs/show.html.erb
  5. 2
      config/routes.rb
  6. 8
      db/migrate/20210908122819_add_case_log.rb
  7. 24
      db/schema.rb
  8. 6
      spec/factories/case_log.rb
  9. 11
      spec/features/case_log_spec.rb

7
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

3
app/models/case_log.rb

@ -0,0 +1,3 @@
class CaseLog < ApplicationRecord
enum status: ["in progress", "submitted"]
end

0
app/views/case_logs/index.html.erb

3
app/views/case_logs/show.html.erb

@ -0,0 +1,3 @@
<h1 class="govuk-heading-xl">Tasklist for log <%= @case_log.id %></h1>
<h2 class="govuk-heading-s govuk-!-margin-bottom-2">This submission is <%= @case_log.status %></h2>

2
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

8
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

24
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

6
spec/factories/case_log.rb

@ -0,0 +1,6 @@
FactoryBot.define do
factory :case_log do
id { 342351 }
status { 0 }
end
end

11
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
Loading…
Cancel
Save