From d75210a4ba414b1acc39fea14ea78af3cabc8278 Mon Sep 17 00:00:00 2001 From: Jack S Date: Fri, 21 Oct 2022 09:15:36 +0100 Subject: [PATCH] Rubocop fixes --- app/helpers/navigation_items_helper.rb | 8 ++++---- app/models/bulk_upload.rb | 5 +---- .../organisation_relationships/managing_agents.html.erb | 2 +- spec/requests/form_controller_spec.rb | 4 ++-- spec/requests/locations_controller_spec.rb | 8 ++++---- spec/requests/users_controller_spec.rb | 6 +++--- 6 files changed, 15 insertions(+), 18 deletions(-) diff --git a/app/helpers/navigation_items_helper.rb b/app/helpers/navigation_items_helper.rb index cb21ad4fe..f8147ccd3 100644 --- a/app/helpers/navigation_items_helper.rb +++ b/app/helpers/navigation_items_helper.rb @@ -40,8 +40,8 @@ module NavigationItemsHelper NavigationItem.new("Schemes", "/organisations/#{current_organisation_id}/schemes", subnav_supported_housing_schemes_path?(path)), NavigationItem.new("Users", "/organisations/#{current_organisation_id}/users", subnav_users_path?(path)), NavigationItem.new("About this organisation", "/organisations/#{current_organisation_id}", subnav_details_path?(path)), - (NavigationItem.new("Housing providers", "/organisations/#{current_organisation_id}/housing-providers", housing_providers_path?(path)) if FeatureToggle.managing_owning_enabled?), - (NavigationItem.new("Managing agents", "/organisations/#{current_organisation_id}/managing-agents", managing_agents_path?(path)) if FeatureToggle.managing_owning_enabled?), + (NavigationItem.new("Housing providers", housing_providers_organisation_path(current_user.organisation), housing_providers_path?(path)) if FeatureToggle.managing_owning_enabled?), + (NavigationItem.new("Managing agents", managing_agents_organisation_path(current_user.organisation), managing_agents_path?(path)) if FeatureToggle.managing_owning_enabled?), ].compact else [ @@ -49,8 +49,8 @@ module NavigationItemsHelper FeatureToggle.sales_log_enabled? ? NavigationItem.new("Sales logs", "/organisations/#{current_organisation_id}/sales-logs", sales_logs_current?(path)) : nil, NavigationItem.new("Users", "/organisations/#{current_organisation_id}/users", subnav_users_path?(path)), NavigationItem.new("About this organisation", "/organisations/#{current_organisation_id}", subnav_details_path?(path)), - (NavigationItem.new("Housing providers", "/organisations/#{current_organisation_id}/housing-providers", housing_providers_path?(path)) if FeatureToggle.managing_owning_enabled?), - (NavigationItem.new("Managing agents", "/organisations/#{current_organisation_id}/managing-agents", managing_agents_path?(path)) if FeatureToggle.managing_owning_enabled?), + (NavigationItem.new("Housing providers", housing_providers_organisation_path(current_user.organisation), housing_providers_path?(path)) if FeatureToggle.managing_owning_enabled?), + (NavigationItem.new("Managing agents", managing_agents_organisation_path(current_user.organisation), managing_agents_path?(path)) if FeatureToggle.managing_owning_enabled?), ].compact end end diff --git a/app/models/bulk_upload.rb b/app/models/bulk_upload.rb index 183dc274e..fa2a7a0e9 100644 --- a/app/models/bulk_upload.rb +++ b/app/models/bulk_upload.rb @@ -35,10 +35,7 @@ class BulkUpload created_by: current_user, ) map_row(row).each do |attr_key, attr_val| - update = lettings_log.update(attr_key => attr_val) - unless update - # TODO: determine what to do when a bulk upload contains field values that don't pass validations - end + _update = lettings_log.update(attr_key => attr_val) rescue ArgumentError # TODO: determine what we want to do when bulk upload contains totally invalid data for a field. end diff --git a/app/views/organisation_relationships/managing_agents.html.erb b/app/views/organisation_relationships/managing_agents.html.erb index 5015b5775..fc9eaa897 100644 --- a/app/views/organisation_relationships/managing_agents.html.erb +++ b/app/views/organisation_relationships/managing_agents.html.erb @@ -5,7 +5,7 @@ <%= render partial: "organisations/headings", locals: { main: @organisation.name, sub: nil } %> <%= render SubNavigationComponent.new( items: secondary_items(request.path, @organisation.id), - ) %> + ) %>

managing agents

A managing agent can submit logs for your organisation.

<% else %> diff --git a/spec/requests/form_controller_spec.rb b/spec/requests/form_controller_spec.rb index f879985b8..ade87cfde 100644 --- a/spec/requests/form_controller_spec.rb +++ b/spec/requests/form_controller_spec.rb @@ -158,7 +158,7 @@ RSpec.describe FormController, type: :request do before do Timecop.freeze(Time.zone.local(2022, 12, 1)) - get "/lettings-logs/#{lettings_log_2022.id}/setup/check-answers", headers: headers, params: {} + get "/lettings-logs/#{lettings_log_2022.id}/setup/check-answers", headers:, params: {} end after do @@ -267,7 +267,7 @@ RSpec.describe FormController, type: :request do it "logs that validation was triggered" do expect(Rails.logger).to receive(:info).with("User triggered validation(s) on: age1").once - post "/lettings-logs/#{lettings_log.id}/form", params: params + post "/lettings-logs/#{lettings_log.id}/form", params: end context "when the number of days is too high for the month" do diff --git a/spec/requests/locations_controller_spec.rb b/spec/requests/locations_controller_spec.rb index 66bd96c72..96b3d1b21 100644 --- a/spec/requests/locations_controller_spec.rb +++ b/spec/requests/locations_controller_spec.rb @@ -100,7 +100,7 @@ RSpec.describe LocationsController, type: :request do before do sign_in user - post "/schemes/#{scheme.id}/locations", params: params + post "/schemes/#{scheme.id}/locations", params: end it "creates a new location for scheme with valid params and redirects to correct page" do @@ -302,7 +302,7 @@ RSpec.describe LocationsController, type: :request do before do allow(user).to receive(:need_two_factor_authentication?).and_return(false) sign_in user - post "/schemes/#{scheme.id}/locations", params: params + post "/schemes/#{scheme.id}/locations", params: end it "creates a new location for scheme with valid params and redirects to correct page" do @@ -573,7 +573,7 @@ RSpec.describe LocationsController, type: :request do before do sign_in user - patch "/schemes/#{scheme.id}/locations/#{location.id}", params: params + patch "/schemes/#{scheme.id}/locations/#{location.id}", params: end it "updates existing location for scheme with valid params and redirects to correct page" do @@ -714,7 +714,7 @@ RSpec.describe LocationsController, type: :request do before do allow(user).to receive(:need_two_factor_authentication?).and_return(false) sign_in user - patch "/schemes/#{scheme.id}/locations/#{location.id}", params: params + patch "/schemes/#{scheme.id}/locations/#{location.id}", params: end it "updates a location for scheme with valid params and redirects to correct page" do diff --git a/spec/requests/users_controller_spec.rb b/spec/requests/users_controller_spec.rb index a404bbd97..048799985 100644 --- a/spec/requests/users_controller_spec.rb +++ b/spec/requests/users_controller_spec.rb @@ -952,7 +952,7 @@ RSpec.describe UsersController, type: :request do context "when the current user matches the user ID" do before do - get "/users/#{user.id}/deactivate", headers: headers, params: {} + get "/users/#{user.id}/deactivate", headers:, params: {} end it "redirects user to user page" do @@ -962,7 +962,7 @@ RSpec.describe UsersController, type: :request do context "when the current user does not match the user ID" do before do - get "/users/#{other_user.id}/deactivate", headers: headers, params: {} + get "/users/#{other_user.id}/deactivate", headers:, params: {} end it "shows deactivation page with deactivate and cancel buttons for the user" do @@ -983,7 +983,7 @@ RSpec.describe UsersController, type: :request do context "when the current user does not match the user ID" do before do other_user.update!(active: false) - get "/users/#{other_user.id}/reactivate", headers: headers, params: {} + get "/users/#{other_user.id}/reactivate", headers:, params: {} end it "shows reactivation page with reactivate and cancel buttons for the user" do