Browse Source

simplified and extended sab nab logic

pull/656/head
JG 3 years ago
parent
commit
7269968795
  1. 8
      app/helpers/navigation_items_helper.rb
  2. 2
      spec/helpers/tab_nav_helper_spec.rb

8
app/helpers/navigation_items_helper.rb

@ -45,19 +45,19 @@ private
end end
def supported_housing_current?(path) def supported_housing_current?(path)
path.include?("/supported-housing") && !organisations_current?(path) path == "/supported-housing" || path.include?("/supported-housing/")
end end
def organisations_current?(path) def organisations_current?(path)
path == "/organisations" || subnav_users_path?(path) || subnav_logs_path?(path) || subnav_details_path?(path) || subnav_supported_housing_path?(path) path == "/organisations" || path.include?("/organisations/")
end end
def subnav_supported_housing_path?(path) def subnav_supported_housing_path?(path)
path.include?("/organisations") && path.include?("/supported-housing") path.include?("/organisations") && path.include?("/supported-housing") || path.include?("/supported-housing/")
end end
def subnav_users_path?(path) def subnav_users_path?(path)
path.include?("/organisations") && path.include?("/users") path.include?("/organisations") && path.include?("/users") || path.include?("/users/")
end end
def subnav_logs_path?(path) def subnav_logs_path?(path)

2
spec/helpers/tab_nav_helper_spec.rb

@ -21,7 +21,7 @@ RSpec.describe TabNavHelper do
describe "#scheme_cell" do describe "#scheme_cell" do
it "returns the scheme link service name and primary user group separated by a newline character" do it "returns the scheme link service name and primary user group separated by a newline character" do
expected_html = "<a class=\"govuk-link\" href=\"/supported-housing\">#{scheme.service_name}</a>\n<span class=\"govuk-visually-hidden\">Scheme </span><span class=\"govuk-!-font-weight-regular app-!-colour-muted\">#{scheme.primary_client_group}</span>" expected_html = "<a class=\"govuk-link\" href=\"/supported-housing\">#{scheme.service_name}</a>\n<span class=\"govuk-visually-hidden\">Scheme </span><span class=\"govuk-!-font-weight-regular app-!-colour-muted\">#{scheme.primary_client_group_display}</span>"
expect(scheme_cell(scheme)).to match(expected_html) expect(scheme_cell(scheme)).to match(expected_html)
end end
end end

Loading…
Cancel
Save