From f38c02cc85c75b0a0f9b9f8397f9f7969ec60efd Mon Sep 17 00:00:00 2001 From: Kat Date: Thu, 17 Nov 2022 16:38:31 +0000 Subject: [PATCH] lint and fix url in tests --- app/helpers/toggle_active_location_helper.rb | 26 ++++++++++---------- spec/features/schemes_spec.rb | 13 +++++----- spec/requests/locations_controller_spec.rb | 4 +-- 3 files changed, 21 insertions(+), 22 deletions(-) diff --git a/app/helpers/toggle_active_location_helper.rb b/app/helpers/toggle_active_location_helper.rb index fbb105219..ffb809a22 100644 --- a/app/helpers/toggle_active_location_helper.rb +++ b/app/helpers/toggle_active_location_helper.rb @@ -1,17 +1,17 @@ module ToggleActiveLocationHelper - def toggle_location_form_path(action, scheme_id, location_id) - if action == "deactivate" - scheme_location_new_deactivation_path(scheme_id:, location_id:) - else - scheme_location_reactivate_path(scheme_id:, location_id:) - end + def toggle_location_form_path(action, scheme_id, location_id) + if action == "deactivate" + scheme_location_new_deactivation_path(scheme_id:, location_id:) + else + scheme_location_reactivate_path(scheme_id:, location_id:) end + end - def date_type_question(action) - action == "deactivate" ? :deactivation_date_type : :reactivation_date_type - end + def date_type_question(action) + action == "deactivate" ? :deactivation_date_type : :reactivation_date_type + end - def date_question(action) - action == "deactivate" ? :deactivation_date : :reactivation_date - end -end \ No newline at end of file + def date_question(action) + action == "deactivate" ? :deactivation_date : :reactivation_date + end +end diff --git a/spec/features/schemes_spec.rb b/spec/features/schemes_spec.rb index 17da1849d..257cf27df 100644 --- a/spec/features/schemes_spec.rb +++ b/spec/features/schemes_spec.rb @@ -695,7 +695,7 @@ RSpec.describe "Schemes scheme Features" do let!(:location) { FactoryBot.create(:location, startdate: Time.zone.local(2022, 4, 4), scheme:) } let!(:deactivated_location) { FactoryBot.create(:location, startdate: Time.zone.local(2022, 4, 4), scheme:) } - before do + before do deactivated_location.location_deactivation_periods << FactoryBot.create(:location_deactivation_period, deactivation_date: Time.zone.local(2022, 6, 4)) click_link(scheme.service_name) end @@ -754,13 +754,12 @@ RSpec.describe "Schemes scheme Features" do expect(page).to have_current_path("/schemes/#{scheme.id}/locations") end - context "when location is incative" do context "and I click to view the location" do before do click_link(deactivated_location.postcode) end - + it "displays details about the selected location" do expect(page).to have_current_path("/schemes/#{scheme.id}/locations/#{deactivated_location.id}") expect(page).to have_content(deactivated_location.postcode) @@ -773,7 +772,7 @@ RSpec.describe "Schemes scheme Features" do expect(page).to have_content("Active from 4 April 2022 to 3 June 2022 Deactivated on 4 June 2022") expect(page).to have_content("Deactivated") end - + it "allows to reactivate a location" do click_link("Reactivate this location") expect(page).to have_current_path("/schemes/#{scheme.id}/locations/#{deactivated_location.id}/new-reactivation") @@ -781,19 +780,19 @@ RSpec.describe "Schemes scheme Features" do expect(page).to have_content("You’ll be able to add logs with this location if their tenancy start date is on or after the date you enter.") expect(page).to have_content("If the date is before 1 April 2022, select ‘From the start of the current collection period’ because the previous period has now closed.") end - + context "when I press the back button" do before do click_link "Back" end - + it "I see location details" do expect(page).to have_content scheme.locations.first.id expect(page).to have_current_path("/schemes/#{scheme.id}/locations") end end + end end - end context "when I click to change location name" do before do diff --git a/spec/requests/locations_controller_spec.rb b/spec/requests/locations_controller_spec.rb index cfce33b8d..f18084e20 100644 --- a/spec/requests/locations_controller_spec.rb +++ b/spec/requests/locations_controller_spec.rb @@ -1428,7 +1428,7 @@ RSpec.describe LocationsController, type: :request do it "renders reactivate this location" do expect(response).to have_http_status(:ok) - expect(page).to have_link("Reactivate this location", href: "/schemes/#{scheme.id}/locations/#{location.id}/reactivate") + expect(page).to have_link("Reactivate this location", href: "/schemes/#{scheme.id}/locations/#{location.id}/new-reactivation") end end @@ -1437,7 +1437,7 @@ RSpec.describe LocationsController, type: :request do it "renders reactivate this location" do expect(response).to have_http_status(:ok) - expect(page).to have_link("Reactivate this location", href: "/schemes/#{scheme.id}/locations/#{location.id}/reactivate") + expect(page).to have_link("Reactivate this location", href: "/schemes/#{scheme.id}/locations/#{location.id}/new-reactivation") end end end