From 6129e3a26cd9328918bd493997935a71e1a66533 Mon Sep 17 00:00:00 2001 From: baarkerlounger Date: Thu, 31 Mar 2022 10:32:57 +0100 Subject: [PATCH] Replace view spec with request spec --- spec/requests/case_logs_controller_spec.rb | 14 ++++++++++++++ spec/views/case_log_index_view_spec.rb | 19 ------------------- 2 files changed, 14 insertions(+), 19 deletions(-) delete mode 100644 spec/views/case_log_index_view_spec.rb diff --git a/spec/requests/case_logs_controller_spec.rb b/spec/requests/case_logs_controller_spec.rb index 0c1e3524a..d81ec41ef 100644 --- a/spec/requests/case_logs_controller_spec.rb +++ b/spec/requests/case_logs_controller_spec.rb @@ -163,12 +163,26 @@ RSpec.describe CaseLogsController, type: :request do get "/logs", headers: headers, params: {} end + it "shows a table of logs" do + expect(CGI.unescape_html(response.body)).to match(//) + expect(CGI.unescape_html(response.body)).to match(/logs/) + end + it "only shows case logs for your organisation" do expected_case_row_log = "#{case_log.id}" unauthorized_case_row_log = "#{unauthorized_case_log.id}" expect(CGI.unescape_html(response.body)).to include(expected_case_row_log) expect(CGI.unescape_html(response.body)).not_to include(unauthorized_case_row_log) end + + it "shows the formatted created at date for each log" do + formatted_date = case_log.created_at.to_formatted_s(:govuk_date) + expect(CGI.unescape_html(response.body)).to include(formatted_date) + end + + it "shows the log's status" do + expect(CGI.unescape_html(response.body)).to include(case_log.status.humanize) + end end context "when requesting a specific case log" do diff --git a/spec/views/case_log_index_view_spec.rb b/spec/views/case_log_index_view_spec.rb deleted file mode 100644 index d7bcadc18..000000000 --- a/spec/views/case_log_index_view_spec.rb +++ /dev/null @@ -1,19 +0,0 @@ -require "rails_helper" - -RSpec.describe "case_logs/index" do - let(:in_progress_log) { FactoryBot.create(:case_log, :in_progress) } - - context "with a log list" do - before do - assign(:case_logs, [in_progress_log]) - render - end - - it "renders a table for all logs" do - expect(rendered).to match(/
/) - expect(rendered).to match(/logs/) - expect(rendered).to match(in_progress_log.created_at.to_formatted_s(:govuk_date)) - expect(rendered).to match(in_progress_log.status.humanize) - end - end -end