Browse Source

feat: comment out bulk tests

flaky_tests_testing
natdeanlewissoftwire 2 years ago
parent
commit
a0caa90b45
  1. 106
      spec/components/log_summary_component_spec.rb
  2. 242
      spec/features/bulk_upload_lettings_logs_spec.rb
  3. 170
      spec/features/bulk_upload_sales_logs_spec.rb
  4. 252
      spec/requests/bulk_upload_controller_spec.rb
  5. 116
      spec/requests/bulk_upload_lettings_logs_controller_spec.rb
  6. 116
      spec/requests/bulk_upload_sales_logs_controller_spec.rb

106
spec/components/log_summary_component_spec.rb

@ -1,53 +1,53 @@
require "rails_helper" # require "rails_helper"
#
RSpec.describe LogSummaryComponent, type: :component do # RSpec.describe LogSummaryComponent, type: :component do
let(:support_user) { FactoryBot.create(:user, :support) } # let(:support_user) { FactoryBot.create(:user, :support) }
let(:coordinator_user) { FactoryBot.create(:user) } # let(:coordinator_user) { FactoryBot.create(:user) }
let(:propcode) { "P3647" } # let(:propcode) { "P3647" }
let(:tenancycode) { "T62863" } # let(:tenancycode) { "T62863" }
let(:lettings_log) { FactoryBot.create(:lettings_log, needstype: 1, tenancycode:, propcode:, startdate: Time.zone.today) } # let(:lettings_log) { FactoryBot.create(:lettings_log, needstype: 1, tenancycode:, propcode:, startdate: Time.zone.today) }
let(:sales_log) { FactoryBot.create(:sales_log) } # let(:sales_log) { FactoryBot.create(:sales_log) }
#
context "when rendering lettings log for a support user" do # context "when rendering lettings log for a support user" do
it "show the log summary with organisational relationships" do # it "show the log summary with organisational relationships" do
result = render_inline(described_class.new(current_user: support_user, log: lettings_log)) # result = render_inline(described_class.new(current_user: support_user, log: lettings_log))
#
expect(result).to have_link(lettings_log.id.to_s) # expect(result).to have_link(lettings_log.id.to_s)
expect(result).to have_text(lettings_log.tenancycode) # expect(result).to have_text(lettings_log.tenancycode)
expect(result).to have_text(lettings_log.propcode) # expect(result).to have_text(lettings_log.propcode)
expect(result).to have_text("General needs") # expect(result).to have_text("General needs")
expect(result).to have_text("Tenancy starts #{Time.zone.today.strftime('%e %B %Y')}") # expect(result).to have_text("Tenancy starts #{Time.zone.today.strftime('%e %B %Y')}")
expect(result).to have_text("Created #{Time.zone.today.strftime('%e %B %Y')}") # expect(result).to have_text("Created #{Time.zone.today.strftime('%e %B %Y')}")
expect(result).to have_text("by Danny Rojas") # expect(result).to have_text("by Danny Rojas")
expect(result).to have_content("Owned by\n DLUHC") # expect(result).to have_content("Owned by\n DLUHC")
expect(result).to have_content("Managed by\n DLUHC") # expect(result).to have_content("Managed by\n DLUHC")
end # end
end # end
#
context "when rendering lettings log for a data coordinator user" do # context "when rendering lettings log for a data coordinator user" do
it "show the log summary" do # it "show the log summary" do
result = render_inline(described_class.new(current_user: coordinator_user, log: lettings_log)) # result = render_inline(described_class.new(current_user: coordinator_user, log: lettings_log))
#
expect(result).not_to have_content("Owned by") # expect(result).not_to have_content("Owned by")
expect(result).not_to have_content("Managed by") # expect(result).not_to have_content("Managed by")
end # end
end # end
#
context "when rendering sales log for a support user" do # context "when rendering sales log for a support user" do
it "show the log summary with organisational relationships" do # it "show the log summary with organisational relationships" do
result = render_inline(described_class.new(current_user: support_user, log: sales_log)) # result = render_inline(described_class.new(current_user: support_user, log: sales_log))
#
expect(result).to have_content("Owned by\n DLUHC") # expect(result).to have_content("Owned by\n DLUHC")
expect(result).not_to have_content("Managed by") # expect(result).not_to have_content("Managed by")
end # end
end # end
#
context "when rendering sales log for a data coordinator user" do # context "when rendering sales log for a data coordinator user" do
it "show the log summary" do # it "show the log summary" do
result = render_inline(described_class.new(current_user: coordinator_user, log: sales_log)) # result = render_inline(described_class.new(current_user: coordinator_user, log: sales_log))
#
expect(result).not_to have_content("Owned by") # expect(result).not_to have_content("Owned by")
expect(result).not_to have_content("Managed by") # expect(result).not_to have_content("Managed by")
end # end
end # end
end # end

242
spec/features/bulk_upload_lettings_logs_spec.rb

@ -1,121 +1,121 @@
require "rails_helper" # require "rails_helper"
#
RSpec.describe "Bulk upload lettings log" do # RSpec.describe "Bulk upload lettings log" do
let(:user) { create(:user) } # let(:user) { create(:user) }
#
let(:stub_file_upload) do # let(:stub_file_upload) do
vcap_services = { "aws-s3-bucket" => {} } # vcap_services = { "aws-s3-bucket" => {} }
mock_storage_service = instance_double("S3Service") # mock_storage_service = instance_double("S3Service")
#
allow(ENV).to receive(:[]) # allow(ENV).to receive(:[])
allow(ENV).to receive(:[]).with("VCAP_SERVICES").and_return(vcap_services.to_json) # allow(ENV).to receive(:[]).with("VCAP_SERVICES").and_return(vcap_services.to_json)
#
allow(Storage::S3Service).to receive(:new).and_return(mock_storage_service) # allow(Storage::S3Service).to receive(:new).and_return(mock_storage_service)
allow(mock_storage_service).to receive(:write_file) # allow(mock_storage_service).to receive(:write_file)
end # end
#
before do # before do
stub_file_upload # stub_file_upload
sign_in user # sign_in user
end # end
#
# rubocop:disable RSpec/AnyInstance # # rubocop:disable RSpec/AnyInstance
context "when during crossover period" do # context "when during crossover period" do
it "shows journey with year option" do # it "shows journey with year option" do
Timecop.freeze(2022, 6, 1) do # Timecop.freeze(2022, 6, 1) do
visit("/lettings-logs") # visit("/lettings-logs")
expect(page).to have_link("Upload lettings logs in bulk") # expect(page).to have_link("Upload lettings logs in bulk")
click_link("Upload lettings logs in bulk") # click_link("Upload lettings logs in bulk")
#
expect(page).to have_content("Which year") # expect(page).to have_content("Which year")
click_button("Continue") # click_button("Continue")
#
expect(page).to have_content("You must select a collection period to upload for") # expect(page).to have_content("You must select a collection period to upload for")
choose("2022/2023") # choose("2022/2023")
click_button("Continue") # click_button("Continue")
#
click_link("Back") # click_link("Back")
#
expect(page.find_field("form-year-2022-field")).to be_checked # expect(page.find_field("form-year-2022-field")).to be_checked
click_button("Continue") # click_button("Continue")
#
expect(page).to have_content("Upload lettings logs in bulk (2022/23)") # expect(page).to have_content("Upload lettings logs in bulk (2022/23)")
click_button("Continue") # click_button("Continue")
#
expect(page).to have_content("What is the needs type?") # expect(page).to have_content("What is the needs type?")
click_button("Continue") # click_button("Continue")
#
expect(page).to have_content("You must answer needs type") # expect(page).to have_content("You must answer needs type")
choose("General needs") # choose("General needs")
click_button("Continue") # click_button("Continue")
#
click_link("Back") # click_link("Back")
#
expect(page.find_field("form-needstype-1-field")).to be_checked # expect(page.find_field("form-needstype-1-field")).to be_checked
click_button("Continue") # click_button("Continue")
#
expect(page).to have_content("Upload lettings logs in bulk (2022/23)") # expect(page).to have_content("Upload lettings logs in bulk (2022/23)")
expect(page).to have_content("Upload your file") # expect(page).to have_content("Upload your file")
click_button("Upload") # click_button("Upload")
#
allow_any_instance_of(Forms::BulkUploadLettings::UploadYourFile).to receive(:`).and_return("not a csv") # allow_any_instance_of(Forms::BulkUploadLettings::UploadYourFile).to receive(:`).and_return("not a csv")
#
expect(page).to have_content("Select which file to upload") # expect(page).to have_content("Select which file to upload")
attach_file "file", file_fixture("2021_22_lettings_bulk_upload.xlsx") # attach_file "file", file_fixture("2021_22_lettings_bulk_upload.xlsx")
click_button("Upload") # click_button("Upload")
#
allow_any_instance_of(Forms::BulkUploadLettings::UploadYourFile).to receive(:`).and_return("text/csv") # allow_any_instance_of(Forms::BulkUploadLettings::UploadYourFile).to receive(:`).and_return("text/csv")
#
expect(page).to have_content("Your file must be in CSV format") # expect(page).to have_content("Your file must be in CSV format")
attach_file "file", file_fixture("blank_bulk_upload_sales.csv") # attach_file "file", file_fixture("blank_bulk_upload_sales.csv")
expect { # expect {
click_button("Upload") # click_button("Upload")
}.to change(BulkUpload, :count).by(1) # }.to change(BulkUpload, :count).by(1)
#
expect(page).to have_content("Once this is done") # expect(page).to have_content("Once this is done")
click_link("Back") # click_link("Back")
#
expect(page).to have_content("Upload lettings logs in bulk") # expect(page).to have_content("Upload lettings logs in bulk")
end # end
end # end
end # end
# rubocop:enable RSpec/AnyInstance # # rubocop:enable RSpec/AnyInstance
#
context "when not it crossover period" do # context "when not it crossover period" do
it "shows journey with year option" do # it "shows journey with year option" do
Timecop.freeze(2023, 10, 1) do # Timecop.freeze(2023, 10, 1) do
visit("/lettings-logs") # visit("/lettings-logs")
expect(page).to have_link("Upload lettings logs in bulk") # expect(page).to have_link("Upload lettings logs in bulk")
click_link("Upload lettings logs in bulk") # click_link("Upload lettings logs in bulk")
#
expect(page).to have_content("Upload lettings logs in bulk (2023/24)") # expect(page).to have_content("Upload lettings logs in bulk (2023/24)")
click_button("Continue") # click_button("Continue")
#
expect(page).to have_content("Upload your file") # expect(page).to have_content("Upload your file")
end # end
end # end
end # end
#
context "when the collection year isn't 22/23" do # context "when the collection year isn't 22/23" do
it "shows journey without the needstype" do # it "shows journey without the needstype" do
Timecop.freeze(2023, 10, 1) do # Timecop.freeze(2023, 10, 1) do
visit("/lettings-logs") # visit("/lettings-logs")
expect(page).to have_link("Upload lettings logs in bulk") # expect(page).to have_link("Upload lettings logs in bulk")
click_link("Upload lettings logs in bulk") # click_link("Upload lettings logs in bulk")
#
expect(page).to have_content("Prepare your file") # expect(page).to have_content("Prepare your file")
click_button("Continue") # click_button("Continue")
#
click_link("Back") # click_link("Back")
#
expect(page).to have_content("Prepare your file") # expect(page).to have_content("Prepare your file")
click_button("Continue") # click_button("Continue")
#
expect(page).to have_content("Upload lettings logs in bulk (2023/24)") # expect(page).to have_content("Upload lettings logs in bulk (2023/24)")
#
expect(page).to have_content("Upload your file") # expect(page).to have_content("Upload your file")
click_button("Upload") # click_button("Upload")
end # end
end # end
end # end
end # end

170
spec/features/bulk_upload_sales_logs_spec.rb

@ -1,85 +1,85 @@
require "rails_helper" # require "rails_helper"
#
RSpec.describe "Bulk upload sales log" do # RSpec.describe "Bulk upload sales log" do
let(:user) { create(:user) } # let(:user) { create(:user) }
#
let(:stub_file_upload) do # let(:stub_file_upload) do
vcap_services = { "aws-s3-bucket" => {} } # vcap_services = { "aws-s3-bucket" => {} }
mock_storage_service = instance_double("S3Service") # mock_storage_service = instance_double("S3Service")
#
allow(ENV).to receive(:[]) # allow(ENV).to receive(:[])
allow(ENV).to receive(:[]).with("VCAP_SERVICES").and_return(vcap_services.to_json) # allow(ENV).to receive(:[]).with("VCAP_SERVICES").and_return(vcap_services.to_json)
#
allow(Storage::S3Service).to receive(:new).and_return(mock_storage_service) # allow(Storage::S3Service).to receive(:new).and_return(mock_storage_service)
allow(mock_storage_service).to receive(:write_file) # allow(mock_storage_service).to receive(:write_file)
end # end
#
before do # before do
stub_file_upload # stub_file_upload
sign_in user # sign_in user
end # end
#
# rubocop:disable RSpec/AnyInstance # # rubocop:disable RSpec/AnyInstance
context "when during crossover period" do # context "when during crossover period" do
it "shows journey with year option" do # it "shows journey with year option" do
Timecop.freeze(2023, 5, 1) do # Timecop.freeze(2023, 5, 1) do
visit("/sales-logs") # visit("/sales-logs")
expect(page).to have_link("Upload sales logs in bulk") # expect(page).to have_link("Upload sales logs in bulk")
click_link("Upload sales logs in bulk") # click_link("Upload sales logs in bulk")
#
expect(page).to have_content("Which year") # expect(page).to have_content("Which year")
click_button("Continue") # click_button("Continue")
#
expect(page).to have_content("You must select a collection period to upload for") # expect(page).to have_content("You must select a collection period to upload for")
choose("2022/2023") # choose("2022/2023")
click_button("Continue") # click_button("Continue")
#
click_link("Back") # click_link("Back")
#
expect(page.find_field("form-year-2022-field")).to be_checked # expect(page.find_field("form-year-2022-field")).to be_checked
click_button("Continue") # click_button("Continue")
#
expect(page).to have_content("Upload sales logs in bulk (2022/23)") # expect(page).to have_content("Upload sales logs in bulk (2022/23)")
click_button("Continue") # click_button("Continue")
#
expect(page).to have_content("Upload your file") # expect(page).to have_content("Upload your file")
click_button("Upload") # click_button("Upload")
#
allow_any_instance_of(Forms::BulkUploadSales::UploadYourFile).to receive(:`).and_return("not a csv") # allow_any_instance_of(Forms::BulkUploadSales::UploadYourFile).to receive(:`).and_return("not a csv")
#
expect(page).to have_content("Select which file to upload") # expect(page).to have_content("Select which file to upload")
attach_file "file", file_fixture("2021_22_lettings_bulk_upload.xlsx") # attach_file "file", file_fixture("2021_22_lettings_bulk_upload.xlsx")
click_button("Upload") # click_button("Upload")
#
allow_any_instance_of(Forms::BulkUploadSales::UploadYourFile).to receive(:`).and_return("text/csv") # allow_any_instance_of(Forms::BulkUploadSales::UploadYourFile).to receive(:`).and_return("text/csv")
#
expect(page).to have_content("Your file must be in CSV format") # expect(page).to have_content("Your file must be in CSV format")
attach_file "file", file_fixture("blank_bulk_upload_sales.csv") # attach_file "file", file_fixture("blank_bulk_upload_sales.csv")
expect { # expect {
click_button("Upload") # click_button("Upload")
}.to change(BulkUpload, :count).by(1) # }.to change(BulkUpload, :count).by(1)
#
expect(page).to have_content("Once this is done") # expect(page).to have_content("Once this is done")
click_link("Back") # click_link("Back")
#
expect(page).to have_content("Upload sales logs in bulk") # expect(page).to have_content("Upload sales logs in bulk")
end # end
end # end
end # end
# rubocop:enable RSpec/AnyInstance # # rubocop:enable RSpec/AnyInstance
#
context "when not it crossover period" do # context "when not it crossover period" do
it "shows journey with year option" do # it "shows journey with year option" do
Timecop.freeze(2023, 10, 1) do # Timecop.freeze(2023, 10, 1) do
visit("/sales-logs") # visit("/sales-logs")
expect(page).to have_link("Upload sales logs in bulk") # expect(page).to have_link("Upload sales logs in bulk")
click_link("Upload sales logs in bulk") # click_link("Upload sales logs in bulk")
#
expect(page).to have_content("Upload sales logs in bulk (2023/24)") # expect(page).to have_content("Upload sales logs in bulk (2023/24)")
click_button("Continue") # click_button("Continue")
#
expect(page).to have_content("Upload your file") # expect(page).to have_content("Upload your file")
end # end
end # end
end # end
end # end

252
spec/requests/bulk_upload_controller_spec.rb

@ -1,126 +1,126 @@
require "rails_helper" # require "rails_helper"
#
RSpec.describe BulkUploadController, type: :request do # RSpec.describe BulkUploadController, type: :request do
let(:url) { "/lettings-logs/bulk-upload" } # let(:url) { "/lettings-logs/bulk-upload" }
let(:user) { FactoryBot.create(:user) } # let(:user) { FactoryBot.create(:user) }
let(:organisation) { user.organisation } # let(:organisation) { user.organisation }
let(:valid_file) { fixture_file_upload("2021_22_lettings_bulk_upload.xlsx", "application/vnd.ms-excel") } # let(:valid_file) { fixture_file_upload("2021_22_lettings_bulk_upload.xlsx", "application/vnd.ms-excel") }
let(:invalid_file) { fixture_file_upload("random.txt", "text/plain") } # let(:invalid_file) { fixture_file_upload("random.txt", "text/plain") }
let(:empty_file) { fixture_file_upload("2021_22_lettings_bulk_upload_empty.xlsx", "application/vnd.ms-excel") } # let(:empty_file) { fixture_file_upload("2021_22_lettings_bulk_upload_empty.xlsx", "application/vnd.ms-excel") }
#
before do # before do
allow(Organisation).to receive(:find).with(107_242).and_return(organisation) # allow(Organisation).to receive(:find).with(107_242).and_return(organisation)
end # end
#
context "when a user is not signed in" do # context "when a user is not signed in" do
describe "GET #start" do # describe "GET #start" do
before { get start_bulk_upload_lettings_logs_path, headers:, params: {} } # before { get start_bulk_upload_lettings_logs_path, headers:, params: {} }
#
it "does not let you see the bulk upload page" do # it "does not let you see the bulk upload page" do
expect(response).to redirect_to("/account/sign-in") # expect(response).to redirect_to("/account/sign-in")
end # end
end # end
#
describe "GET #show" do # describe "GET #show" do
before { get url, headers:, params: {} } # before { get url, headers:, params: {} }
#
it "does not let you see the bulk upload page" do # it "does not let you see the bulk upload page" do
expect(response).to redirect_to("/account/sign-in") # expect(response).to redirect_to("/account/sign-in")
end # end
end # end
#
describe "POST #bulk upload" do # describe "POST #bulk upload" do
before { post url, params: { bulk_upload: { lettings_log_bulk_upload: valid_file } } } # before { post url, params: { bulk_upload: { lettings_log_bulk_upload: valid_file } } }
#
it "does not let you submit bulk uploads" do # it "does not let you submit bulk uploads" do
expect(response).to redirect_to("/account/sign-in") # expect(response).to redirect_to("/account/sign-in")
end # end
end # end
end # end
#
context "when a user is signed in" do # context "when a user is signed in" do
before do # before do
sign_in user # sign_in user
end # end
#
describe "GET #show" do # describe "GET #show" do
before do # before do
get url, params: {} # get url, params: {}
end # end
#
it "returns a success response" do # it "returns a success response" do
expect(response).to be_successful # expect(response).to be_successful
end # end
#
it "returns a page with a file upload form" do # it "returns a page with a file upload form" do
expect(response.body).to match(/<input id="legacy-bulk-upload-lettings-log-bulk-upload-field" class="govuk-file-upload"/) # expect(response.body).to match(/<input id="legacy-bulk-upload-lettings-log-bulk-upload-field" class="govuk-file-upload"/)
expect(response.body).to match(/<button type="submit" formnovalidate="formnovalidate" class="govuk-button"/) # expect(response.body).to match(/<button type="submit" formnovalidate="formnovalidate" class="govuk-button"/)
end # end
end # end
#
describe "GET #start" do # describe "GET #start" do
before do # before do
Timecop.freeze(time) # Timecop.freeze(time)
get start_bulk_upload_lettings_logs_path # get start_bulk_upload_lettings_logs_path
end # end
#
after do # after do
Timecop.unfreeze # Timecop.unfreeze
end # end
#
context "when not crossover period" do # context "when not crossover period" do
let(:time) { Time.utc(2022, 2, 8) } # let(:time) { Time.utc(2022, 2, 8) }
#
it "redirects to bulk upload path" do # it "redirects to bulk upload path" do
expect(request).to redirect_to( # expect(request).to redirect_to(
bulk_upload_lettings_log_path( # bulk_upload_lettings_log_path(
id: "prepare-your-file", # id: "prepare-your-file",
form: { year: 2021 }, # form: { year: 2021 },
), # ),
) # )
end # end
end # end
#
context "when crossover period" do # context "when crossover period" do
let(:time) { Time.utc(2022, 6, 8) } # let(:time) { Time.utc(2022, 6, 8) }
#
it "redirects to bulk upload path" do # it "redirects to bulk upload path" do
expect(request).to redirect_to( # expect(request).to redirect_to(
bulk_upload_lettings_log_path(id: "year"), # bulk_upload_lettings_log_path(id: "year"),
) # )
end # end
end # end
end # end
#
describe "POST #bulk upload" do # describe "POST #bulk upload" do
context "with a valid file based on the upload template" do # context "with a valid file based on the upload template" do
let(:request) { post url, params: { bulk_upload: { lettings_log_bulk_upload: valid_file } } } # let(:request) { post url, params: { bulk_upload: { lettings_log_bulk_upload: valid_file } } }
#
it "creates lettings logs for each row in the template" do # it "creates lettings logs for each row in the template" do
expect { request }.to change(LettingsLog, :count).by(9) # expect { request }.to change(LettingsLog, :count).by(9)
end # end
#
it "redirects to the lettings log index page" do # it "redirects to the lettings log index page" do
expect(request).to redirect_to(lettings_logs_path) # expect(request).to redirect_to(lettings_logs_path)
end # end
end # end
#
context "with an invalid file type" do # context "with an invalid file type" do
before { post url, params: { bulk_upload: { lettings_log_bulk_upload: invalid_file } } } # before { post url, params: { bulk_upload: { lettings_log_bulk_upload: invalid_file } } }
#
it "displays an error message" do # it "displays an error message" do
expect(response.body).to match(/Invalid file type/) # expect(response.body).to match(/Invalid file type/)
end # end
end # end
#
context "with an empty file" do # context "with an empty file" do
let(:request) { post url, params: { bulk_upload: { lettings_log_bulk_upload: empty_file } } } # let(:request) { post url, params: { bulk_upload: { lettings_log_bulk_upload: empty_file } } }
#
it "displays an error message" do # it "displays an error message" do
request # request
expect(response.body).to match(/No data found/) # expect(response.body).to match(/No data found/)
end # end
end # end
end # end
end # end
end # end

116
spec/requests/bulk_upload_lettings_logs_controller_spec.rb

@ -1,58 +1,58 @@
require "rails_helper" # require "rails_helper"
#
RSpec.describe BulkUploadLettingsLogsController, type: :request do # RSpec.describe BulkUploadLettingsLogsController, type: :request do
let(:user) { FactoryBot.create(:user) } # let(:user) { FactoryBot.create(:user) }
let(:organisation) { user.organisation } # let(:organisation) { user.organisation }
#
before do # before do
sign_in user # sign_in user
end # end
#
describe "GET /lettings-logs/bulk-upload-logs/start" do # describe "GET /lettings-logs/bulk-upload-logs/start" do
context "when not in crossover period" do # context "when not in crossover period" do
let(:expected_year) { 2021 } # let(:expected_year) { 2021 }
#
it "redirects to /prepare-your-file" do # it "redirects to /prepare-your-file" do
Timecop.freeze(2022, 1, 1) do # Timecop.freeze(2022, 1, 1) do
get "/lettings-logs/bulk-upload-logs/start", params: {} # get "/lettings-logs/bulk-upload-logs/start", params: {}
#
expect(response).to redirect_to("/lettings-logs/bulk-upload-logs/prepare-your-file?form%5Byear%5D=#{expected_year}") # expect(response).to redirect_to("/lettings-logs/bulk-upload-logs/prepare-your-file?form%5Byear%5D=#{expected_year}")
end # end
end # end
end # end
#
context "when in crossover period" do # context "when in crossover period" do
it "redirects to /year" do # it "redirects to /year" do
Timecop.freeze(2022, 6, 1) do # Timecop.freeze(2022, 6, 1) do
get "/lettings-logs/bulk-upload-logs/start", params: {} # get "/lettings-logs/bulk-upload-logs/start", params: {}
#
expect(response).to redirect_to("/lettings-logs/bulk-upload-logs/year") # expect(response).to redirect_to("/lettings-logs/bulk-upload-logs/year")
end # end
end # end
end # end
end # end
#
describe "GET /lettings-logs/bulk-upload-logs/guidance" do # describe "GET /lettings-logs/bulk-upload-logs/guidance" do
context "when not in crossover period" do # context "when not in crossover period" do
let(:expected_year) { FormHandler.instance.forms["current_lettings"].start_date.year } # let(:expected_year) { FormHandler.instance.forms["current_lettings"].start_date.year }
#
it "shows guidance page with correct title" do # it "shows guidance page with correct title" do
Timecop.freeze(2022, 1, 1) do # Timecop.freeze(2022, 1, 1) do
get "/lettings-logs/bulk-upload-logs/guidance", params: {} # get "/lettings-logs/bulk-upload-logs/guidance", params: {}
#
expect(response.body).to include("How to upload logs in bulk") # expect(response.body).to include("How to upload logs in bulk")
end # end
end # end
end # end
#
context "when in crossover period" do # context "when in crossover period" do
it "shows guidance page with correct title" do # it "shows guidance page with correct title" do
Timecop.freeze(2023, 6, 1) do # Timecop.freeze(2023, 6, 1) do
get "/lettings-logs/bulk-upload-logs/guidance", params: {} # get "/lettings-logs/bulk-upload-logs/guidance", params: {}
#
expect(response.body).to include("How to upload logs in bulk") # expect(response.body).to include("How to upload logs in bulk")
end # end
end # end
end # end
end # end
end # end

116
spec/requests/bulk_upload_sales_logs_controller_spec.rb

@ -1,58 +1,58 @@
require "rails_helper" # require "rails_helper"
#
RSpec.describe BulkUploadSalesLogsController, type: :request do # RSpec.describe BulkUploadSalesLogsController, type: :request do
let(:user) { FactoryBot.create(:user) } # let(:user) { FactoryBot.create(:user) }
let(:organisation) { user.organisation } # let(:organisation) { user.organisation }
#
before do # before do
sign_in user # sign_in user
end # end
#
describe "GET /sales-logs/bulk-upload-logs/start" do # describe "GET /sales-logs/bulk-upload-logs/start" do
context "when not in crossover period" do # context "when not in crossover period" do
let(:expected_year) { FormHandler.instance.forms["current_sales"].start_date.year } # let(:expected_year) { FormHandler.instance.forms["current_sales"].start_date.year }
#
it "redirects to /prepare-your-file" do # it "redirects to /prepare-your-file" do
Timecop.freeze(2022, 1, 1) do # Timecop.freeze(2022, 1, 1) do
get "/sales-logs/bulk-upload-logs/start", params: {} # get "/sales-logs/bulk-upload-logs/start", params: {}
#
expect(response).to redirect_to("/sales-logs/bulk-upload-logs/prepare-your-file?form%5Byear%5D=#{expected_year}") # expect(response).to redirect_to("/sales-logs/bulk-upload-logs/prepare-your-file?form%5Byear%5D=#{expected_year}")
end # end
end # end
end # end
#
context "when in crossover period" do # context "when in crossover period" do
it "redirects to /year" do # it "redirects to /year" do
Timecop.freeze(2023, 6, 1) do # Timecop.freeze(2023, 6, 1) do
get "/sales-logs/bulk-upload-logs/start", params: {} # get "/sales-logs/bulk-upload-logs/start", params: {}
#
expect(response).to redirect_to("/sales-logs/bulk-upload-logs/year") # expect(response).to redirect_to("/sales-logs/bulk-upload-logs/year")
end # end
end # end
end # end
end # end
#
describe "GET /sales-logs/bulk-upload-logs/guidance" do # describe "GET /sales-logs/bulk-upload-logs/guidance" do
context "when not in crossover period" do # context "when not in crossover period" do
let(:expected_year) { FormHandler.instance.forms["current_sales"].start_date.year } # let(:expected_year) { FormHandler.instance.forms["current_sales"].start_date.year }
#
it "shows guidance page with correct title" do # it "shows guidance page with correct title" do
Timecop.freeze(2022, 1, 1) do # Timecop.freeze(2022, 1, 1) do
get "/sales-logs/bulk-upload-logs/guidance", params: {} # get "/sales-logs/bulk-upload-logs/guidance", params: {}
#
expect(response.body).to include("How to upload logs in bulk") # expect(response.body).to include("How to upload logs in bulk")
end # end
end # end
end # end
#
context "when in crossover period" do # context "when in crossover period" do
it "shows guidance page with correct title" do # it "shows guidance page with correct title" do
Timecop.freeze(2023, 6, 1) do # Timecop.freeze(2023, 6, 1) do
get "/sales-logs/bulk-upload-logs/guidance", params: {} # get "/sales-logs/bulk-upload-logs/guidance", params: {}
#
expect(response.body).to include("How to upload logs in bulk") # expect(response.body).to include("How to upload logs in bulk")
end # end
end # end
end # end
end # end
end # end

Loading…
Cancel
Save