|
|
|
@ -92,7 +92,7 @@ RSpec.describe "Form Page Routing" do
|
|
|
|
|
expect(find("#lettings-log-postcode-full-field-error").value).to eq("FAKE_POSTCODE") |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it "does not reset the displayed date" do |
|
|
|
|
it "does not reset the displayed date if it's an invalid date" do |
|
|
|
|
lettings_log.update!(startdate: "2021/10/13") |
|
|
|
|
visit("/lettings-logs/#{id}/tenancy-start-date") |
|
|
|
|
fill_in("lettings_log[startdate(1i)]", with: "202") |
|
|
|
@ -106,6 +106,20 @@ RSpec.describe "Form Page Routing" do
|
|
|
|
|
expect(find_field("lettings_log[startdate(1i)]").value).to eq("2021") |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it "displays the entered date if it's in a valid format" do |
|
|
|
|
lettings_log.update!(startdate: "2021/10/13") |
|
|
|
|
visit("/lettings-logs/#{id}/tenancy-start-date") |
|
|
|
|
fill_in("lettings_log[startdate(1i)]", with: "202") |
|
|
|
|
fill_in("lettings_log[startdate(2i)]", with: "12") |
|
|
|
|
fill_in("lettings_log[startdate(3i)]", with: "1") |
|
|
|
|
click_button("Save and continue") |
|
|
|
|
|
|
|
|
|
expect(page).to have_current_path("/lettings-logs/#{id}/tenancy-start-date") |
|
|
|
|
expect(find_field("lettings_log[startdate(3i)]").value).to eq("1") |
|
|
|
|
expect(find_field("lettings_log[startdate(2i)]").value).to eq("12") |
|
|
|
|
expect(find_field("lettings_log[startdate(1i)]").value).to eq("202") |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it "does not reset the displayed date if it's empty" do |
|
|
|
|
lettings_log.update!(startdate: nil) |
|
|
|
|
visit("/lettings-logs/#{id}/tenancy-start-date") |
|
|
|
|