From d848d8d87cbef49f5f4635b3378b582464bae98a Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Mon, 4 Dec 2023 03:52:21 -0500 Subject: [PATCH] Add helper methods for domains allow and export blocks files (#28196) --- .../admin/export_domain_allows_controller_spec.rb | 10 ++++++++-- .../admin/export_domain_blocks_controller_spec.rb | 8 +++++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/spec/controllers/admin/export_domain_allows_controller_spec.rb b/spec/controllers/admin/export_domain_allows_controller_spec.rb index e1e5ecc1f0..0a2e342620 100644 --- a/spec/controllers/admin/export_domain_allows_controller_spec.rb +++ b/spec/controllers/admin/export_domain_allows_controller_spec.rb @@ -24,7 +24,7 @@ RSpec.describe Admin::ExportDomainAllowsController do get :export, params: { format: :csv } expect(response).to have_http_status(200) - expect(response.body).to eq(File.read(File.join(file_fixture_path, 'domain_allows.csv'))) + expect(response.body).to eq(domain_allows_csv_file) end end @@ -40,7 +40,7 @@ RSpec.describe Admin::ExportDomainAllowsController do # Domains should now be added get :export, params: { format: :csv } expect(response).to have_http_status(200) - expect(response.body).to eq(File.read(File.join(file_fixture_path, 'domain_allows.csv'))) + expect(response.body).to eq(domain_allows_csv_file) end it 'displays error on no file selected' do @@ -49,4 +49,10 @@ RSpec.describe Admin::ExportDomainAllowsController do expect(flash[:error]).to eq(I18n.t('admin.export_domain_allows.no_file')) end end + + private + + def domain_allows_csv_file + File.read(File.join(file_fixture_path, 'domain_allows.csv')) + end end diff --git a/spec/controllers/admin/export_domain_blocks_controller_spec.rb b/spec/controllers/admin/export_domain_blocks_controller_spec.rb index 5a282c9572..bfcccfa06c 100644 --- a/spec/controllers/admin/export_domain_blocks_controller_spec.rb +++ b/spec/controllers/admin/export_domain_blocks_controller_spec.rb @@ -26,7 +26,13 @@ RSpec.describe Admin::ExportDomainBlocksController do get :export, params: { format: :csv } expect(response).to have_http_status(200) - expect(response.body).to eq(File.read(File.join(file_fixture_path, 'domain_blocks.csv'))) + expect(response.body).to eq(domain_blocks_csv_file) + end + + private + + def domain_blocks_csv_file + File.read(File.join(file_fixture_path, 'domain_blocks.csv')) end end