Browse Source

Rubocop fixes

pull/948/head
Jack S 4 years ago
parent
commit
d75210a4ba
  1. 8
      app/helpers/navigation_items_helper.rb
  2. 5
      app/models/bulk_upload.rb
  3. 2
      app/views/organisation_relationships/managing_agents.html.erb
  4. 4
      spec/requests/form_controller_spec.rb
  5. 8
      spec/requests/locations_controller_spec.rb
  6. 6
      spec/requests/users_controller_spec.rb

8
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("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("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("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("Housing providers", housing_providers_organisation_path(current_user.organisation), 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("Managing agents", managing_agents_organisation_path(current_user.organisation), managing_agents_path?(path)) if FeatureToggle.managing_owning_enabled?),
].compact ].compact
else 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, 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("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("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("Housing providers", housing_providers_organisation_path(current_user.organisation), 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("Managing agents", managing_agents_organisation_path(current_user.organisation), managing_agents_path?(path)) if FeatureToggle.managing_owning_enabled?),
].compact ].compact
end end
end end

5
app/models/bulk_upload.rb

@ -35,10 +35,7 @@ class BulkUpload
created_by: current_user, created_by: current_user,
) )
map_row(row).each do |attr_key, attr_val| map_row(row).each do |attr_key, attr_val|
update = lettings_log.update(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
rescue ArgumentError rescue ArgumentError
# TODO: determine what we want to do when bulk upload contains totally invalid data for a field. # TODO: determine what we want to do when bulk upload contains totally invalid data for a field.
end end

2
app/views/organisation_relationships/managing_agents.html.erb

@ -5,7 +5,7 @@
<%= render partial: "organisations/headings", locals: { main: @organisation.name, sub: nil } %> <%= render partial: "organisations/headings", locals: { main: @organisation.name, sub: nil } %>
<%= render SubNavigationComponent.new( <%= render SubNavigationComponent.new(
items: secondary_items(request.path, @organisation.id), items: secondary_items(request.path, @organisation.id),
) %> ) %>
<h2 class="govuk-visually-hidden">managing agents</h2> <h2 class="govuk-visually-hidden">managing agents</h2>
<p class="govuk-body">A managing agent can submit logs for your organisation.</p> <p class="govuk-body">A managing agent can submit logs for your organisation.</p>
<% else %> <% else %>

4
spec/requests/form_controller_spec.rb

@ -158,7 +158,7 @@ RSpec.describe FormController, type: :request do
before do before do
Timecop.freeze(Time.zone.local(2022, 12, 1)) 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 end
after do after do
@ -267,7 +267,7 @@ RSpec.describe FormController, type: :request do
it "logs that validation was triggered" do it "logs that validation was triggered" do
expect(Rails.logger).to receive(:info).with("User triggered validation(s) on: age1").once 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 end
context "when the number of days is too high for the month" do context "when the number of days is too high for the month" do

8
spec/requests/locations_controller_spec.rb

@ -100,7 +100,7 @@ RSpec.describe LocationsController, type: :request do
before do before do
sign_in user sign_in user
post "/schemes/#{scheme.id}/locations", params: params post "/schemes/#{scheme.id}/locations", params:
end end
it "creates a new location for scheme with valid params and redirects to correct page" do 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 before do
allow(user).to receive(:need_two_factor_authentication?).and_return(false) allow(user).to receive(:need_two_factor_authentication?).and_return(false)
sign_in user sign_in user
post "/schemes/#{scheme.id}/locations", params: params post "/schemes/#{scheme.id}/locations", params:
end end
it "creates a new location for scheme with valid params and redirects to correct page" do 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 before do
sign_in user sign_in user
patch "/schemes/#{scheme.id}/locations/#{location.id}", params: params patch "/schemes/#{scheme.id}/locations/#{location.id}", params:
end end
it "updates existing location for scheme with valid params and redirects to correct page" do 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 before do
allow(user).to receive(:need_two_factor_authentication?).and_return(false) allow(user).to receive(:need_two_factor_authentication?).and_return(false)
sign_in user sign_in user
patch "/schemes/#{scheme.id}/locations/#{location.id}", params: params patch "/schemes/#{scheme.id}/locations/#{location.id}", params:
end end
it "updates a location for scheme with valid params and redirects to correct page" do it "updates a location for scheme with valid params and redirects to correct page" do

6
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 context "when the current user matches the user ID" do
before do before do
get "/users/#{user.id}/deactivate", headers: headers, params: {} get "/users/#{user.id}/deactivate", headers:, params: {}
end end
it "redirects user to user page" do 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 context "when the current user does not match the user ID" do
before do before do
get "/users/#{other_user.id}/deactivate", headers: headers, params: {} get "/users/#{other_user.id}/deactivate", headers:, params: {}
end end
it "shows deactivation page with deactivate and cancel buttons for the user" do 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 context "when the current user does not match the user ID" do
before do before do
other_user.update!(active: false) other_user.update!(active: false)
get "/users/#{other_user.id}/reactivate", headers: headers, params: {} get "/users/#{other_user.id}/reactivate", headers:, params: {}
end end
it "shows reactivation page with reactivate and cancel buttons for the user" do it "shows reactivation page with reactivate and cancel buttons for the user" do

Loading…
Cancel
Save