From f741c1308cbc9ae1caa906c1a91afc261bcd5bb2 Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Tue, 30 Apr 2024 12:51:25 -0400 Subject: [PATCH] Check response body instead of assigns in settings imports controller spec --- app/views/settings/imports/index.html.haml | 2 +- spec/controllers/settings/imports_controller_spec.rb | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/views/settings/imports/index.html.haml b/app/views/settings/imports/index.html.haml index ca815720fd..bfddd45460 100644 --- a/app/views/settings/imports/index.html.haml +++ b/app/views/settings/imports/index.html.haml @@ -46,7 +46,7 @@ %th= t('imports.failures') %tbody - @recent_imports.each do |import| - %tr + %tr{ id: dom_id(import) } %td= t("imports.types.#{import.type}") %td - if import.state_unconfirmed? diff --git a/spec/controllers/settings/imports_controller_spec.rb b/spec/controllers/settings/imports_controller_spec.rb index 89ec39e54d..219b882e6d 100644 --- a/spec/controllers/settings/imports_controller_spec.rb +++ b/spec/controllers/settings/imports_controller_spec.rb @@ -21,9 +21,10 @@ RSpec.describe Settings::ImportsController do it 'assigns the expected imports', :aggregate_failures do expect(response).to have_http_status(200) - expect(assigns(:recent_imports)).to eq [import] - expect(assigns(:recent_imports)).to_not include(other_import) expect(response.headers['Cache-Control']).to include('private, no-store') + expect(response.body) + .to include("bulk_import_#{import.id}") + .and not_include("bulk_import_#{other_import.id}") end end @@ -261,7 +262,8 @@ RSpec.describe Settings::ImportsController do it 'does not creates an unconfirmed bulk_import', :aggregate_failures do expect { subject }.to_not(change { user.account.bulk_imports.count }) - expect(assigns(:import).errors).to_not be_empty + expect(response.body) + .to include('field_with_errors') end end