|
|
@ -323,8 +323,7 @@ RSpec.describe LettingsLogsController, type: :request do |
|
|
|
context "with year filter" do |
|
|
|
context "with year filter" do |
|
|
|
let!(:lettings_log_2021) do |
|
|
|
let!(:lettings_log_2021) do |
|
|
|
FactoryBot.create(:lettings_log, :in_progress, |
|
|
|
FactoryBot.create(:lettings_log, :in_progress, |
|
|
|
created_by: user, |
|
|
|
created_by: user) |
|
|
|
startdate: Time.zone.local(2022, 3, 1)) |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
let!(:lettings_log_2022) do |
|
|
|
let!(:lettings_log_2022) do |
|
|
|
lettings_log = FactoryBot.build(:lettings_log, :completed, |
|
|
|
lettings_log = FactoryBot.build(:lettings_log, :completed, |
|
|
@ -337,6 +336,13 @@ RSpec.describe LettingsLogsController, type: :request do |
|
|
|
lettings_log |
|
|
|
lettings_log |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
context "with previous logs" do |
|
|
|
|
|
|
|
before do |
|
|
|
|
|
|
|
Timecop.freeze(Time.zone.local(2022, 3, 1)) |
|
|
|
|
|
|
|
lettings_log_2021.update!(startdate: Time.zone.local(2022, 3, 1)) |
|
|
|
|
|
|
|
Timecop.unfreeze |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
it "shows lettings logs for multiple selected years" do |
|
|
|
it "shows lettings logs for multiple selected years" do |
|
|
|
get "/lettings-logs?years[]=2021&years[]=2022", headers: headers, params: {} |
|
|
|
get "/lettings-logs?years[]=2021&years[]=2022", headers: headers, params: {} |
|
|
|
expect(page).to have_link(lettings_log_2021.id.to_s) |
|
|
|
expect(page).to have_link(lettings_log_2021.id.to_s) |
|
|
@ -349,6 +355,7 @@ RSpec.describe LettingsLogsController, type: :request do |
|
|
|
expect(page).not_to have_link(lettings_log_2022.id.to_s) |
|
|
|
expect(page).not_to have_link(lettings_log_2022.id.to_s) |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
context "with year and status filter" do |
|
|
|
context "with year and status filter" do |
|
|
|
before do |
|
|
|
before do |
|
|
@ -362,7 +369,6 @@ RSpec.describe LettingsLogsController, type: :request do |
|
|
|
let!(:lettings_log_2021) do |
|
|
|
let!(:lettings_log_2021) do |
|
|
|
FactoryBot.create(:lettings_log, :in_progress, |
|
|
|
FactoryBot.create(:lettings_log, :in_progress, |
|
|
|
owning_organisation: organisation, |
|
|
|
owning_organisation: organisation, |
|
|
|
startdate: Time.zone.local(2022, 3, 1), |
|
|
|
|
|
|
|
managing_organisation: organisation, |
|
|
|
managing_organisation: organisation, |
|
|
|
created_by: user) |
|
|
|
created_by: user) |
|
|
|
end |
|
|
|
end |
|
|
@ -386,6 +392,13 @@ RSpec.describe LettingsLogsController, type: :request do |
|
|
|
created_by: user) |
|
|
|
created_by: user) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
context "with previous logs" do |
|
|
|
|
|
|
|
before do |
|
|
|
|
|
|
|
Timecop.freeze(Time.zone.local(2022, 3, 1)) |
|
|
|
|
|
|
|
lettings_log_2021.update!(startdate: Time.zone.local(2022, 3, 1)) |
|
|
|
|
|
|
|
Timecop.unfreeze |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
it "shows lettings logs for multiple selected statuses and years" do |
|
|
|
it "shows lettings logs for multiple selected statuses and years" do |
|
|
|
get "/lettings-logs?years[]=2021&years[]=2022&status[]=in_progress&status[]=completed", headers: headers, params: {} |
|
|
|
get "/lettings-logs?years[]=2021&years[]=2022&status[]=in_progress&status[]=completed", headers: headers, params: {} |
|
|
|
expect(page).to have_link(lettings_log_2021.id.to_s) |
|
|
|
expect(page).to have_link(lettings_log_2021.id.to_s) |
|
|
@ -400,6 +413,7 @@ RSpec.describe LettingsLogsController, type: :request do |
|
|
|
expect(page).not_to have_link(lettings_log_2022.id.to_s) |
|
|
|
expect(page).not_to have_link(lettings_log_2022.id.to_s) |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
context "with bulk_upload_id filter" do |
|
|
|
context "with bulk_upload_id filter" do |
|
|
|
context "with bulk upload that belongs to current user" do |
|
|
|
context "with bulk upload that belongs to current user" do |
|
|
@ -843,8 +857,14 @@ RSpec.describe LettingsLogsController, type: :request do |
|
|
|
expect(page).to have_link("review and make changes to this log", href: "/lettings-logs/#{completed_lettings_log.id}/review") |
|
|
|
expect(page).to have_link("review and make changes to this log", href: "/lettings-logs/#{completed_lettings_log.id}/review") |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
it "displays a closed collection window message for previous collection year logs" do |
|
|
|
context "with past lettings logs" do |
|
|
|
|
|
|
|
before do |
|
|
|
|
|
|
|
Timecop.freeze(Time.zone.local(2021, 4, 1)) |
|
|
|
completed_lettings_log.update!(startdate: Time.zone.local(2021, 4, 1)) |
|
|
|
completed_lettings_log.update!(startdate: Time.zone.local(2021, 4, 1)) |
|
|
|
|
|
|
|
Timecop.unfreeze |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it "displays a closed collection window message for previous collection year logs" do |
|
|
|
completed_lettings_log.reload |
|
|
|
completed_lettings_log.reload |
|
|
|
|
|
|
|
|
|
|
|
get "/lettings-logs/#{completed_lettings_log.id}", headers:, params: {} |
|
|
|
get "/lettings-logs/#{completed_lettings_log.id}", headers:, params: {} |
|
|
@ -853,6 +873,7 @@ RSpec.describe LettingsLogsController, type: :request do |
|
|
|
expect(page).to have_content("This log is from the 2021/2022 collection window, which is now closed.") |
|
|
|
expect(page).to have_content("This log is from the 2021/2022 collection window, which is now closed.") |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
context "with a lettings log with a single section complete" do |
|
|
|
context "with a lettings log with a single section complete" do |
|
|
|
let(:section_completed_lettings_log) do |
|
|
|
let(:section_completed_lettings_log) do |
|
|
@ -919,7 +940,7 @@ RSpec.describe LettingsLogsController, type: :request do |
|
|
|
postcode_known: "No") |
|
|
|
postcode_known: "No") |
|
|
|
end |
|
|
|
end |
|
|
|
let(:id) { postcode_lettings_log.id } |
|
|
|
let(:id) { postcode_lettings_log.id } |
|
|
|
let(:completed_lettings_log) { FactoryBot.create(:lettings_log, :completed, owning_organisation: user.organisation, managing_organisation: user.organisation, created_by: user, startdate: Time.zone.local(2021, 4, 1)) } |
|
|
|
let(:completed_lettings_log) { FactoryBot.create(:lettings_log, :completed, owning_organisation: user.organisation, managing_organisation: user.organisation, created_by: user) } |
|
|
|
|
|
|
|
|
|
|
|
before do |
|
|
|
before do |
|
|
|
stub_request(:get, /api.postcodes.io/) |
|
|
|
stub_request(:get, /api.postcodes.io/) |
|
|
@ -953,6 +974,13 @@ RSpec.describe LettingsLogsController, type: :request do |
|
|
|
expect(CGI.unescape_html(response.body)).to include("You didn’t answer this question") |
|
|
|
expect(CGI.unescape_html(response.body)).to include("You didn’t answer this question") |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
context "with previous logs" do |
|
|
|
|
|
|
|
before do |
|
|
|
|
|
|
|
Timecop.freeze(Time.zone.local(2021, 4, 1)) |
|
|
|
|
|
|
|
completed_lettings_log.update!(startdate: Time.zone.local(2021, 4, 1)) |
|
|
|
|
|
|
|
Timecop.unfreeze |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
it "does not allow you to change the answers for previous collection year logs" do |
|
|
|
it "does not allow you to change the answers for previous collection year logs" do |
|
|
|
get "/lettings-logs/#{completed_lettings_log.id}/setup/check-answers", headers: { "Accept" => "text/html" }, params: {} |
|
|
|
get "/lettings-logs/#{completed_lettings_log.id}/setup/check-answers", headers: { "Accept" => "text/html" }, params: {} |
|
|
|
expect(page).not_to have_link("Change") |
|
|
|
expect(page).not_to have_link("Change") |
|
|
@ -968,6 +996,7 @@ RSpec.describe LettingsLogsController, type: :request do |
|
|
|
expect(response).to redirect_to("/lettings-logs/#{completed_lettings_log.id}") |
|
|
|
expect(response).to redirect_to("/lettings-logs/#{completed_lettings_log.id}") |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
context "when requesting CSV download" do |
|
|
|
context "when requesting CSV download" do |
|
|
|
let(:headers) { { "Accept" => "text/html" } } |
|
|
|
let(:headers) { { "Accept" => "text/html" } } |
|
|
@ -1127,7 +1156,7 @@ RSpec.describe LettingsLogsController, type: :request do |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
context "with an invalid lettings log params" do |
|
|
|
context "with an invalid lettings log params" do |
|
|
|
let(:params) { { age1: 200 } } |
|
|
|
let(:params) { { beds: 200 } } |
|
|
|
|
|
|
|
|
|
|
|
it "returns 422" do |
|
|
|
it "returns 422" do |
|
|
|
expect(response).to have_http_status(:unprocessable_entity) |
|
|
|
expect(response).to have_http_status(:unprocessable_entity) |
|
|
@ -1135,7 +1164,7 @@ RSpec.describe LettingsLogsController, type: :request do |
|
|
|
|
|
|
|
|
|
|
|
it "returns an error message" do |
|
|
|
it "returns an error message" do |
|
|
|
json_response = JSON.parse(response.body) |
|
|
|
json_response = JSON.parse(response.body) |
|
|
|
expect(json_response["errors"]).to eq({ "age1" => ["Lead tenant’s age must be between 16 and 120"] }) |
|
|
|
expect(json_response["errors"]).to eq({ "beds" => ["Number of bedrooms cannot be more than 12"] }) |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|