Matthew Phelan 3 years ago
parent
commit
cf0ff16f7c
  1. 1
      Gemfile
  2. 6
      Gemfile.lock
  3. 7
      app/controllers/case_logs_controller.rb
  4. 3
      app/models/case_log.rb
  5. 0
      app/views/case_logs/index.html.erb
  6. 3
      app/views/case_logs/show.html.erb
  7. 2
      config/routes.rb
  8. 8
      db/migrate/20210908122819_add_case_log.rb
  9. 24
      db/schema.rb
  10. 6
      spec/factories/case_log.rb
  11. 11
      spec/features/case_log_spec.rb
  12. 8
      spec/spec_helper.rb

1
Gemfile

@ -29,6 +29,7 @@ group :development, :test do
gem "pry-byebug"
gem "dotenv-rails"
gem "selenium-webdriver"
gem "factory_bot_rails"
%w[rspec-core rspec-expectations rspec-mocks rspec-rails rspec-support].each do |lib|
gem lib, git: "https://github.com/rspec/#{lib}.git", branch: "main"
end

6
Gemfile.lock

@ -134,6 +134,11 @@ GEM
dotenv (= 2.7.6)
railties (>= 3.2)
erubi (1.10.0)
factory_bot (6.2.0)
activesupport (>= 5.0.0)
factory_bot_rails (6.2.0)
factory_bot (~> 6.2.0)
railties (>= 5.0.0)
ffi (1.15.4)
globalid (0.5.2)
activesupport (>= 5.0)
@ -311,6 +316,7 @@ DEPENDENCIES
byebug
capybara
dotenv-rails
factory_bot_rails
govuk-components
govuk_design_system_formbuilder
jbuilder (~> 2.7)

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

8
spec/spec_helper.rb

@ -13,6 +13,9 @@
# it.
#
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
require "factory_bot"
RSpec.configure do |config|
# rspec-expectations config goes here. You can use an alternate
# assertion/expectation library such as wrong or the stdlib/minitest
@ -84,11 +87,14 @@ RSpec.configure do |config|
# # order dependency and want to debug it, you can fix the order by providing
# # the seed, which is printed after each run.
# # --seed 1234
# config.order = :random
config.order = :random
#
# # Seed global randomization in this process using the `--seed` CLI option.
# # Setting this allows you to use `--seed` to deterministically reproduce
# # test failures related to randomization by passing the same `--seed` value
# # as the one that triggered the failure.
# Kernel.srand config.seed
config.include FactoryBot::Syntax::Methods
end

Loading…
Cancel
Save