diff --git a/app/controllers/case_logs_controller.rb b/app/controllers/case_logs_controller.rb index 85f1ae1b1..2eeba44cf 100644 --- a/app/controllers/case_logs_controller.rb +++ b/app/controllers/case_logs_controller.rb @@ -4,7 +4,7 @@ class CaseLogsController < ApplicationController def index @completed_case_logs = CaseLog.completed - @in_progress_case_logs = CaseLog.in_progress + @in_progress_case_logs = CaseLog.not_completed end def create diff --git a/app/models/case_log.rb b/app/models/case_log.rb index 46d766ccc..96b285527 100644 --- a/app/models/case_log.rb +++ b/app/models/case_log.rb @@ -34,7 +34,9 @@ end class CaseLog < ApplicationRecord include Discard::Model default_scope -> { kept } + scope :not_started, -> { where(status: "not_started") } scope :in_progress, -> { where(status: "in_progress") } + scope :not_completed, -> { where.not(status: "completed") } scope :completed, -> { where(status: "completed") } validate :instance_validations diff --git a/spec/features/case_log_spec.rb b/spec/features/case_log_spec.rb index fed45d5d1..5d9fa1fdb 100644 --- a/spec/features/case_log_spec.rb +++ b/spec/features/case_log_spec.rb @@ -32,6 +32,10 @@ RSpec.describe "Test Features" do describe "Create new log" do it "redirects to the task list for the new log" do visit("/case_logs") + # Ensure that we've finished creating both case logs before running the + # Capybara click part to ensure we don't get creation race conditions + expect(page).to have_link(nil, href: "/case_logs/#{case_log.id}") + expect(page).to have_link(nil, href: "/case_logs/#{empty_case_log.id}") click_link("Create new log") id = CaseLog.order(created_at: :desc).first.id expect(page).to have_content("Tasklist for log #{id}")